Skip to content

Commit 729d58f

Browse files
author
Steve Ramage
committed
feat: Add support for Token Based validators (WIP #2)
1 parent 91288b0 commit 729d58f

File tree

2 files changed

+212
-127
lines changed
  • src
    • main/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/optionvalues/grammar
    • test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/optionvalues/grammar

2 files changed

+212
-127
lines changed

src/main/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/optionvalues/grammar/GrammarOptionValue.kt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,21 @@ open class GrammarOptionValue(
293293
override fun getErrorMessage(value: String): String? {
294294
val syntaticMatch = combinator.SyntacticMatch(value, 0)
295295

296-
if (syntaticMatch.matchResult == -1) {
297-
return "Could not parse value"
298-
}
296+
try {
297+
298+
if (syntaticMatch.matchResult == -1) {
299+
return "Could not parse value"
300+
}
299301

300-
val semanticMatch = combinator.SemanticMatch(value, 0)
302+
val semanticMatch = combinator.SemanticMatch(value, 0)
303+
304+
if (semanticMatch.matchResult == -1) {
305+
return "Value did not semantically match"
306+
}
301307

302-
if (semanticMatch.matchResult == -1) {
303-
return "Value did not semantically match"
308+
} catch (IllegalArgumentException: IllegalArgumentException) {
309+
// TODO add logger
310+
return null
304311
}
305312

306313
return null

0 commit comments

Comments
 (0)