├── .gitattributes ├── .github ├── issue_template.md └── workflows │ ├── github_release.yml │ └── tests.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── build.gradle ├── devguide.md ├── gen └── com │ └── thoughtworks │ └── gauge │ ├── language │ ├── psi │ │ ├── ConceptArg.java │ │ ├── ConceptConcept.java │ │ ├── ConceptConceptHeading.java │ │ ├── ConceptDynamicArg.java │ │ ├── ConceptStaticArg.java │ │ ├── ConceptStep.java │ │ ├── ConceptTable.java │ │ ├── ConceptTableBody.java │ │ ├── ConceptTableHeader.java │ │ ├── ConceptTableRowValue.java │ │ ├── ConceptVisitor.java │ │ ├── SpecArg.java │ │ ├── SpecDetail.java │ │ ├── SpecDynamicArg.java │ │ ├── SpecKeyword.java │ │ ├── SpecScenario.java │ │ ├── SpecStaticArg.java │ │ ├── SpecStep.java │ │ ├── SpecTable.java │ │ ├── SpecTableBody.java │ │ ├── SpecTableHeader.java │ │ ├── SpecTableRowValue.java │ │ ├── SpecTags.java │ │ ├── SpecTeardown.java │ │ ├── SpecVisitor.java │ │ └── impl │ │ │ ├── ConceptArgImpl.java │ │ │ ├── ConceptConceptHeadingImpl.java │ │ │ ├── ConceptConceptImpl.java │ │ │ ├── ConceptDynamicArgImpl.java │ │ │ ├── ConceptStaticArgImpl.java │ │ │ ├── ConceptStepImpl.java │ │ │ ├── ConceptTableBodyImpl.java │ │ │ ├── ConceptTableHeaderImpl.java │ │ │ ├── ConceptTableImpl.java │ │ │ ├── ConceptTableRowValueImpl.java │ │ │ ├── SpecArgImpl.java │ │ │ ├── SpecDetailImpl.java │ │ │ ├── SpecDynamicArgImpl.java │ │ │ ├── SpecKeywordImpl.java │ │ │ ├── SpecScenarioImpl.java │ │ │ ├── SpecStaticArgImpl.java │ │ │ ├── SpecStepImpl.java │ │ │ ├── SpecTableBodyImpl.java │ │ │ ├── SpecTableHeaderImpl.java │ │ │ ├── SpecTableImpl.java │ │ │ ├── SpecTableRowValueImpl.java │ │ │ ├── SpecTagsImpl.java │ │ │ └── SpecTeardownImpl.java │ └── token │ │ ├── ConceptTokenTypes.java │ │ └── SpecTokenTypes.java │ └── parser │ ├── ConceptParser.java │ └── SpecParser.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── images ├── add_plugin.png ├── additional │ ├── create_spec_file.png │ ├── sce_heading_enter.png │ ├── sce_heading_fill.png │ ├── spec_heading.png │ ├── spec_heading_fill.png │ ├── table_column_fill.png │ └── table_type.png ├── auto_completion │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ └── completion.gif ├── creation │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── creation.gif │ ├── maven_add_archetype.png │ └── maven_add_archetype_selenium.png ├── etc.gif ├── execution │ ├── 1.png │ ├── 10.png │ ├── 11.png │ ├── 12.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ ├── 9.png │ ├── intelliJRunConfig.gif │ ├── multipleSpec.png │ ├── run.gif │ └── scenario.gif ├── find_usages │ └── find_usages.gif ├── html_preview │ ├── browser_preview.png │ └── specfile.png ├── quick_fix │ ├── 1.png │ ├── 10.png │ ├── 11.png │ ├── 12.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ ├── 9.png │ └── fix.gif └── syntax_highlight.png ├── notice.md ├── release.sh ├── resources ├── META-INF │ └── plugin.xml ├── fileTemplates │ ├── Concept.cpt.ft │ ├── Concept.cpt.html │ ├── Specification.spec.ft │ └── Specification.spec.html ├── icons │ ├── Gauge-Logo.png │ └── logo.png ├── inspectionDescriptions │ ├── ConceptInspectionProvider.html │ └── SpecInspectionProvider.html ├── intentionDescriptions │ ├── ConvertToDynamicArgIntention │ │ ├── after.spec.template │ │ ├── before.spec.template │ │ └── description.html │ └── ConvertToStaticArgIntention │ │ ├── after.spec.template │ │ ├── before.spec.template │ │ └── description.html ├── liveTemplates │ └── gaugeTemplates.xml └── preview.css ├── src ├── com │ └── thoughtworks │ │ └── gauge │ │ ├── Constants.java │ │ ├── GaugeComponent.java │ │ ├── GaugeEnterHandlerDelegate.java │ │ ├── GaugeModuleComponent.java │ │ ├── annotator │ │ ├── AnnotationHelper.java │ │ ├── CreateStepImplFix.java │ │ ├── FileManager.java │ │ ├── GaugeCreateClassAction.java │ │ ├── GaugeDataContext.java │ │ ├── ParamAnnotator.java │ │ └── StepAnnotator.java │ │ ├── autocomplete │ │ ├── ArgQuoteHandler.java │ │ ├── ConceptDynamicArgCompletionProvider.java │ │ ├── ConceptStaticArgCompletionProvider.java │ │ ├── DynamicArgCompletionProvider.java │ │ ├── GaugePrefixMatcher.java │ │ ├── PairMatcher.java │ │ ├── StaticArgCompletionProvider.java │ │ ├── StepCompletionContributor.java │ │ └── StepCompletionProvider.java │ │ ├── core │ │ ├── Gauge.java │ │ ├── GaugeExceptionHandler.java │ │ ├── GaugeService.java │ │ ├── GaugeVersion.java │ │ ├── GaugeVersionInfo.java │ │ └── Plugin.java │ │ ├── exception │ │ └── GaugeNotFoundException.java │ │ ├── execution │ │ ├── GaugeCommandLine.java │ │ ├── GaugeCommandLineState.java │ │ ├── GaugeDebugInfo.java │ │ ├── GaugeExecutionConfigurationSettingsEditor.form │ │ ├── GaugeExecutionConfigurationSettingsEditor.java │ │ ├── GaugeExecutionProducer.java │ │ ├── GaugeRunConfiguration.java │ │ ├── GaugeRunProcessHandler.java │ │ ├── GaugeRunTaskConfigurationType.java │ │ ├── GaugeTestRunner.java │ │ ├── ScenarioExecutionProducer.java │ │ ├── SpecsExecutionProducer.java │ │ ├── TestRunLineMarkerProvider.java │ │ └── runner │ │ │ ├── GaugeConsoleProperties.java │ │ │ ├── GaugeOutputToGeneralTestEventsProcessor.java │ │ │ ├── GaugeRerunFailedAction.java │ │ │ ├── MessageProcessor.java │ │ │ ├── TestsCache.java │ │ │ ├── event │ │ │ ├── ExecutionError.java │ │ │ ├── ExecutionEvent.java │ │ │ ├── ExecutionResult.java │ │ │ ├── GaugeNotification.java │ │ │ └── TableInfo.java │ │ │ └── processors │ │ │ ├── EventProcessor.java │ │ │ ├── GaugeEventProcessor.java │ │ │ ├── NotificationEventProcessor.java │ │ │ ├── ScenarioEventProcessor.java │ │ │ ├── SpecEventProcessor.java │ │ │ ├── StandardOutputEventProcessor.java │ │ │ ├── SuiteEventProcessor.java │ │ │ └── UnexpectedEndProcessor.java │ │ ├── extract │ │ ├── ExtractConceptAction.java │ │ ├── ExtractConceptDialog.form │ │ ├── ExtractConceptDialog.java │ │ ├── ExtractConceptHandler.java │ │ ├── ExtractConceptInfo.java │ │ ├── ExtractConceptInfoCollector.java │ │ ├── ExtractConceptRequest.java │ │ └── stepBuilder │ │ │ ├── ConceptStepsBuilder.java │ │ │ ├── SpecStepsBuilder.java │ │ │ └── StepsBuilder.java │ │ ├── findUsages │ │ ├── ConceptStepFindUsagesProvider.java │ │ ├── ConceptStepWordScanner.java │ │ ├── CustomFindUsagesHandlerFactory.java │ │ ├── ImplUsageProvider.java │ │ ├── ReferenceSearch.java │ │ ├── SpecStepFindUsagesProvider.java │ │ ├── SpecStepWordScanner.java │ │ ├── StepCollector.java │ │ ├── StepFindUsagesHandler.java │ │ └── helper │ │ │ └── ReferenceSearchHelper.java │ │ ├── folding │ │ ├── ConceptFoldingBuilder.java │ │ ├── GaugeFoldingBuilder.java │ │ └── SpecFoldingBuilder.java │ │ ├── formatter │ │ └── SpecFormatter.java │ │ ├── helper │ │ └── ModuleHelper.java │ │ ├── highlight │ │ ├── ConceptColorSettingsPage.java │ │ ├── ConceptSyntaxHighlighter.java │ │ ├── ConceptSyntaxHighlighterFactory.java │ │ ├── ErrorHighLighter.java │ │ ├── HighlighterTokens.java │ │ ├── SpecColorSettingsPage.java │ │ ├── SpecSyntaxHighlighter.java │ │ └── SpecSyntaxHighlighterFactory.java │ │ ├── idea │ │ ├── icon │ │ │ └── GaugeIcon.java │ │ └── template │ │ │ ├── LiveTemplateContext.java │ │ │ ├── SpecificationLiveTemplate.java │ │ │ └── TableTemplateProvider.java │ │ ├── inspection │ │ ├── ConceptInspectionProvider.java │ │ ├── GaugeError.java │ │ ├── GaugeErrors.java │ │ ├── GaugeInspectionHelper.java │ │ ├── GaugeInspectionProvider.java │ │ ├── GlobalInspectionProvider.java │ │ └── SpecInspectionProvider.java │ │ ├── intention │ │ ├── ConvertArgTypeIntentionBase.java │ │ ├── ConvertToDynamicArgIntention.java │ │ └── ConvertToStaticArgIntention.java │ │ ├── language │ │ ├── Concept.java │ │ ├── ConceptFile.java │ │ ├── ConceptFileType.java │ │ ├── SpecFile.java │ │ ├── SpecFileType.java │ │ ├── SpecFileTypeFactory.java │ │ ├── Specification.java │ │ ├── StepCommenter.java │ │ ├── psi │ │ │ ├── ConceptNamedElement.java │ │ │ ├── ConceptPsiImplUtil.java │ │ │ ├── SpecNamedElement.java │ │ │ ├── SpecPsiImplUtil.java │ │ │ └── impl │ │ │ │ ├── ConceptNamedElementImpl.java │ │ │ │ └── SpecNamedElementImpl.java │ │ └── token │ │ │ ├── ConceptElementType.java │ │ │ ├── ConceptTokenType.java │ │ │ ├── SpecElementType.java │ │ │ └── SpecTokenType.java │ │ ├── lexer │ │ ├── ConceptLexer.java │ │ ├── SpecLexer.java │ │ ├── _ConceptLexer.flex │ │ ├── _ConceptLexer.java │ │ ├── _SpecLexer.flex │ │ ├── _SpecLexer.java │ │ └── _SpecLexer.java~ │ │ ├── markdownPreview │ │ ├── Formatter.java │ │ ├── GaugeWebBrowserPreview.java │ │ └── Spectacle.java │ │ ├── module │ │ ├── GaugeModuleBuilder.java │ │ ├── GaugeModuleConfigurationProvider.java │ │ ├── GaugeModuleType.java │ │ └── lib │ │ │ ├── AbstractLibHelper.java │ │ │ ├── GaugeLibHelper.java │ │ │ ├── LibHelper.java │ │ │ └── LibHelperFactory.java │ │ ├── parser │ │ ├── ConceptParserDefinition.java │ │ └── SpecParserDefinition.java │ │ ├── reference │ │ ├── ConceptReference.java │ │ ├── ReferenceCache.java │ │ └── StepReference.java │ │ ├── rename │ │ ├── CustomRenameHandler.java │ │ ├── GaugeRefactorHandler.java │ │ ├── RefactorStatusCallback.java │ │ ├── RefactoringDialog.form │ │ ├── RefactoringDialog.java │ │ └── RefactoringStatus.java │ │ ├── settings │ │ ├── GaugeConfig.form │ │ ├── GaugeConfig.java │ │ ├── GaugeSettings.java │ │ ├── GaugeSettingsModel.java │ │ └── GaugeSettingsService.java │ │ ├── stub │ │ └── FileStub.java │ │ ├── undo │ │ └── UndoHandler.java │ │ └── util │ │ ├── GaugeUtil.java │ │ ├── HookUtil.java │ │ ├── SocketUtils.java │ │ └── StepUtil.java ├── concept.bnf └── specification.bnf ├── testdata ├── conceptParser │ ├── SimpleConcept.cpt │ └── SimpleConcept.txt ├── specParser │ ├── SimpleSpec.spec │ ├── SimpleSpec.txt │ ├── SpecWithDataTable.spec │ ├── SpecWithDataTable.txt │ ├── SpecWithEmptyTableHeaders.spec │ └── SpecWithEmptyTableHeaders.txt └── stepAutocomplete │ ├── SimpleSpec.spec │ └── SimpleSpec.txt └── tests └── com └── thoughtworks └── gauge ├── annotator ├── ParamAnnotatorTest.java └── StepAnnotatorTest.java ├── autocomplete ├── GaugePrefixMatcherTest.java └── StepCompletionProviderTest.java ├── core ├── GaugeVersionInfoTest.java └── GaugeVersionTest.java ├── execution ├── GaugeExecutionProducerTest.java ├── GaugeTestRunnerTest.java └── runner │ └── processors │ ├── NotificationEventProcessorTest.java │ ├── ScenarioEventProcessorTest.java │ ├── ServiceMessageBuilderMatcher.java │ ├── SpecEventProcessorTest.java │ ├── SuiteEventProcessorTest.java │ └── UnexpectedEndProcessorTest.java ├── extract └── ExtractConceptActionTest.java ├── findUsages ├── ImplUsageProviderTest.java ├── ReferenceSearchTest.java └── helper │ └── ReferenceSearchHelperTest.java ├── folding └── GaugeFoldingBuilderTest.java ├── inspection ├── ConceptInspectionProviderTest.java ├── GaugeErrorTest.java └── SpecInspectionProviderTest.java ├── language └── psi │ └── impl │ ├── ConceptStepImplTest.java │ └── SpecStepImplTest.java ├── markdownPreview └── FormatterTest.java ├── parser ├── ConceptParserTestCase.java └── SpecParsingTestCase.java ├── rename └── CustomRenameHandlerTest.java └── util ├── GaugeUtilTest.java └── HookUtilTest.java /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | 10 | 11 | ### Expected behavior 12 | Tell us what should happen 13 | 14 | ### Actual behavior 15 | Tell us what happens instead 16 | 17 | ### Steps to reproduce 18 | 1. 19 | 2. 20 | 3. 21 | 22 | ### Version information 23 | 24 | * IntelliJ version and edition(Community/Ultimate): 25 | * OS information: 26 | * Gauge IntelliJ plugin version: 27 | * Does the project uses any Build tool(Gradle/Maven)? 28 | ``` 29 | Run gauge -v on your system and paste the results here 30 | ``` 31 | -------------------------------------------------------------------------------- /.github/workflows/github_release.yml: -------------------------------------------------------------------------------- 1 | name: Deploy 2 | 3 | on: [deployment] 4 | 5 | jobs: 6 | deploy: 7 | name: Create Draft with assets 8 | runs-on: macos-latest 9 | env: 10 | GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' 11 | steps: 12 | - uses: actions/checkout@v1 13 | 14 | - name: Setup java 15 | uses: actions/setup-java@v1 16 | with: 17 | java-version: '11.x.x' 18 | 19 | - name: Build artifacts 20 | run: | 21 | ./gradlew clean buildPlugin 22 | 23 | - name: Install hub 24 | run: brew install hub 25 | 26 | - name: update 27 | run: | 28 | cd build/distributions/ 29 | if [ -z "$version" ]; then 30 | version=$(ls Gauge-Java-Intellij-*.zip | sed "s/^Gauge-Java-Intellij-\([^;]*\).zip/\1/"); 31 | fi 32 | artifacts=() 33 | dir=`pwd` 34 | artifacts+="$dir/*.vsix" 35 | echo "---------------------------" 36 | echo "Updating release v$version" 37 | echo "---------------------------" 38 | echo -e "Gauge Intellij Plugin $version\n\n" > desc.txt 39 | release_description=$(ruby -e "$(curl -sSfL https://github.com/getgauge/gauge/raw/master/build/create_release_text.rb)" getgauge Intellij-Plugin) 40 | echo "$release_description" >> desc.txt 41 | echo "Creating new draft for release v$version" 42 | hub release create -d -F ./desc.txt "v$version" 43 | rm -rf desc.txt 44 | echo "Start uploading assets..." 45 | hub release edit -m "" -a "Gauge-Java-Intellij-$version.zip" "v$version" 46 | 47 | - name: 'deployment success' 48 | if: success() 49 | uses: 'deliverybot/status@master' 50 | with: 51 | state: 'success' 52 | token: '${{ secrets.GITHUB_TOKEN }}' 53 | 54 | - name: 'deployment failure' 55 | if: failure() 56 | uses: 'deliverybot/status@master' 57 | with: 58 | state: 'failure' 59 | token: '${{ secrets.GITHUB_TOKEN }}' 60 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test: 7 | name: test - ${{ matrix.os }} 8 | runs-on: ${{ matrix.os }} 9 | strategy: 10 | matrix: 11 | os: [ubuntu-latest, windows-latest] 12 | steps: 13 | 14 | - uses: actions/checkout@v1 15 | 16 | - name: Setup java 17 | uses: actions/setup-java@v1 18 | with: 19 | java-version: '11.x.x' 20 | 21 | - name: Run test 22 | run: | 23 | ./gradlew clean test 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | *.iws 3 | workspace.xml 4 | tasks.xml 5 | misc.xml 6 | .idea/ 7 | production/* 8 | production-test/* 9 | *.zip 10 | .gradle 11 | build 12 | logs 13 | *.iml 14 | classes 15 | .classpath 16 | .settings 17 | .project 18 | bin 19 | tags 20 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing to Gauge 2 | 3 | Contributions to Gauge are welcome and appreciated. Please read this document to understand the process for contributing. 4 | 5 | ## Gauge Core v/s Plugins 6 | 7 | Gauge Core is a project that has features that would reflect across all Gauge use cases. These features are typically agnostic of the user's choice of implementation language. 8 | 9 | Plugins are meant to do something specific. These could be adding support for a new language, or have a new report etc. 10 | 11 | So, depending on where you see your contribution fit, please focus on the respective repository. 12 | 13 | ## Contribution process 14 | 15 | Please read about the Contribution Process [here](https://github.com/getgauge/gauge/blob/master/CONTRIBUTING.md), if you are happy please sign the [Contributor's License Agreement](https://gauge-bot.herokuapp.com/cla/). 16 | 17 | ## How can I contribute 18 | 19 | Contributions can be of many forms: 20 | 21 | - Open an issue, or participate in an existing one. 22 | - Write some code, and send us a pull request. 23 | - Enhance the documentation 24 | - Participate in design discussions on Google Groups 25 | 26 | If you need help in getting started with contribution, feel free to reach out on the [Google Groups](https://groups.google.com/forum/#!forum/getgauge) or [Gitter](https://gitter.im/getgauge/chat). 27 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | maven { url 'http://dl.bintray.com/jetbrains/intellij-plugin-service' } 4 | } 5 | } 6 | 7 | plugins { 8 | id "org.jetbrains.intellij" version "0.4.15" 9 | id "java" 10 | id "idea" 11 | } 12 | 13 | intellij { 14 | plugins 'java' 15 | version ideaVersion 16 | pluginName 'Gauge-Java-Intellij' 17 | sameSinceUntilBuild false 18 | patchPluginXml { 19 | sinceBuild customSinceBuild 20 | untilBuild customUntilBuild 21 | } 22 | } 23 | 24 | allprojects { 25 | sourceSets { 26 | main { 27 | java.srcDirs 'src', 'gen' 28 | resources.srcDirs 'resources' 29 | } 30 | 31 | test { 32 | java.srcDir 'tests' 33 | } 34 | } 35 | repositories { 36 | mavenCentral() 37 | } 38 | } 39 | dependencies { 40 | compile( 41 | 'com.thoughtworks.gauge:gauge-java:0.7.3', 42 | ) 43 | testCompile( 44 | 'org.mockito:mockito-all:1.10.19', 45 | ) 46 | } 47 | 48 | sourceCompatibility = JavaVersion.VERSION_1_8 49 | targetCompatibility = JavaVersion.VERSION_1_8 50 | 51 | group 'org.jetbrains' 52 | version version 53 | -------------------------------------------------------------------------------- /devguide.md: -------------------------------------------------------------------------------- 1 | #Developer Guide 2 | 3 | * install the intellij sdk 4 | * install necessary plugins Grammar-kit, and PsiViewer. For updated list, take a look at 5 | http://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support/prerequisites.html 6 | * Create a run configuration (Plugin -> Use Classpath of module -> Choose the current module), hit run 7 | * A new instance of intellij will be launched with the plugin installed 8 | 9 | ##Lexing and parsing 10 | 11 | * The lexing rules are defined in _SpecLexer.flex and _SpecLexer.java is generated using JFlex 12 | * The grammar rules are defined in specification.bnf and SpecParser.java is generated using grammar kit 13 | SpecParser builds an structure with PsiElements and we can add custom behavior for each element (eg step has get specstep has getStepValue) 14 | 15 | ##Available Features 16 | 17 | * Project Creation 18 | * Syntax Highlighting 19 | * Auto completion 20 | * Navigation from step to implementation 21 | * Quick Fix for unimplemented steps 22 | 23 | 24 | ##Interacting with the core 25 | 26 | Auto completion,step value extraction and other api calls are made from the plugin. Each module is associated with an api connection(GaugeConnection). 27 | This Gauge connection is created during the module initialization phase after the gauge process is started in background. Gauge connection talks to the core using protobuff. 28 | 29 | 30 | ##Debugging specs 31 | 32 | * Create a remote run configuration which attaches on port 50005 33 | * Right click on the spec -> Choose Debug specification (this will wait for a debugger to get attached, currently waits for 30 seconds) 34 | * Choose the previously created remote run configuration and run it (this will attach to the gauge process) 35 | 36 | 37 | ##Some useful links 38 | 39 | [Antlr guy's tips](https://theantlrguy.atlassian.net/wiki/display/~admin/Intellij+plugin+development+notes) 40 | 41 | [Psi Cook book](https://code.google.com/p/ide-examples/wiki/IntelliJIdeaPsiCookbook) 42 | 43 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/ConceptArg.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.psi.PsiElement; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | public interface ConceptArg extends PsiElement { 13 | 14 | @Nullable 15 | ConceptDynamicArg getDynamicArg(); 16 | 17 | @Nullable 18 | ConceptStaticArg getStaticArg(); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/ConceptConcept.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.psi.PsiElement; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | import java.util.List; 13 | 14 | public interface ConceptConcept extends PsiElement { 15 | 16 | @NotNull 17 | ConceptConceptHeading getConceptHeading(); 18 | 19 | @NotNull 20 | List getStepList(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/ConceptConceptHeading.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.psi.PsiElement; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | import java.util.List; 13 | 14 | public interface ConceptConceptHeading extends PsiElement { 15 | 16 | @NotNull 17 | List getDynamicArgList(); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/ConceptDynamicArg.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.psi.PsiElement; 10 | 11 | public interface ConceptDynamicArg extends PsiElement { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/ConceptStaticArg.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.psi.PsiElement; 10 | 11 | public interface ConceptStaticArg extends PsiElement { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/ConceptStep.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.thoughtworks.gauge.StepValue; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jetbrains.annotations.Nullable; 12 | 13 | import java.util.List; 14 | 15 | public interface ConceptStep extends ConceptNamedElement { 16 | 17 | @NotNull 18 | List getArgList(); 19 | 20 | @Nullable 21 | ConceptTable getTable(); 22 | 23 | StepValue getStepValue(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/ConceptTable.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.psi.PsiElement; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | public interface ConceptTable extends PsiElement { 13 | 14 | @NotNull 15 | ConceptTableBody getTableBody(); 16 | 17 | @NotNull 18 | ConceptTableHeader getTableHeader(); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/ConceptTableBody.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.psi.PsiElement; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | import java.util.List; 13 | 14 | public interface ConceptTableBody extends PsiElement { 15 | 16 | @NotNull 17 | List getTableRowValueList(); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/ConceptTableHeader.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.psi.PsiElement; 10 | 11 | public interface ConceptTableHeader extends PsiElement { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/ConceptTableRowValue.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.psi.PsiElement; 10 | 11 | public interface ConceptTableRowValue extends PsiElement { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/ConceptVisitor.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.psi.PsiElement; 10 | import com.intellij.psi.PsiElementVisitor; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | public class ConceptVisitor extends PsiElementVisitor { 14 | 15 | public void visitArg(@NotNull ConceptArg o) { 16 | visitPsiElement(o); 17 | } 18 | 19 | public void visitConcept(@NotNull ConceptConcept o) { 20 | visitPsiElement(o); 21 | } 22 | 23 | public void visitConceptHeading(@NotNull ConceptConceptHeading o) { 24 | visitPsiElement(o); 25 | } 26 | 27 | public void visitDynamicArg(@NotNull ConceptDynamicArg o) { 28 | visitPsiElement(o); 29 | } 30 | 31 | public void visitStaticArg(@NotNull ConceptStaticArg o) { 32 | visitPsiElement(o); 33 | } 34 | 35 | public void visitStep(@NotNull ConceptStep o) { 36 | visitNamedElement(o); 37 | } 38 | 39 | public void visitTable(@NotNull ConceptTable o) { 40 | visitPsiElement(o); 41 | } 42 | 43 | public void visitTableBody(@NotNull ConceptTableBody o) { 44 | visitPsiElement(o); 45 | } 46 | 47 | public void visitTableHeader(@NotNull ConceptTableHeader o) { 48 | visitPsiElement(o); 49 | } 50 | 51 | public void visitTableRowValue(@NotNull ConceptTableRowValue o) { 52 | visitPsiElement(o); 53 | } 54 | 55 | public void visitNamedElement(@NotNull ConceptNamedElement o) { 56 | visitPsiElement(o); 57 | } 58 | 59 | public void visitPsiElement(@NotNull PsiElement o) { 60 | visitElement(o); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/SpecArg.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi; 3 | 4 | import com.intellij.psi.PsiElement; 5 | import org.jetbrains.annotations.Nullable; 6 | 7 | public interface SpecArg extends PsiElement { 8 | 9 | @Nullable 10 | SpecDynamicArg getDynamicArg(); 11 | 12 | @Nullable 13 | SpecStaticArg getStaticArg(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/SpecDetail.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.psi.PsiElement; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jetbrains.annotations.Nullable; 12 | 13 | import java.util.List; 14 | 15 | public interface SpecDetail extends PsiElement { 16 | 17 | @NotNull 18 | List getContextSteps(); 19 | 20 | @Nullable 21 | SpecTable getDataTable(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/SpecDynamicArg.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi; 3 | 4 | import com.intellij.psi.PsiElement; 5 | 6 | public interface SpecDynamicArg extends PsiElement { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/SpecKeyword.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi; 3 | 4 | import com.intellij.psi.PsiElement; 5 | 6 | public interface SpecKeyword extends PsiElement { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/SpecScenario.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi; 3 | 4 | import com.intellij.psi.PsiElement; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | import java.util.List; 9 | 10 | public interface SpecScenario extends PsiElement { 11 | 12 | @NotNull 13 | List getStepList(); 14 | 15 | @Nullable 16 | SpecTags getTags(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/SpecStaticArg.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi; 3 | 4 | import com.intellij.psi.PsiElement; 5 | 6 | public interface SpecStaticArg extends PsiElement { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/SpecStep.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.navigation.ItemPresentation; 10 | import com.intellij.psi.PsiElement; 11 | import com.intellij.psi.PsiReference; 12 | import com.thoughtworks.gauge.StepValue; 13 | 14 | import java.util.List; 15 | 16 | public interface SpecStep extends SpecNamedElement { 17 | 18 | List getArgList(); 19 | 20 | List getStaticArgList(); 21 | 22 | StepValue getStepValue(); 23 | 24 | String getName(); 25 | 26 | PsiElement setName(String newName); 27 | 28 | PsiElement getNameIdentifier(); 29 | 30 | ItemPresentation getPresentation(); 31 | 32 | SpecTable getInlineTable(); 33 | 34 | PsiReference getReference(); 35 | } 36 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/SpecTable.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi; 3 | 4 | import com.intellij.psi.PsiElement; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | public interface SpecTable extends PsiElement { 8 | 9 | @NotNull 10 | SpecTableBody getTableBody(); 11 | 12 | @NotNull 13 | SpecTableHeader getTableHeader(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/SpecTableBody.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi; 3 | 4 | import com.intellij.psi.PsiElement; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.List; 8 | 9 | public interface SpecTableBody extends PsiElement { 10 | 11 | @NotNull 12 | List getTableRowValueList(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/SpecTableHeader.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi; 3 | 4 | import com.intellij.psi.PsiElement; 5 | 6 | import java.util.List; 7 | 8 | public interface SpecTableHeader extends PsiElement { 9 | 10 | List getHeaders(); 11 | } 12 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/SpecTableRowValue.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi; 3 | 4 | import com.intellij.psi.PsiElement; 5 | 6 | public interface SpecTableRowValue extends PsiElement { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/SpecTags.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi; 3 | 4 | import com.intellij.psi.PsiElement; 5 | 6 | public interface SpecTags extends PsiElement { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/SpecTeardown.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.psi.PsiElement; 7 | 8 | public interface SpecTeardown extends PsiElement { 9 | 10 | @NotNull 11 | List getStepList(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/SpecVisitor.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi; 3 | 4 | import com.intellij.psi.PsiElement; 5 | import com.intellij.psi.PsiElementVisitor; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class SpecVisitor extends PsiElementVisitor { 9 | 10 | public void visitArg(@NotNull SpecArg o) { 11 | visitPsiElement(o); 12 | } 13 | 14 | public void visitDynamicArg(@NotNull SpecDynamicArg o) { 15 | visitPsiElement(o); 16 | } 17 | 18 | public void visitKeyword(@NotNull SpecKeyword o) { 19 | visitPsiElement(o); 20 | } 21 | 22 | public void visitScenario(@NotNull SpecScenario o) { 23 | visitPsiElement(o); 24 | } 25 | 26 | public void visitSpecDetail(@NotNull SpecDetail o) { 27 | visitPsiElement(o); 28 | } 29 | 30 | public void visitStaticArg(@NotNull SpecStaticArg o) { 31 | visitPsiElement(o); 32 | } 33 | 34 | public void visitStep(@NotNull SpecStep o) { 35 | visitNamedElement(o); 36 | } 37 | 38 | public void visitTable(@NotNull SpecTable o) { 39 | visitPsiElement(o); 40 | } 41 | 42 | public void visitTableBody(@NotNull SpecTableBody o) { 43 | visitPsiElement(o); 44 | } 45 | 46 | public void visitTableHeader(@NotNull SpecTableHeader o) { 47 | visitPsiElement(o); 48 | } 49 | 50 | public void visitTableRowValue(@NotNull SpecTableRowValue o) { 51 | visitPsiElement(o); 52 | } 53 | 54 | public void visitTags(@NotNull SpecTags o) { 55 | visitPsiElement(o); 56 | } 57 | 58 | public void visitTeardown(@NotNull SpecTeardown o) { 59 | visitPsiElement(o); 60 | } 61 | 62 | public void visitNamedElement(@NotNull SpecNamedElement o) { 63 | visitPsiElement(o); 64 | } 65 | 66 | public void visitPsiElement(@NotNull PsiElement o) { 67 | visitElement(o); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/ConceptArgImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.thoughtworks.gauge.language.psi.ConceptArg; 8 | import com.thoughtworks.gauge.language.psi.ConceptDynamicArg; 9 | import com.thoughtworks.gauge.language.psi.ConceptStaticArg; 10 | import com.thoughtworks.gauge.language.psi.ConceptVisitor; 11 | import org.jetbrains.annotations.NotNull; 12 | import org.jetbrains.annotations.Nullable; 13 | 14 | public class ConceptArgImpl extends ASTWrapperPsiElement implements ConceptArg { 15 | 16 | public ConceptArgImpl(ASTNode node) { 17 | super(node); 18 | } 19 | 20 | public void accept(@NotNull PsiElementVisitor visitor) { 21 | if (visitor instanceof ConceptVisitor) ((ConceptVisitor) visitor).visitArg(this); 22 | else super.accept(visitor); 23 | } 24 | 25 | @Override 26 | @Nullable 27 | public ConceptDynamicArg getDynamicArg() { 28 | return findChildByClass(ConceptDynamicArg.class); 29 | } 30 | 31 | @Override 32 | @Nullable 33 | public ConceptStaticArg getStaticArg() { 34 | return findChildByClass(ConceptStaticArg.class); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/ConceptConceptHeadingImpl.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi.impl; 8 | 9 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 10 | import com.intellij.lang.ASTNode; 11 | import com.intellij.psi.PsiElementVisitor; 12 | import com.intellij.psi.util.PsiTreeUtil; 13 | import com.thoughtworks.gauge.language.psi.ConceptConceptHeading; 14 | import com.thoughtworks.gauge.language.psi.ConceptDynamicArg; 15 | import com.thoughtworks.gauge.language.psi.ConceptVisitor; 16 | import org.jetbrains.annotations.NotNull; 17 | 18 | import java.util.List; 19 | 20 | public class ConceptConceptHeadingImpl extends ASTWrapperPsiElement implements ConceptConceptHeading { 21 | 22 | public ConceptConceptHeadingImpl(ASTNode node) { 23 | super(node); 24 | } 25 | 26 | public void accept(@NotNull PsiElementVisitor visitor) { 27 | if (visitor instanceof ConceptVisitor) ((ConceptVisitor) visitor).visitConceptHeading(this); 28 | else super.accept(visitor); 29 | } 30 | 31 | @Override 32 | @NotNull 33 | public List getDynamicArgList() { 34 | return PsiTreeUtil.getChildrenOfTypeAsList(this, ConceptDynamicArg.class); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/ConceptConceptImpl.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi.impl; 8 | 9 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 10 | import com.intellij.lang.ASTNode; 11 | import com.intellij.psi.PsiElementVisitor; 12 | import com.intellij.psi.util.PsiTreeUtil; 13 | import com.thoughtworks.gauge.StepValue; 14 | import com.thoughtworks.gauge.language.psi.*; 15 | import org.jetbrains.annotations.NotNull; 16 | 17 | import java.util.List; 18 | 19 | public class ConceptConceptImpl extends ASTWrapperPsiElement implements ConceptConcept { 20 | 21 | public ConceptConceptImpl(ASTNode node) { 22 | super(node); 23 | } 24 | 25 | public void accept(@NotNull PsiElementVisitor visitor) { 26 | if (visitor instanceof ConceptVisitor) ((ConceptVisitor) visitor).visitConcept(this); 27 | else super.accept(visitor); 28 | } 29 | 30 | @Override 31 | @NotNull 32 | public ConceptConceptHeading getConceptHeading() { 33 | return findNotNullChildByClass(ConceptConceptHeading.class); 34 | } 35 | 36 | @Override 37 | @NotNull 38 | public List getStepList() { 39 | return PsiTreeUtil.getChildrenOfTypeAsList(this, ConceptStep.class); 40 | } 41 | 42 | public StepValue getStepValue() { 43 | return ConceptPsiImplUtil.getStepValue(this); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/ConceptDynamicArgImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.thoughtworks.gauge.language.psi.ConceptDynamicArg; 8 | import com.thoughtworks.gauge.language.psi.ConceptVisitor; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | public class ConceptDynamicArgImpl extends ASTWrapperPsiElement implements ConceptDynamicArg { 12 | 13 | public ConceptDynamicArgImpl(ASTNode node) { 14 | super(node); 15 | } 16 | 17 | public void accept(@NotNull PsiElementVisitor visitor) { 18 | if (visitor instanceof ConceptVisitor) ((ConceptVisitor) visitor).visitDynamicArg(this); 19 | else super.accept(visitor); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/ConceptStaticArgImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.thoughtworks.gauge.language.psi.ConceptStaticArg; 8 | import com.thoughtworks.gauge.language.psi.ConceptVisitor; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | public class ConceptStaticArgImpl extends ASTWrapperPsiElement implements ConceptStaticArg { 12 | 13 | public ConceptStaticArgImpl(ASTNode node) { 14 | super(node); 15 | } 16 | 17 | public void accept(@NotNull PsiElementVisitor visitor) { 18 | if (visitor instanceof ConceptVisitor) ((ConceptVisitor) visitor).visitStaticArg(this); 19 | else super.accept(visitor); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/ConceptTableBodyImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.intellij.psi.util.PsiTreeUtil; 8 | import com.thoughtworks.gauge.language.psi.ConceptTableBody; 9 | import com.thoughtworks.gauge.language.psi.ConceptTableRowValue; 10 | import com.thoughtworks.gauge.language.psi.ConceptVisitor; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | import java.util.List; 14 | 15 | public class ConceptTableBodyImpl extends ASTWrapperPsiElement implements ConceptTableBody { 16 | 17 | public ConceptTableBodyImpl(ASTNode node) { 18 | super(node); 19 | } 20 | 21 | public void accept(@NotNull PsiElementVisitor visitor) { 22 | if (visitor instanceof ConceptVisitor) ((ConceptVisitor) visitor).visitTableBody(this); 23 | else super.accept(visitor); 24 | } 25 | 26 | @Override 27 | @NotNull 28 | public List getTableRowValueList() { 29 | return PsiTreeUtil.getChildrenOfTypeAsList(this, ConceptTableRowValue.class); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/ConceptTableHeaderImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.thoughtworks.gauge.language.psi.ConceptTableHeader; 8 | import com.thoughtworks.gauge.language.psi.ConceptVisitor; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | public class ConceptTableHeaderImpl extends ASTWrapperPsiElement implements ConceptTableHeader { 12 | 13 | public ConceptTableHeaderImpl(ASTNode node) { 14 | super(node); 15 | } 16 | 17 | public void accept(@NotNull PsiElementVisitor visitor) { 18 | if (visitor instanceof ConceptVisitor) ((ConceptVisitor) visitor).visitTableHeader(this); 19 | else super.accept(visitor); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/ConceptTableImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.thoughtworks.gauge.language.psi.ConceptTable; 8 | import com.thoughtworks.gauge.language.psi.ConceptTableBody; 9 | import com.thoughtworks.gauge.language.psi.ConceptTableHeader; 10 | import com.thoughtworks.gauge.language.psi.ConceptVisitor; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | public class ConceptTableImpl extends ASTWrapperPsiElement implements ConceptTable { 14 | 15 | public ConceptTableImpl(ASTNode node) { 16 | super(node); 17 | } 18 | 19 | public void accept(@NotNull PsiElementVisitor visitor) { 20 | if (visitor instanceof ConceptVisitor) ((ConceptVisitor) visitor).visitTable(this); 21 | else super.accept(visitor); 22 | } 23 | 24 | @Override 25 | @NotNull 26 | public ConceptTableBody getTableBody() { 27 | return findNotNullChildByClass(ConceptTableBody.class); 28 | } 29 | 30 | @Override 31 | @NotNull 32 | public ConceptTableHeader getTableHeader() { 33 | return findNotNullChildByClass(ConceptTableHeader.class); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/ConceptTableRowValueImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.thoughtworks.gauge.language.psi.ConceptTableRowValue; 8 | import com.thoughtworks.gauge.language.psi.ConceptVisitor; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | public class ConceptTableRowValueImpl extends ASTWrapperPsiElement implements ConceptTableRowValue { 12 | 13 | public ConceptTableRowValueImpl(ASTNode node) { 14 | super(node); 15 | } 16 | 17 | public void accept(@NotNull PsiElementVisitor visitor) { 18 | if (visitor instanceof ConceptVisitor) ((ConceptVisitor) visitor).visitTableRowValue(this); 19 | else super.accept(visitor); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/SpecArgImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.thoughtworks.gauge.language.psi.SpecArg; 8 | import com.thoughtworks.gauge.language.psi.SpecDynamicArg; 9 | import com.thoughtworks.gauge.language.psi.SpecStaticArg; 10 | import com.thoughtworks.gauge.language.psi.SpecVisitor; 11 | import org.jetbrains.annotations.NotNull; 12 | import org.jetbrains.annotations.Nullable; 13 | 14 | public class SpecArgImpl extends ASTWrapperPsiElement implements SpecArg { 15 | 16 | public SpecArgImpl(ASTNode node) { 17 | super(node); 18 | } 19 | 20 | public void accept(@NotNull PsiElementVisitor visitor) { 21 | if (visitor instanceof SpecVisitor) ((SpecVisitor) visitor).visitArg(this); 22 | else super.accept(visitor); 23 | } 24 | 25 | @Override 26 | @Nullable 27 | public SpecDynamicArg getDynamicArg() { 28 | return findChildByClass(SpecDynamicArg.class); 29 | } 30 | 31 | @Override 32 | @Nullable 33 | public SpecStaticArg getStaticArg() { 34 | return findChildByClass(SpecStaticArg.class); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/SpecDetailImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.intellij.psi.util.PsiTreeUtil; 8 | import com.thoughtworks.gauge.language.psi.SpecDetail; 9 | import com.thoughtworks.gauge.language.psi.SpecStep; 10 | import com.thoughtworks.gauge.language.psi.SpecTable; 11 | import com.thoughtworks.gauge.language.psi.SpecVisitor; 12 | import org.jetbrains.annotations.NotNull; 13 | import org.jetbrains.annotations.Nullable; 14 | 15 | import java.util.List; 16 | 17 | public class SpecDetailImpl extends ASTWrapperPsiElement implements SpecDetail { 18 | 19 | public SpecDetailImpl(ASTNode node) { 20 | super(node); 21 | } 22 | 23 | public void accept(@NotNull PsiElementVisitor visitor) { 24 | if (visitor instanceof SpecVisitor) ((SpecVisitor) visitor).visitSpecDetail(this); 25 | else super.accept(visitor); 26 | } 27 | 28 | @Override 29 | @NotNull 30 | public List getContextSteps() { 31 | return PsiTreeUtil.getChildrenOfTypeAsList(this, SpecStep.class); 32 | } 33 | 34 | @Override 35 | @Nullable 36 | public SpecTable getDataTable() { 37 | return findChildByClass(SpecTable.class); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/SpecDynamicArgImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElement; 7 | import com.thoughtworks.gauge.language.psi.SpecDynamicArg; 8 | import com.thoughtworks.gauge.language.token.SpecTokenTypes; 9 | 10 | public class SpecDynamicArgImpl extends ASTWrapperPsiElement implements SpecDynamicArg { 11 | 12 | public SpecDynamicArgImpl(ASTNode node) { 13 | super(node); 14 | } 15 | 16 | @Override 17 | public String getText() { 18 | PsiElement arg = findChildByType(SpecTokenTypes.DYNAMIC_ARG); 19 | return arg != null ? arg.getText() : null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/SpecKeywordImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.thoughtworks.gauge.language.psi.SpecKeyword; 8 | import com.thoughtworks.gauge.language.psi.SpecVisitor; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | public class SpecKeywordImpl extends ASTWrapperPsiElement implements SpecKeyword { 12 | 13 | public SpecKeywordImpl(ASTNode node) { 14 | super(node); 15 | } 16 | 17 | public void accept(@NotNull PsiElementVisitor visitor) { 18 | if (visitor instanceof SpecVisitor) ((SpecVisitor) visitor).visitKeyword(this); 19 | else super.accept(visitor); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/SpecScenarioImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.intellij.psi.util.PsiTreeUtil; 8 | import com.thoughtworks.gauge.language.psi.SpecScenario; 9 | import com.thoughtworks.gauge.language.psi.SpecStep; 10 | import com.thoughtworks.gauge.language.psi.SpecTags; 11 | import com.thoughtworks.gauge.language.psi.SpecVisitor; 12 | import org.jetbrains.annotations.NotNull; 13 | import org.jetbrains.annotations.Nullable; 14 | 15 | import java.util.List; 16 | 17 | public class SpecScenarioImpl extends ASTWrapperPsiElement implements SpecScenario { 18 | 19 | public SpecScenarioImpl(ASTNode node) { 20 | super(node); 21 | } 22 | 23 | public void accept(@NotNull PsiElementVisitor visitor) { 24 | if (visitor instanceof SpecVisitor) ((SpecVisitor) visitor).visitScenario(this); 25 | else super.accept(visitor); 26 | } 27 | 28 | @Override 29 | @NotNull 30 | public List getStepList() { 31 | return PsiTreeUtil.getChildrenOfTypeAsList(this, SpecStep.class); 32 | } 33 | 34 | @Override 35 | @Nullable 36 | public SpecTags getTags() { 37 | return findChildByClass(SpecTags.class); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/SpecStaticArgImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElement; 7 | import com.thoughtworks.gauge.language.psi.SpecStaticArg; 8 | import com.thoughtworks.gauge.language.token.SpecTokenTypes; 9 | 10 | public class SpecStaticArgImpl extends ASTWrapperPsiElement implements SpecStaticArg { 11 | 12 | public SpecStaticArgImpl(ASTNode node) { 13 | super(node); 14 | } 15 | 16 | @Override 17 | public String getText() { 18 | PsiElement arg = findChildByType(SpecTokenTypes.ARG); 19 | return arg != null ? arg.getText() : null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/SpecTableBodyImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.intellij.psi.util.PsiTreeUtil; 8 | import com.thoughtworks.gauge.language.psi.SpecTableBody; 9 | import com.thoughtworks.gauge.language.psi.SpecTableRowValue; 10 | import com.thoughtworks.gauge.language.psi.SpecVisitor; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | import java.util.List; 14 | 15 | public class SpecTableBodyImpl extends ASTWrapperPsiElement implements SpecTableBody { 16 | 17 | public SpecTableBodyImpl(ASTNode node) { 18 | super(node); 19 | } 20 | 21 | public void accept(@NotNull PsiElementVisitor visitor) { 22 | if (visitor instanceof SpecVisitor) ((SpecVisitor) visitor).visitTableBody(this); 23 | else super.accept(visitor); 24 | } 25 | 26 | @Override 27 | @NotNull 28 | public List getTableRowValueList() { 29 | return PsiTreeUtil.getChildrenOfTypeAsList(this, SpecTableRowValue.class); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/SpecTableHeaderImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElement; 7 | import com.intellij.psi.PsiElementVisitor; 8 | import com.thoughtworks.gauge.language.psi.SpecTableHeader; 9 | import com.thoughtworks.gauge.language.psi.SpecVisitor; 10 | import com.thoughtworks.gauge.language.token.SpecTokenTypes; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | public class SpecTableHeaderImpl extends ASTWrapperPsiElement implements SpecTableHeader { 17 | 18 | public SpecTableHeaderImpl(ASTNode node) { 19 | super(node); 20 | } 21 | 22 | @Override 23 | public List getHeaders() { 24 | List headers = findChildrenByType(SpecTokenTypes.TABLE_HEADER); 25 | List headerValue = new ArrayList(); 26 | for (PsiElement header : headers) { 27 | headerValue.add(header.getText().trim()); 28 | } 29 | return headerValue; 30 | } 31 | 32 | public void accept(@NotNull PsiElementVisitor visitor) { 33 | if (visitor instanceof SpecVisitor) ((SpecVisitor) visitor).visitTableHeader(this); 34 | else super.accept(visitor); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/SpecTableImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.thoughtworks.gauge.language.psi.SpecTable; 8 | import com.thoughtworks.gauge.language.psi.SpecTableBody; 9 | import com.thoughtworks.gauge.language.psi.SpecTableHeader; 10 | import com.thoughtworks.gauge.language.psi.SpecVisitor; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | public class SpecTableImpl extends ASTWrapperPsiElement implements SpecTable { 14 | 15 | public SpecTableImpl(ASTNode node) { 16 | super(node); 17 | } 18 | 19 | public void accept(@NotNull PsiElementVisitor visitor) { 20 | if (visitor instanceof SpecVisitor) ((SpecVisitor) visitor).visitTable(this); 21 | else super.accept(visitor); 22 | } 23 | 24 | @Override 25 | @NotNull 26 | public SpecTableBody getTableBody() { 27 | return findNotNullChildByClass(SpecTableBody.class); 28 | } 29 | 30 | @Override 31 | @NotNull 32 | public SpecTableHeader getTableHeader() { 33 | return findNotNullChildByClass(SpecTableHeader.class); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/SpecTableRowValueImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.thoughtworks.gauge.language.psi.SpecTableRowValue; 7 | 8 | public class SpecTableRowValueImpl extends ASTWrapperPsiElement implements SpecTableRowValue { 9 | 10 | public SpecTableRowValueImpl(ASTNode node) { 11 | super(node); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/SpecTagsImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.thoughtworks.gauge.language.psi.SpecTags; 8 | import com.thoughtworks.gauge.language.psi.SpecVisitor; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | public class SpecTagsImpl extends ASTWrapperPsiElement implements SpecTags { 12 | 13 | public SpecTagsImpl(ASTNode node) { 14 | super(node); 15 | } 16 | 17 | public void accept(@NotNull PsiElementVisitor visitor) { 18 | if (visitor instanceof SpecVisitor) ((SpecVisitor) visitor).visitTags(this); 19 | else super.accept(visitor); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /gen/com/thoughtworks/gauge/language/psi/impl/SpecTeardownImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package com.thoughtworks.gauge.language.psi.impl; 3 | 4 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 5 | import com.intellij.lang.ASTNode; 6 | import com.intellij.psi.PsiElementVisitor; 7 | import com.intellij.psi.util.PsiTreeUtil; 8 | import com.thoughtworks.gauge.language.psi.SpecStep; 9 | import com.thoughtworks.gauge.language.psi.SpecTeardown; 10 | import com.thoughtworks.gauge.language.psi.SpecVisitor; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | import java.util.List; 14 | 15 | public class SpecTeardownImpl extends ASTWrapperPsiElement implements SpecTeardown { 16 | 17 | public SpecTeardownImpl(ASTNode node) { 18 | super(node); 19 | } 20 | 21 | public void accept(@NotNull SpecVisitor visitor) { 22 | visitor.visitTeardown(this); 23 | } 24 | 25 | public void accept(@NotNull PsiElementVisitor visitor) { 26 | if (visitor instanceof SpecVisitor) accept((SpecVisitor) visitor); 27 | else super.accept(visitor); 28 | } 29 | 30 | @Override 31 | @NotNull 32 | public List getStepList() { 33 | return PsiTreeUtil.getChildrenOfTypeAsList(this, SpecStep.class); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ideaVersion=2020.1 2 | customSinceBuild=172.3317.76 3 | customUntilBuild=201.* 4 | buildNumber=SNAPSHOT 5 | version=0.3.21 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /images/add_plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/add_plugin.png -------------------------------------------------------------------------------- /images/additional/create_spec_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/additional/create_spec_file.png -------------------------------------------------------------------------------- /images/additional/sce_heading_enter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/additional/sce_heading_enter.png -------------------------------------------------------------------------------- /images/additional/sce_heading_fill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/additional/sce_heading_fill.png -------------------------------------------------------------------------------- /images/additional/spec_heading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/additional/spec_heading.png -------------------------------------------------------------------------------- /images/additional/spec_heading_fill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/additional/spec_heading_fill.png -------------------------------------------------------------------------------- /images/additional/table_column_fill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/additional/table_column_fill.png -------------------------------------------------------------------------------- /images/additional/table_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/additional/table_type.png -------------------------------------------------------------------------------- /images/auto_completion/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/auto_completion/1.png -------------------------------------------------------------------------------- /images/auto_completion/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/auto_completion/2.png -------------------------------------------------------------------------------- /images/auto_completion/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/auto_completion/3.png -------------------------------------------------------------------------------- /images/auto_completion/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/auto_completion/4.png -------------------------------------------------------------------------------- /images/auto_completion/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/auto_completion/5.png -------------------------------------------------------------------------------- /images/auto_completion/completion.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/auto_completion/completion.gif -------------------------------------------------------------------------------- /images/creation/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/creation/1.png -------------------------------------------------------------------------------- /images/creation/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/creation/2.png -------------------------------------------------------------------------------- /images/creation/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/creation/3.png -------------------------------------------------------------------------------- /images/creation/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/creation/4.png -------------------------------------------------------------------------------- /images/creation/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/creation/5.png -------------------------------------------------------------------------------- /images/creation/creation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/creation/creation.gif -------------------------------------------------------------------------------- /images/creation/maven_add_archetype.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/creation/maven_add_archetype.png -------------------------------------------------------------------------------- /images/creation/maven_add_archetype_selenium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/creation/maven_add_archetype_selenium.png -------------------------------------------------------------------------------- /images/etc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/etc.gif -------------------------------------------------------------------------------- /images/execution/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/1.png -------------------------------------------------------------------------------- /images/execution/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/10.png -------------------------------------------------------------------------------- /images/execution/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/11.png -------------------------------------------------------------------------------- /images/execution/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/12.png -------------------------------------------------------------------------------- /images/execution/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/2.png -------------------------------------------------------------------------------- /images/execution/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/3.png -------------------------------------------------------------------------------- /images/execution/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/4.png -------------------------------------------------------------------------------- /images/execution/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/5.png -------------------------------------------------------------------------------- /images/execution/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/6.png -------------------------------------------------------------------------------- /images/execution/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/7.png -------------------------------------------------------------------------------- /images/execution/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/8.png -------------------------------------------------------------------------------- /images/execution/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/9.png -------------------------------------------------------------------------------- /images/execution/intelliJRunConfig.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/intelliJRunConfig.gif -------------------------------------------------------------------------------- /images/execution/multipleSpec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/multipleSpec.png -------------------------------------------------------------------------------- /images/execution/run.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/run.gif -------------------------------------------------------------------------------- /images/execution/scenario.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/execution/scenario.gif -------------------------------------------------------------------------------- /images/find_usages/find_usages.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/find_usages/find_usages.gif -------------------------------------------------------------------------------- /images/html_preview/browser_preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/html_preview/browser_preview.png -------------------------------------------------------------------------------- /images/html_preview/specfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/html_preview/specfile.png -------------------------------------------------------------------------------- /images/quick_fix/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/quick_fix/1.png -------------------------------------------------------------------------------- /images/quick_fix/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/quick_fix/10.png -------------------------------------------------------------------------------- /images/quick_fix/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/quick_fix/11.png -------------------------------------------------------------------------------- /images/quick_fix/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/quick_fix/12.png -------------------------------------------------------------------------------- /images/quick_fix/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/quick_fix/2.png -------------------------------------------------------------------------------- /images/quick_fix/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/quick_fix/3.png -------------------------------------------------------------------------------- /images/quick_fix/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/quick_fix/4.png -------------------------------------------------------------------------------- /images/quick_fix/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/quick_fix/5.png -------------------------------------------------------------------------------- /images/quick_fix/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/quick_fix/6.png -------------------------------------------------------------------------------- /images/quick_fix/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/quick_fix/7.png -------------------------------------------------------------------------------- /images/quick_fix/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/quick_fix/8.png -------------------------------------------------------------------------------- /images/quick_fix/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/quick_fix/9.png -------------------------------------------------------------------------------- /images/quick_fix/fix.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/quick_fix/fix.gif -------------------------------------------------------------------------------- /images/syntax_highlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/images/syntax_highlight.png -------------------------------------------------------------------------------- /notice.md: -------------------------------------------------------------------------------- 1 | | Dependency Name | Copyright Information | Description | Repo URL | License Type | License URL | 2 | |-----------------|-----------------------|-------------|----------|--------------|-------------| 3 | |commons-io|Copyright © 2002-2014 The Apache Software Foundation.|A library of utilities to assist with developing IO functionality|http://commons.apache.org/proper/commons-io/|Apache 2.0|| 4 | -------------------------------------------------------------------------------- /release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z "$GITHUB_TOKEN" ]; then 4 | echo "GITHUB_TOKEN is not set." 5 | echo "Please create an personal access token with repo:public_repo scopes." 6 | exit 1 7 | fi 8 | 9 | curl \ 10 | -X POST \ 11 | -H "Authorization: token $GITHUB_TOKEN" \ 12 | -H "Accept: application/vnd.github.ant-man-preview+json" \ 13 | -H "Content-Type: application/json" \ 14 | https://api.github.com/repos/getgauge/IntelliJ-Plugin/deployments \ 15 | --data '{"ref": "master", "required_contexts": [], "environment": "production"}' -------------------------------------------------------------------------------- /resources/fileTemplates/Concept.cpt.ft: -------------------------------------------------------------------------------- 1 | Created by ${USER} on ${DATE} 2 | 3 | This is a concept file with following syntax for each concept. 4 | # Concept Heading 5 | * step1 6 | * step2 -------------------------------------------------------------------------------- /resources/fileTemplates/Concept.cpt.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 |
This is a built-in template used each time you create 10 | a new Gauge Concept File. 11 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /resources/fileTemplates/Specification.spec.ft: -------------------------------------------------------------------------------- 1 | Specification Heading 2 | ===================== 3 | Created by ${USER} on ${DATE} 4 | 5 | This is an executable specification file which follows markdown syntax. 6 | Every heading in this file denotes a scenario. Every bulleted point denotes a step. 7 | 8 | Scenario Heading 9 | ---------------- -------------------------------------------------------------------------------- /resources/fileTemplates/Specification.spec.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 13 | 14 |
This is a built-in template used each time you create 11 | a new Gauge Specification file. 12 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /resources/icons/Gauge-Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/resources/icons/Gauge-Logo.png -------------------------------------------------------------------------------- /resources/icons/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/getgauge/Intellij-Plugin/cba31f7fd56c375c5ec0f9cfb94493d886e59dd1/resources/icons/logo.png -------------------------------------------------------------------------------- /resources/inspectionDescriptions/ConceptInspectionProvider.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Concept inspection helps locate parse and validation errors in your concept files. 4 | Documentation 5 | 6 | -------------------------------------------------------------------------------- /resources/inspectionDescriptions/SpecInspectionProvider.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Specification inspection helps locate parse and validation errors in your specification files. 4 | Documentation 5 | 6 | -------------------------------------------------------------------------------- /resources/intentionDescriptions/ConvertToDynamicArgIntention/after.spec.template: -------------------------------------------------------------------------------- 1 | * This is a sample step with -------------------------------------------------------------------------------- /resources/intentionDescriptions/ConvertToDynamicArgIntention/before.spec.template: -------------------------------------------------------------------------------- 1 | * This is a sample step with "argument" -------------------------------------------------------------------------------- /resources/intentionDescriptions/ConvertToDynamicArgIntention/description.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | This intention converts a Step's Static parameter to Dynamic parameter.
4 | 5 | -------------------------------------------------------------------------------- /resources/intentionDescriptions/ConvertToStaticArgIntention/after.spec.template: -------------------------------------------------------------------------------- 1 | * This is a sample step with "argument" -------------------------------------------------------------------------------- /resources/intentionDescriptions/ConvertToStaticArgIntention/before.spec.template: -------------------------------------------------------------------------------- 1 | * This is a sample step with -------------------------------------------------------------------------------- /resources/intentionDescriptions/ConvertToStaticArgIntention/description.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | This intention converts a Step's Dynamic parameter to Static parameter.
4 | 5 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/GaugeComponent.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge; 2 | 3 | import com.intellij.notification.Notification; 4 | import com.intellij.notification.NotificationType; 5 | import com.intellij.notification.Notifications; 6 | import com.intellij.openapi.components.ProjectComponent; 7 | import com.intellij.openapi.diagnostic.Logger; 8 | import com.intellij.openapi.module.ModuleManager; 9 | import com.intellij.openapi.project.Project; 10 | import com.thoughtworks.gauge.core.Gauge; 11 | import com.thoughtworks.gauge.core.GaugeVersion; 12 | 13 | import java.io.File; 14 | import java.util.Arrays; 15 | 16 | import static com.thoughtworks.gauge.Constants.MIN_GAUGE_VERSION; 17 | import static com.thoughtworks.gauge.util.GaugeUtil.isGaugeProjectDir; 18 | 19 | public class GaugeComponent implements ProjectComponent { 20 | private static final Logger LOG = Logger.getInstance("#com.thoughtworks.gauge.GaugeComponent"); 21 | private Project project; 22 | 23 | public GaugeComponent(Project project) { 24 | this.project = project; 25 | } 26 | 27 | @Override 28 | public void projectOpened() { 29 | if (isGaugeProjectDir(new File(this.project.getBasePath()))) { 30 | if (!GaugeVersion.isGreaterOrEqual(MIN_GAUGE_VERSION, false)) { 31 | String notificationTitle = String.format("Unsupported Gauge Version(%s)", GaugeVersion.getVersion(false).version); 32 | String errorMessage = String.format("This version of Gauge Intellij plugin only works with Gauge version >= %s", MIN_GAUGE_VERSION); 33 | LOG.debug(String.format("%s\n%s", notificationTitle, errorMessage)); 34 | Notification notification = new Notification("Error", notificationTitle, errorMessage, NotificationType.ERROR); 35 | Notifications.Bus.notify(notification, this.project); 36 | } 37 | } 38 | } 39 | 40 | @Override 41 | public void projectClosed() { 42 | Arrays.stream(ModuleManager.getInstance(project).getModules()).forEach(Gauge::disposeComponent); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/GaugeEnterHandlerDelegate.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge; 8 | 9 | import com.intellij.codeInsight.editorActions.enter.EnterHandlerDelegate; 10 | import com.intellij.openapi.actionSystem.DataContext; 11 | import com.intellij.openapi.editor.Document; 12 | import com.intellij.openapi.editor.Editor; 13 | import com.intellij.openapi.editor.actionSystem.EditorActionHandler; 14 | import com.intellij.openapi.fileEditor.FileDocumentManager; 15 | import com.intellij.openapi.util.Ref; 16 | import com.intellij.openapi.vfs.VirtualFile; 17 | import com.intellij.psi.PsiFile; 18 | import com.thoughtworks.gauge.util.GaugeUtil; 19 | 20 | public class GaugeEnterHandlerDelegate implements EnterHandlerDelegate { 21 | 22 | @Override 23 | public Result preprocessEnter(PsiFile psiFile, Editor editor, Ref ref, Ref ref1, DataContext dataContext, EditorActionHandler editorActionHandler) { 24 | return Result.Continue; 25 | } 26 | 27 | @Override 28 | public Result postProcessEnter(PsiFile psiFile, Editor editor, DataContext dataContext) { 29 | Document document = editor.getDocument(); 30 | VirtualFile file = FileDocumentManager.getInstance().getFile(document); 31 | if (GaugeUtil.isGaugeFile(file)) { 32 | FileDocumentManager.getInstance().saveDocumentAsIs(document); 33 | } 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/annotator/AnnotationHelper.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.annotator; 2 | 3 | import com.intellij.openapi.module.Module; 4 | import com.intellij.psi.PsiElement; 5 | import com.intellij.psi.PsiMethod; 6 | import com.thoughtworks.gauge.StepValue; 7 | import com.thoughtworks.gauge.helper.ModuleHelper; 8 | import com.thoughtworks.gauge.language.psi.SpecPsiImplUtil; 9 | import com.thoughtworks.gauge.language.psi.SpecStep; 10 | import com.thoughtworks.gauge.util.StepUtil; 11 | 12 | import java.util.List; 13 | import java.util.stream.Collectors; 14 | 15 | class AnnotationHelper { 16 | private static ModuleHelper helper = new ModuleHelper(); 17 | 18 | boolean isImplemented(SpecStep step, Module module) { 19 | return StepUtil.isImplementedStep(step, module); 20 | } 21 | 22 | boolean isEmpty(SpecStep step) { 23 | return step.getStepValue().getStepText().trim().isEmpty(); 24 | } 25 | 26 | boolean isGaugeModule(PsiElement element) { 27 | return helper.isGaugeModule(element); 28 | } 29 | 30 | Module getModule(SpecStep step) { 31 | return helper.getModule(step); 32 | } 33 | 34 | List getStepValues(PsiMethod psiElement) { 35 | return StepUtil.getGaugeStepAnnotationValues(psiElement).stream().map(s -> SpecPsiImplUtil.getStepValueFor(psiElement, s, false)).collect(Collectors.toList()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/annotator/GaugeCreateClassAction.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.annotator; 8 | 9 | import com.intellij.ide.actions.CreateClassAction; 10 | import com.intellij.openapi.vfs.VirtualFile; 11 | import com.intellij.psi.PsiClass; 12 | 13 | import java.util.Map; 14 | 15 | public class GaugeCreateClassAction extends CreateClassAction { 16 | private PsiClass createdElement; 17 | 18 | @Override 19 | protected void postProcess(PsiClass createdElement, String templateName, Map customProperties) { 20 | super.postProcess(createdElement, templateName, customProperties); 21 | this.createdElement = createdElement; 22 | } 23 | 24 | 25 | public VirtualFile getCreatedFile() { 26 | if (createdElement == null) { 27 | return null; 28 | } 29 | return createdElement.getContainingFile().getVirtualFile(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/annotator/ParamAnnotator.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.annotator; 2 | 3 | import com.intellij.lang.annotation.AnnotationHolder; 4 | import com.intellij.lang.annotation.Annotator; 5 | import com.intellij.psi.PsiElement; 6 | import com.intellij.psi.PsiMethod; 7 | import com.thoughtworks.gauge.StepValue; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | public class ParamAnnotator implements Annotator { 11 | private AnnotationHelper helper; 12 | 13 | public ParamAnnotator(AnnotationHelper helper) { 14 | this.helper = helper; 15 | } 16 | 17 | public ParamAnnotator() { 18 | this.helper = new AnnotationHelper(); 19 | } 20 | 21 | 22 | @Override 23 | public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder holder) { 24 | if (helper.isGaugeModule(psiElement) && psiElement instanceof PsiMethod) 25 | helper.getStepValues((PsiMethod) psiElement).stream() 26 | .filter(value -> value.getParameters().size() != ((PsiMethod) psiElement).getParameterList().getParametersCount()) 27 | .forEach(value -> createWarning((PsiMethod) psiElement, holder, value.getStepAnnotationText(), value)); 28 | } 29 | 30 | private void createWarning(@NotNull PsiMethod psiElement, @NotNull AnnotationHolder holder, String alias, StepValue value) { 31 | int actual = psiElement.getParameterList().getParametersCount(); 32 | int expected = value.getParameters().size(); 33 | holder.createErrorAnnotation(psiElement.getParameterList().getTextRange(), getWarning(alias, actual, expected)); 34 | } 35 | 36 | private String getWarning(String step, int actual, int expected) { 37 | return String.format("Parameter count mismatch(found [%d] expected [%d]) with step annotation : \"%s\". ", actual, expected, step); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/annotator/StepAnnotator.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.annotator; 8 | 9 | import com.intellij.lang.annotation.AnnotationHolder; 10 | import com.intellij.psi.PsiElement; 11 | import com.thoughtworks.gauge.language.psi.ConceptStep; 12 | import com.thoughtworks.gauge.language.psi.SpecStep; 13 | import com.thoughtworks.gauge.language.psi.impl.SpecStepImpl; 14 | import org.jetbrains.annotations.NotNull; 15 | 16 | public class StepAnnotator implements com.intellij.lang.annotation.Annotator { 17 | 18 | private AnnotationHelper helper; 19 | 20 | public StepAnnotator(AnnotationHelper helper) { 21 | this.helper = helper; 22 | } 23 | 24 | public StepAnnotator() { 25 | this.helper = new AnnotationHelper(); 26 | } 27 | 28 | @Override 29 | public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) { 30 | if (!helper.isGaugeModule(element)) return; 31 | if (element instanceof SpecStep) 32 | createWarning(element, holder, (SpecStep) element); 33 | else if (element instanceof ConceptStep) { 34 | SpecStepImpl step = new SpecStepImpl(element.getNode()); 35 | step.setConcept(true); 36 | createWarning(element, holder, step); 37 | } 38 | } 39 | 40 | private void createWarning(PsiElement element, AnnotationHolder holder, SpecStep step) { 41 | if (helper.isEmpty(step)) 42 | holder.createErrorAnnotation(element.getTextRange(), "Step should not be blank"); 43 | else if (!helper.isImplemented(step, helper.getModule(step))) 44 | holder.createErrorAnnotation(element.getTextRange(), "Undefined Step").registerFix(new CreateStepImplFix(step)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/autocomplete/ArgQuoteHandler.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.autocomplete; 8 | 9 | import com.intellij.codeInsight.editorActions.SimpleTokenSetQuoteHandler; 10 | import com.thoughtworks.gauge.language.token.SpecTokenTypes; 11 | 12 | public class ArgQuoteHandler extends SimpleTokenSetQuoteHandler { 13 | public ArgQuoteHandler() { 14 | super(SpecTokenTypes.ARG_START); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/autocomplete/ConceptDynamicArgCompletionProvider.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.autocomplete; 2 | 3 | import com.intellij.codeInsight.completion.CompletionParameters; 4 | import com.intellij.codeInsight.completion.CompletionProvider; 5 | import com.intellij.codeInsight.completion.CompletionResultSet; 6 | import com.intellij.codeInsight.completion.PlainPrefixMatcher; 7 | import com.intellij.codeInsight.lookup.LookupElementBuilder; 8 | import com.intellij.psi.util.PsiTreeUtil; 9 | import com.intellij.util.ProcessingContext; 10 | import com.thoughtworks.gauge.language.psi.ConceptDynamicArg; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | import java.util.Collection; 14 | 15 | import static com.thoughtworks.gauge.autocomplete.StepCompletionContributor.getPrefix; 16 | 17 | public class ConceptDynamicArgCompletionProvider extends CompletionProvider { 18 | public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) { 19 | String prefix = getPrefix(parameters); 20 | resultSet = resultSet.withPrefixMatcher(new PlainPrefixMatcher(prefix)); 21 | Collection args = PsiTreeUtil.collectElementsOfType(parameters.getOriginalFile(), ConceptDynamicArg.class); 22 | for (ConceptDynamicArg arg : args) { 23 | LookupElementBuilder item = LookupElementBuilder.create(arg.getText().replaceAll("<|>", "")); 24 | resultSet.addElement(item); 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/autocomplete/ConceptStaticArgCompletionProvider.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.autocomplete; 2 | 3 | import com.intellij.codeInsight.completion.CompletionParameters; 4 | import com.intellij.codeInsight.completion.CompletionProvider; 5 | import com.intellij.codeInsight.completion.CompletionResultSet; 6 | import com.intellij.codeInsight.completion.PlainPrefixMatcher; 7 | import com.intellij.codeInsight.lookup.LookupElementBuilder; 8 | import com.intellij.psi.util.PsiTreeUtil; 9 | import com.intellij.util.ProcessingContext; 10 | import com.thoughtworks.gauge.language.psi.ConceptStaticArg; 11 | 12 | import java.util.Collection; 13 | 14 | import static com.thoughtworks.gauge.autocomplete.StepCompletionContributor.getPrefix; 15 | 16 | 17 | public class ConceptStaticArgCompletionProvider extends CompletionProvider { 18 | @Override 19 | protected void addCompletions(CompletionParameters parameters, ProcessingContext processingContext, CompletionResultSet resultSet) { 20 | String prefix = getPrefix(parameters); 21 | resultSet = resultSet.withPrefixMatcher(new PlainPrefixMatcher(prefix)); 22 | Collection staticArgs = PsiTreeUtil.collectElementsOfType(parameters.getOriginalFile(), ConceptStaticArg.class); 23 | for (ConceptStaticArg arg : staticArgs) { 24 | if (arg != null) { 25 | String text = arg.getText().replaceFirst("\"", ""); 26 | String textWithoutQuotes = text.substring(0, text.length() - 1); 27 | if (!textWithoutQuotes.equals("")) 28 | resultSet.addElement(LookupElementBuilder.create(textWithoutQuotes)); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/autocomplete/GaugePrefixMatcher.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.autocomplete; 2 | 3 | import com.intellij.codeInsight.completion.PrefixMatcher; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import java.util.regex.Matcher; 7 | import java.util.regex.Pattern; 8 | 9 | public class GaugePrefixMatcher extends PrefixMatcher { 10 | 11 | private Pattern regexPattern; 12 | 13 | protected GaugePrefixMatcher(String prefix) { 14 | super(prefix); 15 | regexPattern = Pattern.compile(toRegex(this.getPrefix()), Pattern.CASE_INSENSITIVE); 16 | } 17 | 18 | @Override 19 | public boolean prefixMatches(@NotNull String name) { 20 | Matcher matcher = regexPattern.matcher(name); 21 | return matcher.find(); 22 | } 23 | 24 | @NotNull 25 | @Override 26 | public PrefixMatcher cloneWithPrefix(@NotNull String prefix) { 27 | return new GaugePrefixMatcher(prefix); 28 | } 29 | 30 | private static String toRegex(String prefix) { 31 | Pattern pattern = Pattern.compile("[^a-z0-9]", Pattern.CASE_INSENSITIVE); 32 | String substring = ""; 33 | if (!prefix.isEmpty()) substring = String.valueOf(prefix.charAt(0)); 34 | Matcher matcher = pattern.matcher(substring); 35 | String escape = ""; 36 | if (matcher.matches()) escape = "\\"; 37 | return escape + prefix.replaceAll("\"[\\w ]+\"", "<[\\\\w ]*>"); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/autocomplete/PairMatcher.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.autocomplete; 8 | 9 | import com.intellij.lang.BracePair; 10 | import com.intellij.lang.PairedBraceMatcher; 11 | import com.intellij.psi.PsiFile; 12 | import com.intellij.psi.tree.IElementType; 13 | import com.thoughtworks.gauge.language.token.SpecTokenTypes; 14 | import org.jetbrains.annotations.NotNull; 15 | import org.jetbrains.annotations.Nullable; 16 | 17 | public class PairMatcher implements PairedBraceMatcher { 18 | private final BracePair[] pairs = new BracePair[]{ 19 | new BracePair(SpecTokenTypes.DYNAMIC_ARG_START, SpecTokenTypes.DYNAMIC_ARG_END, false), 20 | new BracePair(SpecTokenTypes.ARG_START, SpecTokenTypes.ARG_END, false) 21 | }; 22 | 23 | @Override 24 | public BracePair[] getPairs() { 25 | return pairs; 26 | } 27 | 28 | @Override 29 | public boolean isPairedBracesAllowedBeforeType(@NotNull IElementType lbraceType, @Nullable IElementType contextType) { 30 | return true; 31 | } 32 | 33 | @Override 34 | public int getCodeConstructStart(PsiFile file, int openingBraceOffset) { 35 | return openingBraceOffset; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/core/GaugeService.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.core; 8 | 9 | import com.thoughtworks.gauge.connection.GaugeConnection; 10 | 11 | public class GaugeService { 12 | private final Process gaugeProcess; 13 | private final GaugeConnection gaugeConnection; 14 | 15 | public GaugeService(Process gaugeProcess, GaugeConnection gaugeConnection) { 16 | this.gaugeProcess = gaugeProcess; 17 | this.gaugeConnection = gaugeConnection; 18 | } 19 | 20 | public GaugeConnection getGaugeConnection() { 21 | return gaugeConnection; 22 | } 23 | 24 | public Process getGaugeProcess() { 25 | return gaugeProcess; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/core/GaugeVersionInfo.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.core; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class GaugeVersionInfo { 7 | public String version; 8 | public List plugins; 9 | 10 | public GaugeVersionInfo(String v, List plugins) { 11 | this.version = v; 12 | this.plugins = plugins; 13 | } 14 | 15 | public GaugeVersionInfo(String v) { 16 | this.version = v; 17 | this.plugins = new ArrayList<>(); 18 | } 19 | 20 | public GaugeVersionInfo() { 21 | } 22 | 23 | public Boolean isPluginInstalled(String plugin) { 24 | return plugins.stream().anyMatch(p -> plugin.equalsIgnoreCase(p.name)); 25 | } 26 | 27 | Boolean isGreaterOrEqual(GaugeVersionInfo versionInfo) { 28 | return this.version != null && this.version.compareTo(versionInfo.version) >= 0; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/core/Plugin.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.core; 2 | 3 | public class Plugin { 4 | public String name; 5 | public String version; 6 | } 7 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/exception/GaugeNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.exception; 2 | 3 | 4 | public class GaugeNotFoundException extends Exception { 5 | public GaugeNotFoundException(String message) { 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/GaugeCommandLine.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution; 2 | 3 | import com.intellij.execution.configurations.GeneralCommandLine; 4 | import com.intellij.openapi.module.Module; 5 | import com.intellij.openapi.project.Project; 6 | import com.thoughtworks.gauge.Constants; 7 | import com.thoughtworks.gauge.exception.GaugeNotFoundException; 8 | import com.thoughtworks.gauge.settings.GaugeSettingsModel; 9 | import com.thoughtworks.gauge.util.GaugeUtil; 10 | 11 | import java.util.Map; 12 | 13 | public class GaugeCommandLine { 14 | public static GeneralCommandLine getInstance(Module module, Project project) { 15 | GeneralCommandLine commandLine = new GeneralCommandLine(); 16 | try { 17 | GaugeSettingsModel settings = GaugeUtil.getGaugeSettings(); 18 | commandLine.setExePath(settings.getGaugePath()); 19 | Map environment = commandLine.getEnvironment(); 20 | environment.put(Constants.GAUGE_HOME, settings.getHomePath()); 21 | } catch (GaugeNotFoundException e) { 22 | commandLine.setExePath(Constants.GAUGE); 23 | } finally { 24 | commandLine.setWorkDirectory(project.getBasePath()); 25 | if (module != null) 26 | commandLine.setWorkDirectory(GaugeUtil.moduleDir(module)); 27 | return commandLine; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/GaugeDebugInfo.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution; 2 | 3 | import com.intellij.execution.configurations.GeneralCommandLine; 4 | import com.intellij.execution.executors.DefaultDebugExecutor; 5 | import com.intellij.execution.runners.ExecutionEnvironment; 6 | import com.thoughtworks.gauge.util.SocketUtils; 7 | 8 | 9 | public class GaugeDebugInfo { 10 | private final boolean shouldDebug; 11 | private final String port; 12 | private static final String host = "localhost"; 13 | 14 | private GaugeDebugInfo(boolean shouldDebug, String port) { 15 | this.shouldDebug = shouldDebug; 16 | this.port = port; 17 | } 18 | 19 | public boolean shouldDebug() { 20 | return shouldDebug; 21 | } 22 | 23 | public String getPort() { 24 | return port; 25 | } 26 | 27 | public int getPortInt() { 28 | return Integer.parseInt(port); 29 | } 30 | 31 | public String getHost() { 32 | return host; 33 | } 34 | 35 | public static GaugeDebugInfo getInstance(GeneralCommandLine commandLine, ExecutionEnvironment env) { 36 | if (isDebugExecution(env)) { 37 | String port = debugPort(); 38 | commandLine.getEnvironment().put("GAUGE_DEBUG_OPTS", port); 39 | return new GaugeDebugInfo(true, port); 40 | } 41 | return new GaugeDebugInfo(false, ""); 42 | } 43 | 44 | public static boolean isDebugExecution(ExecutionEnvironment env) { 45 | return DefaultDebugExecutor.EXECUTOR_ID.equals(env.getExecutor().getId()); 46 | } 47 | 48 | private static String debugPort() { 49 | return String.valueOf(SocketUtils.findFreePortForApi()); 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/GaugeExecutionConfigurationSettingsEditor.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution; 2 | 3 | import com.intellij.execution.ui.CommonProgramParametersPanel; 4 | import com.intellij.openapi.options.ConfigurationException; 5 | import com.intellij.openapi.options.SettingsEditor; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import javax.swing.*; 9 | 10 | public class GaugeExecutionConfigurationSettingsEditor extends SettingsEditor { 11 | private JTextField specification; 12 | private JTextField environment; 13 | private JPanel configWindow; 14 | private JTextField tags; 15 | private JCheckBox inParallel; 16 | private JTextField numberOfParallelNodes; 17 | private CommonProgramParametersPanel commonProgramParameters; 18 | private JTextField rowsRange; 19 | 20 | @Override 21 | protected void resetEditorFrom(GaugeRunConfiguration config) { 22 | specification.setText(config.getSpecsToExecute()); 23 | environment.setText(config.getEnvironment()); 24 | tags.setText(config.getTags()); 25 | inParallel.setSelected(config.getExecInParallel()); 26 | numberOfParallelNodes.setText(config.getParallelNodes()); 27 | commonProgramParameters.reset(config.programParameters); 28 | rowsRange.setText(config.getRowsRange()); 29 | } 30 | 31 | @Override 32 | protected void applyEditorTo(GaugeRunConfiguration config) throws ConfigurationException { 33 | config.setSpecsToExecute(specification.getText()); 34 | config.setEnvironment(environment.getText()); 35 | config.setTags(tags.getText()); 36 | config.setExecInParallel(inParallel.isSelected()); 37 | config.setParallelNodes(numberOfParallelNodes.getText()); 38 | commonProgramParameters.applyTo(config.programParameters); 39 | config.setRowsRange(rowsRange.getText()); 40 | } 41 | 42 | @NotNull 43 | @Override 44 | protected JComponent createEditor() { 45 | return configWindow; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/GaugeRunTaskConfigurationType.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.execution; 8 | 9 | import com.intellij.execution.configuration.ConfigurationFactoryEx; 10 | import com.intellij.execution.configurations.ConfigurationFactory; 11 | import com.intellij.execution.configurations.ConfigurationTypeBase; 12 | import com.intellij.execution.configurations.RunConfiguration; 13 | import com.intellij.icons.AllIcons; 14 | import com.intellij.openapi.extensions.Extensions; 15 | import com.intellij.openapi.project.Project; 16 | import com.intellij.util.containers.ContainerUtil; 17 | 18 | public class GaugeRunTaskConfigurationType extends ConfigurationTypeBase { 19 | public GaugeRunTaskConfigurationType() { 20 | super("executeSpecs", "Gauge Execution", "Execute the gauge tests", AllIcons.Actions.Execute); 21 | final ConfigurationFactory scenarioConfigFactory = new ConfigurationFactoryEx(this) { 22 | @Override 23 | public RunConfiguration createTemplateConfiguration(Project project) { 24 | return new GaugeRunConfiguration("Gauge Execution", project, this); 25 | } 26 | }; 27 | 28 | addFactory(scenarioConfigFactory); 29 | } 30 | 31 | 32 | public GaugeRunTaskConfigurationType getInstance() { 33 | return ContainerUtil.findInstance(Extensions.getExtensions(CONFIGURATION_TYPE_EP), GaugeRunTaskConfigurationType.class); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/GaugeTestRunner.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.execution; 8 | 9 | import com.intellij.execution.ExecutionException; 10 | import com.intellij.execution.ExecutionResult; 11 | import com.intellij.execution.configurations.RunProfile; 12 | import com.intellij.execution.configurations.RunProfileState; 13 | import com.intellij.execution.runners.DefaultProgramRunner; 14 | import com.intellij.execution.runners.ExecutionEnvironment; 15 | import com.intellij.execution.runners.RunContentBuilder; 16 | import com.intellij.execution.ui.RunContentDescriptor; 17 | import com.intellij.openapi.fileEditor.FileDocumentManager; 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public class GaugeTestRunner extends DefaultProgramRunner { 21 | @NotNull 22 | public String getRunnerId() { 23 | return "GaugeApplicationRunner"; 24 | } 25 | 26 | public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) { 27 | return profile instanceof GaugeRunConfiguration; 28 | } 29 | 30 | protected RunContentDescriptor doExecute(RunProfileState state, ExecutionEnvironment env) throws ExecutionException { 31 | FileDocumentManager.getInstance().saveAllDocuments(); 32 | ExecutionResult executionResult = state.execute(env.getExecutor(), this); 33 | return executionResult == null ? null : new RunContentBuilder(executionResult, env).showRunContent(env.getContentToReuse()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/TestRunLineMarkerProvider.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution; 2 | 3 | import com.intellij.execution.lineMarker.ExecutorAction; 4 | import com.intellij.execution.lineMarker.RunLineMarkerContributor; 5 | import com.intellij.icons.AllIcons; 6 | import com.intellij.psi.PsiElement; 7 | import com.intellij.psi.impl.source.tree.LeafPsiElement; 8 | import com.intellij.psi.tree.IElementType; 9 | import com.intellij.util.Function; 10 | import com.thoughtworks.gauge.helper.ModuleHelper; 11 | import com.thoughtworks.gauge.language.token.SpecTokenTypes; 12 | import org.jetbrains.annotations.Nullable; 13 | 14 | import java.util.Arrays; 15 | import java.util.List; 16 | 17 | 18 | public class TestRunLineMarkerProvider extends RunLineMarkerContributor { 19 | private static final Function TOOLTIP_PROVIDER = psiElement -> "Run Element"; 20 | private ModuleHelper helper; 21 | 22 | public TestRunLineMarkerProvider(ModuleHelper helper) { 23 | this.helper = helper; 24 | } 25 | 26 | public TestRunLineMarkerProvider() { 27 | this.helper = new ModuleHelper(); 28 | } 29 | 30 | @Nullable 31 | @Override 32 | public Info getInfo(PsiElement psiElement) { 33 | if (!this.helper.isGaugeModule(psiElement)) return null; 34 | List types = Arrays.asList(SpecTokenTypes.SPEC_HEADING, SpecTokenTypes.SCENARIO_HEADING); 35 | if (psiElement instanceof LeafPsiElement && types.contains(((LeafPsiElement) psiElement).getElementType())) 36 | return new Info(AllIcons.RunConfigurations.TestState.Run, TOOLTIP_PROVIDER, ExecutorAction.getActions(1)); 37 | else return null; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/runner/MessageProcessor.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution.runner; 2 | 3 | import com.intellij.execution.testframework.sm.ServiceMessageBuilder; 4 | 5 | import java.text.ParseException; 6 | 7 | public interface MessageProcessor { 8 | boolean process(ServiceMessageBuilder msg, Integer nodeId, Integer parentId) throws ParseException; 9 | 10 | void process(String text); 11 | 12 | boolean processLineBreak(); 13 | } 14 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/runner/TestsCache.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution.runner; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class TestsCache { 7 | private Map idCache = new HashMap<>(); 8 | private Integer id = 0; 9 | 10 | public Integer getId(String key) { 11 | return idCache.get(key); 12 | } 13 | 14 | public Integer getCurrentId() { 15 | return id; 16 | } 17 | 18 | public void setId(String key, Integer id) { 19 | idCache.put(key, id); 20 | } 21 | 22 | public void setId(String key) { 23 | idCache.put(key, ++this.id); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/runner/event/ExecutionError.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution.runner.event; 2 | 3 | public class ExecutionError { 4 | public String text; 5 | public String filename; 6 | public String lineNo; 7 | public String message; 8 | public String stackTrace; 9 | 10 | public String format(String status) { 11 | return format(this.text, status, "\n") + 12 | format(getFileNameWithLineNo(), "Filename: ", "\n") + 13 | format(this.message, "Message: ", "\n") + 14 | format(this.stackTrace, "Stack Trace:\n", ""); 15 | } 16 | 17 | private String getFileNameWithLineNo() { 18 | return lineNo.isEmpty() ? filename : format(":", filename, lineNo); 19 | 20 | } 21 | 22 | private String format(String text, String prefix, String suffix) { 23 | return text != null && !text.isEmpty() ? prefix + text + suffix : ""; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/runner/event/ExecutionEvent.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution.runner.event; 2 | 3 | public class ExecutionEvent { 4 | public String type; 5 | public String id; 6 | public String filename; 7 | public Integer line; 8 | public String parentId; 9 | public String name; 10 | public String message; 11 | public GaugeNotification notification; 12 | public ExecutionResult result; 13 | public static final String SUITE_START = "suiteStart"; 14 | public static final String SPEC_START = "specStart"; 15 | public static final String SPEC_END = "specEnd"; 16 | public static final String SCENARIO_START = "scenarioStart"; 17 | public static final String SCENARIO_END = "scenarioEnd"; 18 | public static final String SUITE_END = "suiteEnd"; 19 | public static final String NOTIFICATION = "notification"; 20 | public static final String STANDARD_OUTPUT = "out"; 21 | public static final String FAIL = "fail"; 22 | public static final String SKIP = "skip"; 23 | } 24 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/runner/event/ExecutionResult.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution.runner.event; 2 | 3 | public class ExecutionResult { 4 | public String status; 5 | public Integer time; 6 | public String out; 7 | public ExecutionError[] errors; 8 | public ExecutionError beforeHookFailure; 9 | public ExecutionError afterHookFailure; 10 | public TableInfo table; 11 | 12 | public boolean skipped() { 13 | return status.equalsIgnoreCase(ExecutionEvent.SKIP); 14 | } 15 | 16 | public boolean failed() { 17 | return status.equalsIgnoreCase(ExecutionEvent.FAIL); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/runner/event/GaugeNotification.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution.runner.event; 2 | 3 | 4 | import com.intellij.notification.NotificationType; 5 | 6 | public class GaugeNotification { 7 | public String title; 8 | public String message; 9 | public String type; 10 | 11 | public NotificationType getType() { 12 | switch (type) { 13 | case "error": 14 | return NotificationType.ERROR; 15 | case "warning": 16 | return NotificationType.WARNING; 17 | case "info": 18 | return NotificationType.INFORMATION; 19 | default: 20 | return NotificationType.INFORMATION; 21 | 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/runner/event/TableInfo.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution.runner.event; 2 | 3 | public class TableInfo { 4 | public String text; 5 | public int rowIndex; 6 | } 7 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/runner/processors/EventProcessor.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution.runner.processors; 2 | 3 | import com.thoughtworks.gauge.execution.runner.event.ExecutionEvent; 4 | 5 | import java.text.ParseException; 6 | 7 | public interface EventProcessor { 8 | Boolean canProcess(ExecutionEvent event) throws ParseException; 9 | 10 | Boolean process(ExecutionEvent event) throws ParseException; 11 | } 12 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/runner/processors/NotificationEventProcessor.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution.runner.processors; 2 | 3 | 4 | import com.intellij.notification.Notification; 5 | import com.intellij.notification.NotificationListener; 6 | import com.intellij.notification.Notifications; 7 | import com.thoughtworks.gauge.execution.runner.MessageProcessor; 8 | import com.thoughtworks.gauge.execution.runner.TestsCache; 9 | import com.thoughtworks.gauge.execution.runner.event.ExecutionEvent; 10 | 11 | public class NotificationEventProcessor extends GaugeEventProcessor { 12 | 13 | public NotificationEventProcessor(MessageProcessor processor, TestsCache cache) { 14 | super(processor, cache); 15 | } 16 | 17 | @Override 18 | Boolean onStart(ExecutionEvent event) { 19 | return true; 20 | } 21 | 22 | @Override 23 | Boolean onEnd(ExecutionEvent event) { 24 | String title = event.notification.title; 25 | String message = event.notification.message; 26 | Notification notification = new Notification("Gauge", title, message, event.notification.getType(), NotificationListener.URL_OPENING_LISTENER); 27 | Notifications.Bus.notify(notification); 28 | return true; 29 | } 30 | 31 | @Override 32 | public Boolean canProcess(ExecutionEvent event) { 33 | return event.type.equalsIgnoreCase(ExecutionEvent.NOTIFICATION); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/runner/processors/StandardOutputEventProcessor.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution.runner.processors; 2 | 3 | import com.thoughtworks.gauge.execution.runner.MessageProcessor; 4 | import com.thoughtworks.gauge.execution.runner.TestsCache; 5 | import com.thoughtworks.gauge.execution.runner.event.ExecutionEvent; 6 | import org.apache.commons.lang3.StringUtils; 7 | 8 | public class StandardOutputEventProcessor extends GaugeEventProcessor { 9 | 10 | public StandardOutputEventProcessor(MessageProcessor processor, TestsCache cache) { 11 | super(processor, cache); 12 | } 13 | 14 | @Override 15 | Boolean onStart(ExecutionEvent event) { 16 | return true; 17 | } 18 | 19 | @Override 20 | Boolean onEnd(ExecutionEvent event) { 21 | getProcessor().process(StringUtils.appendIfMissing(event.message, "\n")); 22 | getProcessor().processLineBreak(); 23 | return true; 24 | } 25 | 26 | @Override 27 | public Boolean canProcess(ExecutionEvent event) { 28 | return event.type.equalsIgnoreCase(ExecutionEvent.STANDARD_OUTPUT); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/runner/processors/SuiteEventProcessor.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution.runner.processors; 2 | 3 | import com.thoughtworks.gauge.execution.runner.MessageProcessor; 4 | import com.thoughtworks.gauge.execution.runner.TestsCache; 5 | import com.thoughtworks.gauge.execution.runner.event.ExecutionEvent; 6 | 7 | import java.text.ParseException; 8 | 9 | public class SuiteEventProcessor extends GaugeEventProcessor { 10 | private static final String BEFORE_SUITE = "Before Suite"; 11 | private static final String AFTER_SUITE = "After Suite"; 12 | static final int SUITE_ID = 0; 13 | 14 | public SuiteEventProcessor(MessageProcessor processor, TestsCache cache) { 15 | super(processor, cache); 16 | } 17 | 18 | @Override 19 | Boolean onStart(ExecutionEvent event) throws ParseException { 20 | return getProcessor().processLineBreak(); 21 | } 22 | 23 | @Override 24 | Boolean onEnd(ExecutionEvent event) throws ParseException { 25 | return super.addHooks(event, BEFORE_SUITE, AFTER_SUITE, "", SUITE_ID); 26 | } 27 | 28 | @Override 29 | public Boolean canProcess(ExecutionEvent event) throws ParseException { 30 | return event.type.equalsIgnoreCase(ExecutionEvent.SUITE_START) || 31 | event.type.equalsIgnoreCase(ExecutionEvent.SUITE_END); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/execution/runner/processors/UnexpectedEndProcessor.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution.runner.processors; 2 | 3 | import com.intellij.execution.testframework.sm.ServiceMessageBuilder; 4 | import com.thoughtworks.gauge.execution.runner.MessageProcessor; 5 | import com.thoughtworks.gauge.execution.runner.TestsCache; 6 | import com.thoughtworks.gauge.execution.runner.event.ExecutionEvent; 7 | 8 | import java.text.ParseException; 9 | 10 | public class UnexpectedEndProcessor extends GaugeEventProcessor { 11 | public UnexpectedEndProcessor(MessageProcessor processor, TestsCache cache) { 12 | super(processor, cache); 13 | } 14 | 15 | @Override 16 | Boolean onStart(ExecutionEvent event) throws ParseException { 17 | return true; 18 | } 19 | 20 | @Override 21 | Boolean onEnd(ExecutionEvent event) throws ParseException { 22 | String name = "Failed"; 23 | ServiceMessageBuilder msg = ServiceMessageBuilder.testFailed(name); 24 | if (event.result.skipped()) { 25 | name = "Ignored"; 26 | msg = ServiceMessageBuilder.testIgnored(name); 27 | } 28 | getProcessor().process(ServiceMessageBuilder.testStarted(name), 1, SuiteEventProcessor.SUITE_ID); 29 | msg.addAttribute("message", " "); 30 | getProcessor().process(msg, 1, 0); 31 | getProcessor().process(ServiceMessageBuilder.testFinished(name), 1, SuiteEventProcessor.SUITE_ID); 32 | return false; 33 | } 34 | 35 | @Override 36 | public Boolean process(ExecutionEvent event) throws ParseException { 37 | return onEnd(event); 38 | } 39 | 40 | @Override 41 | public Boolean canProcess(ExecutionEvent event) throws ParseException { 42 | return getCache().getCurrentId() == SuiteEventProcessor.SUITE_ID; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/extract/ExtractConceptInfo.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.extract; 2 | 3 | public class ExtractConceptInfo { 4 | public final String conceptName; 5 | public final String fileName; 6 | public final Boolean cancelled; 7 | 8 | public ExtractConceptInfo(String conceptName, String fileName, Boolean cancelled) { 9 | this.conceptName = conceptName; 10 | this.fileName = fileName; 11 | this.cancelled = cancelled; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/extract/stepBuilder/ConceptStepsBuilder.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.extract.stepBuilder; 2 | 3 | import com.intellij.openapi.editor.Editor; 4 | import com.intellij.psi.PsiElement; 5 | import com.intellij.psi.PsiFile; 6 | import com.thoughtworks.gauge.language.psi.impl.ConceptStepImpl; 7 | 8 | import java.util.List; 9 | 10 | public class ConceptStepsBuilder extends StepsBuilder { 11 | public ConceptStepsBuilder(Editor editor, PsiFile psiFile) { 12 | super(editor, psiFile); 13 | } 14 | 15 | @Override 16 | public List build() { 17 | List specSteps = getPsiElements(ConceptStepImpl.class); 18 | Integer count = 0; 19 | for (PsiElement element : specSteps) { 20 | ConceptStepImpl specStep = (ConceptStepImpl) element; 21 | if (specStep.getTable() != null && TextToTableMap.get(specStep.getTable().getText().trim()) == null) { 22 | tableMap.put("table" + (++count).toString(), specStep.getTable().getText().trim()); 23 | TextToTableMap.put(specStep.getTable().getText().trim(), "table" + (count).toString()); 24 | } 25 | } 26 | return specSteps; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/extract/stepBuilder/SpecStepsBuilder.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.extract.stepBuilder; 2 | 3 | import com.intellij.openapi.editor.Editor; 4 | import com.intellij.psi.PsiElement; 5 | import com.intellij.psi.PsiFile; 6 | import com.thoughtworks.gauge.language.psi.impl.SpecStepImpl; 7 | 8 | import java.util.List; 9 | 10 | public class SpecStepsBuilder extends StepsBuilder { 11 | 12 | public SpecStepsBuilder(Editor editor, PsiFile psiFile) { 13 | super(editor, psiFile); 14 | } 15 | 16 | public List build() { 17 | List specSteps = getPsiElements(SpecStepImpl.class); 18 | Integer count = 0; 19 | for (PsiElement element : specSteps) { 20 | SpecStepImpl specStep = (SpecStepImpl) element; 21 | if (specStep.getInlineTable() != null && TextToTableMap.get(specStep.getInlineTable().getText().trim()) == null) { 22 | tableMap.put("table" + (++count).toString(), specStep.getInlineTable().getText().trim()); 23 | TextToTableMap.put(specStep.getInlineTable().getText().trim(), "table" + (count).toString()); 24 | } 25 | } 26 | return specSteps; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/findUsages/ConceptStepFindUsagesProvider.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.findUsages; 8 | 9 | import com.intellij.lang.HelpID; 10 | import com.intellij.lang.cacheBuilder.WordsScanner; 11 | import com.intellij.lang.findUsages.FindUsagesProvider; 12 | import com.intellij.psi.PsiElement; 13 | import com.thoughtworks.gauge.language.psi.impl.ConceptStepImpl; 14 | import com.thoughtworks.gauge.language.psi.impl.SpecStepImpl; 15 | import org.jetbrains.annotations.NotNull; 16 | import org.jetbrains.annotations.Nullable; 17 | 18 | public class ConceptStepFindUsagesProvider implements FindUsagesProvider { 19 | @Nullable 20 | @Override 21 | public WordsScanner getWordsScanner() { 22 | return new ConceptStepWordScanner(); 23 | } 24 | 25 | @Override 26 | public boolean canFindUsagesFor(PsiElement psiElement) { 27 | return psiElement instanceof SpecStepImpl || psiElement instanceof ConceptStepImpl; 28 | } 29 | 30 | @Nullable 31 | @Override 32 | public String getHelpId(PsiElement psiElement) { 33 | return HelpID.FIND_OTHER_USAGES; 34 | } 35 | 36 | @NotNull 37 | @Override 38 | public String getType(PsiElement psiElement) { 39 | if (psiElement instanceof ConceptStepImpl) return "Step"; 40 | return ""; 41 | } 42 | 43 | @NotNull 44 | @Override 45 | public String getDescriptiveName(@NotNull PsiElement psiElement) { 46 | return psiElement.toString(); 47 | } 48 | 49 | @NotNull 50 | @Override 51 | public String getNodeText(@NotNull PsiElement psiElement, boolean b) { 52 | return getDescriptiveName(psiElement); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/findUsages/ConceptStepWordScanner.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.findUsages; 8 | 9 | import com.intellij.lang.cacheBuilder.DefaultWordsScanner; 10 | import com.intellij.psi.tree.TokenSet; 11 | import com.thoughtworks.gauge.language.token.ConceptTokenTypes; 12 | import com.thoughtworks.gauge.lexer.ConceptLexer; 13 | 14 | 15 | public class ConceptStepWordScanner extends DefaultWordsScanner { 16 | public ConceptStepWordScanner() { 17 | super(new ConceptLexer(), TokenSet.create(ConceptTokenTypes.STEP), TokenSet.create(ConceptTokenTypes.COMMENT), TokenSet.create(ConceptTokenTypes.STEP)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/findUsages/CustomFindUsagesHandlerFactory.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.findUsages; 8 | 9 | import com.intellij.find.findUsages.FindUsagesHandler; 10 | import com.intellij.find.findUsages.FindUsagesHandlerFactory; 11 | import com.intellij.psi.PsiElement; 12 | import com.intellij.psi.PsiMethod; 13 | import com.thoughtworks.gauge.language.psi.impl.ConceptStepImpl; 14 | import com.thoughtworks.gauge.language.psi.impl.SpecStepImpl; 15 | import com.thoughtworks.gauge.util.StepUtil; 16 | import org.jetbrains.annotations.Nullable; 17 | 18 | public class CustomFindUsagesHandlerFactory extends FindUsagesHandlerFactory { 19 | @Override 20 | public boolean canFindUsages(PsiElement psiElement) { 21 | if (psiElement instanceof PsiMethod) 22 | return StepUtil.getGaugeStepAnnotationValues((PsiMethod) psiElement).size() > 0; 23 | return psiElement instanceof SpecStepImpl || psiElement instanceof ConceptStepImpl; 24 | } 25 | 26 | @Nullable 27 | @Override 28 | public FindUsagesHandler createFindUsagesHandler(PsiElement psiElement, boolean b) { 29 | return new StepFindUsagesHandler(psiElement); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/findUsages/SpecStepFindUsagesProvider.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.findUsages; 8 | 9 | import com.intellij.lang.HelpID; 10 | import com.intellij.lang.cacheBuilder.WordsScanner; 11 | import com.intellij.lang.findUsages.FindUsagesProvider; 12 | import com.intellij.psi.PsiElement; 13 | import com.intellij.psi.PsiNamedElement; 14 | import com.thoughtworks.gauge.language.psi.impl.ConceptStepImpl; 15 | import com.thoughtworks.gauge.language.psi.impl.SpecStepImpl; 16 | import org.jetbrains.annotations.NotNull; 17 | import org.jetbrains.annotations.Nullable; 18 | 19 | public class SpecStepFindUsagesProvider implements FindUsagesProvider { 20 | @Nullable 21 | @Override 22 | public WordsScanner getWordsScanner() { 23 | return new SpecStepWordScanner(); 24 | } 25 | 26 | @Override 27 | public boolean canFindUsagesFor(PsiElement psiElement) { 28 | return psiElement instanceof SpecStepImpl || psiElement instanceof ConceptStepImpl; 29 | } 30 | 31 | @Nullable 32 | @Override 33 | public String getHelpId(PsiElement psiElement) { 34 | return HelpID.FIND_OTHER_USAGES; 35 | } 36 | 37 | @NotNull 38 | @Override 39 | public String getType(PsiElement psiElement) { 40 | if (psiElement instanceof SpecStepImpl) return "Step"; 41 | return ""; 42 | } 43 | 44 | @NotNull 45 | @Override 46 | public String getDescriptiveName(@NotNull PsiElement psiElement) { 47 | return ((PsiNamedElement) psiElement).getName(); 48 | } 49 | 50 | @NotNull 51 | @Override 52 | public String getNodeText(@NotNull PsiElement psiElement, boolean b) { 53 | return getDescriptiveName(psiElement); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/findUsages/SpecStepWordScanner.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.findUsages; 8 | 9 | import com.intellij.lang.cacheBuilder.DefaultWordsScanner; 10 | import com.intellij.psi.tree.TokenSet; 11 | import com.thoughtworks.gauge.language.token.SpecTokenTypes; 12 | import com.thoughtworks.gauge.lexer.SpecLexer; 13 | 14 | 15 | public class SpecStepWordScanner extends DefaultWordsScanner { 16 | public SpecStepWordScanner() { 17 | super(new SpecLexer(), TokenSet.create(SpecTokenTypes.STEP), TokenSet.create(SpecTokenTypes.COMMENT), TokenSet.create(SpecTokenTypes.STEP)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/folding/ConceptFoldingBuilder.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.folding; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.lang.folding.FoldingDescriptor; 5 | import com.intellij.openapi.editor.Document; 6 | import com.intellij.psi.tree.TokenSet; 7 | import com.thoughtworks.gauge.language.token.ConceptTokenTypes; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public class ConceptFoldingBuilder extends GaugeFoldingBuilder { 14 | @NotNull 15 | @Override 16 | public FoldingDescriptor[] buildFoldRegions(@NotNull ASTNode astNode, @NotNull Document document) { 17 | List descriptors = new ArrayList<>(); 18 | for (ASTNode node : astNode.getChildren(TokenSet.create(ConceptTokenTypes.CONCEPT))) 19 | addNode(descriptors, node, node.findChildByType(ConceptTokenTypes.CONCEPT_HEADING)); 20 | return descriptors.toArray(new FoldingDescriptor[0]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/folding/GaugeFoldingBuilder.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.folding; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.lang.folding.FoldingBuilder; 5 | import com.intellij.lang.folding.FoldingDescriptor; 6 | import com.intellij.openapi.util.TextRange; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import java.util.List; 11 | 12 | abstract class GaugeFoldingBuilder implements FoldingBuilder { 13 | 14 | protected void addNode(List descriptors, ASTNode node, ASTNode heading) { 15 | if (heading == null) return; 16 | String text = node.getText().endsWith("\n") ? node.getText() : node.getText() + "\n"; 17 | int startOffset = node.getStartOffset() + getLength(heading); 18 | int endOffset = node.getStartOffset() + text.lastIndexOf("\n"); 19 | if (text.endsWith("\n\n")) endOffset--; 20 | if (endOffset <= startOffset) return; 21 | TextRange textRange = new TextRange(startOffset, endOffset); 22 | descriptors.add(new FoldingDescriptor(node, textRange)); 23 | } 24 | 25 | @Nullable 26 | @Override 27 | public String getPlaceholderText(@NotNull ASTNode astNode) { 28 | return " ..."; 29 | } 30 | 31 | @Override 32 | public boolean isCollapsedByDefault(@NotNull ASTNode astNode) { 33 | return false; 34 | } 35 | 36 | @NotNull 37 | private Integer getLength(ASTNode heading) { 38 | return heading.getText().length(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/folding/SpecFoldingBuilder.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.folding; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.lang.folding.FoldingDescriptor; 5 | import com.intellij.openapi.editor.Document; 6 | import com.intellij.psi.tree.IElementType; 7 | import com.intellij.psi.tree.TokenSet; 8 | import com.thoughtworks.gauge.language.token.SpecTokenTypes; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | public class SpecFoldingBuilder extends GaugeFoldingBuilder { 15 | @NotNull 16 | @Override 17 | public FoldingDescriptor[] buildFoldRegions(@NotNull ASTNode astNode, @NotNull Document document) { 18 | List descriptors = new ArrayList<>(); 19 | addNodes(astNode, descriptors, SpecTokenTypes.SPEC_DETAIL, SpecTokenTypes.SPEC_HEADING); 20 | addNodes(astNode, descriptors, SpecTokenTypes.SCENARIO, SpecTokenTypes.SCENARIO_HEADING); 21 | addNodes(astNode, descriptors, SpecTokenTypes.TEARDOWN, SpecTokenTypes.TEARDOWN_IDENTIFIER); 22 | return descriptors.toArray(new FoldingDescriptor[0]); 23 | } 24 | 25 | private void addNodes(@NotNull ASTNode astNode, List descriptors, IElementType pNode, IElementType cNode) { 26 | for (ASTNode node : astNode.getChildren(TokenSet.create(pNode))) 27 | addNode(descriptors, node, node.findChildByType(cNode)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/helper/ModuleHelper.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.helper; 2 | 3 | import com.intellij.openapi.module.Module; 4 | import com.intellij.openapi.module.ModuleUtil; 5 | import com.intellij.openapi.project.Project; 6 | import com.intellij.openapi.vfs.VirtualFile; 7 | import com.intellij.psi.PsiElement; 8 | import com.thoughtworks.gauge.util.GaugeUtil; 9 | 10 | public class ModuleHelper { 11 | public boolean isGaugeModule(PsiElement element) { 12 | Module module = GaugeUtil.moduleForPsiElement(element); 13 | return module != null && GaugeUtil.isGaugeModule(module); 14 | } 15 | 16 | public boolean isGaugeModule(Module module) { 17 | return GaugeUtil.isGaugeModule(module); 18 | } 19 | 20 | public Module getModule(PsiElement step) { 21 | return GaugeUtil.moduleForPsiElement(step); 22 | } 23 | 24 | public Module getModule(VirtualFile file, Project project) { 25 | return ModuleUtil.findModuleForFile(file, project); 26 | } 27 | 28 | public boolean isGaugeModule(VirtualFile file, Project project) { 29 | Module module = ModuleUtil.findModuleForFile(file, project); 30 | return module != null && isGaugeModule(module); 31 | } 32 | } -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/highlight/ConceptSyntaxHighlighterFactory.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.highlight; 8 | 9 | import com.intellij.openapi.fileTypes.SyntaxHighlighter; 10 | import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; 11 | import com.intellij.openapi.project.Project; 12 | import com.intellij.openapi.vfs.VirtualFile; 13 | import org.jetbrains.annotations.NotNull; 14 | 15 | /** 16 | * A factory for creating a syntax highlighter for Gauge concepts. 17 | */ 18 | public class ConceptSyntaxHighlighterFactory extends SyntaxHighlighterFactory { 19 | @NotNull 20 | @Override 21 | public SyntaxHighlighter getSyntaxHighlighter(Project project, VirtualFile virtualFile) { 22 | return new ConceptSyntaxHighlighter(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/highlight/ErrorHighLighter.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.highlight; 2 | 3 | import com.intellij.openapi.util.Condition; 4 | import com.intellij.openapi.vfs.VirtualFile; 5 | import com.thoughtworks.gauge.util.GaugeUtil; 6 | 7 | /** 8 | * The highlighter condition that determines if a Gauge file should be displayed differently due to errors within (e.g. 9 | * syntax errors). In most themes, this will result in the Gauge file with errors should be red. 10 | */ 11 | public class ErrorHighLighter implements Condition { 12 | 13 | @Override 14 | public boolean value(VirtualFile virtualFile) { 15 | return GaugeUtil.isGaugeFile(virtualFile); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/highlight/SpecSyntaxHighlighterFactory.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.highlight; 8 | 9 | import com.intellij.openapi.fileTypes.SyntaxHighlighter; 10 | import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; 11 | import com.intellij.openapi.project.Project; 12 | import com.intellij.openapi.vfs.VirtualFile; 13 | import org.jetbrains.annotations.NotNull; 14 | 15 | /** 16 | * A factory for creating a syntax highlighter for Gauge specifications. 17 | */ 18 | public class SpecSyntaxHighlighterFactory extends SyntaxHighlighterFactory { 19 | @NotNull 20 | @Override 21 | public SyntaxHighlighter getSyntaxHighlighter(Project project, VirtualFile virtualFile) { 22 | return new SpecSyntaxHighlighter(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/idea/icon/GaugeIcon.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.idea.icon; 8 | 9 | import com.intellij.openapi.util.IconLoader; 10 | 11 | import javax.swing.*; 12 | 13 | public interface GaugeIcon { 14 | 15 | Icon GAUGE_SPEC_FILE_ICON = IconLoader.findIcon("/icons/logo.png"); 16 | Icon GAUGE_CONCEPT_FILE_ICON = IconLoader.findIcon("/icons/logo.png"); 17 | Icon GAUGE_LOGO = IconLoader.findIcon("/icons/Gauge-Logo.png"); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/idea/template/LiveTemplateContext.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.idea.template; 2 | 3 | import com.intellij.codeInsight.template.TemplateContextType; 4 | import com.intellij.psi.PsiFile; 5 | import com.thoughtworks.gauge.language.ConceptFileType; 6 | import com.thoughtworks.gauge.language.SpecFileType; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class LiveTemplateContext extends TemplateContextType { 10 | protected LiveTemplateContext() { 11 | super("GAUGE", "Gauge"); 12 | } 13 | 14 | @Override 15 | public boolean isInContext(@NotNull PsiFile psiFile, int i) { 16 | return psiFile.getFileType() instanceof SpecFileType || psiFile.getFileType() instanceof ConceptFileType; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/idea/template/SpecificationLiveTemplate.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.idea.template; 8 | 9 | import com.intellij.ide.fileTemplates.FileTemplateDescriptor; 10 | import com.intellij.ide.fileTemplates.FileTemplateGroupDescriptor; 11 | import com.intellij.ide.fileTemplates.FileTemplateGroupDescriptorFactory; 12 | import com.thoughtworks.gauge.idea.icon.GaugeIcon; 13 | import com.thoughtworks.gauge.language.ConceptFileType; 14 | import com.thoughtworks.gauge.language.SpecFileType; 15 | 16 | public class SpecificationLiveTemplate implements FileTemplateGroupDescriptorFactory { 17 | @Override 18 | public FileTemplateGroupDescriptor getFileTemplatesDescriptor() { 19 | 20 | FileTemplateGroupDescriptor descriptor = new FileTemplateGroupDescriptor("Specification", GaugeIcon.GAUGE_SPEC_FILE_ICON); 21 | descriptor.addTemplate(new FileTemplateDescriptor("Specification.spec", SpecFileType.INSTANCE.getIcon())); 22 | descriptor.addTemplate(new FileTemplateDescriptor("Concept.cpt", ConceptFileType.INSTANCE.getIcon())); 23 | return descriptor; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/idea/template/TableTemplateProvider.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.idea.template; 8 | 9 | import com.intellij.codeInsight.template.impl.DefaultLiveTemplatesProvider; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | public class TableTemplateProvider implements DefaultLiveTemplatesProvider { 13 | @Override 14 | public String[] getDefaultLiveTemplateFiles() { 15 | return new String[]{"liveTemplates/gaugeTemplates"}; 16 | } 17 | 18 | @Nullable 19 | @Override 20 | public String[] getHiddenLiveTemplateFiles() { 21 | return new String[]{}; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/inspection/ConceptInspectionProvider.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.inspection; 2 | 3 | import com.intellij.psi.PsiElement; 4 | import com.thoughtworks.gauge.language.psi.ConceptConceptHeading; 5 | import com.thoughtworks.gauge.language.psi.ConceptStep; 6 | 7 | public class ConceptInspectionProvider extends GaugeInspectionProvider { 8 | PsiElement getElement(PsiElement element) { 9 | if (element == null) return null; 10 | if (element instanceof ConceptStep || element instanceof ConceptConceptHeading) return element; 11 | return getElement(element.getParent()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/inspection/GaugeError.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.inspection; 2 | 3 | import com.intellij.openapi.diagnostic.Logger; 4 | import com.intellij.openapi.util.text.StringUtil; 5 | import com.thoughtworks.gauge.Constants; 6 | 7 | public class GaugeError { 8 | private static final Logger LOG = Logger.getInstance("#com.thoughtworks.gauge.inspection.GaugeError"); 9 | private String type; 10 | private String fileName; 11 | private int lineNumber; 12 | private String message; 13 | 14 | public GaugeError(String type, String fileName, int lineNumber, String message) { 15 | this.type = type; 16 | this.fileName = fileName; 17 | this.lineNumber = lineNumber; 18 | this.message = String.format("%s line number: %d, %s", this.type, lineNumber, message); 19 | } 20 | 21 | boolean isFrom(String fileName) { 22 | return this.fileName.equals(fileName); 23 | } 24 | 25 | public String getMessage() { 26 | return message; 27 | } 28 | 29 | public int getLineNumber() { 30 | return lineNumber; 31 | } 32 | 33 | public String getFileName() { 34 | return fileName; 35 | } 36 | 37 | int getOffset(String text) { 38 | return StringUtil.lineColToOffset(text, lineNumber - 1, 0); 39 | } 40 | 41 | public static GaugeError getInstance(String error) { 42 | try { 43 | String[] parts = error.split(" "); 44 | String[] fileInfo = parts[1].split(Constants.SPEC_SCENARIO_DELIMITER); 45 | return new GaugeError(parts[0], fileInfo[0], Integer.parseInt(fileInfo[1]), error.split(":\\d+:? ")[1]); 46 | } catch (Exception e) { 47 | LOG.debug(e); 48 | return null; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/inspection/GaugeErrors.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.inspection; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | class GaugeErrors { 9 | private static Map> e = new HashMap<>(); 10 | 11 | static void add(String key, List errors) { 12 | e.put(key, errors); 13 | } 14 | 15 | static void init() { 16 | e = new HashMap<>(); 17 | } 18 | 19 | static List get(String key) { 20 | return e.get(key) == null ? new ArrayList<>() : e.get(key); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/inspection/GaugeInspectionHelper.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.inspection; 2 | 3 | import com.intellij.openapi.diagnostic.Logger; 4 | import com.thoughtworks.gauge.Constants; 5 | import com.thoughtworks.gauge.exception.GaugeNotFoundException; 6 | import com.thoughtworks.gauge.settings.GaugeSettingsModel; 7 | import com.thoughtworks.gauge.util.GaugeUtil; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import java.io.File; 11 | import java.io.IOException; 12 | import java.util.ArrayList; 13 | import java.util.Arrays; 14 | import java.util.List; 15 | import java.util.Objects; 16 | import java.util.stream.Collectors; 17 | 18 | import static com.thoughtworks.gauge.util.GaugeUtil.getGaugeSettings; 19 | 20 | class GaugeInspectionHelper { 21 | private static final Logger LOG = Logger.getInstance("#com.thoughtworks.gauge.inspection.GaugeInspectionHelper"); 22 | @NotNull 23 | static List getErrors(File directory) { 24 | try { 25 | GaugeSettingsModel settings = getGaugeSettings(); 26 | ProcessBuilder processBuilder = new ProcessBuilder(settings.getGaugePath(), Constants.VALIDATE); 27 | GaugeUtil.setGaugeEnvironmentsTo(processBuilder, settings); 28 | processBuilder.directory(directory); 29 | Process process = processBuilder.start(); 30 | process.waitFor(); 31 | String[] errors = GaugeUtil.getOutput(process.getInputStream(), "\n").split("\n"); 32 | return Arrays.stream(errors).map(GaugeError::getInstance).filter(Objects::nonNull).collect(Collectors.toList()); 33 | } catch (IOException | InterruptedException | GaugeNotFoundException e) { 34 | LOG.debug(e); 35 | e.printStackTrace(); 36 | } 37 | return new ArrayList<>(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/inspection/GaugeInspectionProvider.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.inspection; 2 | 3 | import com.intellij.codeInspection.InspectionManager; 4 | import com.intellij.codeInspection.LocalInspectionTool; 5 | import com.intellij.codeInspection.ProblemDescriptor; 6 | import com.intellij.codeInspection.ProblemHighlightType; 7 | import com.intellij.psi.PsiElement; 8 | import com.intellij.psi.PsiFile; 9 | import com.thoughtworks.gauge.util.GaugeUtil; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jetbrains.annotations.Nullable; 12 | 13 | import java.io.File; 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | abstract class GaugeInspectionProvider extends LocalInspectionTool { 18 | @Nullable 19 | @Override 20 | public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { 21 | if (isOnTheFly) return new ProblemDescriptor[0]; 22 | File dir = GaugeUtil.moduleDir(GaugeUtil.moduleForPsiElement(file)); 23 | if (dir == null) return new ProblemDescriptor[0]; 24 | return getDescriptors(GaugeErrors.get(dir.getAbsolutePath()), manager, file); 25 | } 26 | 27 | private ProblemDescriptor[] getDescriptors(List errors, InspectionManager manager, PsiFile file) { 28 | List descriptors = new ArrayList<>(); 29 | for (GaugeError e : errors) { 30 | if (!e.isFrom(file.getVirtualFile().getPath())) continue; 31 | PsiElement element = getElement(file.findElementAt(e.getOffset(file.getText()))); 32 | if (element == null) continue; 33 | descriptors.add(manager.createProblemDescriptor(element, e.getMessage(), null, ProblemHighlightType.ERROR, false, false)); 34 | } 35 | return descriptors.toArray(new ProblemDescriptor[0]); 36 | } 37 | 38 | abstract PsiElement getElement(PsiElement element); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/inspection/GlobalInspectionProvider.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.inspection; 2 | 3 | import com.intellij.analysis.AnalysisScope; 4 | import com.intellij.codeInspection.GlobalInspectionContext; 5 | import com.intellij.codeInspection.GlobalInspectionTool; 6 | import com.intellij.codeInspection.InspectionManager; 7 | import com.intellij.codeInspection.ProblemDescriptionsProcessor; 8 | import com.intellij.openapi.module.Module; 9 | import com.intellij.openapi.module.ModuleManager; 10 | import com.thoughtworks.gauge.util.GaugeUtil; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | import java.io.File; 14 | 15 | public class GlobalInspectionProvider extends GlobalInspectionTool { 16 | @Override 17 | public void runInspection(@NotNull AnalysisScope scope, @NotNull InspectionManager manager, @NotNull GlobalInspectionContext globalContext, @NotNull ProblemDescriptionsProcessor processor) { 18 | GaugeErrors.init(); 19 | Module[] modules = ModuleManager.getInstance(globalContext.getProject()).getModules(); 20 | for (Module module : modules) { 21 | File dir = GaugeUtil.moduleDir(module); 22 | GaugeErrors.add(dir.getAbsolutePath(), GaugeInspectionHelper.getErrors(dir)); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/inspection/SpecInspectionProvider.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.inspection; 2 | 3 | import com.intellij.psi.PsiElement; 4 | import com.intellij.psi.impl.source.tree.LeafPsiElement; 5 | import com.intellij.psi.tree.IElementType; 6 | import com.thoughtworks.gauge.language.psi.SpecStep; 7 | import com.thoughtworks.gauge.language.token.SpecTokenTypes; 8 | 9 | import java.util.Arrays; 10 | import java.util.List; 11 | 12 | public class SpecInspectionProvider extends GaugeInspectionProvider { 13 | PsiElement getElement(PsiElement element) { 14 | if (element == null) return null; 15 | if (element instanceof SpecStep) return element; 16 | List types = Arrays.asList(SpecTokenTypes.SPEC_HEADING, SpecTokenTypes.SCENARIO_HEADING); 17 | if (element instanceof LeafPsiElement && types.contains(((LeafPsiElement) element).getElementType())) 18 | return element; 19 | return getElement(element.getParent()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/intention/ConvertArgTypeIntentionBase.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.intention; 2 | 3 | import com.intellij.codeInsight.intention.IntentionAction; 4 | import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; 5 | import com.intellij.openapi.editor.Editor; 6 | import com.intellij.openapi.project.Project; 7 | import com.intellij.psi.PsiElement; 8 | import com.intellij.psi.util.PsiTreeUtil; 9 | import com.intellij.util.IncorrectOperationException; 10 | import com.thoughtworks.gauge.language.psi.ConceptArg; 11 | import com.thoughtworks.gauge.language.psi.SpecArg; 12 | import org.apache.commons.lang.StringUtils; 13 | import org.jetbrains.annotations.Nls; 14 | import org.jetbrains.annotations.NotNull; 15 | 16 | abstract class ConvertArgTypeIntentionBase extends PsiElementBaseIntentionAction implements IntentionAction { 17 | @Override 18 | public boolean startInWriteAction() { 19 | return true; 20 | } 21 | 22 | @Override 23 | public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { 24 | PsiElement arg = PsiTreeUtil.getParentOfType(element, SpecArg.class); 25 | if (arg == null) 26 | arg = PsiTreeUtil.getParentOfType(element, ConceptArg.class); 27 | if (arg == null) 28 | return; 29 | String text = arg.getText(); 30 | String paramText = StringUtils.substring(text, 1, text.length() - 1); 31 | String newText = getReplacementString(paramText); 32 | int startOffset = arg.getTextOffset(); 33 | int endOffset = startOffset + arg.getTextLength(); 34 | editor.getDocument().replaceString(startOffset, endOffset, newText); 35 | editor.getSelectionModel().setSelection(startOffset + 1, endOffset - 1); 36 | } 37 | 38 | @NotNull 39 | protected abstract String getReplacementString(String paramText); 40 | 41 | @Nls 42 | @NotNull 43 | @Override 44 | public String getFamilyName() { 45 | return getText(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/intention/ConvertToDynamicArgIntention.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.intention; 2 | 3 | import com.intellij.openapi.editor.Editor; 4 | import com.intellij.openapi.project.Project; 5 | import com.intellij.psi.PsiElement; 6 | import com.intellij.psi.util.PsiTreeUtil; 7 | import com.thoughtworks.gauge.language.psi.ConceptStaticArg; 8 | import com.thoughtworks.gauge.language.psi.SpecStaticArg; 9 | import org.jetbrains.annotations.Nls; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | public class ConvertToDynamicArgIntention extends ConvertArgTypeIntentionBase { 13 | @Nls 14 | @NotNull 15 | @Override 16 | public String getText() { 17 | return "Convert to Dynamic Parameter"; 18 | } 19 | 20 | @Override 21 | public boolean isAvailable(@NotNull Project project, Editor editor, PsiElement element) { 22 | if (null == element) return false; 23 | if (!element.isWritable()) return false; 24 | return PsiTreeUtil.getParentOfType(element, SpecStaticArg.class) != null 25 | || PsiTreeUtil.getParentOfType(element, ConceptStaticArg.class) != null; 26 | } 27 | 28 | @NotNull 29 | @Override 30 | protected String getReplacementString(String paramText) { 31 | return "<" + paramText + ">"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/intention/ConvertToStaticArgIntention.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.intention; 2 | 3 | import com.intellij.codeInsight.intention.IntentionAction; 4 | import com.intellij.openapi.editor.Editor; 5 | import com.intellij.openapi.project.Project; 6 | import com.intellij.psi.PsiElement; 7 | import com.intellij.psi.util.PsiTreeUtil; 8 | import com.thoughtworks.gauge.language.psi.ConceptDynamicArg; 9 | import com.thoughtworks.gauge.language.psi.SpecDynamicArg; 10 | import org.jetbrains.annotations.Nls; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | public class ConvertToStaticArgIntention extends ConvertArgTypeIntentionBase { 14 | @Nls 15 | @NotNull 16 | @Override 17 | public String getText() { 18 | return "Convert to Static Parameter"; 19 | } 20 | 21 | @Override 22 | public boolean isAvailable(@NotNull Project project, Editor editor, PsiElement element) { 23 | if (null == element) return false; 24 | if (!element.isWritable()) return false; 25 | return PsiTreeUtil.getParentOfType(element, SpecDynamicArg.class) != null 26 | || PsiTreeUtil.getParentOfType(element, ConceptDynamicArg.class) != null; 27 | } 28 | 29 | @NotNull 30 | @Override 31 | protected String getReplacementString(String paramText) { 32 | return "\"" + paramText + "\""; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/Concept.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language; 8 | 9 | import com.intellij.lang.Language; 10 | 11 | public class Concept extends Language { 12 | public static final Concept INSTANCE = new Concept(); 13 | 14 | private Concept() { 15 | super("Concept"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/ConceptFile.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language; 8 | 9 | import com.intellij.extapi.psi.PsiFileBase; 10 | import com.intellij.openapi.fileTypes.FileType; 11 | import com.intellij.psi.FileViewProvider; 12 | import org.jetbrains.annotations.NotNull; 13 | 14 | 15 | public class ConceptFile extends PsiFileBase { 16 | public ConceptFile(@NotNull FileViewProvider viewProvider) { 17 | super(viewProvider, Concept.INSTANCE); 18 | } 19 | 20 | @NotNull 21 | @Override 22 | public FileType getFileType() { 23 | return ConceptFileType.INSTANCE; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "Concept File"; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/ConceptFileType.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language; 8 | 9 | import com.intellij.openapi.fileTypes.FileType; 10 | import com.intellij.openapi.fileTypes.LanguageFileType; 11 | import com.thoughtworks.gauge.Constants; 12 | import com.thoughtworks.gauge.idea.icon.GaugeIcon; 13 | import org.jetbrains.annotations.NotNull; 14 | import org.jetbrains.annotations.Nullable; 15 | 16 | import javax.swing.*; 17 | 18 | public class ConceptFileType extends LanguageFileType { 19 | public static final FileType INSTANCE = new ConceptFileType(); 20 | 21 | public ConceptFileType() { 22 | super(Concept.INSTANCE); 23 | } 24 | 25 | @NotNull 26 | @Override 27 | public String getName() { 28 | return "Concept"; 29 | } 30 | 31 | @NotNull 32 | @Override 33 | public String getDescription() { 34 | return "Gauge Concept"; 35 | } 36 | 37 | @NotNull 38 | @Override 39 | public String getDefaultExtension() { 40 | return Constants.CONCEPT_EXTENSION; 41 | } 42 | 43 | @Nullable 44 | @Override 45 | public Icon getIcon() { 46 | return GaugeIcon.GAUGE_CONCEPT_FILE_ICON; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/SpecFile.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language; 8 | 9 | import com.intellij.extapi.psi.PsiFileBase; 10 | import com.intellij.openapi.fileTypes.FileType; 11 | import com.intellij.psi.FileViewProvider; 12 | import org.jetbrains.annotations.NotNull; 13 | 14 | public class SpecFile extends PsiFileBase { 15 | public SpecFile(@NotNull FileViewProvider viewProvider) { 16 | super(viewProvider, Specification.INSTANCE); 17 | } 18 | 19 | @NotNull 20 | @Override 21 | public FileType getFileType() { 22 | return SpecFileType.INSTANCE; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "Specification File"; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/SpecFileType.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language; 8 | 9 | import com.intellij.openapi.fileTypes.LanguageFileType; 10 | import com.thoughtworks.gauge.Constants; 11 | import com.thoughtworks.gauge.idea.icon.GaugeIcon; 12 | import org.jetbrains.annotations.NotNull; 13 | import org.jetbrains.annotations.Nullable; 14 | 15 | import javax.swing.*; 16 | 17 | public class SpecFileType extends LanguageFileType { 18 | public static final SpecFileType INSTANCE = new SpecFileType(); 19 | 20 | private SpecFileType() { 21 | super(Specification.INSTANCE); 22 | } 23 | 24 | @NotNull 25 | @Override 26 | public String getName() { 27 | return "Specification"; 28 | } 29 | 30 | @NotNull 31 | @Override 32 | public String getDescription() { 33 | return "Gauge specification file"; 34 | } 35 | 36 | @NotNull 37 | @Override 38 | public String getDefaultExtension() { 39 | return Constants.SPEC_EXTENSION; 40 | } 41 | 42 | @Nullable 43 | @Override 44 | public Icon getIcon() { 45 | return GaugeIcon.GAUGE_SPEC_FILE_ICON; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/SpecFileTypeFactory.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language; 8 | 9 | import com.intellij.openapi.fileTypes.FileTypeConsumer; 10 | import com.intellij.openapi.fileTypes.FileTypeFactory; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | import static com.thoughtworks.gauge.Constants.*; 14 | 15 | public class SpecFileTypeFactory extends FileTypeFactory { 16 | 17 | @Override 18 | public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) { 19 | fileTypeConsumer.consume(SpecFileType.INSTANCE, SPEC_EXTENSION); 20 | fileTypeConsumer.consume(SpecFileType.INSTANCE, MD_EXTENSION); 21 | fileTypeConsumer.consume(ConceptFileType.INSTANCE, CONCEPT_EXTENSION); 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/Specification.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language; 8 | 9 | import com.intellij.lang.Language; 10 | 11 | public class Specification extends Language { 12 | public static final Specification INSTANCE = new Specification(); 13 | 14 | private Specification() { 15 | super("Specification"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/StepCommenter.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.language; 2 | 3 | import com.intellij.lang.Commenter; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | public class StepCommenter implements Commenter { 7 | @Nullable 8 | @Override 9 | public String getLineCommentPrefix() { 10 | return "//"; 11 | } 12 | 13 | @Nullable 14 | @Override 15 | public String getBlockCommentPrefix() { 16 | return null; 17 | } 18 | 19 | @Nullable 20 | @Override 21 | public String getBlockCommentSuffix() { 22 | return null; 23 | } 24 | 25 | @Nullable 26 | @Override 27 | public String getCommentedBlockCommentPrefix() { 28 | return null; 29 | } 30 | 31 | @Nullable 32 | @Override 33 | public String getCommentedBlockCommentSuffix() { 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/psi/ConceptNamedElement.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.psi.PsiNameIdentifierOwner; 10 | 11 | public interface ConceptNamedElement extends PsiNameIdentifierOwner { 12 | } 13 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/psi/ConceptPsiImplUtil.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.lang.ASTNode; 10 | import com.thoughtworks.gauge.StepValue; 11 | import com.thoughtworks.gauge.language.psi.impl.ConceptConceptImpl; 12 | 13 | public class ConceptPsiImplUtil extends SpecPsiImplUtil { 14 | 15 | public static StepValue getStepValue(ConceptStep element) { 16 | ASTNode step = element.getNode(); 17 | String stepText = step.getText().trim(); 18 | int newLineIndex = stepText.indexOf("\n"); 19 | int endIndex = newLineIndex == -1 ? stepText.length() : newLineIndex; 20 | ConceptTable inlineTable = element.getTable(); 21 | int index = 0; 22 | if (stepText.trim().charAt(0) == '#') 23 | index = 1; 24 | stepText = stepText.substring(index, endIndex).trim(); 25 | return getStepValueFor(element, stepText, inlineTable != null); 26 | } 27 | 28 | public static StepValue getStepValue(ConceptConceptImpl conceptConcept) { 29 | String conceptHeadingText = conceptConcept.getConceptHeading().getText(); 30 | conceptHeadingText = conceptHeadingText.trim().split("\n")[0]; 31 | String text = conceptHeadingText.trim().replaceFirst("#", ""); 32 | return getStepValueFor(conceptConcept, text, false); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/psi/SpecNamedElement.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi; 8 | 9 | import com.intellij.psi.PsiNameIdentifierOwner; 10 | 11 | public interface SpecNamedElement extends PsiNameIdentifierOwner { 12 | } 13 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/psi/impl/ConceptNamedElementImpl.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi.impl; 8 | 9 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 10 | import com.intellij.lang.ASTNode; 11 | import com.thoughtworks.gauge.language.psi.ConceptNamedElement; 12 | import org.jetbrains.annotations.NotNull; 13 | 14 | public abstract class ConceptNamedElementImpl extends ASTWrapperPsiElement implements ConceptNamedElement { 15 | public ConceptNamedElementImpl(@NotNull ASTNode node) { 16 | super(node); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/psi/impl/SpecNamedElementImpl.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.psi.impl; 8 | 9 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 10 | import com.intellij.lang.ASTNode; 11 | import com.thoughtworks.gauge.language.psi.SpecNamedElement; 12 | import org.jetbrains.annotations.NotNull; 13 | 14 | public abstract class SpecNamedElementImpl extends ASTWrapperPsiElement implements SpecNamedElement { 15 | public SpecNamedElementImpl(@NotNull ASTNode node) { 16 | super(node); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/token/ConceptElementType.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.token; 8 | 9 | import com.intellij.psi.tree.IElementType; 10 | import com.thoughtworks.gauge.language.Concept; 11 | import org.jetbrains.annotations.NonNls; 12 | import org.jetbrains.annotations.NotNull; 13 | 14 | public class ConceptElementType extends IElementType { 15 | public ConceptElementType(@NotNull @NonNls String debugName) { 16 | super(debugName, Concept.INSTANCE); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/token/ConceptTokenType.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.token; 8 | 9 | import com.intellij.psi.tree.IElementType; 10 | import com.thoughtworks.gauge.language.Concept; 11 | import org.jetbrains.annotations.NonNls; 12 | import org.jetbrains.annotations.NotNull; 13 | 14 | public class ConceptTokenType extends IElementType { 15 | public ConceptTokenType(@NotNull @NonNls String debugName) { 16 | super(debugName, Concept.INSTANCE); 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return "Concept." + super.toString(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/token/SpecElementType.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.token; 8 | 9 | import com.intellij.psi.tree.IElementType; 10 | import com.thoughtworks.gauge.language.Specification; 11 | import org.jetbrains.annotations.NonNls; 12 | import org.jetbrains.annotations.NotNull; 13 | 14 | public class SpecElementType extends IElementType { 15 | public SpecElementType(@NotNull @NonNls String debugName) { 16 | super(debugName, Specification.INSTANCE); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/language/token/SpecTokenType.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.language.token; 8 | 9 | import com.intellij.psi.tree.IElementType; 10 | import com.thoughtworks.gauge.language.Specification; 11 | import org.jetbrains.annotations.NonNls; 12 | import org.jetbrains.annotations.NotNull; 13 | 14 | public class SpecTokenType extends IElementType { 15 | public SpecTokenType(@NotNull @NonNls String debugName) { 16 | super(debugName, Specification.INSTANCE); 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return "Specification." + super.toString(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/lexer/ConceptLexer.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.lexer; 8 | 9 | import com.intellij.lexer.FlexAdapter; 10 | 11 | /** 12 | * An adapter for integrating with the auto-generated _ConceptLexer created by _ConceptLexer.flex 13 | * It is used to break .cpt file text into semantic tokens. 14 | * 15 | * Use of this code, and how to generate _ConceptLexer from the .flex file, can be found at 16 | * http://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support/lexer_and_parser_definition.html 17 | */ 18 | public class ConceptLexer extends FlexAdapter { 19 | public ConceptLexer() { 20 | super(new _ConceptLexer()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/lexer/SpecLexer.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.lexer; 8 | 9 | import com.intellij.lexer.FlexAdapter; 10 | 11 | /** 12 | * An adapter for integrating with the auto-generated _SpecLexer created by _SpecLexer.flex. 13 | * It is used to break .spec file text into semantic tokens. 14 | * 15 | * Use of this code, and how to generate _SpecLexer from the .flex file, can be found at 16 | * http://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support/lexer_and_parser_definition.html 17 | */ 18 | public class SpecLexer extends FlexAdapter { 19 | public SpecLexer() { 20 | super(new _SpecLexer()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/markdownPreview/Formatter.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.markdownPreview; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | public class Formatter { 7 | 8 | public static final String REGEX_FOR_TABLE = "\\s*\\|(.*\\n[^*]+)"; 9 | 10 | public static String format(String text) { 11 | Pattern regex = Pattern.compile(REGEX_FOR_TABLE); 12 | Matcher regexMatcher = regex.matcher(text); 13 | while (regexMatcher.find()) 14 | text = text.replace(regexMatcher.group(0), 15 | String.format("\n%s", regexMatcher.group(0).replaceAll("\n\\s+\\|", "\n\t|"))); 16 | return text.replace("<", "<").replace(">", ">"); 17 | } 18 | } -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/module/GaugeModuleConfigurationProvider.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.module; 8 | 9 | import com.intellij.openapi.module.Module; 10 | import com.intellij.openapi.module.ModuleConfigurationEditor; 11 | import com.intellij.openapi.module.ModuleType; 12 | import com.intellij.openapi.roots.ui.configuration.DefaultModuleConfigurationEditorFactory; 13 | import com.intellij.openapi.roots.ui.configuration.ModuleConfigurationEditorProvider; 14 | import com.intellij.openapi.roots.ui.configuration.ModuleConfigurationState; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | public class GaugeModuleConfigurationProvider implements ModuleConfigurationEditorProvider { 20 | @Override 21 | public ModuleConfigurationEditor[] createEditors(ModuleConfigurationState state) { 22 | final Module module = state.getRootModel().getModule(); 23 | 24 | final ModuleType moduleType = ModuleType.get(module); 25 | 26 | if (!(moduleType instanceof GaugeModuleType)) { 27 | return ModuleConfigurationEditor.EMPTY; 28 | } 29 | 30 | final DefaultModuleConfigurationEditorFactory editorFactory = DefaultModuleConfigurationEditorFactory.getInstance(); 31 | List editors = new ArrayList<>(); 32 | editors.add(editorFactory.createModuleContentRootsEditor(state)); 33 | editors.add(editorFactory.createOutputEditor(state)); 34 | editors.add(editorFactory.createClasspathEditor(state)); 35 | return editors.toArray(new ModuleConfigurationEditor[editors.size()]); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/module/GaugeModuleType.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.module; 8 | 9 | import com.intellij.openapi.module.ModuleType; 10 | import com.intellij.openapi.module.ModuleTypeManager; 11 | import com.thoughtworks.gauge.idea.icon.GaugeIcon; 12 | import org.jetbrains.annotations.NotNull; 13 | 14 | import javax.swing.*; 15 | 16 | public class GaugeModuleType extends ModuleType { 17 | public static final String MODULE_TYPE_ID = "Gauge_Module"; 18 | private static final String GAUGE_MODULE = "Gauge Module"; 19 | 20 | public GaugeModuleType() { 21 | super(MODULE_TYPE_ID); 22 | } 23 | 24 | public static GaugeModuleType getInstance() { 25 | return (GaugeModuleType) ModuleTypeManager.getInstance().findByID(MODULE_TYPE_ID); 26 | } 27 | 28 | @NotNull 29 | @Override 30 | public GaugeModuleBuilder createModuleBuilder() { 31 | return new GaugeModuleBuilder(); 32 | } 33 | 34 | @NotNull 35 | @Override 36 | public String getName() { 37 | return GAUGE_MODULE; 38 | } 39 | 40 | @NotNull 41 | @Override 42 | public String getDescription() { 43 | return "module supported for writing gauge tests"; 44 | } 45 | 46 | @Override 47 | public Icon getIcon() { 48 | return GaugeIcon.GAUGE_LOGO; 49 | } 50 | 51 | @Override 52 | public Icon getNodeIcon(@Deprecated boolean isOpened) { 53 | return GaugeIcon.GAUGE_LOGO; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/module/lib/AbstractLibHelper.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.module.lib; 8 | 9 | import com.intellij.openapi.module.Module; 10 | import com.thoughtworks.gauge.GaugeModuleComponent; 11 | import com.thoughtworks.gauge.core.Gauge; 12 | import com.thoughtworks.gauge.util.GaugeUtil; 13 | 14 | import static com.thoughtworks.gauge.GaugeModuleComponent.isGaugeProject; 15 | 16 | public abstract class AbstractLibHelper implements LibHelper { 17 | 18 | private Module module; 19 | 20 | public AbstractLibHelper(Module module) { 21 | this.module = module; 22 | if (isGaugeProject(module)) { 23 | if (!GaugeUtil.isMavenModule(module) && !GaugeUtil.isGradleModule(module)) 24 | GaugeModuleComponent.makeGaugeModuleType(module); 25 | if (Gauge.getGaugeService(module, true) == null) 26 | GaugeModuleComponent.createGaugeService(module); 27 | } 28 | } 29 | 30 | public Module getModule() { 31 | return module; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/module/lib/LibHelper.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.module.lib; 8 | 9 | public interface LibHelper { 10 | void checkDeps(); 11 | } 12 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/module/lib/LibHelperFactory.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.module.lib; 8 | 9 | 10 | import com.intellij.openapi.module.Module; 11 | import com.thoughtworks.gauge.util.GaugeUtil; 12 | 13 | import static com.thoughtworks.gauge.GaugeModuleComponent.isGaugeModule; 14 | 15 | public class LibHelperFactory { 16 | private static final LibHelper DEFAULT = () -> { 17 | }; 18 | 19 | // Check if it is a maven module first, java deps will be added via maven so project libs dont need to be changed 20 | public LibHelper helperFor(Module module) { 21 | if (GaugeUtil.isMavenModule(module) || GaugeUtil.isGradleModule(module)) { 22 | return new GaugeModuleLibHelper(module); 23 | } else if (isGaugeModule(module)) { 24 | return new GaugeLibHelper(module); 25 | } 26 | return LibHelperFactory.DEFAULT; 27 | } 28 | 29 | private class GaugeModuleLibHelper extends AbstractLibHelper { 30 | 31 | public GaugeModuleLibHelper(Module module) { 32 | super(module); 33 | } 34 | 35 | public void checkDeps() { 36 | 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/reference/ConceptReference.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.reference; 8 | 9 | import com.intellij.openapi.util.TextRange; 10 | import com.intellij.psi.PsiElement; 11 | import com.intellij.psi.PsiMethod; 12 | import com.intellij.psi.PsiReferenceBase; 13 | import com.thoughtworks.gauge.language.psi.ConceptStep; 14 | import com.thoughtworks.gauge.language.psi.impl.SpecStepImpl; 15 | import com.thoughtworks.gauge.util.StepUtil; 16 | import org.jetbrains.annotations.NotNull; 17 | import org.jetbrains.annotations.Nullable; 18 | 19 | import static com.thoughtworks.gauge.util.GaugeUtil.moduleForPsiElement; 20 | 21 | public class ConceptReference extends PsiReferenceBase { 22 | 23 | 24 | public ConceptReference(@NotNull ConceptStep element) { 25 | super(element); 26 | } 27 | 28 | @Nullable 29 | @Override 30 | public PsiElement resolve() { 31 | SpecStepImpl step = new SpecStepImpl(this.myElement.getNode()); 32 | step.setConcept(true); 33 | return StepUtil.findStepImpl(step, moduleForPsiElement(this.myElement)); 34 | } 35 | 36 | @NotNull 37 | @Override 38 | public Object[] getVariants() { 39 | return new Object[0]; 40 | } 41 | 42 | @Override 43 | public TextRange getRangeInElement() { 44 | return new TextRange(0, myElement.getTextLength()); 45 | } 46 | 47 | @Override 48 | public boolean isReferenceTo(PsiElement element) { 49 | if (element instanceof PsiMethod) { 50 | PsiMethod method = (PsiMethod) element; 51 | return StepUtil.isMatch(method, this.myElement.getStepValue().getStepText(), moduleForPsiElement(element)); 52 | } else { 53 | return false; 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/reference/StepReference.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.reference; 8 | 9 | import com.intellij.openapi.util.TextRange; 10 | import com.intellij.psi.PsiElement; 11 | import com.intellij.psi.PsiMethod; 12 | import com.intellij.psi.PsiReferenceBase; 13 | import com.thoughtworks.gauge.language.psi.SpecStep; 14 | import com.thoughtworks.gauge.util.GaugeUtil; 15 | import com.thoughtworks.gauge.util.StepUtil; 16 | import org.jetbrains.annotations.NotNull; 17 | import org.jetbrains.annotations.Nullable; 18 | 19 | import static com.thoughtworks.gauge.util.GaugeUtil.moduleForPsiElement; 20 | 21 | public class StepReference extends PsiReferenceBase { 22 | 23 | 24 | public StepReference(@NotNull SpecStep element) { 25 | super(element); 26 | } 27 | 28 | @Nullable 29 | @Override 30 | public PsiElement resolve() { 31 | return StepUtil.findStepImpl(this.myElement, GaugeUtil.moduleForPsiElement(this.myElement)); 32 | } 33 | 34 | @NotNull 35 | @Override 36 | public Object[] getVariants() { 37 | return new Object[0]; 38 | } 39 | 40 | @Override 41 | public TextRange getRangeInElement() { 42 | return new TextRange(0, myElement.getTextLength()); 43 | } 44 | 45 | @Override 46 | public boolean isReferenceTo(PsiElement element) { 47 | if (element instanceof PsiMethod) { 48 | PsiMethod method = (PsiMethod) element; 49 | return StepUtil.isMatch(method, this.myElement.getStepValue().getStepText(), moduleForPsiElement(element)); 50 | } else { 51 | return false; 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/rename/RefactorStatusCallback.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.rename; 2 | 3 | interface RefactorStatusCallback { 4 | void onStatusChange(String statusMessage); 5 | 6 | void onFinish(RefactoringStatus refactoringStatus); 7 | } 8 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/rename/RefactoringStatus.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.rename; 2 | 3 | public class RefactoringStatus { 4 | 5 | private String errorMessage; 6 | private Boolean isPassed; 7 | 8 | public RefactoringStatus(Boolean isPassed, String errorMessage) { 9 | this.errorMessage = errorMessage; 10 | this.isPassed = isPassed; 11 | } 12 | 13 | public RefactoringStatus(boolean isPassed) { 14 | this.isPassed = isPassed; 15 | } 16 | 17 | public String getErrorMessage() { 18 | return errorMessage; 19 | } 20 | 21 | public Boolean isPassed() { 22 | return isPassed; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/settings/GaugeConfig.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.settings; 2 | 3 | import com.intellij.openapi.fileChooser.FileChooserDescriptor; 4 | import com.intellij.openapi.ui.TextComponentAccessor; 5 | 6 | import javax.swing.*; 7 | 8 | public class GaugeConfig { 9 | private JPanel configWindow; 10 | private com.intellij.openapi.ui.TextFieldWithBrowseButton gaugePath; 11 | private com.intellij.openapi.ui.TextFieldWithBrowseButton homePath; 12 | private JCheckBox useIntelliJTestRunner; 13 | 14 | JComponent createEditor() { 15 | FileChooserDescriptor homeFileDescriptor = new FileChooserDescriptor(false, true, false, false, false, false); 16 | homePath.addBrowseFolderListener( 17 | "", 18 | "Gauge Home Path", 19 | null, 20 | homeFileDescriptor, 21 | TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); 22 | 23 | FileChooserDescriptor gaugePathFileDescriptor = new FileChooserDescriptor(true, false, false, false, false, false); 24 | gaugePath.addBrowseFolderListener( 25 | "", 26 | "Gauge Binary Path", 27 | null, 28 | gaugePathFileDescriptor, 29 | TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); 30 | 31 | return configWindow; 32 | } 33 | 34 | void setValues(GaugeSettingsModel model) { 35 | this.homePath.setText(model.homePath); 36 | this.gaugePath.setText(model.gaugePath); 37 | this.useIntelliJTestRunner.setSelected(model.useIntelliJTestRunner); 38 | } 39 | 40 | GaugeSettingsModel getValues() { 41 | return new GaugeSettingsModel(this.gaugePath.getText(), this.homePath.getText(), this.useIntelliJTestRunner.isSelected()); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/settings/GaugeSettings.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.settings; 2 | 3 | import com.intellij.openapi.Disposable; 4 | import com.intellij.openapi.options.ConfigurationException; 5 | import com.intellij.openapi.options.SearchableConfigurable; 6 | import com.intellij.openapi.util.Disposer; 7 | import org.jetbrains.annotations.Nls; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | import javax.swing.*; 12 | 13 | public class GaugeSettings implements SearchableConfigurable, Disposable { 14 | 15 | private GaugeConfig gaugeConfig; 16 | private GaugeSettingsModel model; 17 | 18 | 19 | @NotNull 20 | @Override 21 | public String getId() { 22 | return "gauge"; 23 | } 24 | 25 | @Nls(capitalization = Nls.Capitalization.Title) 26 | @Override 27 | public String getDisplayName() { 28 | return "Gauge"; 29 | } 30 | 31 | @Nullable 32 | @Override 33 | public JComponent createComponent() { 34 | model = GaugeSettingsService.getSettings(); 35 | gaugeConfig = new GaugeConfig(); 36 | gaugeConfig.setValues(model); 37 | return gaugeConfig.createEditor(); 38 | } 39 | 40 | @Override 41 | public boolean isModified() { 42 | return !model.equals(gaugeConfig.getValues()); 43 | } 44 | 45 | @Override 46 | public void apply() throws ConfigurationException { 47 | model = gaugeConfig.getValues(); 48 | GaugeSettingsService.getService().loadState(model); 49 | } 50 | 51 | @Override 52 | public void reset() { 53 | gaugeConfig.setValues(model); 54 | } 55 | 56 | @Override 57 | public void disposeUIResources() { 58 | Disposer.dispose(this); 59 | } 60 | 61 | @Override 62 | public void dispose() { 63 | gaugeConfig = null; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/settings/GaugeSettingsModel.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.settings; 2 | 3 | import com.thoughtworks.gauge.Constants; 4 | 5 | public class GaugeSettingsModel { 6 | public String gaugePath; 7 | public String homePath; 8 | public Boolean useIntelliJTestRunner; 9 | 10 | public GaugeSettingsModel(String gaugePath, String homePath, Boolean useIntelliJTestRunner) { 11 | this.gaugePath = gaugePath; 12 | this.homePath = homePath; 13 | this.useIntelliJTestRunner = useIntelliJTestRunner; 14 | } 15 | 16 | public GaugeSettingsModel() { 17 | this("", "", true); 18 | } 19 | 20 | public String getGaugePath() { 21 | return gaugePath; 22 | } 23 | 24 | public String getHomePath() { 25 | return homePath == null ? System.getenv(Constants.GAUGE_HOME) : homePath; 26 | } 27 | 28 | public Boolean useIntelliJTestRunner() { 29 | return useIntelliJTestRunner; 30 | } 31 | 32 | public boolean isGaugePathSet() { 33 | return gaugePath != null && !gaugePath.isEmpty(); 34 | } 35 | 36 | @Override 37 | public boolean equals(Object o) { 38 | if (this == o) return true; 39 | if (o == null || getClass() != o.getClass()) return false; 40 | GaugeSettingsModel that = (GaugeSettingsModel) o; 41 | return (gaugePath != null ? gaugePath.equals(that.gaugePath) : that.gaugePath == null) 42 | && (homePath != null ? homePath.equals(that.homePath) : that.homePath == null) && 43 | useIntelliJTestRunner() == that.useIntelliJTestRunner(); 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return "GaugeSettingsModel{" + 49 | "gaugePath='" + gaugePath + '\'' + 50 | ", homePath='" + homePath + '\'' + 51 | ", useIntelliJTestRunner=" + useIntelliJTestRunner + 52 | '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/settings/GaugeSettingsService.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | package com.thoughtworks.gauge.settings; 8 | 9 | import com.intellij.openapi.application.ApplicationManager; 10 | import com.intellij.openapi.components.PersistentStateComponent; 11 | import com.intellij.openapi.components.State; 12 | import com.intellij.openapi.components.Storage; 13 | import org.jetbrains.annotations.Nullable; 14 | 15 | import static com.intellij.openapi.components.RoamingType.DISABLED; 16 | 17 | @State( 18 | name = "GaugeConfiguration", 19 | storages = { 20 | @Storage(file = "GaugeConfig.xml", roamingType = DISABLED), 21 | } 22 | ) 23 | public class GaugeSettingsService implements PersistentStateComponent { 24 | private GaugeSettingsModel state = new GaugeSettingsModel(); 25 | 26 | @Nullable 27 | @Override 28 | public GaugeSettingsModel getState() { 29 | return state; 30 | } 31 | 32 | @Override 33 | public void loadState(GaugeSettingsModel state) { 34 | this.state = state; 35 | } 36 | 37 | public static GaugeSettingsModel getSettings() { 38 | GaugeSettingsService service = getService(); 39 | return service.getState(); 40 | } 41 | 42 | public static GaugeSettingsService getService() { 43 | return ApplicationManager.getApplication().getComponent(GaugeSettingsService.class); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/util/HookUtil.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.util; 2 | 3 | import com.intellij.psi.PsiAnnotation; 4 | import com.intellij.psi.PsiElement; 5 | import com.intellij.psi.PsiMethod; 6 | import com.thoughtworks.gauge.*; 7 | 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | public class HookUtil { 12 | private static List hooks = Arrays.asList( 13 | BeforeSuite.class.getCanonicalName(), 14 | BeforeSpec.class.getCanonicalName(), 15 | BeforeScenario.class.getCanonicalName(), 16 | BeforeStep.class.getCanonicalName(), 17 | AfterSuite.class.getCanonicalName(), 18 | AfterSpec.class.getCanonicalName(), 19 | AfterScenario.class.getCanonicalName(), 20 | AfterStep.class.getCanonicalName()); 21 | 22 | public static boolean isHook(PsiElement element) { 23 | if (!(element instanceof PsiMethod)) return false; 24 | for (PsiAnnotation annotation : ((PsiMethod) element).getModifierList().getAnnotations()) 25 | if (hooks.contains(annotation.getQualifiedName())) 26 | return true; 27 | return false; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/com/thoughtworks/gauge/util/SocketUtils.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.util; 2 | 3 | import com.intellij.openapi.diagnostic.Logger; 4 | 5 | import java.io.IOException; 6 | import java.net.ServerSocket; 7 | 8 | public class SocketUtils { 9 | private static final Logger LOG = Logger.getInstance("#com.thoughtworks.gauge.util.SocketUtils"); 10 | public static int findFreePortForApi() { 11 | ServerSocket socket = null; 12 | try { 13 | socket = new ServerSocket(0); 14 | return socket.getLocalPort(); 15 | } catch (IOException e) { 16 | LOG.debug(e); 17 | } finally { 18 | if (socket != null) { 19 | try { 20 | socket.close(); 21 | } catch (IOException e) { 22 | LOG.debug(e); 23 | } 24 | } 25 | } 26 | return -1; 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /src/concept.bnf: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------- 2 | * Copyright (c) ThoughtWorks, Inc. 3 | * Licensed under the Apache License, Version 2.0 4 | * See LICENSE.txt in the project root for license information. 5 | *----------------------------------------------------------------*/ 6 | 7 | { 8 | parserClass="com.thoughtworks.gauge.parser.ConceptParser" 9 | 10 | extends="com.intellij.extapi.psi.ASTWrapperPsiElement" 11 | 12 | psiClassPrefix="Concept" 13 | psiImplClassSuffix="Impl" 14 | psiPackage="com.thoughtworks.gauge.language.psi" 15 | psiImplPackage="com.thoughtworks.gauge.language.psi.impl" 16 | 17 | elementTypeHolderClass="com.thoughtworks.gauge.language.token.ConceptTokenTypes" 18 | elementTypeClass="com.thoughtworks.gauge.language.token.ConceptElementType" 19 | tokenTypeClass="com.thoughtworks.gauge.language.token.ConceptTokenType" 20 | 21 | psiImplUtilClass="com.thoughtworks.gauge.language.psi.ConceptPsiImplUtil" 22 | 23 | } 24 | 25 | conceptFile ::= (comment)* concept+ 26 | concept ::= conceptHeading NEW_LINE* (step NEW_LINE* | comment) + 27 | private comment ::= COMMENT 28 | private conceptComment ::= CONCEPT_COMMENT 29 | conceptHeading ::= ((CONCEPT_HEADING_IDENTIFIER (CONCEPT_HEADING|dynamicArg)* NEW_LINE) | (CONCEPT_HEADING)) 30 | step ::= STEP_IDENTIFIER (arg|STEP)+ (comment | NEW_LINE)* table? {mixin="com.thoughtworks.gauge.language.psi.impl.ConceptNamedElementImpl" 31 | implements="com.thoughtworks.gauge.language.psi.ConceptNamedElement" methods = [getStepValue]} 32 | arg ::= dynamicArg | staticArg 33 | dynamicArg ::= DYNAMIC_ARG_START DYNAMIC_ARG DYNAMIC_ARG_END 34 | staticArg ::= ARG_START ARG? ARG_END 35 | table ::= tableHeader tableBody 36 | tableHeader ::= TABLE_BORDER (TABLE_HEADER TABLE_BORDER)+ NEW_LINE ((TABLE_BORDER)* NEW_LINE)? 37 | tableBody ::=(TABLE_BORDER (WHITESPACE* tableRowValue? WHITESPACE* TABLE_BORDER)+ NEW_LINE?)* 38 | tableRowValue ::= TABLE_ROW_VALUE+ | (DYNAMIC_ARG_START DYNAMIC_ARG+ DYNAMIC_ARG_END WHITESPACE* TABLE_ROW_VALUE* WHITESPACE*)+ 39 | -------------------------------------------------------------------------------- /testdata/conceptParser/SimpleConcept.cpt: -------------------------------------------------------------------------------- 1 | # Create a user with and 2 | * create user 3 | * add and to user 4 | * click "save" 5 | 6 | 7 | Search and verify product under category 8 | =============================================== 9 | 10 | * open of products 11 | 12 | * search for 13 | 14 | * verify is in -------------------------------------------------------------------------------- /testdata/specParser/SimpleSpec.spec: -------------------------------------------------------------------------------- 1 | My Specification Heading 2 | ===================== 3 | 4 | tags: first, second 5 | 6 | This is an executable specification file. This file follows markdown syntax. Every heading in this file denotes a scenario. Every bulleted point denotes a step. 7 | 8 | To execute this specification, use 9 | 10 | gauge spec/hello_world.spec 11 | 12 | * A context step which gets executed before every scenario 13 | 14 | First scenario 15 | -------------- 16 | 17 | Tags: hello world, first test 18 | 19 | * Say "hello" to "gauge" 20 | * another one with "ss" and "sss" 21 | * another one with "ss" and "sss" 22 | 23 | 24 | 25 | ## Second scenario 26 | 27 | This is the second scenario in this specification 28 | 29 | * another one with "ss" and "sss" 30 | * a new step 31 | 32 | 33 | * Say "hello again" to "gauge" 34 | * Step that takes a table 35 | |Product| Description | 36 | |-------|-----------------------------| 37 | |Gauge |BDD style testing with ease | 38 | |Mingle |Agile project management | 39 | |Snap |Hosted continuous integration| 40 | |Gocd |Continuous delivery platform | 41 | -------------------------------------------------------------------------------- /testdata/specParser/SpecWithDataTable.spec: -------------------------------------------------------------------------------- 1 | # Spec with data table 2 | 3 | tags: first, second 4 | 5 | |first|second | third | 6 | |111 | 33 | hello | 7 | |122 | 344 | world | 8 | 9 | * execute this before every scenario 10 | 11 | 12 | My First scenario 13 | -------------- 14 | 15 | Tags: hello world, first test 16 | 17 | * First step with 18 | * second step with a param 19 | 20 | 21 | 22 | ## Second scenario 23 | 24 | * another one with "ss" and "sss" 25 | 26 | This is the second scenario in this specification 27 | 28 | * Step that takes a table 29 | |Product| Description | 30 | |-------|-----------------------------| 31 | |Gauge |BDD style testing with ease | 32 | | |Agile project management | 33 | |Snap |Hosted continuous integration| 34 | 35 | * a new step -------------------------------------------------------------------------------- /testdata/specParser/SpecWithEmptyTableHeaders.spec: -------------------------------------------------------------------------------- 1 | # Spec with empty data table headers 2 | 3 | || 4 | |---| 5 | || 6 | 7 | My First scenario 8 | -------------- 9 | * my step -------------------------------------------------------------------------------- /testdata/specParser/SpecWithEmptyTableHeaders.txt: -------------------------------------------------------------------------------- 1 | Specification File(0,93) 2 | SpecDetailImpl(SPEC_DETAIL)(0,51) 3 | PsiElement(Specification.SPEC_HEADING)('# Spec with empty data table headers\n')(0,37) 4 | PsiElement(Specification.COMMENT)('\n')(37,38) 5 | SpecTableImpl(TABLE)(38,50) 6 | SpecTableHeaderImpl(Specification.TABLE_HEADER)(38,47) 7 | PsiElement(Specification.TABLE_BORDER)('|')(38,39) 8 | PsiElement(Specification.TABLE_BORDER)('|')(39,40) 9 | PsiElement(Specification.NEW_LINE)('\n')(40,41) 10 | PsiElement(Specification.TABLE_BORDER)('|')(41,42) 11 | PsiElement(Specification.TABLE_BORDER)('---')(42,45) 12 | PsiElement(Specification.TABLE_BORDER)('|')(45,46) 13 | PsiElement(Specification.NEW_LINE)('\n')(46,47) 14 | SpecTableBodyImpl(TABLE_BODY)(47,50) 15 | PsiElement(Specification.TABLE_BORDER)('|')(47,48) 16 | PsiElement(Specification.TABLE_BORDER)('|')(48,49) 17 | PsiElement(Specification.NEW_LINE)('\n')(49,50) 18 | PsiElement(Specification.COMMENT)('\n')(50,51) 19 | SpecScenarioImpl(SCENARIO)(51,93) 20 | PsiElement(Specification.SCENARIO_HEADING)('My First scenario\n--------------\n')(51,84) 21 | SpecStepImpl(Specification.STEP)(84,93) 22 | PsiElement(Specification.STEP_IDENTIFIER)('*')(84,85) 23 | PsiElement(Specification.STEP)(' my step')(85,93) 24 | -------------------------------------------------------------------------------- /testdata/stepAutocomplete/SimpleSpec.spec: -------------------------------------------------------------------------------- 1 | My Specification Heading 2 | ===================== 3 | *T -------------------------------------------------------------------------------- /testdata/stepAutocomplete/SimpleSpec.txt: -------------------------------------------------------------------------------- 1 | Specification File(0,49) 2 | SpecDetailImpl(SPEC_DETAIL)(0,49) 3 | PsiElement(Specification.SPEC_HEADING)('My Specification Heading\n=====================\n')(0,47) 4 | SpecStepImpl(Specification.STEP)(47,49) 5 | PsiElement(Specification.STEP_IDENTIFIER)('*')(47,48) 6 | PsiElement(Specification.STEP)('T')(48,49) 7 | -------------------------------------------------------------------------------- /tests/com/thoughtworks/gauge/core/GaugeVersionInfoTest.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.core; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class GaugeVersionInfoTest { 7 | @Test 8 | public void testIsGreaterThanWithGreaterVersionsToInstalledVersion() throws Exception { 9 | Assert.assertTrue(new GaugeVersionInfo("0.4.7").isGreaterOrEqual(new GaugeVersionInfo("0.4.4"))); 10 | Assert.assertTrue(new GaugeVersionInfo("0.4.6").isGreaterOrEqual(new GaugeVersionInfo("0.3.6"))); 11 | Assert.assertTrue(new GaugeVersionInfo("2.4.0").isGreaterOrEqual(new GaugeVersionInfo("1.6.3"))); 12 | Assert.assertTrue(new GaugeVersionInfo("0.4.0").isGreaterOrEqual(new GaugeVersionInfo("0.4.0"))); 13 | } 14 | 15 | @Test 16 | public void testIsGreaterThanWithLowerVersionsToInstalledVersion() throws Exception { 17 | Assert.assertFalse(new GaugeVersionInfo("0.4.2").isGreaterOrEqual(new GaugeVersionInfo("0.4.3"))); 18 | Assert.assertFalse(new GaugeVersionInfo("0.4.1.nightly-2016-05-12").isGreaterOrEqual(new GaugeVersionInfo("0.4.2"))); 19 | Assert.assertFalse(new GaugeVersionInfo("0.4.2").isGreaterOrEqual(new GaugeVersionInfo("0.5.0"))); 20 | Assert.assertFalse(new GaugeVersionInfo("0.4.0").isGreaterOrEqual(new GaugeVersionInfo("0.5.5"))); 21 | Assert.assertFalse(new GaugeVersionInfo("2.4.0").isGreaterOrEqual(new GaugeVersionInfo("5.5.3"))); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /tests/com/thoughtworks/gauge/core/GaugeVersionTest.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.core; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | 7 | import java.util.Arrays; 8 | import java.util.List; 9 | 10 | public class GaugeVersionTest { 11 | 12 | private List plugins; 13 | 14 | @Before 15 | public void setup() { 16 | Plugin java = new Plugin(); 17 | java.name = "java"; 18 | Plugin spectacle = new Plugin(); 19 | spectacle.name = "spectacle"; 20 | plugins = Arrays.asList(java, spectacle); 21 | } 22 | 23 | @Test 24 | public void testIsPluginInstalledForInstalledPlugin() throws Exception { 25 | Assert.assertTrue(new GaugeVersionInfo("0.4.0", plugins).isPluginInstalled(plugins.get(0).name)); 26 | } 27 | 28 | @Test 29 | public void testIsPluginInstalledForUnInstalledPlugin() throws Exception { 30 | Assert.assertFalse(new GaugeVersionInfo("0.4.0", plugins).isPluginInstalled("haha")); 31 | } 32 | } -------------------------------------------------------------------------------- /tests/com/thoughtworks/gauge/execution/GaugeTestRunnerTest.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution; 2 | 3 | import com.intellij.execution.configurations.RunProfile; 4 | import org.junit.Test; 5 | 6 | import static org.junit.Assert.assertFalse; 7 | import static org.junit.Assert.assertTrue; 8 | import static org.mockito.Mockito.mock; 9 | 10 | public class GaugeTestRunnerTest { 11 | @Test 12 | public void shouldRunOnlyGaugeRunConfiguration() { 13 | RunProfile profile = mock(GaugeRunConfiguration.class); 14 | GaugeTestRunner runner = new GaugeTestRunner(); 15 | 16 | assertTrue("Should run only GaugeRunConfiguration Expected: true, Actual: false", runner.canRun("", profile)); 17 | } 18 | 19 | @Test 20 | public void shouldNotRunNonGaugeRunConfigurationProfile() { 21 | RunProfile profile = mock(RunProfile.class); 22 | GaugeTestRunner runner = new GaugeTestRunner(); 23 | 24 | assertFalse("Should run only GaugeRunConfiguration Expected: false, Actual: true", runner.canRun("", profile)); 25 | } 26 | } -------------------------------------------------------------------------------- /tests/com/thoughtworks/gauge/execution/runner/processors/NotificationEventProcessorTest.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution.runner.processors; 2 | 3 | import com.thoughtworks.gauge.execution.runner.event.ExecutionEvent; 4 | import org.junit.Test; 5 | 6 | import static org.junit.Assert.assertTrue; 7 | 8 | 9 | public class NotificationEventProcessorTest { 10 | @Test 11 | public void canProcess() { 12 | NotificationEventProcessor processor = new NotificationEventProcessor(null, null); 13 | ExecutionEvent event = new ExecutionEvent(); 14 | event.type = ExecutionEvent.NOTIFICATION; 15 | assertTrue(processor.canProcess(event)); 16 | } 17 | } -------------------------------------------------------------------------------- /tests/com/thoughtworks/gauge/execution/runner/processors/ServiceMessageBuilderMatcher.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.execution.runner.processors; 2 | 3 | import org.mockito.ArgumentMatcher; 4 | 5 | public class ServiceMessageBuilderMatcher extends ArgumentMatcher { 6 | private ServiceMessageBuilder builder; 7 | 8 | public ServiceMessageBuilderMatcher(ServiceMessageBuilder builder) { 9 | this.builder = builder; 10 | } 11 | 12 | @Override 13 | public boolean matches(Object argument) { 14 | return argument.toString().equals(builder.toString()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/com/thoughtworks/gauge/inspection/ConceptInspectionProviderTest.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.inspection; 2 | 3 | import com.intellij.psi.PsiElement; 4 | import com.thoughtworks.gauge.language.psi.ConceptConceptHeading; 5 | import com.thoughtworks.gauge.language.psi.ConceptStep; 6 | import org.junit.Test; 7 | 8 | import static org.junit.Assert.assertEquals; 9 | import static org.mockito.Mockito.mock; 10 | import static org.mockito.Mockito.when; 11 | 12 | public class ConceptInspectionProviderTest { 13 | @Test 14 | public void testGetElementReturnsStep() throws Exception { 15 | ConceptStep step = mock(ConceptStep.class); 16 | 17 | PsiElement element = new ConceptInspectionProvider().getElement(step); 18 | 19 | assertEquals(step, element); 20 | } 21 | 22 | @Test 23 | public void testGetElementReturnsNullIfElementNotPresent() throws Exception { 24 | PsiElement element = new ConceptInspectionProvider().getElement(null); 25 | 26 | assertEquals(null, element); 27 | } 28 | 29 | @Test 30 | public void testGetElementReturnsConceptHeading() throws Exception { 31 | PsiElement e = mock(ConceptConceptHeading.class); 32 | 33 | when(e.getParent()).thenReturn(e); 34 | 35 | PsiElement element = new ConceptInspectionProvider().getElement(e); 36 | 37 | assertEquals(e, element); 38 | } 39 | } -------------------------------------------------------------------------------- /tests/com/thoughtworks/gauge/inspection/GaugeErrorTest.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.inspection; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertTrue; 6 | import static org.junit.Assert.assertEquals; 7 | import static org.junit.Assert.assertFalse; 8 | import static org.junit.Assert.assertNull; 9 | 10 | public class GaugeErrorTest { 11 | @Test 12 | public void getInstance() throws Exception { 13 | String message = "Duplicate scenario definition 'Vowel counts in single word' found in the same specification => 'Vowel counts in single word'"; 14 | GaugeError error = GaugeError.getInstance("[ParseError] specs/example.spec:37 " + message); 15 | 16 | assertEquals("[ParseError] line number: 37, " + message, error.getMessage()); 17 | assertTrue(error.isFrom("specs/example.spec")); 18 | assertFalse(error.isFrom("example.spec")); 19 | } 20 | 21 | @Test 22 | public void getInstanceWithErrorInWrongFormat() throws Exception { 23 | String message = "Duplicate scenario definition 'Vowel counts in single word' found in the same specification => 'Vowel counts in single word'"; 24 | GaugeError error = GaugeError.getInstance("[ParseError] " + message); 25 | 26 | assertNull(error); 27 | } 28 | } -------------------------------------------------------------------------------- /tests/com/thoughtworks/gauge/language/psi/impl/ConceptStepImplTest.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.language.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.psi.PsiReference; 5 | import com.thoughtworks.gauge.helper.ModuleHelper; 6 | import com.thoughtworks.gauge.reference.ConceptReference; 7 | import org.junit.Test; 8 | 9 | import static org.junit.Assert.assertEquals; 10 | import static org.junit.Assert.assertNull; 11 | import static org.mockito.Mockito.mock; 12 | import static org.mockito.Mockito.when; 13 | 14 | public class ConceptStepImplTest { 15 | @Test 16 | public void testShouldGetReferenceInGaugeModule() throws Exception { 17 | ModuleHelper helper = mock(ModuleHelper.class); 18 | ASTNode node = mock(ASTNode.class); 19 | ConceptStepImpl conceptStep = new ConceptStepImpl(node, helper); 20 | when(helper.isGaugeModule(conceptStep)).thenReturn(true); 21 | 22 | PsiReference reference = conceptStep.getReference(); 23 | 24 | assertEquals(reference.getClass(), ConceptReference.class); 25 | } 26 | 27 | @Test 28 | public void testShouldNotGetReferenceInNonGaugeModule() throws Exception { 29 | ModuleHelper helper = mock(ModuleHelper.class); 30 | ASTNode node = mock(ASTNode.class); 31 | ConceptStepImpl conceptStep = new ConceptStepImpl(node, helper); 32 | when(helper.isGaugeModule(conceptStep)).thenReturn(false); 33 | 34 | PsiReference reference = conceptStep.getReference(); 35 | 36 | assertNull(reference); 37 | } 38 | } -------------------------------------------------------------------------------- /tests/com/thoughtworks/gauge/language/psi/impl/SpecStepImplTest.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.language.psi.impl; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.psi.PsiReference; 5 | import com.thoughtworks.gauge.helper.ModuleHelper; 6 | import com.thoughtworks.gauge.reference.StepReference; 7 | import org.junit.Test; 8 | 9 | import static org.junit.Assert.assertEquals; 10 | import static org.junit.Assert.assertNull; 11 | import static org.mockito.Mockito.mock; 12 | import static org.mockito.Mockito.when; 13 | 14 | public class SpecStepImplTest { 15 | @Test 16 | public void testShouldGetReferenceInGaugeModule() throws Exception { 17 | ModuleHelper helper = mock(ModuleHelper.class); 18 | ASTNode node = mock(ASTNode.class); 19 | SpecStepImpl specStep = new SpecStepImpl(node, helper); 20 | when(helper.isGaugeModule(specStep)).thenReturn(true); 21 | 22 | PsiReference reference = specStep.getReference(); 23 | 24 | assertEquals(reference.getClass(), StepReference.class); 25 | } 26 | 27 | @Test 28 | public void testShouldNotGetReferenceInNonGaugeModule() throws Exception { 29 | ModuleHelper helper = mock(ModuleHelper.class); 30 | ASTNode node = mock(ASTNode.class); 31 | SpecStepImpl specStep = new SpecStepImpl(node, helper); 32 | when(helper.isGaugeModule(specStep)).thenReturn(false); 33 | 34 | PsiReference reference = specStep.getReference(); 35 | 36 | assertNull(reference); 37 | } 38 | } -------------------------------------------------------------------------------- /tests/com/thoughtworks/gauge/parser/ConceptParserTestCase.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.parser; 2 | 3 | import com.intellij.testFramework.ParsingTestCase; 4 | 5 | import java.io.File; 6 | 7 | public class ConceptParserTestCase extends ParsingTestCase { 8 | public ConceptParserTestCase() { 9 | super("", "cpt", new ConceptParserDefinition()); 10 | } 11 | 12 | public void testSimpleConcept() { 13 | doTest(true); 14 | } 15 | 16 | @Override 17 | protected String getTestDataPath() { 18 | return new File("testdata", "conceptParser").getAbsolutePath(); 19 | } 20 | 21 | @Override 22 | protected boolean skipSpaces() { 23 | return false; 24 | } 25 | 26 | @Override 27 | protected boolean includeRanges() { 28 | return true; 29 | } 30 | } -------------------------------------------------------------------------------- /tests/com/thoughtworks/gauge/parser/SpecParsingTestCase.java: -------------------------------------------------------------------------------- 1 | package com.thoughtworks.gauge.parser; 2 | 3 | import com.intellij.testFramework.ParsingTestCase; 4 | 5 | import java.io.File; 6 | 7 | public class SpecParsingTestCase extends ParsingTestCase { 8 | public SpecParsingTestCase() { 9 | super("", "spec", new SpecParserDefinition()); 10 | } 11 | 12 | public void testSimpleSpec() { 13 | doTest(true); 14 | } 15 | 16 | public void testSpecWithDataTable() { 17 | doTest(true); 18 | } 19 | 20 | public void testSpecWithEmptyTableHeaders() { 21 | doTest(true); 22 | } 23 | 24 | @Override 25 | protected String getTestDataPath() { 26 | return new File("testdata", "specParser").getAbsolutePath(); 27 | } 28 | 29 | @Override 30 | protected boolean skipSpaces() { 31 | return false; 32 | } 33 | 34 | @Override 35 | protected boolean includeRanges() { 36 | return true; 37 | } 38 | } --------------------------------------------------------------------------------