diff options
author | Kristóf Marussy <marussy@mit.bme.hu> | 2020-05-08 18:28:19 +0200 |
---|---|---|
committer | Kristóf Marussy <marussy@mit.bme.hu> | 2020-05-08 18:28:19 +0200 |
commit | 419e76265ecbdf65e960e0624be006d31ed1e191 (patch) | |
tree | dad200fe9fd0beae7adde969206b77691a51b85a /Application/org.eclipse.viatra.solver.language.ui/src/org/eclipse/viatra/solver/language/ui/highlight/SolverSemanticTextAttributeProvider.xtend | |
parent | Fix check expressions in generated VIATRA (diff) | |
download | VIATRA-Generator-419e76265ecbdf65e960e0624be006d31ed1e191.tar.gz VIATRA-Generator-419e76265ecbdf65e960e0624be006d31ed1e191.tar.zst VIATRA-Generator-419e76265ecbdf65e960e0624be006d31ed1e191.zip |
Update solver language grammar
First version, still needs TokenSource and Linker to work.
Diffstat (limited to 'Application/org.eclipse.viatra.solver.language.ui/src/org/eclipse/viatra/solver/language/ui/highlight/SolverSemanticTextAttributeProvider.xtend')
-rw-r--r-- | Application/org.eclipse.viatra.solver.language.ui/src/org/eclipse/viatra/solver/language/ui/highlight/SolverSemanticTextAttributeProvider.xtend | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/Application/org.eclipse.viatra.solver.language.ui/src/org/eclipse/viatra/solver/language/ui/highlight/SolverSemanticTextAttributeProvider.xtend b/Application/org.eclipse.viatra.solver.language.ui/src/org/eclipse/viatra/solver/language/ui/highlight/SolverSemanticTextAttributeProvider.xtend deleted file mode 100644 index 4eed59ce..00000000 --- a/Application/org.eclipse.viatra.solver.language.ui/src/org/eclipse/viatra/solver/language/ui/highlight/SolverSemanticTextAttributeProvider.xtend +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | package org.eclipse.viatra.solver.language.ui.highlight | ||
2 | |||
3 | import com.google.inject.Inject | ||
4 | import java.util.WeakHashMap | ||
5 | import org.eclipse.jface.text.TextAttribute | ||
6 | import org.eclipse.swt.graphics.RGB | ||
7 | import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreAccess | ||
8 | import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightingConfiguration | ||
9 | import org.eclipse.xtext.ui.editor.syntaxcoloring.PreferenceStoreAccessor | ||
10 | import org.eclipse.xtext.ui.editor.syntaxcoloring.TextAttributeProvider | ||
11 | import org.eclipse.xtext.ui.editor.utils.EditorUtils | ||
12 | import org.eclipse.xtext.ui.editor.utils.TextStyle | ||
13 | |||
14 | class SolverSemanticTextAttributeProvider extends TextAttributeProvider { | ||
15 | |||
16 | val defaultTextStyle = new TextStyle | ||
17 | val colorID2TextAttribute = new WeakHashMap<String,TextAttribute> | ||
18 | |||
19 | @Inject | ||
20 | new(IHighlightingConfiguration highlightingConfig, IPreferenceStoreAccess preferenceStoreAccess, PreferenceStoreAccessor prefStoreAccessor) { | ||
21 | super(highlightingConfig, preferenceStoreAccess, prefStoreAccessor) | ||
22 | } | ||
23 | |||
24 | |||
25 | override getAttribute(String id) { | ||
26 | if(isMetamodelElementColorID(id)) { | ||
27 | if(colorID2TextAttribute.containsKey(id)) { | ||
28 | return colorID2TextAttribute.get(id) | ||
29 | } else { | ||
30 | val style = metamodelElementTextStyle(id) | ||
31 | colorID2TextAttribute.put(id,style) | ||
32 | return style | ||
33 | } | ||
34 | } else { | ||
35 | super.getAttribute(id) | ||
36 | } | ||
37 | } | ||
38 | |||
39 | private def isMetamodelElementColorID(String id) { | ||
40 | id.startsWith(SolverSemanticHighlightCalculator::SmybolCode) | ||
41 | } | ||
42 | |||
43 | private def TextAttribute metamodelElementTextStyle(String id) { | ||
44 | val texts = id.split(' ') | ||
45 | val backgroundColor = new RGB( | ||
46 | Float.parseFloat(texts.get(1)), | ||
47 | Float.parseFloat(texts.get(2)), | ||
48 | Float.parseFloat(texts.get(3)) | ||
49 | ) | ||
50 | return new TextAttribute( | ||
51 | EditorUtils.colorFromRGB(defaultTextStyle.color), | ||
52 | EditorUtils.colorFromRGB(backgroundColor), | ||
53 | defaultTextStyle.style, | ||
54 | EditorUtils.fontFromFontData(defaultTextStyle.getFontData())); | ||
55 | } | ||
56 | |||
57 | } \ No newline at end of file | ||