Search in sources :

Example 1 with TextDocumentItem

use of org.eclipse.lsp4j.TextDocumentItem in project vscode-nextgenas by BowlerHatLLC.

the class ActionScriptTextDocumentService method didOpen.

/**
     * Called whan a file is opened for editing in Visual Studio Code. We store
     * the file's contents in a String since any changes that have been made to
     * it may not have been saved yet. This method will not be called again if
     * the user simply switches to a different tab for another file and then
     * switched back to this one, without every closing it completely. In
     * other words, the language server does not usually know which file is
     * currently visible to the user in VSCode.
     */
@Override
public void didOpen(DidOpenTextDocumentParams params) {
    TextDocumentItem textDocument = params.getTextDocument();
    String textDocumentUri = textDocument.getUri();
    if (!textDocumentUri.endsWith(AS_EXTENSION) && !textDocumentUri.endsWith(MXML_EXTENSION)) {
        return;
    }
    Path path = LanguageServerUtils.getPathFromLanguageServerURI(textDocumentUri);
    if (path != null) {
        String text = textDocument.getText();
        sourceByPath.put(path, text);
        //we need to check for problems when opening a new file because it
        //may not have been in the workspace before.
        checkFilePathForProblems(path, false);
    }
}
Also used : Path(java.nio.file.Path) TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem)

Example 2 with TextDocumentItem

use of org.eclipse.lsp4j.TextDocumentItem in project xtext-core by eclipse.

the class UnknownProjectConfigTest method testCompletionWithInmemoryScheme_01.

@Test
public void testCompletionWithInmemoryScheme_01() {
    final Procedure1<InitializeParams> _function = (InitializeParams it) -> {
        it.setRootUri(null);
    };
    this.initialize(_function);
    final String inmemoryUri = "inmemory:/mydoc.testlang";
    DidOpenTextDocumentParams _didOpenTextDocumentParams = new DidOpenTextDocumentParams();
    final Procedure1<DidOpenTextDocumentParams> _function_1 = (DidOpenTextDocumentParams it) -> {
        TextDocumentItem _textDocumentItem = new TextDocumentItem();
        final Procedure1<TextDocumentItem> _function_2 = (TextDocumentItem it_1) -> {
            it_1.setUri(inmemoryUri);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("type Foo {}");
            _builder.newLine();
            it_1.setText(_builder.toString());
        };
        TextDocumentItem _doubleArrow = ObjectExtensions.<TextDocumentItem>operator_doubleArrow(_textDocumentItem, _function_2);
        it.setTextDocument(_doubleArrow);
    };
    DidOpenTextDocumentParams _doubleArrow = ObjectExtensions.<DidOpenTextDocumentParams>operator_doubleArrow(_didOpenTextDocumentParams, _function_1);
    this.languageServer.didOpen(_doubleArrow);
    this.checkCompletion(inmemoryUri);
}
Also used : TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) InitializeParams(org.eclipse.lsp4j.InitializeParams) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 3 with TextDocumentItem

use of org.eclipse.lsp4j.TextDocumentItem in project xtext-core by eclipse.

the class AbstractLanguageServerTest method open.

protected void open(final String fileUri, final String langaugeId, final String model) {
    DidOpenTextDocumentParams _didOpenTextDocumentParams = new DidOpenTextDocumentParams();
    final Procedure1<DidOpenTextDocumentParams> _function = (DidOpenTextDocumentParams it) -> {
        TextDocumentItem _textDocumentItem = new TextDocumentItem();
        final Procedure1<TextDocumentItem> _function_1 = (TextDocumentItem it_1) -> {
            it_1.setUri(fileUri);
            it_1.setLanguageId(langaugeId);
            it_1.setVersion(1);
            it_1.setText(model);
        };
        TextDocumentItem _doubleArrow = ObjectExtensions.<TextDocumentItem>operator_doubleArrow(_textDocumentItem, _function_1);
        it.setTextDocument(_doubleArrow);
    };
    DidOpenTextDocumentParams _doubleArrow = ObjectExtensions.<DidOpenTextDocumentParams>operator_doubleArrow(_didOpenTextDocumentParams, _function);
    this.languageServer.didOpen(_doubleArrow);
}
Also used : TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1)

Example 4 with TextDocumentItem

use of org.eclipse.lsp4j.TextDocumentItem in project xtext-core by eclipse.

the class UnknownProjectConfigTest method testCompletionWithInmemoryScheme_02.

@Test
public void testCompletionWithInmemoryScheme_02() {
    this.initialize();
    final String inmemoryUri = "inmemory:/mydoc.testlang";
    DidOpenTextDocumentParams _didOpenTextDocumentParams = new DidOpenTextDocumentParams();
    final Procedure1<DidOpenTextDocumentParams> _function = (DidOpenTextDocumentParams it) -> {
        TextDocumentItem _textDocumentItem = new TextDocumentItem();
        final Procedure1<TextDocumentItem> _function_1 = (TextDocumentItem it_1) -> {
            it_1.setUri(inmemoryUri);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("type Foo {}");
            _builder.newLine();
            it_1.setText(_builder.toString());
        };
        TextDocumentItem _doubleArrow = ObjectExtensions.<TextDocumentItem>operator_doubleArrow(_textDocumentItem, _function_1);
        it.setTextDocument(_doubleArrow);
    };
    DidOpenTextDocumentParams _doubleArrow = ObjectExtensions.<DidOpenTextDocumentParams>operator_doubleArrow(_didOpenTextDocumentParams, _function);
    this.languageServer.didOpen(_doubleArrow);
    this.checkCompletion(inmemoryUri);
}
Also used : TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 5 with TextDocumentItem

use of org.eclipse.lsp4j.TextDocumentItem in project xtext-core by eclipse.

the class UnknownProjectConfigTest method testCompletionWithFileScheme_02.

@Test
public void testCompletionWithFileScheme_02() {
    this.initialize();
    final String fileUri = "file:/home/test/workspace/mydoc.testlang";
    DidOpenTextDocumentParams _didOpenTextDocumentParams = new DidOpenTextDocumentParams();
    final Procedure1<DidOpenTextDocumentParams> _function = (DidOpenTextDocumentParams it) -> {
        TextDocumentItem _textDocumentItem = new TextDocumentItem();
        final Procedure1<TextDocumentItem> _function_1 = (TextDocumentItem it_1) -> {
            it_1.setUri(fileUri);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("type Foo {}");
            _builder.newLine();
            it_1.setText(_builder.toString());
        };
        TextDocumentItem _doubleArrow = ObjectExtensions.<TextDocumentItem>operator_doubleArrow(_textDocumentItem, _function_1);
        it.setTextDocument(_doubleArrow);
    };
    DidOpenTextDocumentParams _doubleArrow = ObjectExtensions.<DidOpenTextDocumentParams>operator_doubleArrow(_didOpenTextDocumentParams, _function);
    this.languageServer.didOpen(_doubleArrow);
    this.checkCompletion(fileUri);
}
Also used : TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Aggregations

TextDocumentItem (org.eclipse.lsp4j.TextDocumentItem)7 DidOpenTextDocumentParams (org.eclipse.lsp4j.DidOpenTextDocumentParams)6 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)6 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)5 AbstractTestLangLanguageServerTest (org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)5 Test (org.junit.Test)5 InitializeParams (org.eclipse.lsp4j.InitializeParams)2 Path (java.nio.file.Path)1 TestLangLSPExtension (org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension)1 Pair (org.eclipse.xtext.xbase.lib.Pair)1