From 517874a677c2fec204c70553f8c6c6f4f5cc1fba Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Tue, 3 Aug 2021 12:53:18 +0300 Subject: [PATCH] refactor: Make error message close to Snakemake runtime error --- .../SmkRuleSectionAfterExecutionInspection.kt | 23 +++++++++---------- src/main/resources/SnakemakeBundle.properties | 2 +- ...e_keywords_after_execution_section.feature | 6 ++--- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/com/jetbrains/snakecharm/inspections/SmkRuleSectionAfterExecutionInspection.kt b/src/main/kotlin/com/jetbrains/snakecharm/inspections/SmkRuleSectionAfterExecutionInspection.kt index 1ea6e011d..ef816caa3 100644 --- a/src/main/kotlin/com/jetbrains/snakecharm/inspections/SmkRuleSectionAfterExecutionInspection.kt +++ b/src/main/kotlin/com/jetbrains/snakecharm/inspections/SmkRuleSectionAfterExecutionInspection.kt @@ -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) @@ -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)) ) } } @@ -57,7 +56,7 @@ class SmkRuleSectionAfterExecutionInspection : SnakemakeInspection() { } private class MoveExecutionSectionToEndOfRuleQuickFix( - private val executionSectionPointer: SmartPsiElementPointer + private val executionSectionPointer: SmartPsiElementPointer, ) : LocalQuickFix { override fun getFamilyName() = SnakemakeBundle.message("INSP.INTN.move.execution.section.down.family") diff --git a/src/main/resources/SnakemakeBundle.properties b/src/main/resources/SnakemakeBundle.properties index 098663299..bf5af1c02 100644 --- a/src/main/resources/SnakemakeBundle.properties +++ b/src/main/resources/SnakemakeBundle.properties @@ -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 diff --git a/src/test/resources/features/highlighting/inspections/rule_keywords_after_execution_section.feature b/src/test/resources/features/highlighting/inspections/rule_keywords_after_execution_section.feature index 9bf3b2935..5c23f35d9 100644 --- a/src/test/resources/features/highlighting/inspections/rule_keywords_after_execution_section.feature +++ b/src/test/resources/features/highlighting/inspections/rule_keywords_after_execution_section.feature @@ -14,7 +14,7 @@ Feature: Rule sections after execution sections inspection. And SmkRuleSectionAfterExecutionInspection inspection is enabled Then I expect inspection error on <: > with message """ - Rule section '' isn't allowed after '' section. + No rule keywords allowed after '' in rule. """ When I check highlighting errors Examples: @@ -45,11 +45,11 @@ Feature: Rule sections after execution sections inspection. And SmkRuleSectionAfterExecutionInspection inspection is enabled Then I expect inspection error on 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 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: