Search in sources :

Example 51 with SymbolInformation

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

the class WorkspaceSymbolHandlerTest method testEmptyNames.

@Test
public void testEmptyNames() throws Exception {
    importProjects("maven/reactor");
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("reactor");
    assertIsJavaProject(project);
    String query = "Mono";
    List<SymbolInformation> results = WorkspaceSymbolHandler.search(query, 0, "reactor", false, monitor);
    assertNotNull(results);
    assertEquals("Found ", 119, results.size());
    boolean hasEmptyName = results.stream().filter(s -> (s.getName() == null || s.getName().isEmpty())).findFirst().isPresent();
    assertFalse("Found empty name", hasEmptyName);
}
Also used : SymbolInformation(org.eclipse.lsp4j.SymbolInformation) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test) AbstractProjectsManagerBasedTest(org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)

Example 52 with SymbolInformation

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

the class WorkspaceSymbolHandlerTest method testDeprecated_property.

@Test
public void testDeprecated_property() {
    when(preferenceManager.getClientPreferences().isSymbolTagSupported()).thenReturn(false);
    List<SymbolInformation> results = WorkspaceSymbolHandler.search("Certificate", monitor);
    assertNotNull(results);
    SymbolInformation deprecated = results.stream().filter(symbol -> symbol.getContainerName().equals("java.security")).findFirst().orElse(null);
    assertNotNull(deprecated);
    assertNotNull(deprecated.getDeprecated());
    assertTrue("Should be deprecated", deprecated.getDeprecated());
}
Also used : SymbolInformation(org.eclipse.lsp4j.SymbolInformation) Test(org.junit.Test) AbstractProjectsManagerBasedTest(org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)

Example 53 with SymbolInformation

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

the class WorkspaceSymbolHandlerTest method testDeprecated.

@Test
public void testDeprecated() {
    when(preferenceManager.getClientPreferences().isSymbolTagSupported()).thenReturn(true);
    List<SymbolInformation> results = WorkspaceSymbolHandler.search("Certificate", monitor);
    assertNotNull(results);
    SymbolInformation deprecated = results.stream().filter(symbol -> symbol.getContainerName().equals("java.security")).findFirst().orElse(null);
    assertNotNull(deprecated);
    assertNotNull(deprecated.getTags());
    assertTrue("Should have deprecated tag", deprecated.getTags().contains(SymbolTag.Deprecated));
    SymbolInformation notDeprecated = results.stream().filter(symbol -> symbol.getContainerName().equals("java.security.cert")).findFirst().orElse(null);
    assertNotNull(notDeprecated);
    if (notDeprecated.getTags() != null) {
        assertFalse("Should not have deprecated tag", deprecated.getTags().contains(SymbolTag.Deprecated));
    }
}
Also used : SymbolInformation(org.eclipse.lsp4j.SymbolInformation) Test(org.junit.Test) AbstractProjectsManagerBasedTest(org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)

Example 54 with SymbolInformation

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

the class WorkspaceSymbolHandlerTest method testProjectSearch.

@Test
public void testProjectSearch() {
    String query = "IFoo";
    List<SymbolInformation> results = WorkspaceSymbolHandler.search(query, monitor);
    assertNotNull(results);
    assertEquals("Found " + results.size() + " results", 2, results.size());
    SymbolInformation symbol = results.get(0);
    assertEquals(SymbolKind.Interface, symbol.getKind());
    assertEquals("java", symbol.getContainerName());
    assertEquals(query, symbol.getName());
    Location location = symbol.getLocation();
    assertNotEquals("Range should not equal the default range", JDTUtils.newRange(), location.getRange());
    assertTrue("Unexpected uri " + location.getUri(), location.getUri().endsWith("Foo.java"));
}
Also used : SymbolInformation(org.eclipse.lsp4j.SymbolInformation) Location(org.eclipse.lsp4j.Location) Test(org.junit.Test) AbstractProjectsManagerBasedTest(org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)

Aggregations

SymbolInformation (org.eclipse.lsp4j.SymbolInformation)54 Location (org.eclipse.lsp4j.Location)24 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)11 List (java.util.List)10 AbstractProjectsManagerBasedTest (org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)10 SymbolKind (org.eclipse.lsp4j.SymbolKind)9 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)8 ImmutableList (com.google.common.collect.ImmutableList)7 EnhancedSymbolInformation (org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation)7 URI (java.net.URI)6 Path (java.nio.file.Path)6 TextDocument (org.springframework.ide.vscode.commons.util.text.TextDocument)6 Range (org.eclipse.lsp4j.Range)5 Paths (java.nio.file.Paths)4 Arrays (java.util.Arrays)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4 Map (java.util.Map)4 Optional (java.util.Optional)4