From b9be14a3492cac3dc9d4fb81d3f7024dcfa7cbd1 Mon Sep 17 00:00:00 2001 From: Ed Seidewitz Date: Fri, 10 Dec 2021 14:27:53 -0800 Subject: [PATCH 1/3] ST6RI-487 Updated grammar converter to handle usage keywords w/ spaces. --- .../syntax-highlighting/xtext_grammar_converter.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tool-support/syntax-highlighting/xtext_grammar_converter.py b/tool-support/syntax-highlighting/xtext_grammar_converter.py index 38e649ae4..b3356c3b5 100644 --- a/tool-support/syntax-highlighting/xtext_grammar_converter.py +++ b/tool-support/syntax-highlighting/xtext_grammar_converter.py @@ -255,8 +255,8 @@ def parse_xtext_grammar(self, xtext_source_paths: List[str]): logging.info(f"{var:{max_name_len}s} = {keywords_dict[var]}") if var.endswith("DefKeyword"): def_keyword_var = keywords_dict[var][0].split()[0] - def_keyword_value = [x for x in keywords_dict[def_keyword_var] if x.isalpha()][0] - def_keywords_set.add(def_keyword_value) + def_keyword_value = [x for x in keywords_dict[def_keyword_var] if x.replace(" ","").isalpha()][0] + def_keywords_set.add(def_keyword_value.split()[-1]) # Remove interpunction terminals that should not be highlighted operators_set.remove(".") @@ -344,6 +344,7 @@ def export_jupyter_syntax_highlighting_files( additional_def_keywords.add(keyword) logging.info(f"additional_def_keywords={sorted(additional_def_keywords)}") + logging.info(f"keywords = {self.keywords}") keywords_minus_atoms = list(self.keywords) keywords_minus_atoms.remove("false") keywords_minus_atoms.remove("true") @@ -353,7 +354,7 @@ def export_jupyter_syntax_highlighting_files( def_keywords_set.update(additional_def_keywords) self.def_keywords = sorted(def_keywords_set) for def_keyword in self.def_keywords: - if def_keyword not in keywords_minus_atoms: + if any([x not in keywords_minus_atoms for x in def_keyword.split()]): logging.error(f"def keyword '{def_keyword}' " f"is not in the list of keywords obtained from the xtext grammar") From 23c9a54b8032e69aef6c5582398434e58a3f02dd Mon Sep 17 00:00:00 2001 From: Ed Seidewitz Date: Fri, 10 Dec 2021 14:28:29 -0800 Subject: [PATCH 2/3] ST6RI-487 Generated new highlighting files. --- .../src/main/mode.ts | 21 ++++++++++--------- .../src/main/resources/kernel/kernel.js | 21 ++++++++++--------- .../syntax-highlighting/jetbrains/KerML.xml | 2 +- .../syntax-highlighting/jetbrains/SysML.xml | 4 ++-- .../syntax-highlighting/jupyter/kernel.js | 21 ++++++++++--------- .../syntax-highlighting/jupyter/mode.ts | 21 ++++++++++--------- .../kerml/syntaxes/kerml.tmLanguage.json | 2 +- .../sysml/syntaxes/sysml.tmLanguage.json | 4 ++-- 8 files changed, 50 insertions(+), 46 deletions(-) diff --git a/org.omg.sysml.jupyter.jupyterlab/src/main/mode.ts b/org.omg.sysml.jupyter.jupyterlab/src/main/mode.ts index fdc9877a0..de4db8e7c 100644 --- a/org.omg.sysml.jupyter.jupyterlab/src/main/mode.ts +++ b/org.omg.sysml.jupyter.jupyterlab/src/main/mode.ts @@ -39,16 +39,17 @@ export function defineSysMLv2Mode(): void { name: 'clike', keywords: [ "about", "abstract", "accept", "action", "actor", "alias", "all", "allocate", "allocation", "analysis", - "and", "as", "assert", "assume", "attribute", "bind", "binding", "by", "calc", "case", "comment", - "concern", "connect", "connection", "constraint", "decide", "def", "default", "defined", "dependency", - "derived", "do", "doc", "else", "end", "entry", "enum", "event", "exhibit", "exit", "expose", "feature", - "filter", "first", "flow", "for", "fork", "frame", "from", "hastype", "if", "implies", "import", "in", - "include", "individual", "inout", "interface", "istype", "item", "join", "language", "merge", "message", - "metadata", "nonunique", "not", "objective", "occurrence", "of", "or", "ordered", "out", "package", - "parallel", "part", "perform", "port", "private", "protected", "public", "readonly", "redefines", "ref", - "render", "rendering", "rep", "require", "requirement", "return", "satisfy", "send", "snapshot", - "specializes", "stakeholder", "state", "subject", "subsets", "succession", "then", "timeslice", "to", - "transition", "use", "variant", "variation", "verification", "verify", "via", "view", "viewpoint", "xor" + "and", "as", "assert", "assign", "assume", "attribute", "bind", "binding", "by", "calc", "case", + "comment", "concern", "connect", "connection", "constraint", "decide", "def", "default", "defined", + "dependency", "derived", "do", "doc", "else", "end", "entry", "enum", "event", "exhibit", "exit", + "expose", "feature", "filter", "first", "flow", "for", "fork", "frame", "from", "hastype", "if", + "implies", "import", "in", "include", "individual", "inout", "interface", "istype", "item", "join", + "language", "merge", "message", "metadata", "nonunique", "not", "objective", "occurrence", "of", "or", + "ordered", "out", "package", "parallel", "part", "perform", "port", "private", "protected", "public", + "readonly", "redefines", "ref", "render", "rendering", "rep", "require", "requirement", "return", + "satisfy", "send", "snapshot", "specializes", "stakeholder", "state", "subject", "subsets", + "succession", "then", "timeslice", "to", "transition", "use", "variant", "variation", "verification", + "verify", "via", "view", "viewpoint", "xor" ].reduce(f_wordify, {}), defKeywords: [ "action", "allocation", "analysis", "attribute", "binding", "calc", "case", "comment", "concern", diff --git a/org.omg.sysml.jupyter.kernel/src/main/resources/kernel/kernel.js b/org.omg.sysml.jupyter.kernel/src/main/resources/kernel/kernel.js index 426f42173..2902250c1 100644 --- a/org.omg.sysml.jupyter.kernel/src/main/resources/kernel/kernel.js +++ b/org.omg.sysml.jupyter.kernel/src/main/resources/kernel/kernel.js @@ -51,16 +51,17 @@ var enableMode = function (CodeMirror) { name: "clike", keywords: words([ "about", "abstract", "accept", "action", "actor", "alias", "all", "allocate", "allocation", "analysis", - "and", "as", "assert", "assume", "attribute", "bind", "binding", "by", "calc", "case", "comment", - "concern", "connect", "connection", "constraint", "decide", "def", "default", "defined", "dependency", - "derived", "do", "doc", "else", "end", "entry", "enum", "event", "exhibit", "exit", "expose", "feature", - "filter", "first", "flow", "for", "fork", "frame", "from", "hastype", "if", "implies", "import", "in", - "include", "individual", "inout", "interface", "istype", "item", "join", "language", "merge", "message", - "metadata", "nonunique", "not", "objective", "occurrence", "of", "or", "ordered", "out", "package", - "parallel", "part", "perform", "port", "private", "protected", "public", "readonly", "redefines", "ref", - "render", "rendering", "rep", "require", "requirement", "return", "satisfy", "send", "snapshot", - "specializes", "stakeholder", "state", "subject", "subsets", "succession", "then", "timeslice", "to", - "transition", "use", "variant", "variation", "verification", "verify", "via", "view", "viewpoint", "xor" + "and", "as", "assert", "assign", "assume", "attribute", "bind", "binding", "by", "calc", "case", + "comment", "concern", "connect", "connection", "constraint", "decide", "def", "default", "defined", + "dependency", "derived", "do", "doc", "else", "end", "entry", "enum", "event", "exhibit", "exit", + "expose", "feature", "filter", "first", "flow", "for", "fork", "frame", "from", "hastype", "if", + "implies", "import", "in", "include", "individual", "inout", "interface", "istype", "item", "join", + "language", "merge", "message", "metadata", "nonunique", "not", "objective", "occurrence", "of", "or", + "ordered", "out", "package", "parallel", "part", "perform", "port", "private", "protected", "public", + "readonly", "redefines", "ref", "render", "rendering", "rep", "require", "requirement", "return", + "satisfy", "send", "snapshot", "specializes", "stakeholder", "state", "subject", "subsets", + "succession", "then", "timeslice", "to", "transition", "use", "variant", "variation", "verification", + "verify", "via", "view", "viewpoint", "xor" ]), defKeywords: words([ "action", "allocation", "analysis", "attribute", "binding", "calc", "case", "comment", "concern", diff --git a/tool-support/syntax-highlighting/jetbrains/KerML.xml b/tool-support/syntax-highlighting/jetbrains/KerML.xml index 9e7c55418..e52d13034 100644 --- a/tool-support/syntax-highlighting/jetbrains/KerML.xml +++ b/tool-support/syntax-highlighting/jetbrains/KerML.xml @@ -12,7 +12,7 @@