Search in sources :

Example 1 with HoverParams

use of org.eclipse.lsp4j.HoverParams in project eclipse.jdt.ls by eclipse.

the class SyntaxServerTest method testHoverUnresolvedType.

@Test
public void testHoverUnresolvedType() throws Exception {
    URI fileURI = openFile("maven/salut4", "src/main/java/java/Foo.java");
    String fileUri = ResourceUtils.fixURI(fileURI);
    TextDocumentIdentifier identifier = new TextDocumentIdentifier(fileUri);
    HoverParams params = new HoverParams(identifier, new Position(7, 30));
    Hover result = server.hover(params).join();
    assertNotNull(result);
    assertNotNull(result.getContents());
    assertTrue(result.getContents().isLeft());
    List<Either<String, MarkedString>> list = result.getContents().getLeft();
    assertNotNull(list);
    assertEquals(2, list.size());
    assertTrue(list.get(1).isLeft());
    assertEquals("This is interface IFoo.", list.get(1).getLeft());
}
Also used : HoverParams(org.eclipse.lsp4j.HoverParams) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) Hover(org.eclipse.lsp4j.Hover) Either(org.eclipse.lsp4j.jsonrpc.messages.Either) MarkedString(org.eclipse.lsp4j.MarkedString) URI(java.net.URI) Test(org.junit.Test)

Example 2 with HoverParams

use of org.eclipse.lsp4j.HoverParams 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();
        HoverParams _hoverParams = new HoverParams();
        final Procedure1<HoverParams> _function = (HoverParams 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);
        };
        HoverParams _doubleArrow = ObjectExtensions.<HoverParams>operator_doubleArrow(_hoverParams, _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) HoverParams(org.eclipse.lsp4j.HoverParams) VersionedTextDocumentIdentifier(org.eclipse.lsp4j.VersionedTextDocumentIdentifier) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) Hover(org.eclipse.lsp4j.Hover)

Example 3 with HoverParams

use of org.eclipse.lsp4j.HoverParams in project eclipse.jdt.ls by eclipse.

the class SyntaxServerTest method testHover.

@Test
public void testHover() throws Exception {
    URI fileURI = openFile("maven/salut4", "src/main/java/java/TestJavadoc.java");
    String fileUri = ResourceUtils.fixURI(fileURI);
    TextDocumentIdentifier identifier = new TextDocumentIdentifier(fileUri);
    HoverParams params = new HoverParams(identifier, new Position(8, 23));
    Hover result = server.hover(params).join();
    assertNotNull(result);
    assertNotNull(result.getContents());
    assertTrue(result.getContents().isLeft());
    List<Either<String, MarkedString>> list = result.getContents().getLeft();
    assertNotNull(list);
    assertEquals(2, list.size());
    assertTrue(list.get(1).isLeft());
    assertEquals("Test", list.get(1).getLeft());
}
Also used : HoverParams(org.eclipse.lsp4j.HoverParams) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) Hover(org.eclipse.lsp4j.Hover) Either(org.eclipse.lsp4j.jsonrpc.messages.Either) MarkedString(org.eclipse.lsp4j.MarkedString) URI(java.net.URI) Test(org.junit.Test)

Example 4 with HoverParams

use of org.eclipse.lsp4j.HoverParams in project eclipse.jdt.ls by eclipse.

the class SyntaxServerTest method testHoverType.

@Test
public void testHoverType() throws Exception {
    URI fileURI = openFile("maven/salut4", "src/main/java/java/Foo.java");
    String fileUri = ResourceUtils.fixURI(fileURI);
    TextDocumentIdentifier identifier = new TextDocumentIdentifier(fileUri);
    HoverParams params = new HoverParams(identifier, new Position(11, 9));
    Hover result = server.hover(params).join();
    assertNotNull(result);
    assertNotNull(result.getContents());
    assertTrue(result.getContents().isLeft());
    List<Either<String, MarkedString>> list = result.getContents().getLeft();
    assertNotNull(list);
    assertEquals(2, list.size());
    assertTrue(list.get(1).isLeft());
    assertEquals("This is Bar.", list.get(1).getLeft());
}
Also used : HoverParams(org.eclipse.lsp4j.HoverParams) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) Hover(org.eclipse.lsp4j.Hover) Either(org.eclipse.lsp4j.jsonrpc.messages.Either) MarkedString(org.eclipse.lsp4j.MarkedString) URI(java.net.URI) Test(org.junit.Test)

Aggregations

Hover (org.eclipse.lsp4j.Hover)4 HoverParams (org.eclipse.lsp4j.HoverParams)4 Position (org.eclipse.lsp4j.Position)4 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)4 URI (java.net.URI)3 MarkedString (org.eclipse.lsp4j.MarkedString)3 Either (org.eclipse.lsp4j.jsonrpc.messages.Either)3 Test (org.junit.Test)3 VersionedTextDocumentIdentifier (org.eclipse.lsp4j.VersionedTextDocumentIdentifier)1 Extension (org.eclipse.xtext.xbase.lib.Extension)1