Search in sources :

Example 1 with DocumentSymbolConfiguraiton

use of org.eclipse.xtext.testing.DocumentSymbolConfiguraiton in project xtext-core by eclipse.

the class AbstractLanguageServerTest method testDocumentSymbol.

protected void testDocumentSymbol(final Procedure1<? super DocumentSymbolConfiguraiton> configurator) {
    try {
        @Extension final DocumentSymbolConfiguraiton configuration = new DocumentSymbolConfiguraiton();
        configuration.setFilePath(("MyModel." + this.fileExtension));
        configurator.apply(configuration);
        final String fileUri = this.initializeContext(configuration).getUri();
        TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
        DocumentSymbolParams _documentSymbolParams = new DocumentSymbolParams(_textDocumentIdentifier);
        final CompletableFuture<List<? extends SymbolInformation>> symbolsFuture = this.languageServer.documentSymbol(_documentSymbolParams);
        final List<? extends SymbolInformation> symbols = symbolsFuture.get();
        Procedure1<? super List<? extends SymbolInformation>> _assertSymbols = configuration.getAssertSymbols();
        boolean _tripleNotEquals = (_assertSymbols != null);
        if (_tripleNotEquals) {
            configuration.getAssertSymbols().apply(symbols);
        } else {
            final String actualSymbols = this.toExpectation(symbols);
            this.assertEquals(configuration.getExpectedSymbols(), actualSymbols);
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Extension(org.eclipse.xtext.xbase.lib.Extension) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) DocumentSymbolParams(org.eclipse.lsp4j.DocumentSymbolParams) List(java.util.List) CompletionList(org.eclipse.lsp4j.CompletionList) DocumentSymbolConfiguraiton(org.eclipse.xtext.testing.DocumentSymbolConfiguraiton) SymbolInformation(org.eclipse.lsp4j.SymbolInformation)

Example 2 with DocumentSymbolConfiguraiton

use of org.eclipse.xtext.testing.DocumentSymbolConfiguraiton in project xtext-core by eclipse.

the class DocumentSymbolTest method testDocumentSymbol_01.

@Test
public void testDocumentSymbol_01() {
    final Procedure1<DocumentSymbolConfiguraiton> _function = (DocumentSymbolConfiguraiton it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("type Foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("int bar");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        _builder.append("type Bar {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("Foo foo");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        it.setModel(_builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("symbol \"Foo\" {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("kind: 7");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("location: MyModel.testlang [[0, 5] .. [0, 8]]");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.append("symbol \"Foo.bar\" {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("kind: 7");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("location: MyModel.testlang [[1, 5] .. [1, 8]]");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("container: \"Foo\"");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.append("symbol \"Foo.bar.int\" {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("kind: 7");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("location: MyModel.testlang [[1, 1] .. [1, 4]]");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("container: \"Foo.bar\"");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.append("symbol \"Bar\" {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("kind: 7");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("location: MyModel.testlang [[3, 5] .. [3, 8]]");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.append("symbol \"Bar.foo\" {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("kind: 7");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("location: MyModel.testlang [[4, 5] .. [4, 8]]");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("container: \"Bar\"");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        it.setExpectedSymbols(_builder_1.toString());
    };
    this.testDocumentSymbol(_function);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) DocumentSymbolConfiguraiton(org.eclipse.xtext.testing.DocumentSymbolConfiguraiton) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Aggregations

DocumentSymbolConfiguraiton (org.eclipse.xtext.testing.DocumentSymbolConfiguraiton)2 List (java.util.List)1 CompletionList (org.eclipse.lsp4j.CompletionList)1 DocumentSymbolParams (org.eclipse.lsp4j.DocumentSymbolParams)1 SymbolInformation (org.eclipse.lsp4j.SymbolInformation)1 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 AbstractTestLangLanguageServerTest (org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)1 Extension (org.eclipse.xtext.xbase.lib.Extension)1 Test (org.junit.Test)1