From 9c2a142dc5f3bc0ea63a25d08e3f1a072701eef7 Mon Sep 17 00:00:00 2001 From: phannebohm Date: Wed, 18 Sep 2024 13:12:20 +0200 Subject: [PATCH] Fix scope of Option literals (#73) - Only match `SOME`, not what's inside. - Make test smaller --- syntaxes/metamodelica.tmGrammar.yaml | 2 +- test/metamodelica/Option.test.mo | 16 ++++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/syntaxes/metamodelica.tmGrammar.yaml b/syntaxes/metamodelica.tmGrammar.yaml index 8aa5dbd..5e40875 100644 --- a/syntaxes/metamodelica.tmGrammar.yaml +++ b/syntaxes/metamodelica.tmGrammar.yaml @@ -106,7 +106,7 @@ patterns: - include: "source.metamodelica" # Option literals - - match: (SOME\(.*\)|NONE\(\)) + - match: (SOME\(|NONE\(\)) name: entity.name.type # Function calls diff --git a/test/metamodelica/Option.test.mo b/test/metamodelica/Option.test.mo index 15c9fa2..e7a5eef 100644 --- a/test/metamodelica/Option.test.mo +++ b/test/metamodelica/Option.test.mo @@ -1,14 +1,6 @@ // SYNTAX TEST "source.metamodelica" "Option" -function f - input Option oi; -// ^^^^^^ source.metamodelica storage.type -// ^^^^^^^ source.metamodelica storage.type -algorithm - () := match oi - case SOME(i) then (); -// ^^^^ source.metamodelica entity.name.type - case NONE() then (); -// ^^^^ source.metamodelica entity.name.type - end match; -end f; +opt := if cond then SOME(i) else NONE(); +// ^^^^ source.metamodelica entity.name.type +// ^^^^ source.metamodelica keyword.control +// ^^^^ source.metamodelica entity.name.type