Search in sources :

Example 6 with DocumentHighlightConfiguration

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

the class DocumentHighlightTest method singleLineMultipleOccurrences_SelectionOnReadSite.

@Test
public void singleLineMultipleOccurrences_SelectionOnReadSite() {
    final Procedure1<DocumentHighlightConfiguration> _function = (DocumentHighlightConfiguration it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("type A { op foo() { } op bar() { foo(10) } }");
        it.setModel(_builder.toString());
        it.setLine(0);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("type A { op foo() { } op bar() { fo");
        it.setColumn(_builder_1.length());
        it.setExpectedDocumentHighlight("W [[0, 12] .. [0, 15]] | R [[0, 33] .. [0, 36]]");
    };
    this.testDocumentHighlight(_function);
}
Also used : DocumentHighlightConfiguration(org.eclipse.xtext.testing.DocumentHighlightConfiguration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 7 with DocumentHighlightConfiguration

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

the class DocumentHighlightTest method singleLineSingleOccurrence.

@Test
public void singleLineSingleOccurrence() {
    final Procedure1<DocumentHighlightConfiguration> _function = (DocumentHighlightConfiguration it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("type A { op foo() { } }");
        it.setModel(_builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("type A { op fo");
        it.setColumn(_builder_1.length());
        it.setExpectedDocumentHighlight("W [[0, 12] .. [0, 15]]");
    };
    this.testDocumentHighlight(_function);
}
Also used : DocumentHighlightConfiguration(org.eclipse.xtext.testing.DocumentHighlightConfiguration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 8 with DocumentHighlightConfiguration

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

the class AbstractLanguageServerTest method testDocumentHighlight.

protected void testDocumentHighlight(final Procedure1<? super DocumentHighlightConfiguration> configurator) {
    try {
        DocumentHighlightConfiguration _documentHighlightConfiguration = new DocumentHighlightConfiguration();
        final Procedure1<DocumentHighlightConfiguration> _function = (DocumentHighlightConfiguration it) -> {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("MyModel.");
            _builder.append(this.fileExtension);
            it.setFilePath(_builder.toString());
        };
        @Extension final DocumentHighlightConfiguration configuration = ObjectExtensions.<DocumentHighlightConfiguration>operator_doubleArrow(_documentHighlightConfiguration, _function);
        configurator.apply(configuration);
        final String fileUri = this.initializeContext(configuration).getUri();
        TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
        final Procedure1<TextDocumentPositionParams> _function_1 = (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_1);
        final CompletableFuture<List<? extends DocumentHighlight>> highlights = this.languageServer.documentHighlight(_doubleArrow);
        final Function1<DocumentHighlight, String> _function_2 = (DocumentHighlight it) -> {
            return this.toExpectation(it);
        };
        final String actualDocumentHighlight = IterableExtensions.join(ListExtensions.map(highlights.get(), _function_2), " | ");
        this.assertEquals(configuration.getExpectedDocumentHighlight(), actualDocumentHighlight);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : DocumentHighlight(org.eclipse.lsp4j.DocumentHighlight) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) Extension(org.eclipse.xtext.xbase.lib.Extension) DocumentHighlightConfiguration(org.eclipse.xtext.testing.DocumentHighlightConfiguration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) List(java.util.List) CompletionList(org.eclipse.lsp4j.CompletionList) TextDocumentPositionParams(org.eclipse.lsp4j.TextDocumentPositionParams)

Example 9 with DocumentHighlightConfiguration

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

the class DocumentHighlightTest method singleLineSingleOccurrenceWithVariable.

@Test
public void singleLineSingleOccurrenceWithVariable() {
    final Procedure1<DocumentHighlightConfiguration> _function = (DocumentHighlightConfiguration it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("type A { int foo op foo() { } }");
        it.setModel(_builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("type A { int fo");
        it.setColumn(_builder_1.length());
        it.setExpectedDocumentHighlight("W [[0, 13] .. [0, 16]]");
    };
    this.testDocumentHighlight(_function);
}
Also used : DocumentHighlightConfiguration(org.eclipse.xtext.testing.DocumentHighlightConfiguration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 10 with DocumentHighlightConfiguration

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

the class DocumentHighlightTest method singleLineNoOccurrences_SelectionAfterWriteSiteMethodName.

@Test
public void singleLineNoOccurrences_SelectionAfterWriteSiteMethodName() {
    final Procedure1<DocumentHighlightConfiguration> _function = (DocumentHighlightConfiguration it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("type A { op foo() { } }");
        it.setModel(_builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("type A { op foo(");
        it.setColumn(_builder_1.length());
        it.setExpectedDocumentHighlight("");
    };
    this.testDocumentHighlight(_function);
}
Also used : DocumentHighlightConfiguration(org.eclipse.xtext.testing.DocumentHighlightConfiguration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Aggregations

StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)10 DocumentHighlightConfiguration (org.eclipse.xtext.testing.DocumentHighlightConfiguration)10 AbstractTestLangLanguageServerTest (org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)9 Test (org.junit.Test)9 List (java.util.List)1 CompletionList (org.eclipse.lsp4j.CompletionList)1 DocumentHighlight (org.eclipse.lsp4j.DocumentHighlight)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