diff options
author | 2024-01-03 02:47:05 +0100 | |
---|---|---|
committer | 2024-01-03 13:33:55 +0100 | |
commit | d2ef593cbb097ed04f38a09680a656598dd7d8d3 (patch) | |
tree | d2538d6c414196da2e39de414e1ee3126adb76d1 /subprojects/language-ide/src | |
parent | feat(web): color identifiers and nodes (diff) | |
download | refinery-d2ef593cbb097ed04f38a09680a656598dd7d8d3.tar.gz refinery-d2ef593cbb097ed04f38a09680a656598dd7d8d3.tar.zst refinery-d2ef593cbb097ed04f38a09680a656598dd7d8d3.zip |
refactor(web): subtler error predicate highlight
Diffstat (limited to 'subprojects/language-ide/src')
-rw-r--r-- | subprojects/language-ide/src/main/java/tools/refinery/language/ide/syntaxcoloring/ProblemSemanticHighlightingCalculator.java | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/subprojects/language-ide/src/main/java/tools/refinery/language/ide/syntaxcoloring/ProblemSemanticHighlightingCalculator.java b/subprojects/language-ide/src/main/java/tools/refinery/language/ide/syntaxcoloring/ProblemSemanticHighlightingCalculator.java index 4c775fc6..f64d4066 100644 --- a/subprojects/language-ide/src/main/java/tools/refinery/language/ide/syntaxcoloring/ProblemSemanticHighlightingCalculator.java +++ b/subprojects/language-ide/src/main/java/tools/refinery/language/ide/syntaxcoloring/ProblemSemanticHighlightingCalculator.java | |||
@@ -43,7 +43,7 @@ public class ProblemSemanticHighlightingCalculator extends DefaultSemanticHighli | |||
43 | 43 | ||
44 | @Override | 44 | @Override |
45 | protected boolean highlightElement(EObject object, IHighlightedPositionAcceptor acceptor, | 45 | protected boolean highlightElement(EObject object, IHighlightedPositionAcceptor acceptor, |
46 | CancelIndicator cancelIndicator) { | 46 | CancelIndicator cancelIndicator) { |
47 | highlightName(object, acceptor); | 47 | highlightName(object, acceptor); |
48 | highlightCrossReferences(object, acceptor, cancelIndicator); | 48 | highlightCrossReferences(object, acceptor, cancelIndicator); |
49 | return false; | 49 | return false; |
@@ -60,7 +60,7 @@ public class ProblemSemanticHighlightingCalculator extends DefaultSemanticHighli | |||
60 | } | 60 | } |
61 | 61 | ||
62 | protected void highlightCrossReferences(EObject object, IHighlightedPositionAcceptor acceptor, | 62 | protected void highlightCrossReferences(EObject object, IHighlightedPositionAcceptor acceptor, |
63 | CancelIndicator cancelIndicator) { | 63 | CancelIndicator cancelIndicator) { |
64 | for (EReference reference : object.eClass().getEAllReferences()) { | 64 | for (EReference reference : object.eClass().getEAllReferences()) { |
65 | if (reference.isContainment()) { | 65 | if (reference.isContainment()) { |
66 | continue; | 66 | continue; |
@@ -101,7 +101,7 @@ public class ProblemSemanticHighlightingCalculator extends DefaultSemanticHighli | |||
101 | boolean isError = ProblemUtil.isError(eObject); | 101 | boolean isError = ProblemUtil.isError(eObject); |
102 | if (ProblemUtil.isBuiltIn(eObject)) { | 102 | if (ProblemUtil.isBuiltIn(eObject)) { |
103 | var className = isError ? ERROR_CLASS : BUILTIN_CLASS; | 103 | var className = isError ? ERROR_CLASS : BUILTIN_CLASS; |
104 | return new String[] { className }; | 104 | return new String[]{className}; |
105 | } | 105 | } |
106 | return getUserDefinedElementHighlightClass(eObject, reference, isError); | 106 | return getUserDefinedElementHighlightClass(eObject, reference, isError); |
107 | } | 107 | } |
@@ -116,19 +116,12 @@ public class ProblemSemanticHighlightingCalculator extends DefaultSemanticHighli | |||
116 | && desugarer.isContainmentReference(referenceDeclaration)) { | 116 | && desugarer.isContainmentReference(referenceDeclaration)) { |
117 | classesBuilder.add(CONTAINMENT_CLASS); | 117 | classesBuilder.add(CONTAINMENT_CLASS); |
118 | } | 118 | } |
119 | if (isError) { | 119 | if (isError && reference != null) { |
120 | // References to error patterns should be highlighted as errors, but error pattern definitions shouldn't. | ||
120 | classesBuilder.add(ERROR_CLASS); | 121 | classesBuilder.add(ERROR_CLASS); |
121 | } | 122 | } |
122 | if (eObject instanceof Node node) { | 123 | if (eObject instanceof Node node) { |
123 | if (reference == ProblemPackage.Literals.VARIABLE_OR_NODE_EXPR__VARIABLE_OR_NODE) { | 124 | highlightNode(node, reference, classesBuilder); |
124 | classesBuilder.add(NODE_CLASS); | ||
125 | } | ||
126 | if (ProblemUtil.isIndividualNode(node)) { | ||
127 | classesBuilder.add(INDIVIDUAL_NODE_CLASS); | ||
128 | } | ||
129 | if (ProblemUtil.isNewNode(node)) { | ||
130 | classesBuilder.add(NEW_NODE_CLASS); | ||
131 | } | ||
132 | } | 125 | } |
133 | if (eObject instanceof Relation relation) { | 126 | if (eObject instanceof Relation relation) { |
134 | var typeHash = typeHashProvider.getTypeHash(relation); | 127 | var typeHash = typeHashProvider.getTypeHash(relation); |
@@ -139,4 +132,16 @@ public class ProblemSemanticHighlightingCalculator extends DefaultSemanticHighli | |||
139 | List<String> classes = classesBuilder.build(); | 132 | List<String> classes = classesBuilder.build(); |
140 | return classes.toArray(new String[0]); | 133 | return classes.toArray(new String[0]); |
141 | } | 134 | } |
135 | |||
136 | private static void highlightNode(Node node, EReference reference, ImmutableList.Builder<String> classesBuilder) { | ||
137 | if (reference == ProblemPackage.Literals.VARIABLE_OR_NODE_EXPR__VARIABLE_OR_NODE) { | ||
138 | classesBuilder.add(NODE_CLASS); | ||
139 | } | ||
140 | if (ProblemUtil.isIndividualNode(node)) { | ||
141 | classesBuilder.add(INDIVIDUAL_NODE_CLASS); | ||
142 | } | ||
143 | if (ProblemUtil.isNewNode(node)) { | ||
144 | classesBuilder.add(NEW_NODE_CLASS); | ||
145 | } | ||
146 | } | ||
142 | } | 147 | } |