-
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.
Browse files
Browse the repository at this point in the history
feat: Inspection: Show ERROR for execution sections in 'use' section (#408)
- Loading branch information
Showing
8 changed files
with
120 additions
and
46 deletions.
There are no files selected for viewing
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
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")) | ||
} | ||
} | ||
} | ||
} |
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> |
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 overridden in 'use rule' | ||
""" | ||
Then I expect inspection error on <shell> with message | ||
""" | ||
Execution sections can't be overridden in 'use rule' | ||
""" | ||
Then I expect inspection error on <notebook> with message | ||
""" | ||
Execution sections can't be overridden in 'use rule' | ||
""" | ||
Then I expect inspection error on <script> with message | ||
""" | ||
Execution sections can't be overridden in 'use rule' | ||
""" | ||
Then I expect inspection error on <cwl> with message | ||
""" | ||
Execution sections can't be overridden in 'use rule' | ||
""" | ||
Then I expect inspection error on <wrapper> with message | ||
""" | ||
Execution sections can't be overridden in 'use rule' | ||
""" | ||
When I check highlighting errors |
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