Skip to content

Commit

Permalink
refactor: Make error message close to Snakemake runtime error
Browse files Browse the repository at this point in the history
  • Loading branch information
iromeo committed Aug 3, 2021
1 parent de8adcd commit 517874a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import com.jetbrains.snakecharm.lang.psi.*

class SmkRuleSectionAfterExecutionInspection : SnakemakeInspection() {
override fun buildVisitor(
holder: ProblemsHolder,
isOnTheFly: Boolean,
session: LocalInspectionToolSession
holder: ProblemsHolder,
isOnTheFly: Boolean,
session: LocalInspectionToolSession,
) = object : SnakemakeInspectionVisitor(holder, session) {
override fun visitSmkRule(rule: SmkRule) {
visitSMKRuleLike(rule)
Expand All @@ -41,14 +41,13 @@ class SmkRuleSectionAfterExecutionInspection : SnakemakeInspection() {
requireNotNull(executionSection.name)

registerProblem(st,
SnakemakeBundle.message(
"INSP.NAME.rule.section.after.execution.message",
sectionName,
executionSection.name!!
),
ProblemHighlightType.GENERIC_ERROR,
null,
MoveExecutionSectionToEndOfRuleQuickFix(SmartPointerManager.createPointer(executionSection))
SnakemakeBundle.message(
"INSP.NAME.rule.section.after.execution.message",
executionSection.name!!
),
ProblemHighlightType.GENERIC_ERROR,
null,
MoveExecutionSectionToEndOfRuleQuickFix(SmartPointerManager.createPointer(executionSection))
)
}
}
Expand All @@ -57,7 +56,7 @@ class SmkRuleSectionAfterExecutionInspection : SnakemakeInspection() {
}

private class MoveExecutionSectionToEndOfRuleQuickFix(
private val executionSectionPointer: SmartPsiElementPointer<SmkSection>
private val executionSectionPointer: SmartPsiElementPointer<SmkSection>,
) : LocalQuickFix {
override fun getFamilyName() = SnakemakeBundle.message("INSP.INTN.move.execution.section.down.family")

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/SnakemakeBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ INSP.INTN.rename.element=Rename element

# SnakemakeRuleSectionAfterExecutionInspection
INSP.NAME.rule.section.after.execution=No rule sections allowed after execution sections.
INSP.NAME.rule.section.after.execution.message=Rule section ''{0}'' isn''t allowed after ''{1}'' section.
INSP.NAME.rule.section.after.execution.message=No rule keywords allowed after ''{0}'' in rule.
INSP.INTN.move.execution.section.down.family=Move execution section to the end of the rule

# SnakemakeShadowSettingsInspection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Feature: Rule sections after execution sections inspection.
And SmkRuleSectionAfterExecutionInspection inspection is enabled
Then I expect inspection error on <<sect2>: <sect2_text>> with message
"""
Rule section '<sect2>' isn't allowed after '<sect1>' section.
No rule keywords allowed after '<sect1>' in rule.
"""
When I check highlighting errors
Examples:
Expand Down Expand Up @@ -45,11 +45,11 @@ Feature: Rule sections after execution sections inspection.
And SmkRuleSectionAfterExecutionInspection inspection is enabled
Then I expect inspection error on <resources: a=4> with message
"""
Rule section 'resources' isn't allowed after 'shell' section.
No rule keywords allowed after 'shell' in rule.
"""
And I expect inspection error on <version: 2.0> with message
"""
Rule section 'version' isn't allowed after 'shell' section.
No rule keywords allowed after 'shell' in rule.
"""
When I check highlighting errors
And I invoke quick fix Move execution section to the end of the rule and see text:
Expand Down

0 comments on commit 517874a

Please sign in to comment.