From bd5e06e0c95d8892f4eb66dd16054d159f7ee98b Mon Sep 17 00:00:00 2001 From: phannebohm Date: Wed, 18 Sep 2024 18:04:19 +0200 Subject: [PATCH] Solve polymorphic/comparison ambiguity Workaround is to have no space for polymorphic and space for comparisons. This is consistent with usual formatting in omc. --- syntaxes/metamodelica.tmGrammar.yaml | 6 +++--- test/metamodelica/FunctionDoc.test.mo | 3 ++- test/metamodelica/Types.test.mo | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/syntaxes/metamodelica.tmGrammar.yaml b/syntaxes/metamodelica.tmGrammar.yaml index 272da4c..c0929bf 100644 --- a/syntaxes/metamodelica.tmGrammar.yaml +++ b/syntaxes/metamodelica.tmGrammar.yaml @@ -43,7 +43,7 @@ patterns: name: storage.type ## Polymorphic types - - begin: \b(list|tuple|array|Option)\s*< + - begin: \b(list|tuple|array|Option)< end: '>' beginCaptures: 1: @@ -51,7 +51,7 @@ patterns: patterns: - include: '#polymorphic_type' - - begin: \b(\w+)\s*< + - begin: \b(\w+)< end : '>' beginCaptures: 1: @@ -171,7 +171,7 @@ repository: - include: '#polymorphic_type' - match: \b(Real|Integer|Boolean|String|enumeration|type)\b name: storage.type - - match: \b([\w\.]+)\b + - match: \b(\w+)\b name: entity.name.type scopeName: source.metamodelica diff --git a/test/metamodelica/FunctionDoc.test.mo b/test/metamodelica/FunctionDoc.test.mo index c7f61c8..0c01d92 100644 --- a/test/metamodelica/FunctionDoc.test.mo +++ b/test/metamodelica/FunctionDoc.test.mo @@ -11,7 +11,8 @@ public function foo output Option awesome; //^^^^^^ source.metamodelica keyword.control // ^^^^^^ source.metamodelica storage.type -// ^^^^^^^^^^^^^^^ source.metamodelica entity.name.type +// ^^^^^^^ source.metamodelica entity.name.type +// ^^^^^^^ source.metamodelica entity.name.type // [...] end foo; diff --git a/test/metamodelica/Types.test.mo b/test/metamodelica/Types.test.mo index ea99047..652acd4 100644 --- a/test/metamodelica/Types.test.mo +++ b/test/metamodelica/Types.test.mo @@ -29,3 +29,8 @@ type TL = UnorderedMap; // ^^^^^^^^^^^^ source.metamodelica entity.name.type // ^^^ source.metamodelica entity.name.type // ^^^^^ source.metamodelica entity.name.type + +x < 1 and x > 0; +//^ keyword.operator.comparison +// ^^^ keyword.control +// ^ keyword.operator.comparison