Reconcile and content assist for ReleaseName references

This commit is contained in:
Kris De Volder
2017-07-18 10:52:33 -07:00
parent 2ffaed4436
commit fc1a0fec46
7 changed files with 154 additions and 25 deletions

View File

@@ -383,6 +383,32 @@ public class Editor {
}
}
public void assertContextualCompletions(LanguageId language, Predicate<CompletionItem> isInteresting, String textBefore, String... textAfter) throws Exception {
Editor editor = harness.newEditor(language, this.getText());
editor.reconcile(); //this ensures the conText is parsed and its AST is cached (will be used for
//dynamic CA when the conText + textBefore is not parsable.
textBefore = replaceSelection(textBefore);
textAfter = Arrays.stream(textAfter)
.map((String t) -> replaceSelection(t))
.collect(Collectors.toList()).toArray(new String[0]);
editor.setText(textBefore);
editor.assertCompletions(isInteresting, textAfter);
}
public void assertContextualCompletions(String textBefore, String... textAfter) throws Exception {
assertContextualCompletions(getLanguageId(), (x) -> true, textBefore, textAfter);
}
private String replaceSelection(String replacement) {
try {
String text = getRawText();
return text.substring(0, selectionStart) + replacement + text.substring(selectionEnd);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void apply(CompletionItem completion) throws Exception {
completion = harness.resolveCompletionItem(completion);
TextEdit edit = completion.getTextEdit();