use of org.springframework.ide.vscode.commons.util.text.LanguageId in project sts4 by spring-projects.
the class Editor method assertContextualCompletions.
public void assertContextualCompletions(Predicate<CompletionItem> isInteresting, String textBefore, String... textAfter) throws Exception {
LanguageId language = this.getLanguageId();
Editor editor = harness.newEditor(language, this.getText());
// this ensures the conText is parsed and its AST is cached (will be used for
editor.reconcile();
// 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);
}
use of org.springframework.ide.vscode.commons.util.text.LanguageId in project sts4 by spring-projects.
the class AbstractPropsEditorTest method setup.
@Before
public void setup() throws Exception {
md = new PropertyIndexHarness();
harness = new LanguageServerHarness(this::newLanguageServer) {
@Override
protected LanguageId getDefaultLanguageId() {
return AbstractPropsEditorTest.this.getLanguageId();
}
protected String getFileExtension() {
return AbstractPropsEditorTest.this.getFileExtension();
}
};
harness.intialize(null);
}
use of org.springframework.ide.vscode.commons.util.text.LanguageId in project sts4 by spring-projects.
the class SimpleTextDocumentService method didOpen.
@Override
public void didOpen(DidOpenTextDocumentParams params) {
async.execute(() -> {
TextDocumentItem docId = params.getTextDocument();
String url = docId.getUri();
// Log.info("didOpen: "+params.getTextDocument().getUri());
LanguageId languageId = LanguageId.of(docId.getLanguageId());
int version = docId.getVersion();
if (url != null) {
String text = params.getTextDocument().getText();
TrackedDocument td = createDocument(url, languageId, version, text).open();
// Log.info("Opened "+td.getOpenCount()+" times: "+url);
TextDocument doc = td.getDocument();
TextDocumentContentChangeEvent change = new TextDocumentContentChangeEvent() {
@Override
public Range getRange() {
return null;
}
@Override
public Integer getRangeLength() {
return null;
}
@Override
public String getText() {
return text;
}
};
TextDocumentContentChange evt = new TextDocumentContentChange(doc, ImmutableList.of(change));
documentChangeListeners.fire(evt);
}
});
}
Aggregations