diff --git a/org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/LanguageServerWrapperTest.java b/org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/LanguageServerWrapperTest.java index 75d3b0d40..d44c8fa28 100644 --- a/org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/LanguageServerWrapperTest.java +++ b/org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/LanguageServerWrapperTest.java @@ -87,11 +87,7 @@ public void testStopAndActive() throws CoreException, IOException, AssertionErro started.countDown(); while (!Thread.interrupted()) { wrapper.stop(); - try { - wrapper.start(); - } catch (IOException e) { - throw new RuntimeException(e); - } + wrapper.start(); } }); try { diff --git a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/LanguageServerWrapper.java b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/LanguageServerWrapper.java index 52229f1d9..e9b7e61c1 100644 --- a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/LanguageServerWrapper.java +++ b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/LanguageServerWrapper.java @@ -243,10 +243,8 @@ private List getRelevantWorkspaceFolders() { /** * Starts a language server and triggers initialization. If language server is * started and active, does nothing. If language server is inactive, restart it. - * - * @throws IOException */ - public synchronized void start() throws IOException { + public synchronized void start() { start(false); } @@ -254,10 +252,9 @@ public synchronized void start() throws IOException { * Restarts a language server. If language server is not started, calling this * method is the same as calling {@link #start()}. * - * @throws IOException * @since 0.18 */ - public synchronized void restart() throws IOException { + public synchronized void restart() { start(true); } @@ -268,9 +265,8 @@ public synchronized void restart() throws IOException { * * @param forceRestart * whether to restart the language server, even it is not inactive. - * @throws IOException */ - private synchronized void start(boolean forceRestart) throws IOException { + private synchronized void start(boolean forceRestart) { final var filesToReconnect = new HashMap(); if (this.languageServer != null) { if (isActive() && !forceRestart) { @@ -785,11 +781,7 @@ protected LanguageServer getServer() { */ @NonNull protected CompletableFuture getInitializedServer() { - try { - start(); - } catch (IOException ex) { - LanguageServerPlugin.logError(ex); - } + start(); final CompletableFuture currentInitializeFuture = initializeFuture; if (currentInitializeFuture != null && !currentInitializeFuture.isDone()) { diff --git a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/LanguageServiceAccessor.java b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/LanguageServiceAccessor.java index e3192c4eb..43e33dce5 100644 --- a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/LanguageServiceAccessor.java +++ b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/LanguageServiceAccessor.java @@ -347,17 +347,16 @@ protected static Collection getLSWrappers(@NonNull final * @param project * @param serverDefinition * @return a new or existing {@link LanguageServerWrapper} for the given definition. - * @throws IOException */ @NonNull public static LanguageServerWrapper getLSWrapper(@Nullable IProject project, - @NonNull LanguageServerDefinition serverDefinition) throws IOException { + @NonNull LanguageServerDefinition serverDefinition) { return getLSWrapper(project, serverDefinition, null); } @NonNull private static LanguageServerWrapper getLSWrapper(@Nullable IProject project, - @NonNull LanguageServerDefinition serverDefinition, @Nullable IPath initialPath) throws IOException { + @NonNull LanguageServerDefinition serverDefinition, @Nullable IPath initialPath) { final Predicate serverSelector = wrapper -> wrapper.canOperate(project) && wrapper.serverDefinition.equals(serverDefinition); @@ -384,7 +383,7 @@ private static LanguageServerWrapper getLSWrapper(@Nullable IProject project, } } - public static @NonNull LanguageServerWrapper startLanguageServer(@NonNull LanguageServerDefinition serverDefinition) throws IOException { + public static @NonNull LanguageServerWrapper startLanguageServer(@NonNull LanguageServerDefinition serverDefinition) { synchronized (startedServers) { LanguageServerWrapper wrapper = startedServers.stream().filter(w -> w.serverDefinition == serverDefinition).findFirst().orElseGet(() -> { LanguageServerWrapper w = new LanguageServerWrapper(serverDefinition, null); diff --git a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/codeactions/CodeActionMarkerResolution.java b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/codeactions/CodeActionMarkerResolution.java index e2f8cfe75..0e35472b5 100644 --- a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/codeactions/CodeActionMarkerResolution.java +++ b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/codeactions/CodeActionMarkerResolution.java @@ -12,7 +12,6 @@ *******************************************************************************/ package org.eclipse.lsp4e.operations.codeactions; -import java.io.IOException; import java.util.Arrays; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -108,7 +107,7 @@ public void run(IMarker marker) { } } } - } catch (ExecutionException | IOException | TimeoutException | InterruptedException ex) { + } catch (ExecutionException | TimeoutException | InterruptedException ex) { LanguageServerPlugin.logError(ex); } } diff --git a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/codeactions/CommandMarkerResolution.java b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/codeactions/CommandMarkerResolution.java index e4f91d2c8..0bdddbd73 100644 --- a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/codeactions/CommandMarkerResolution.java +++ b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/codeactions/CommandMarkerResolution.java @@ -12,12 +12,9 @@ *******************************************************************************/ package org.eclipse.lsp4e.operations.codeactions; -import java.io.IOException; - import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.lsp4e.LanguageServerPlugin; import org.eclipse.lsp4e.LanguageServerWrapper; import org.eclipse.lsp4e.LanguageServersRegistry; import org.eclipse.lsp4e.LanguageServersRegistry.LanguageServerDefinition; @@ -59,19 +56,15 @@ public void run(IMarker marker) { return; } - try { - LanguageServerWrapper wrapper = LanguageServiceAccessor.getLSWrapper(resource.getProject(), definition); - if (wrapper != null) { - ExecuteCommandOptions provider = wrapper.getServerCapabilities().getExecuteCommandProvider(); - if (provider != null && provider.getCommands().contains(command.getCommand())) { - wrapper.execute(ls -> ls.getWorkspaceService() - .executeCommand(new ExecuteCommandParams(command.getCommand(), command.getArguments()))); - } else { - CommandExecutor.executeCommandClientSide(command, resource); - } + LanguageServerWrapper wrapper = LanguageServiceAccessor.getLSWrapper(resource.getProject(), definition); + if (wrapper != null) { + ExecuteCommandOptions provider = wrapper.getServerCapabilities().getExecuteCommandProvider(); + if (provider != null && provider.getCommands().contains(command.getCommand())) { + wrapper.execute(ls -> ls.getWorkspaceService() + .executeCommand(new ExecuteCommandParams(command.getCommand(), command.getArguments()))); + } else { + CommandExecutor.executeCommandClientSide(command, resource); } - } catch (IOException ex) { - LanguageServerPlugin.logError(ex); } } diff --git a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/diagnostics/LSPDiagnosticsToMarkers.java b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/diagnostics/LSPDiagnosticsToMarkers.java index 210bd3cde..062d1aab9 100644 --- a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/diagnostics/LSPDiagnosticsToMarkers.java +++ b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/diagnostics/LSPDiagnosticsToMarkers.java @@ -100,7 +100,7 @@ public void accept(PublishDiagnosticsParams diagnostics) { .map(ISourceViewer.class::cast) .forEach(sourceViewer -> updateEditorAnnotations(sourceViewer, diagnostics)); } - } catch (CoreException ex) { + } catch (Exception ex) { LanguageServerPlugin.logError(ex); } } @@ -131,7 +131,7 @@ private void updateEditorAnnotations(@NonNull ISourceViewer sourceViewer, Publis } } - private WorkspaceJob updateMarkers(PublishDiagnosticsParams diagnostics, IResource resource) throws CoreException { + private WorkspaceJob updateMarkers(PublishDiagnosticsParams diagnostics, IResource resource) { WorkspaceJob job = new WorkspaceJob("Update markers from diagnostics") { //$NON-NLS-1$ @Override public boolean belongsTo(Object family) { @@ -288,7 +288,6 @@ private IMarker getExistingMarkerFor(IDocument document, Diagnostic diagnostic, attributes.put(IMarker.CHAR_END, end); } - markerAttributeComputer .ifPresent(c -> c.addMarkerAttributesForDiagnostic(diagnostic, document, resource, attributes)); diff --git a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/references/LSFindReferences.java b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/references/LSFindReferences.java index a4fb42278..bc49e668e 100644 --- a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/references/LSFindReferences.java +++ b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/references/LSFindReferences.java @@ -15,7 +15,6 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.IHandler; -import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.viewers.ISelection; @@ -42,7 +41,7 @@ protected void execute(ExecutionEvent event, ITextEditor textEditor) { try { final var query = new LSSearchQuery(textSelection.getOffset(), document); HandlerUtil.getActiveShell(event).getDisplay().asyncExec(() -> NewSearchUI.runQueryInBackground(query)); - } catch (BadLocationException e) { + } catch (Exception e) { LanguageServerPlugin.logError(e); } } diff --git a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/references/LSSearchQuery.java b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/references/LSSearchQuery.java index 203d00086..ba936aa7b 100644 --- a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/references/LSSearchQuery.java +++ b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/references/LSSearchQuery.java @@ -66,8 +66,7 @@ public class LSSearchQuery extends FileSearchQuery { * @param offset * @param document */ - public LSSearchQuery(int offset, @NonNull IDocument document) - throws BadLocationException { + public LSSearchQuery(int offset, @NonNull IDocument document) { super("", false, false, true, true, null); //$NON-NLS-1$ this.document = document; this.offset = offset;