-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed: execution section inspection is fixed
refactored: tests and error messages Resolves: #408
- Loading branch information
Dmitry Kochik
committed
Aug 16, 2021
1 parent
e0ae895
commit 8d88ffb
Showing
10 changed files
with
125 additions
and
181 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...tlin/com/jetbrains/snakecharm/inspections/SmkExecutionSubsectionInUseSectionInspection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.jetbrains.snakecharm.inspections | ||
|
||
import com.intellij.codeInspection.LocalInspectionToolSession | ||
import com.intellij.codeInspection.ProblemsHolder | ||
import com.jetbrains.snakecharm.SnakemakeBundle | ||
import com.jetbrains.snakecharm.codeInsight.SnakemakeAPI | ||
import com.jetbrains.snakecharm.lang.SnakemakeNames | ||
import com.jetbrains.snakecharm.lang.psi.* | ||
|
||
class SmkExecutionSubsectionInUseSectionInspection : SnakemakeInspection() { | ||
override fun buildVisitor( | ||
holder: ProblemsHolder, | ||
isOnTheFly: Boolean, | ||
session: LocalInspectionToolSession | ||
) = object : SnakemakeInspectionVisitor(holder, session) { | ||
|
||
override fun visitSmkRuleOrCheckpointArgsSection(st: SmkRuleOrCheckpointArgsSection) { | ||
val sectionNamePsi = st.nameIdentifier | ||
val sectionKeyword = st.sectionKeyword | ||
if (st.getParentRuleOrCheckPoint() is SmkUse && | ||
sectionKeyword in (SnakemakeAPI.EXECUTION_SECTIONS_KEYWORDS + SnakemakeNames.SECTION_RUN) | ||
) { | ||
registerProblem(sectionNamePsi, SnakemakeBundle.message("INSP.NAME.unexpected.execution.section")) | ||
} | ||
} | ||
} | ||
} |
57 changes: 0 additions & 57 deletions
57
src/main/kotlin/com/jetbrains/snakecharm/inspections/SmkUnexpectedSectionInspection.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/resources/inspectionDescriptions/SmkExecutionSubsectionInUseSectionInspection.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<html> | ||
<body> | ||
This inspection highlights the sections which can't be overridden in 'use rule' ('shell', 'script', | ||
'notebook', 'cwl' and 'run' sections). | ||
</body> | ||
</html> |
6 changes: 0 additions & 6 deletions
6
src/main/resources/inspectionDescriptions/SmkUnexpectedSectionInspection.html
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
.../features/highlighting/inspections/execution_subsection_in_use_section_inspection.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Feature: Inspection if subsection is unexpected for section but it i appropriate for another section | ||
|
||
Scenario: When 'use' section contains execution subsections | ||
Given a snakemake project | ||
Given I open a file "foo.smk" with text | ||
""" | ||
use rule RULE as NEW_RULE with: | ||
run: "" | ||
shell: "" | ||
notebook: "" | ||
input: "file1" | ||
script: "" | ||
cwl: "" | ||
wrapper: "" | ||
output: "file2" | ||
""" | ||
And SmkExecutionSubsectionInUseSectionInspection inspection is enabled | ||
Then I expect inspection error on <run> with message | ||
""" | ||
Execution sections can't be used in 'use rule' | ||
""" | ||
Then I expect inspection error on <shell> with message | ||
""" | ||
Execution sections can't be used in 'use rule' | ||
""" | ||
Then I expect inspection error on <notebook> with message | ||
""" | ||
Execution sections can't be used in 'use rule' | ||
""" | ||
Then I expect inspection error on <script> with message | ||
""" | ||
Execution sections can't be used in 'use rule' | ||
""" | ||
Then I expect inspection error on <cwl> with message | ||
""" | ||
Execution sections can't be used in 'use rule' | ||
""" | ||
Then I expect inspection error on <wrapper> with message | ||
""" | ||
Execution sections can't be used in 'use rule' | ||
""" | ||
When I check highlighting errors |
75 changes: 0 additions & 75 deletions
75
src/test/resources/features/highlighting/inspections/unexpected_section_inspection.feature
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters