Skip to content

Commit

Permalink
Merge branch 'master' into features/#407-duplicated-args-inspection-t…
Browse files Browse the repository at this point in the history
…op-level
  • Loading branch information
dakochik authored Nov 20, 2021
2 parents d382440 + 2ea11e3 commit b3a6af1
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Released on ...

### Fixed
- SmkSectionDuplicatedArgsInspection now checks workflow top-level sections (see [#407](https://github.com/JetBrains-Research/snakecharm/issues/407))
- All inspections warnings now can be overridden (see [#423](https://github.com/JetBrains-Research/snakecharm/issues/423))
- Completion for .smk files in module 'snakefile' section (see [#428](https://github.com/JetBrains-Research/snakecharm/issues/428))
- Default path "config/config.yaml" now supported (see [#363](https://github.com/JetBrains-Research/snakecharm/issues/363))
- Access by index to input/output sections with 'multiext' function (see [#278](https://github.com/JetBrains-Research/snakecharm/issues/278))
- Inspection: Do not show warning that rule section is unused variable if rule is defined in method (see [#385](https://github.com/JetBrains-Research/snakecharm/issues/385))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package com.jetbrains.snakecharm.inspections

import com.intellij.codeInspection.LocalInspectionToolSession
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemHighlightType.GENERIC_ERROR
import com.intellij.codeInspection.ProblemHighlightType.WEAK_WARNING
import com.intellij.codeInspection.ProblemHighlightType.*
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
Expand Down Expand Up @@ -102,7 +101,7 @@ class SmkRuleRedeclarationInspection : SnakemakeInspection() {
) == null

val (msg, severity) = when {
isTopLevelDeclaration -> SnakemakeBundle.message("INSP.NAME.rule.redeclaration") to GENERIC_ERROR
isTopLevelDeclaration -> SnakemakeBundle.message("INSP.NAME.rule.redeclaration") to GENERIC_ERROR_OR_WARNING
else -> SnakemakeBundle.message("INSP.NAME.rule.redeclaration.possible") to WEAK_WARNING
}
registerProblem(ruleLike, msg, severity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class SmkRuleSectionAfterExecutionInspection : SnakemakeInspection() {
"INSP.NAME.rule.section.after.execution.message",
executionSection.name!!
),
ProblemHighlightType.GENERIC_ERROR,
null,
MoveExecutionSectionToEndOfRuleQuickFix(SmartPointerManager.createPointer(executionSection))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import com.jetbrains.snakecharm.stringLanguage.lang.psi.references.SmkSLWildcard

class SmkSLWildcardNameIsConfusingInspection : SnakemakeInspection() {
override fun buildVisitor(
holder: ProblemsHolder,
isOnTheFly: Boolean,
session: LocalInspectionToolSession
) = object : SmkSLInspectionVisitor(holder, session) {
holder: ProblemsHolder,
isOnTheFly: Boolean,
session: LocalInspectionToolSession
) = object : SmkSLInspectionVisitor(holder, session) {

override fun visitSmkSLReferenceExpression(expr: SmkSLReferenceExpressionImpl) {
// expr.isQualified: 'wildcards' in 'wildcards.input'
Expand All @@ -28,16 +28,20 @@ class SmkSLWildcardNameIsConfusingInspection : SnakemakeInspection() {
expr.containingSection()?.getParentRuleOrCheckPoint() ?: return

registerProblem(
expr,
SnakemakeBundle.message("INSP.NAME.wildcards.confusing.name.like.section.message", wildcardName),
PyRenameElementQuickFix(expr)
expr,
SnakemakeBundle.message(
"INSP.NAME.wildcards.confusing.name.like.section.message",
wildcardName
),
ProblemHighlightType.WARNING,
null,
PyRenameElementQuickFix(expr),
)
} else if ('.' in wildcardName) {
// E.g. 'wildcards.name' or 'foo.boo.doo'
registerProblem(
ref.getWildcardTrueExpression(),
SnakemakeBundle.message("INSP.NAME.wildcards.confusing.name.with.dot.message", wildcardName),
ProblemHighlightType.GENERIC_ERROR
ref.getWildcardTrueExpression(),
SnakemakeBundle.message("INSP.NAME.wildcards.confusing.name.with.dot.message", wildcardName)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class SmkIncludeReference(
path: String
) : SmkFileReference(element, textRange, stringLiteralExpression, path) {
override fun getVariants() = collectFileSystemItemLike {
it is SmkFile && it.name != element.containingFile.name
it is SmkFile && it.originalFile != element.containingFile.originalFile
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
<localInspection
language="SnakemakeSL" shortName="SmkSLWildcardNameIsConfusingInspection"
enabledByDefault="true"
level="WARNING"
level="ERROR"
suppressId="SmkSLWildcardNameIsConfusing"
bundle="SnakemakeBundle"
groupKey="INSP.GROUP.snakemake"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,30 @@ Feature: Complete file name in conda section

Scenario Outline: Completion list in path dependent section
Given a snakemake project
Given a file "xoo.<ext>" with text
Given a file "<file>" with text
"""
"""
Given I open a file "foo.smk" with text
"""
<rule_like> NAME:
<section>: "x"
<section>: ""
"""
When I put the caret after x
When I put the caret after : "
And I invoke autocompletion popup and see a text:
"""
<rule_like> NAME:
<section>: "xoo.<ext>"
<section>: "<file>"
"""
Examples:
| rule_like | section | ext |
| rule | conda | yaml |
| checkpoint | conda | yaml |
| rule | conda | yml |
| rule | notebook | py.ipynb |
| rule | notebook | r.ipynb |
| module | snakefile | smk |
| rule_like | section | file |
| rule | conda | xoo.yaml |
| checkpoint | conda | xoo.yaml |
| rule | conda | xoo.yml |
| rule | notebook | xoo.py.ipynb |
| rule | notebook | xoo.r.ipynb |
| module | snakefile | xoo.smk |
| module | snakefile | other/files/foo.smk |
| module | snakefile | other/files/Snakefile |
Scenario Outline: Completion list when there are no appropriate files
Given a snakemake project
Expand Down

0 comments on commit b3a6af1

Please sign in to comment.