Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/#384 inspections are enabled for workflows #391

Merged
merged 5 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.jetbrains.snakecharm.SnakemakeBundle
import com.jetbrains.snakecharm.codeInsight.SnakemakeAPI.SINGLE_ARGUMENT_SECTIONS_KEYWORDS
import com.jetbrains.snakecharm.lang.psi.SmkRuleOrCheckpointArgsSection
import com.jetbrains.snakecharm.lang.psi.SmkSubworkflowArgsSection
import com.jetbrains.snakecharm.lang.psi.SmkWorkflowArgsSection

class SmkSectionMultipleArgsInspection : SnakemakeInspection() {
override fun buildVisitor(
Expand All @@ -25,6 +26,13 @@ class SmkSectionMultipleArgsInspection : SnakemakeInspection() {
}
}

override fun visitSmkWorkflowArgsSection(st: SmkWorkflowArgsSection) {
val name = st.sectionKeyword
if (name != null && name in SINGLE_ARGUMENT_SECTIONS_KEYWORDS) {
iromeo marked this conversation as resolved.
Show resolved Hide resolved
checkArgumentList(st.argumentList, name)
}
}

private fun checkArgumentList(
argumentList: PyArgumentList?,
sectionName: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.jetbrains.snakecharm.codeInsight.SnakemakeAPI.SECTIONS_WHERE_KEYWORD_
import com.jetbrains.snakecharm.lang.psi.SmkArgsSection
import com.jetbrains.snakecharm.lang.psi.SmkRuleOrCheckpointArgsSection
import com.jetbrains.snakecharm.lang.psi.SmkSubworkflowArgsSection
import com.jetbrains.snakecharm.lang.psi.SmkWorkflowArgsSection

class SmkSectionUnexpectedKeywordArgsInspection : SnakemakeInspection() {
override fun buildVisitor(
Expand All @@ -27,6 +28,12 @@ class SmkSectionUnexpectedKeywordArgsInspection : SnakemakeInspection() {
}
}

override fun visitSmkWorkflowArgsSection(st: SmkWorkflowArgsSection) {
if (st.sectionKeyword in SECTIONS_WHERE_KEYWORD_ARGS_PROHIBITED) {
iromeo marked this conversation as resolved.
Show resolved Hide resolved
checkArgumentList(st.argumentList, st)
}
}

private fun checkArgumentList(
argumentList: PyArgumentList?,
section: SmkArgsSection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,26 @@ Feature: Inspection for multiple arguments in various sections
| notebook |
| container |
| containerized |
| handover |
| handover |

Scenario Outline: Multiple arguments in workflow section
Given a snakemake project
Given I open a file "foo.smk" with text
"""
<section_name>: "a", "b", "c"
"""
And SmkSectionMultipleArgsInspection inspection is enabled
Then I expect inspection error on <"b"> with message
"""
Only one argument is allowed for '<section_name>' section.
"""
And I expect inspection error on <"c"> with message
"""
Only one argument is allowed for '<section_name>' section.
"""
When I check highlighting errors
Examples:
| section_name |
| containerized |
| singularity |
| container |
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,21 @@ Feature: Inspection for unexpected keyword arguments in section
| checkpoint | log |
| checkpoint | resources |
| checkpoint | wildcard_constraints |

Scenario Outline: Unexpected keyword arguments in workflow
Given a snakemake project
Given I open a file "foo.smk" with text
"""
<section_name>: a="foo.bar"
"""
And SmkSectionUnexpectedKeywordArgsInspection inspection is enabled
Then I expect inspection error on <a="foo.bar"> with message
"""
Section '<section_name>' does not support keyword arguments
"""
When I check highlighting errors
Examples:
| section_name |
| containerized |
| singularity |
| container |