Search in sources :

Example 1 with HoverTestConfiguration

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

the class HoverTest method testHover_03.

@Test
public void testHover_03() {
    final Procedure1<HoverTestConfiguration> _function = (HoverTestConfiguration it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("/**");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("* Some documentation.");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("*/");
        _builder.newLine();
        _builder.append("type Foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("Foo foo");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        it.setModel(_builder.toString());
        it.setLine(4);
        it.setColumn("\tF".length());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("[[4, 1] .. [4, 4]]");
        _builder_1.newLine();
        _builder_1.append("Some documentation.");
        _builder_1.newLine();
        it.setExpectedHover(_builder_1.toString());
    };
    this.testHover(_function);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) HoverTestConfiguration(org.eclipse.xtext.testing.HoverTestConfiguration) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 2 with HoverTestConfiguration

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

the class HoverTest method testHover_01.

@Test
public void testHover_01() {
    final Procedure1<HoverTestConfiguration> _function = (HoverTestConfiguration it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("/**");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("* Some documentation.");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("*/");
        _builder.newLine();
        _builder.append("type Foo {");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        it.setModel(_builder.toString());
        it.setLine(3);
        it.setColumn("type F".length());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("[[3, 5] .. [3, 8]]");
        _builder_1.newLine();
        _builder_1.append("Some documentation.");
        _builder_1.newLine();
        it.setExpectedHover(_builder_1.toString());
    };
    this.testHover(_function);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) HoverTestConfiguration(org.eclipse.xtext.testing.HoverTestConfiguration) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 3 with HoverTestConfiguration

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

the class HoverTest method testHover_04.

@Test
public void testHover_04() {
    final Procedure1<HoverTestConfiguration> _function = (HoverTestConfiguration it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("/**");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("* Some documentation.");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("*/");
        _builder.newLine();
        _builder.append("type Foo {");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        _builder.append("type Bar extends Foo {");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        it.setModel(_builder.toString());
        it.setLine(5);
        it.setColumn("type Bar extends F".length());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("[[5, 17] .. [5, 20]]");
        _builder_1.newLine();
        _builder_1.append("Some documentation.");
        _builder_1.newLine();
        it.setExpectedHover(_builder_1.toString());
    };
    this.testHover(_function);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) HoverTestConfiguration(org.eclipse.xtext.testing.HoverTestConfiguration) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 4 with HoverTestConfiguration

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

the class AbstractLanguageServerTest method testHover.

protected void testHover(final Procedure1<? super HoverTestConfiguration> configurator) {
    try {
        @Extension final HoverTestConfiguration configuration = new HoverTestConfiguration();
        configuration.setFilePath(("MyModel." + this.fileExtension));
        configurator.apply(configuration);
        final String fileUri = this.initializeContext(configuration).getUri();
        TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
        final Procedure1<TextDocumentPositionParams> _function = (TextDocumentPositionParams it) -> {
            TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
            it.setTextDocument(_textDocumentIdentifier);
            int _line = configuration.getLine();
            int _column = configuration.getColumn();
            Position _position = new Position(_line, _column);
            it.setPosition(_position);
        };
        TextDocumentPositionParams _doubleArrow = ObjectExtensions.<TextDocumentPositionParams>operator_doubleArrow(_textDocumentPositionParams, _function);
        final CompletableFuture<Hover> hoverFuture = this.languageServer.hover(_doubleArrow);
        final Hover hover = hoverFuture.get();
        Procedure1<? super Hover> _assertHover = configuration.getAssertHover();
        boolean _tripleNotEquals = (_assertHover != null);
        if (_tripleNotEquals) {
            configuration.getAssertHover().apply(hover);
        } else {
            final String actualHover = this.toExpectation(hover);
            this.assertEquals(configuration.getExpectedHover(), actualHover);
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Extension(org.eclipse.xtext.xbase.lib.Extension) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) Hover(org.eclipse.lsp4j.Hover) HoverTestConfiguration(org.eclipse.xtext.testing.HoverTestConfiguration) TextDocumentPositionParams(org.eclipse.lsp4j.TextDocumentPositionParams)

Example 5 with HoverTestConfiguration

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

the class HoverTest method testHover_02.

@Test
public void testHover_02() {
    final Procedure1<HoverTestConfiguration> _function = (HoverTestConfiguration it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("/**");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("* Some documentation.");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("*/");
        _builder.newLine();
        _builder.append("type Foo {}");
        _builder.newLine();
        it.setModel(_builder.toString());
        it.setLine(3);
        it.setColumn("{".length());
    };
    this.testHover(_function);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) HoverTestConfiguration(org.eclipse.xtext.testing.HoverTestConfiguration) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Aggregations

HoverTestConfiguration (org.eclipse.xtext.testing.HoverTestConfiguration)6 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)5 AbstractTestLangLanguageServerTest (org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)5 Test (org.junit.Test)5 Hover (org.eclipse.lsp4j.Hover)1 Position (org.eclipse.lsp4j.Position)1 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)1 TextDocumentPositionParams (org.eclipse.lsp4j.TextDocumentPositionParams)1 Extension (org.eclipse.xtext.xbase.lib.Extension)1 Pair (org.eclipse.xtext.xbase.lib.Pair)1