public void setQuickfixes(TextDocumentIdentifier docId, List<Quickfix> quickfixes) { TrackedDocument td = documents.get(docId.getUri()); if (td!=null) { td.setQuickfixes(quickfixes); } }
public List<Either<SymbolInformation, DocumentSymbol>> documentSymbol(DocumentSymbolParams params, IProgressMonitor monitor) { ITypeRoot unit = JDTUtils.resolveTypeRoot(params.getTextDocument().getUri()); if (unit == null) { return Collections.emptyList(); } if (hierarchicalDocumentSymbolSupported) { List<DocumentSymbol> symbols = this.getHierarchicalOutline(unit, monitor); return symbols.stream().map(Either::<SymbolInformation, DocumentSymbol>forRight).collect(toList()); } else { SymbolInformation[] elements = this.getOutline(unit, monitor); return Arrays.asList(elements).stream().map(Either::<SymbolInformation, DocumentSymbol>forLeft).collect(toList()); } }
TextDocumentIdentifier clone(TextDocumentIdentifier textDocumentIdentifier) { if (textDocumentIdentifier == null) { return null; } String uri = textDocumentIdentifier.getUri(); TextDocumentIdentifier cloned = new TextDocumentIdentifier(); cloned.setUri(uri); return cloned; }
public List<TextEdit> willSaveWaitUntil(WillSaveTextDocumentParams params, IProgressMonitor monitor) { List<TextEdit> edit = new ArrayList<>(); if (monitor.isCanceled()) { return edit; } String documentUri = params.getTextDocument().getUri(); if (preferenceManager.getPreferences().isJavaSaveActionsOrganizeImportsEnabled()) { edit.addAll(handleSaveActionOrganizeImports(documentUri, monitor)); } return edit; }
@Override public CompletableFuture<List<? extends SymbolInformation>> documentSymbol(DocumentSymbolParams params) { URI uri = Uris.resolveToRoot(getWorkspacePath(), params.getTextDocument().getUri()); List<SymbolInformation> symbols = Optional.fromNullable(getState().getCompilerWrapper().getFileSymbols() .get(uri).stream().collect(Collectors.toList())).or(Lists.newArrayList()); return CompletableFuture.completedFuture(symbols); } }
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)); }
public void updateConfiguration(TextDocumentIdentifier param) { IFile file = JDTUtils.findFile(param.getUri()); if (file == null) { return; } // most likely the handler is invoked intentionally by the user, that's why // we force the update despite no changes of in build descriptor being made projectManager.updateProject(file.getProject(), true); } }
public void publishDiagnostics(TextDocumentIdentifier docId, Collection<Diagnostic> diagnostics) { LanguageClient client = server.getClient(); if (client!=null && diagnostics!=null) { PublishDiagnosticsParams params = new PublishDiagnosticsParams(); params.setUri(docId.getUri()); params.setDiagnostics(ImmutableList.copyOf(diagnostics)); client.publishDiagnostics(params); } }
public List<? extends Location> definition(TextDocumentPositionParams position, IProgressMonitor monitor) { ITypeRoot unit = JDTUtils.resolveTypeRoot(position.getTextDocument().getUri()); Location location = null; if (unit != null && !monitor.isCanceled()) { location = computeDefinitionNavigation(unit, position.getPosition().getLine(), position.getPosition().getCharacter(), monitor); } return location == null ? null : Arrays.asList(location); }
public List<? extends Location> typeDefinition(TextDocumentPositionParams position, IProgressMonitor monitor) { ITypeRoot unit = JDTUtils.resolveTypeRoot(position.getTextDocument().getUri()); Location location = null; if (unit != null && !monitor.isCanceled()) { location = computeTypeDefinitionNavigation(unit, position.getPosition().getLine(), position.getPosition().getCharacter(), monitor); } return location == null ? null : Arrays.asList(location); }
@Override public CompletableFuture<BallerinaProject> project(BallerinaProjectParams params) { return CompletableFuture.supplyAsync(() -> { Path sourceFilePath = new LSDocument(params.getDocumentIdentifier().getUri()).getPath(); BallerinaProject project = new BallerinaProject(); project.setPath(getSourceRoot(sourceFilePath)); return project; }); }
@Override public CompletableFuture<String> classFileContents(TextDocumentIdentifier param) { logInfo(">> java/classFileContents"); ContentProviderManager handler = JavaLanguageServerPlugin.getContentProviderManager(); URI uri = JDTUtils.toURI(param.getUri()); return computeAsync((monitor) -> handler.getContent(uri, monitor)); }
@Override public void didClose(final DidCloseTextDocumentParams params) { final Function0<BuildManager.Buildable> _function = () -> { return this.workspaceManager.didClose(this._uriExtensions.toUri(params.getTextDocument().getUri())); }; final Function2<CancelIndicator, BuildManager.Buildable, List<IResourceDescription.Delta>> _function_1 = (CancelIndicator cancelIndicator, BuildManager.Buildable buildable) -> { return buildable.build(cancelIndicator); }; this.requestManager.<BuildManager.Buildable, List<IResourceDescription.Delta>>runWrite(_function, _function_1); }
public Hover hover(TextDocumentPositionParams position, IProgressMonitor monitor) { ITypeRoot unit = JDTUtils.resolveTypeRoot(position.getTextDocument().getUri()); List<Either<String, MarkedString>> content = null; if (unit != null && !monitor.isCanceled()) { content = computeHover(unit, position.getPosition().getLine(), position.getPosition().getCharacter(), monitor); } else { content = Collections.singletonList(Either.forLeft("")); } Hover $ = new Hover(); $.setContents(content); return $; }
@Override public CompletableFuture<List<? extends CodeLens>> codeLens(CodeLensParams params) { logInfo(">> document/codeLens"); CodeLensHandler handler = new CodeLensHandler(preferenceManager); return computeAsync((monitor) -> { waitForLifecycleJobs(monitor); return handler.getCodeLensSymbols(params.getTextDocument().getUri(), monitor); }); }
@Override public CompletableFuture<Either<List<CompletionItem>, CompletionList>> completion( TextDocumentPositionParams position) { return CompletableFuture.completedFuture(Either.forRight( getState().getCompilerWrapper() .getCompletion( Uris.resolveToRoot(getWorkspacePath(), position.getTextDocument().getUri()), position.getPosition()))); }
@Override public final void didSave(DidSaveTextDocumentParams params) { URI uri = Uris.resolveToRoot(getWorkspacePath(), params.getTextDocument().getUri()); getState().getCompilerWrapper().handleFileSaved(uri, Optional.fromNullable(params.getText())); getState().publishDiagnostics(getState().getCompilerWrapper().compile(ImmutableSet.of(uri))); }
public List<? extends DocumentHighlight> documentHighlight(TextDocumentPositionParams position, IProgressMonitor monitor) { ITypeRoot type = JDTUtils.resolveTypeRoot(position.getTextDocument().getUri()); return computeOccurrences(type, position.getPosition().getLine(), position.getPosition().getCharacter(), monitor); }
@Override public final void didClose(DidCloseTextDocumentParams params) { URI uri = Uris.resolveToRoot(getWorkspacePath(), params.getTextDocument().getUri()); getState().getCompilerWrapper().handleFileClosed(uri); getState().publishDiagnostics(getState().getCompilerWrapper().compile(ImmutableSet.of(uri))); }