Search in sources :

Example 76 with TextDocumentIdentifier

use of org.eclipse.lsp4j.TextDocumentIdentifier in project sts4 by spring-projects.

the class InFileSymbolsProvider method fetchFor.

@Override
public Collection<SymbolInformation> fetchFor(String query) throws Exception {
    DocumentSymbolParams params = new DocumentSymbolParams(new TextDocumentIdentifier(info.getFileUri().toString()));
    CompletableFuture<List<? extends SymbolInformation>> symbolsFuture = info.getLanguageClient().getTextDocumentService().documentSymbol(params);
    List<? extends SymbolInformation> symbols = symbolsFuture.get();
    return symbols == null ? ImmutableList.of() : ImmutableList.copyOf(symbols);
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) DocumentSymbolParams(org.eclipse.lsp4j.DocumentSymbolParams) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) SymbolInformation(org.eclipse.lsp4j.SymbolInformation)

Example 77 with TextDocumentIdentifier

use of org.eclipse.lsp4j.TextDocumentIdentifier in project sts4 by spring-projects.

the class Editor method assertGotoDefinition.

public void assertGotoDefinition(Position pos, Range expectedTarget) throws Exception {
    TextDocumentIdentifier textDocumentId = doc.getId();
    TextDocumentPositionParams params = new TextDocumentPositionParams(textDocumentId, textDocumentId.getUri(), pos);
    List<? extends Location> defs = harness.getDefinitions(params);
    assertEquals(1, defs.size());
    assertEquals(new Location(textDocumentId.getUri(), expectedTarget), defs.get(0));
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) TextDocumentPositionParams(org.eclipse.lsp4j.TextDocumentPositionParams) Location(org.eclipse.lsp4j.Location)

Example 78 with TextDocumentIdentifier

use of org.eclipse.lsp4j.TextDocumentIdentifier in project sts4 by spring-projects.

the class TextDocumentInfo method getId.

public TextDocumentIdentifier getId() {
    TextDocumentIdentifier id = new TextDocumentIdentifier();
    id.setUri(getUri());
    return id;
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier)

Example 79 with TextDocumentIdentifier

use of org.eclipse.lsp4j.TextDocumentIdentifier in project sts4 by spring-projects.

the class SpringIndexer method createDocument.

public CompletableFuture<Void> createDocument(String docURI) {
    synchronized (this) {
        if (docURI.endsWith(".java") && lastInitializeItem != null) {
            try {
                Optional<IJavaProject> maybeProject = projectFinder.find(new TextDocumentIdentifier(docURI));
                if (maybeProject.isPresent()) {
                    String[] classpathEntries = getClasspathEntries(maybeProject.get());
                    String content = FileUtils.readFileToString(new File(new URI(docURI)));
                    UpdateItem updateItem = new UpdateItem(docURI, content, classpathEntries);
                    updateQueue.put(updateItem);
                    return updateItem.getFuture();
                }
            } catch (Exception e) {
                log.error("", e);
                return Futures.error(e);
            }
        }
    }
    return CompletableFuture.completedFuture(null);
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) File(java.io.File) URI(java.net.URI)

Example 80 with TextDocumentIdentifier

use of org.eclipse.lsp4j.TextDocumentIdentifier in project sts4 by spring-projects.

the class SpringIndexer method updateDocument.

public CompletableFuture<Void> updateDocument(String docURI, String content) {
    synchronized (this) {
        if (docURI.endsWith(".java") && lastInitializeItem != null) {
            try {
                Optional<IJavaProject> maybeProject = projectFinder.find(new TextDocumentIdentifier(docURI));
                if (maybeProject.isPresent()) {
                    String[] classpathEntries = getClasspathEntries(maybeProject.get());
                    UpdateItem updateItem = new UpdateItem(docURI, content, classpathEntries);
                    updateQueue.put(updateItem);
                    return updateItem.getFuture();
                }
            } catch (Exception e) {
                log.error("{}", e);
            }
        }
    }
    return null;
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject)

Aggregations

TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)172 Test (org.junit.Test)113 Position (org.eclipse.lsp4j.Position)102 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)56 Range (org.eclipse.lsp4j.Range)47 TextDocumentPositionParams (org.eclipse.lsp4j.TextDocumentPositionParams)37 Either (org.eclipse.lsp4j.jsonrpc.messages.Either)35 URI (java.net.URI)34 AbstractProjectsManagerBasedTest (org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)33 CodeActionContext (org.eclipse.lsp4j.CodeActionContext)32 CodeActionParams (org.eclipse.lsp4j.CodeActionParams)32 List (java.util.List)26 VersionedTextDocumentIdentifier (org.eclipse.lsp4j.VersionedTextDocumentIdentifier)25 Location (org.eclipse.lsp4j.Location)23 AbstractQuickFixTest (org.eclipse.jdt.ls.core.internal.correction.AbstractQuickFixTest)22 Command (org.eclipse.lsp4j.Command)22 PrepareRenameParams (org.eclipse.lsp4j.PrepareRenameParams)20 FormattingOptions (org.eclipse.lsp4j.FormattingOptions)19 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)18 CodeAction (org.eclipse.lsp4j.CodeAction)18