Search in sources :

Example 1 with LanguageId

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);
}
Also used : MarkedString(org.eclipse.lsp4j.MarkedString) LanguageId(org.springframework.ide.vscode.commons.util.text.LanguageId)

Example 2 with LanguageId

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);
}
Also used : LanguageServerHarness(org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness) LanguageId(org.springframework.ide.vscode.commons.util.text.LanguageId) Before(org.junit.Before)

Example 3 with LanguageId

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);
        }
    });
}
Also used : TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) TextDocument(org.springframework.ide.vscode.commons.util.text.TextDocument) LanguageId(org.springframework.ide.vscode.commons.util.text.LanguageId) TextDocumentContentChangeEvent(org.eclipse.lsp4j.TextDocumentContentChangeEvent)

Aggregations

LanguageId (org.springframework.ide.vscode.commons.util.text.LanguageId)3 MarkedString (org.eclipse.lsp4j.MarkedString)1 TextDocumentContentChangeEvent (org.eclipse.lsp4j.TextDocumentContentChangeEvent)1 TextDocumentItem (org.eclipse.lsp4j.TextDocumentItem)1 Before (org.junit.Before)1 TextDocument (org.springframework.ide.vscode.commons.util.text.TextDocument)1 LanguageServerHarness (org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness)1