Skip to content

Commit

Permalink
PR: Features/#515 improve rule declaration message (#519)
Browse files Browse the repository at this point in the history
* Closes #515
  • Loading branch information
Xewar313 authored Apr 23, 2024
1 parent 322d25b commit 3d1bc51
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

# SnakeCharm Plugin Changelog


## [2024.1.2]
Released on <not released>

### Fixed
- Improve parser error message when rule/module is declared with name but lacks ':' (see [#515](https://github.com/JetBrains-Research/snakecharm/issues/515))

## [2024.1.1]
Released on 20 April 2024

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,25 @@ class SmkStatementParsing(
}

// Other case: `rule` / `checkpoint` / etc.
var nameIdentifierSeen = false
if (atToken(PyTokenTypes.IDENTIFIER)) {
// rule name
//val ruleNameMarker: PsiBuilder.Marker = myBuilder.mark()
nextToken()
nameIdentifierSeen = true
}

// XXX at the moment we continue parsing rule even if colon missed, probably better
// XXX to drop rule and scroll up to next STATEMENT_BREAK/RULE/CHECKPOINT/other toplevel keyword or eof()
checkMatches(PyTokenTypes.COLON,
"${
checkMatches(
PyTokenTypes.COLON,
if (nameIdentifierSeen) {
"':' expected"
} else {
section.name.replaceFirstChar {
if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
}
} name identifier or ':' expected"
} + " name identifier or ':' expected"
}
) // bundle

val ruleStatements = myBuilder.mark()
Expand Down
2 changes: 1 addition & 1 deletion testData/psi/ModuleIncomplete.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SnakemakeFile: ModuleIncomplete.smk
PsiElement(Py:MODULE_KEYWORD)('module')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('z')
PsiErrorElement:Module name identifier or ':' expected
PsiErrorElement:':' expected
<empty list>
PyStatementList
PsiErrorElement:Indent expected
Expand Down
2 changes: 1 addition & 1 deletion testData/psi/RuleIncomplete2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SnakemakeFile: RuleIncomplete2.smk
PsiElement(Py:RULE_KEYWORD)('rule')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('foo')
PsiErrorElement:Rule name identifier or ':' expected
PsiErrorElement:':' expected
<empty list>
PyStatementList
<empty list>
Expand Down

0 comments on commit 3d1bc51

Please sign in to comment.