Skip to content

Commit af6b18b

Browse files
authored
IConfigurationElement arrays changed for ArrayLists in GEMOC tools (#177)
* IConfigurationElement arrays changed for ArrayLists in GEMOC tools * DslValidator check for metaprogramming approach now in its own function Signed-off-by: Ronan Guéguen <[email protected]>
1 parent 55aa52a commit af6b18b

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

commons/plugins/org.eclipse.gemoc.dsl.ui/src/org/eclipse/gemoc/ui/contentassist/DslProposalProvider.xtend

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class DslProposalProvider extends AbstractDslProposalProvider {
4242
super.complete_SPACE(model, ruleCall, context, acceptor)
4343

4444
var String metaprog
45-
var IConfigurationElement[] keys
45+
var ArrayList<IConfigurationElement> keys = new ArrayList<IConfigurationElement>()
4646
var ArrayList<String> dslKeys = new ArrayList<String>()
4747

4848
if (model instanceof Dsl){

commons/plugins/org.eclipse.gemoc.dsl.ui/src/org/eclipse/gemoc/ui/highlighting/DslHighlightingCalculator.xtend

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import org.eclipse.core.runtime.IConfigurationElement
1515
import org.eclipse.gemoc.dsl.Dsl
1616
import org.eclipse.gemoc.dsl.Entry
1717
import org.eclipse.gemoc.xdsmlframework.api.extensions.metaprog.LanguageComponentHelper
18+
import java.util.ArrayList
1819

1920
public class DslHighlightingCalculator extends DefaultSemanticHighlightingCalculator {
2021

@@ -24,16 +25,15 @@ public class DslHighlightingCalculator extends DefaultSemanticHighlightingCalcul
2425
val LanguageComponentHelper languageHelper = new LanguageComponentHelper()
2526
var Dsl dsl = root.getSemanticElement as Dsl
2627
var String metaprog
27-
var IConfigurationElement[] keys
28+
var ArrayList<IConfigurationElement> keys = new ArrayList<IConfigurationElement>();
2829

2930
for(Entry entry : dsl.getEntries){
3031
if("metaprog".equals(entry.key)){
3132
metaprog = entry.value
33+
keys = languageHelper.getFullApproachKeys(metaprog)
3234
}
3335
}
3436

35-
keys = languageHelper.getFullApproachKeys(metaprog)
36-
3737
for (INode node : root.getAsTreeIterable()) {
3838
val EObject grammarElement = node.getGrammarElement();
3939

@@ -54,13 +54,20 @@ public class DslHighlightingCalculator extends DefaultSemanticHighlightingCalcul
5454

5555
if(sem instanceof Entry){
5656

57-
if(!keys.filter[e | (e.getAttribute('name') == sem.key) && (e.getAttribute('optional').matches("false"))].isEmpty){
58-
acceptor.addPosition(node.getOffset(), node.getLength(),
57+
if(!keys.empty){
58+
if(!keys.filter[e | (e.getAttribute('name') == sem.key) && (e.getAttribute('optional').matches("false"))].isEmpty){
59+
acceptor.addPosition(node.getOffset(), node.getLength(),
5960
DslHighlightingConfiguration.KEY_PLUGIN_ID);
60-
}else if (!keys.filter[e | (e.getAttribute('name') == sem.key) && (e.getAttribute('optional').matches("true"))].isEmpty){
61-
acceptor.addPosition(node.getOffset(), node.getLength(),
62-
DslHighlightingConfiguration.OPTIONAL_KEY_PLUGIN_ID);
63-
}else{
61+
}else if(!keys.filter[e | (e.getAttribute('name') == sem.key) && (e.getAttribute('optional').matches("true"))].isEmpty){
62+
acceptor.addPosition(node.getOffset(), node.getLength(),
63+
DslHighlightingConfiguration.OPTIONAL_KEY_PLUGIN_ID);
64+
}else{
65+
acceptor.addPosition(node.getOffset(), node.getLength(),
66+
DslHighlightingConfiguration.KEY_ID);
67+
68+
}
69+
}
70+
else{
6471
acceptor.addPosition(node.getOffset(), node.getLength(),
6572
DslHighlightingConfiguration.KEY_ID);
6673
}

commons/plugins/org.eclipse.gemoc.dsl/src/org/eclipse/gemoc/validation/DslValidator.xtend

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class DslValidator extends AbstractDslValidator {
2828

2929
public val IConfigurationElement[] exts = org.eclipse.core.runtime.Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.gemoc.gemoc_language_workbench.metaprog")
3030
public val LanguageComponentHelper languageHelper = new LanguageComponentHelper();
31-
public var IConfigurationElement[] keys
31+
public var ArrayList<IConfigurationElement> keys = new ArrayList<IConfigurationElement>()
32+
public var String metaprog
3233

3334
//public var IRuleProvider providedValidator
3435

@@ -86,23 +87,26 @@ class DslValidator extends AbstractDslValidator {
8687
}
8788

8889
@Check
89-
def checkMissingKeys(Dsl dsl){
90-
var String metaprog
90+
def checkApproach(Entry entry) {
91+
9192
var ArrayList<String> approachesList = new ArrayList<String>()
9293

93-
for (Entry entry: dsl.getEntries){
94-
if("metaprog".matches(entry.key)){
94+
if("metaprog".matches(entry.key)){
9595
metaprog = entry.value
9696

9797
for(IConfigurationElement elem : exts){
9898
approachesList.add(elem.getAttribute("name"))
9999
}
100100

101-
if(!approachesList.contains(entry.value)){
101+
if(!approachesList.contains(metaprog)){
102102
error("Unknown metaprogramming approach", DslPackage.Literals.ENTRY__VALUE)
103103
}
104104
}
105-
}
105+
}
106+
107+
108+
@Check
109+
def checkMissingKeys(Dsl dsl){
106110

107111
var ArrayList<String> dslKeys = new ArrayList<String>()
108112
for(Entry entry : dsl.getEntries){
@@ -118,7 +122,5 @@ class DslValidator extends AbstractDslValidator {
118122

119123
}
120124
}
121-
122-
123125

124126
}

0 commit comments

Comments
 (0)