diff --git a/src/main/kotlin/com/jetbrains/snakecharm/codeInsight/SnakemakeAPI.kt b/src/main/kotlin/com/jetbrains/snakecharm/codeInsight/SnakemakeAPI.kt index a86b7fcf..f0ee345f 100644 --- a/src/main/kotlin/com/jetbrains/snakecharm/codeInsight/SnakemakeAPI.kt +++ b/src/main/kotlin/com/jetbrains/snakecharm/codeInsight/SnakemakeAPI.kt @@ -5,7 +5,6 @@ import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.Service import com.intellij.openapi.project.Project import com.intellij.openapi.util.Disposer -import com.jetbrains.snakecharm.codeInsight.SnakemakeAPI.ALLOWED_LAMBDA_OR_CALLABLE_ARGS import com.jetbrains.snakecharm.codeInsight.SnakemakeAPI.EXECUTION_SECTIONS_KEYWORDS import com.jetbrains.snakecharm.codeInsight.SnakemakeAPICompanion.RULE_OR_CHECKPOINT_ARGS_SECTION_KEYWORDS_HARDCODED import com.jetbrains.snakecharm.framework.SmkSupportProjectSettings @@ -326,12 +325,6 @@ class SnakemakeAPIService { val RULE_OR_CHECKPOINT_ARGS_SECTION_KEYWORDS = RULE_OR_CHECKPOINT_ARGS_SECTION_KEYWORDS_HARDCODED + SnakemakeFrameworkAPIProvider.getInstance().collectAllPossibleRuleOrCheckpointSubsectionKeywords() - val SECTION_LAMBDA_ARG_POSSIBLE_PARAMS: Set = - ALLOWED_LAMBDA_OR_CALLABLE_ARGS.values.flatMap { it.asIterable() }.toMutableSet().also { - // TODO merge with deprecation provider keywords - it.addAll(RULE_OR_CHECKPOINT_ARGS_SECTION_KEYWORDS) - } - val RULE_OR_CHECKPOINT_SECTION_KEYWORDS = (RULE_OR_CHECKPOINT_ARGS_SECTION_KEYWORDS + setOf(SECTION_RUN)) val USE_SECTIONS_KEYWORDS = RULE_OR_CHECKPOINT_SECTION_KEYWORDS + SnakemakeFrameworkAPIProvider.getInstance() diff --git a/src/main/kotlin/com/jetbrains/snakecharm/inspections/SmkSectionVariableRequiresLambdaAccessInspection.kt b/src/main/kotlin/com/jetbrains/snakecharm/inspections/SmkSectionVariableRequiresLambdaAccessInspection.kt index 428ae128..54159212 100644 --- a/src/main/kotlin/com/jetbrains/snakecharm/inspections/SmkSectionVariableRequiresLambdaAccessInspection.kt +++ b/src/main/kotlin/com/jetbrains/snakecharm/inspections/SmkSectionVariableRequiresLambdaAccessInspection.kt @@ -19,6 +19,10 @@ class SmkSectionVariableRequiresLambdaAccessInspection : SnakemakeInspection() { isOnTheFly: Boolean, session: LocalInspectionToolSession, ) = object : SnakemakeInspectionVisitor(holder, getContext(session)) { + val apiService = SnakemakeAPIService.getInstance() + val SECTION_LAMBDA_ARG_POSSIBLE_PARAMS: Set = + ALLOWED_LAMBDA_OR_CALLABLE_ARGS.values.flatMap { it.asIterable() }.toSet() + override fun visitPyReferenceExpression(node: PyReferenceExpression) { @Suppress("UnstableApiUsage") if (node.isQualified) { @@ -27,7 +31,11 @@ class SmkSectionVariableRequiresLambdaAccessInspection : SnakemakeInspection() { } @Suppress("UnstableApiUsage") val varName = node.referencedName - if (varName == null || varName !in SnakemakeAPIService.getInstance().SECTION_LAMBDA_ARG_POSSIBLE_PARAMS) { + // Not allowed arg (e.g. wildcards, ..) and not section keyword (e.g. 'threads', 'version' etc) + if (varName == null || ( + (varName !in SECTION_LAMBDA_ARG_POSSIBLE_PARAMS) && + ( varName !in apiService.RULE_OR_CHECKPOINT_ARGS_SECTION_KEYWORDS)) + ) { // Not suitable case return }