Search in sources :

Example 1 with WorkspaceSymbolConfiguration

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

the class AbstractLanguageServerTest method testSymbol.

protected void testSymbol(final Procedure1<? super WorkspaceSymbolConfiguration> configurator) {
    try {
        @Extension final WorkspaceSymbolConfiguration configuration = new WorkspaceSymbolConfiguration();
        configuration.setFilePath(("MyModel." + this.fileExtension));
        configurator.apply(configuration);
        this.initializeContext(configuration);
        String _query = configuration.getQuery();
        WorkspaceSymbolParams _workspaceSymbolParams = new WorkspaceSymbolParams(_query);
        final List<? extends SymbolInformation> symbols = this.languageServer.symbol(_workspaceSymbolParams).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) WorkspaceSymbolConfiguration(org.eclipse.xtext.testing.WorkspaceSymbolConfiguration) WorkspaceSymbolParams(org.eclipse.lsp4j.WorkspaceSymbolParams)

Example 2 with WorkspaceSymbolConfiguration

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

the class WorkspaceSymbolTest method testSymbol_01.

@Test
public void testSymbol_01() {
    final Procedure1<WorkspaceSymbolConfiguration> _function = (WorkspaceSymbolConfiguration 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());
        it.setQuery("F");
        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("}");
        _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("}");
        _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("}");
        _builder_1.newLine();
        it.setExpectedSymbols(_builder_1.toString());
    };
    this.testSymbol(_function);
}
Also used : WorkspaceSymbolConfiguration(org.eclipse.xtext.testing.WorkspaceSymbolConfiguration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 3 with WorkspaceSymbolConfiguration

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

the class WorkspaceSymbolTest method testSymbol_02.

@Test
public void testSymbol_02() {
    final Procedure1<WorkspaceSymbolConfiguration> _function = (WorkspaceSymbolConfiguration 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());
        it.setQuery("oO");
        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("}");
        _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("}");
        _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("}");
        _builder_1.newLine();
        it.setExpectedSymbols(_builder_1.toString());
    };
    this.testSymbol(_function);
}
Also used : WorkspaceSymbolConfiguration(org.eclipse.xtext.testing.WorkspaceSymbolConfiguration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Aggregations

WorkspaceSymbolConfiguration (org.eclipse.xtext.testing.WorkspaceSymbolConfiguration)3 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)2 AbstractTestLangLanguageServerTest (org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)2 Test (org.junit.Test)2 WorkspaceSymbolParams (org.eclipse.lsp4j.WorkspaceSymbolParams)1 Extension (org.eclipse.xtext.xbase.lib.Extension)1