From 0355079a20596a660c6c8d4a910511b81ac36adb Mon Sep 17 00:00:00 2001 From: phannebohm Date: Fri, 15 Mar 2024 13:08:45 +0100 Subject: [PATCH] Fix runaway regex in comment string detection (#42) * Fix runaway regex in comment string detection * Adding tests * Update version --------- Co-authored-by: AnHeuermann <38031952+AnHeuermann@users.noreply.github.com> --- .vscode/tasks.json | 2 +- README.md | 2 +- package-lock.json | 10 +++++----- package.json | 2 +- syntaxes/metamodelica.tmGrammar.yaml | 6 ++++-- syntaxes/modelica.tmGrammar.yaml | 8 +++++--- .../{function.test.mo => Function.test.mo} | 0 test/metamodelica/FunctionDoc.test.mo | 15 +++++++++++++++ test/modelica/Comments.test.mo | 4 ++++ test/modelica/Function.test.mo | 18 ++++++++++++++++++ 10 files changed, 54 insertions(+), 13 deletions(-) rename test/metamodelica/{function.test.mo => Function.test.mo} (100%) create mode 100644 test/metamodelica/FunctionDoc.test.mo create mode 100644 test/modelica/Function.test.mo diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 528bd09..e7272c9 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -20,7 +20,7 @@ "group": "test", "presentation": { "reveal": "always", - "panel": "new", + "panel": "dedicated", }, "problemMatcher": { "owner": "vscode-tmgrammar-test", diff --git a/README.md b/README.md index 7c678be..6a34581 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ for more details on the publishing process. npm install ``` -Translate the `*tmGrammar.yaml` files to `*.tmGrammar.json` JSON files. +Translate the `*.tmGrammar.yaml` files to `*.tmGrammar.json` JSON files. Start build task (Ctrl+Shift+B) ```bash diff --git a/package-lock.json b/package-lock.json index 5badbd3..874b3be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "metamodelica", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "metamodelica", - "version": "1.3.0", + "version": "1.3.1", "license": "See LICENSE.txt", "devDependencies": { "@vscode/vsce": "^2.21.1", @@ -509,9 +509,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", - "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "dev": true, "funding": [ { diff --git a/package.json b/package.json index 6461cc3..e7425f8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "metamodelica", "displayName": "MetaModelica", "description": "MetaModelica, Susan and Modelica language support.", - "version": "1.3.0", + "version": "1.3.1", "publisher": "AnHeuermann", "license": "See LICENSE.txt", "engines": { diff --git a/syntaxes/metamodelica.tmGrammar.yaml b/syntaxes/metamodelica.tmGrammar.yaml index 69ba3b0..c11cdc8 100644 --- a/syntaxes/metamodelica.tmGrammar.yaml +++ b/syntaxes/metamodelica.tmGrammar.yaml @@ -92,11 +92,13 @@ patterns: - name: keyword end: \)\s*; - # Strings - - match: (? awesome; +//^^^^^^ source.metamodelica keyword.control +// ^^^^^^^^^^^^^^^^^^^^^^^ source.metamodelica storage.type +// [...] +end foo; diff --git a/test/modelica/Comments.test.mo b/test/modelica/Comments.test.mo index 0cf3578..93eb638 100644 --- a/test/modelica/Comments.test.mo +++ b/test/modelica/Comments.test.mo @@ -1,6 +1,8 @@ // SYNTAX TEST "source.modelica" "Comments" model M "Documentation" +//<-- source.modelica keyword +// ^ source.modelica entity.name.type // ^^^^^^^^^^^^^^^ source.modelica comment.line Real x "Variable \"x\""; // ^^^^^^^^^^^^^^^^ source.modelica comment.line @@ -28,3 +30,5 @@ model M "Documentation" // ^^^ source.modelica string.quoted.double // ^^^ source.modelica string.quoted.double end M; +//<-- source.modelica keyword +// ^ source.modelica entity.name.type diff --git a/test/modelica/Function.test.mo b/test/modelica/Function.test.mo new file mode 100644 index 0000000..fd5e27e --- /dev/null +++ b/test/modelica/Function.test.mo @@ -0,0 +1,18 @@ +// SYNTAX TEST "source.modelica" "Function with doc string" + +public function foo + "Function does crazy stuff --fmiFlags + and creates an awesome record for stuff. + Author: ItIsI" + input Boolean isAwesome = true; +//^^^^^ source.modelica keyword.control +// ^^^^^^^ source.modelica storage.type +// ^^^^ source.modelica constant.language + output MyRecord awesome; +//^^^^^^ source.modelica keyword.control +// [...] +//<--- source.modelica comment.line +//^^^^^^ source.modelica comment.line +end foo; +//<--- source.modelica keyword +// ^^^ source.modelica entity.name.type