Skip to content

Commit 469f572

Browse files
committed
[#20116] Fix content assist for create domain project: when no 'syntax' keyword add the proposal in first position
1 parent 75e425b commit 469f572

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

java_execution/java_xdsml/plugins/org.gemoc.execution.sequential.javaxdsml.ide.ui/src/org/gemoc/execution/sequential/javaxdsml/ide/ui/commands/CreateDomainModelProjectHandler.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,39 @@ protected void updateMelange(ExecutionEvent event, Language language, String eco
6464
length = 0;
6565
newRegion = "syntax \""+ecoreURI+"\"\n\t";
6666
}
67+
else if(nodesOp.isEmpty()){ //no operators, search for '{'
68+
EStructuralFeature name = language.eClass().getEStructuralFeature("name");
69+
List<INode> nameNode = NodeModelUtils.findNodesForFeature(language, name);
70+
INode node = nameNode.get(0);
71+
int endName = node.getEndOffset();
72+
73+
74+
XtextEditor editor = EditorUtils.getActiveXtextEditor();
75+
if (editor != null) {
76+
String content = editor.getDocument().get();
77+
startOffset = content.indexOf("{", endName) + 1;
78+
length = 0;
79+
newRegion = "\n\tsyntax \""+ecoreURI+"\"\n\t";
80+
}
81+
else{
82+
String melangeWSLocation = language.eResource().getURI().toPlatformString(true);
83+
URI uri = language.eResource().getURI();
84+
String melangeLocation =ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()+melangeWSLocation;
85+
List<String> lines;
86+
try {
87+
lines = Files.readAllLines(Paths.get(melangeLocation));
88+
StringBuffer newContent = new StringBuffer();
89+
lines.forEach(
90+
line -> newContent.append(line+"\n")
91+
);
92+
startOffset = newContent.indexOf("{", endName) + 1;
93+
length = 0;
94+
newRegion = "\n\tsyntax \""+ecoreURI+"\"\n\t";
95+
} catch (IOException e) {
96+
e.printStackTrace();
97+
}
98+
}
99+
}
67100

68101
// Replace in document or Melange file
69102
if(startOffset != -1 && length != -1 && newRegion != null){

0 commit comments

Comments
 (0)