Reconcile and content assist for ReleaseName references
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user