Don't throw an exception if none LS was found for some uri (#11094)
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>6.19.x
parent
7efbacc274
commit
206baad2c2
|
|
@ -12,7 +12,6 @@
|
|||
package org.eclipse.che.ide.ext.java.client.settings.compiler;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.eclipse.che.api.core.model.workspace.WorkspaceStatus.RUNNING;
|
||||
import static org.eclipse.che.ide.ext.java.client.settings.compiler.ErrorWarningsOptions.COMPARING_IDENTICAL_VALUES;
|
||||
import static org.eclipse.che.ide.ext.java.client.settings.compiler.ErrorWarningsOptions.COMPILER_UNUSED_IMPORT;
|
||||
import static org.eclipse.che.ide.ext.java.client.settings.compiler.ErrorWarningsOptions.COMPILER_UNUSED_LOCAL;
|
||||
|
|
@ -34,18 +33,15 @@ import static org.eclipse.che.ide.ext.java.client.settings.compiler.ErrorWarning
|
|||
|
||||
import com.google.gwt.user.client.ui.AcceptsOneWidget;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.eclipse.che.ide.api.app.AppContext;
|
||||
import org.eclipse.che.ide.api.notification.NotificationManager;
|
||||
import org.eclipse.che.ide.api.preferences.AbstractPreferencePagePresenter;
|
||||
import org.eclipse.che.ide.api.preferences.PreferencesManager;
|
||||
import org.eclipse.che.ide.api.workspace.event.WorkspaceRunningEvent;
|
||||
import org.eclipse.che.ide.api.workspace.WorkspaceReadyEvent;
|
||||
import org.eclipse.che.ide.ext.java.client.JavaLocalizationConstant;
|
||||
import org.eclipse.che.ide.ext.java.client.inject.factories.PropertyWidgetFactory;
|
||||
import org.eclipse.che.ide.ext.java.client.settings.property.PropertyWidget;
|
||||
|
|
@ -57,14 +53,12 @@ import org.eclipse.che.ide.ext.java.client.settings.property.PropertyWidget;
|
|||
*/
|
||||
@Singleton
|
||||
public class JavaCompilerPreferencePresenter extends AbstractPreferencePagePresenter
|
||||
implements PropertyWidget.ActionDelegate, WorkspaceRunningEvent.Handler {
|
||||
implements PropertyWidget.ActionDelegate {
|
||||
public static final String CATEGORY = "Java Compiler";
|
||||
|
||||
private final ErrorWarningsView view;
|
||||
private final PropertyWidgetFactory propertyFactory;
|
||||
private final PreferencesManager preferencesManager;
|
||||
private final Provider<NotificationManager> notificationManagerProvider;
|
||||
private final JavaLocalizationConstant locale;
|
||||
|
||||
private List<ErrorWarningsOptions> options;
|
||||
private Map<String, PropertyWidget> widgets;
|
||||
|
|
@ -72,31 +66,22 @@ public class JavaCompilerPreferencePresenter extends AbstractPreferencePagePrese
|
|||
@Inject
|
||||
public JavaCompilerPreferencePresenter(
|
||||
JavaLocalizationConstant locale,
|
||||
EventBus eventBus,
|
||||
ErrorWarningsView view,
|
||||
PropertyWidgetFactory propertyFactory,
|
||||
@JavaCompilerPreferenceManager PreferencesManager preferencesManager,
|
||||
Provider<NotificationManager> notificationManagerProvider) {
|
||||
@JavaCompilerPreferenceManager PreferencesManager preferencesManager) {
|
||||
super(locale.compilerSetup(), CATEGORY);
|
||||
|
||||
this.view = view;
|
||||
this.propertyFactory = propertyFactory;
|
||||
this.preferencesManager = preferencesManager;
|
||||
this.notificationManagerProvider = notificationManagerProvider;
|
||||
this.locale = locale;
|
||||
this.widgets = new HashMap<>();
|
||||
|
||||
eventBus.addHandler(WorkspaceReadyEvent.getType(), e -> updateErrorWarningsPanel());
|
||||
|
||||
fillUpOptions();
|
||||
}
|
||||
|
||||
@Inject
|
||||
private void initialize(AppContext appContext, EventBus eventBus) {
|
||||
eventBus.addHandler(WorkspaceRunningEvent.TYPE, this);
|
||||
|
||||
if (appContext.getWorkspace().getStatus() == RUNNING) {
|
||||
updateErrorWarningsPanel();
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
|
|
@ -165,11 +150,6 @@ public class JavaCompilerPreferencePresenter extends AbstractPreferencePagePrese
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorkspaceRunning(WorkspaceRunningEvent event) {
|
||||
updateErrorWarningsPanel();
|
||||
}
|
||||
|
||||
private void updateErrorWarningsPanel() {
|
||||
preferencesManager
|
||||
.loadPreferences()
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ import org.eclipse.che.api.promises.client.PromiseError;
|
|||
import org.eclipse.che.ide.api.notification.NotificationManager;
|
||||
import org.eclipse.che.ide.api.preferences.PreferencePagePresenter.DirtyStateListener;
|
||||
import org.eclipse.che.ide.api.preferences.PreferencesManager;
|
||||
import org.eclipse.che.ide.api.workspace.event.WorkspaceRunningEvent;
|
||||
import org.eclipse.che.ide.ext.java.client.JavaLocalizationConstant;
|
||||
import org.eclipse.che.ide.ext.java.client.inject.factories.PropertyWidgetFactory;
|
||||
import org.eclipse.che.ide.ext.java.client.settings.property.PropertyWidget;
|
||||
|
|
@ -88,7 +87,6 @@ public class JavaCompilerPreferencePresenterTest {
|
|||
@Mock private Promise<Map<String, String>> mapPromise;
|
||||
@Mock private AcceptsOneWidget container;
|
||||
@Mock private PropertyWidget widget;
|
||||
@Mock private WorkspaceRunningEvent workspaceRunningEvent;
|
||||
|
||||
@Captor private ArgumentCaptor<Map<String, String>> mapCaptor;
|
||||
@Captor private ArgumentCaptor<Operation<Map<String, String>>> operationCaptor;
|
||||
|
|
@ -125,7 +123,6 @@ public class JavaCompilerPreferencePresenterTest {
|
|||
when(widget.getSelectedValue()).thenReturn(VALUE_2);
|
||||
when(preferencesManager.getValue(anyString())).thenReturn(VALUE_1);
|
||||
|
||||
presenter.onWorkspaceRunning(workspaceRunningEvent);
|
||||
presenter.go(container);
|
||||
|
||||
verify(mapPromise).then(operationCaptor.capture());
|
||||
|
|
@ -148,7 +145,6 @@ public class JavaCompilerPreferencePresenterTest {
|
|||
when(widget.getSelectedValue()).thenReturn(VALUE_2);
|
||||
when(preferencesManager.getValue(anyString())).thenReturn(VALUE_1);
|
||||
|
||||
presenter.onWorkspaceRunning(workspaceRunningEvent);
|
||||
presenter.go(container);
|
||||
|
||||
verify(mapPromise).then(operationCaptor.capture());
|
||||
|
|
@ -219,7 +215,6 @@ public class JavaCompilerPreferencePresenterTest {
|
|||
|
||||
@Test
|
||||
public void propertiesShouldBeDisplayed() throws Exception {
|
||||
presenter.onWorkspaceRunning(workspaceRunningEvent);
|
||||
presenter.go(container);
|
||||
|
||||
verify(mapPromise).then(operationCaptor.capture());
|
||||
|
|
@ -239,7 +234,6 @@ public class JavaCompilerPreferencePresenterTest {
|
|||
|
||||
when(notificationManagerProvider.get()).thenReturn(notificationManager);
|
||||
|
||||
presenter.onWorkspaceRunning(workspaceRunningEvent);
|
||||
presenter.go(container);
|
||||
|
||||
verify(mapPromise).catchError(errorOperationCaptor.capture());
|
||||
|
|
|
|||
|
|
@ -955,7 +955,9 @@ public class JavaLanguageServerExtensionService {
|
|||
*/
|
||||
public JavaCoreOptions getJavaCoreOptions(List<String> filter) {
|
||||
Type type = new TypeToken<JavaCoreOptions>() {}.getType();
|
||||
return doGetOne(Commands.GET_JAVA_CORE_OPTIONS_СOMMAND, new ArrayList<>(filter), type);
|
||||
JavaCoreOptions result =
|
||||
doGetOne(Commands.GET_JAVA_CORE_OPTIONS_СOMMAND, new ArrayList<>(filter), type);
|
||||
return result == null ? new JavaCoreOptions() : result;
|
||||
}
|
||||
|
||||
/** Updates JDT LS java core options. */
|
||||
|
|
|
|||
|
|
@ -107,9 +107,8 @@ public class LanguageServerInitializer {
|
|||
* any point - skips them and proceeds with the rest.
|
||||
*
|
||||
* @param wsPath absolute workspace path
|
||||
* @return accumulated server capabilities of all initialized language servers
|
||||
* @throws CompletionException if no server initialized throws {@link LanguageServerException}
|
||||
* wrapped by {@link CompletionException}
|
||||
* @return accumulated server capabilities of all initialized language servers or empty
|
||||
* capabilities if none language server was found for current path
|
||||
*/
|
||||
public CompletableFuture<ServerCapabilities> initialize(String wsPath) {
|
||||
return supplyAsync(
|
||||
|
|
@ -135,10 +134,8 @@ public class LanguageServerInitializer {
|
|||
|
||||
LOG.debug("Calculating number of initialized servers and accumulating capabilities");
|
||||
if (serverCapabilitiesSet.isEmpty()) {
|
||||
String message = String.format("Could not initialize any server for '%s'", wsPath);
|
||||
LOG.error(message);
|
||||
LanguageServerException cause = new LanguageServerException(message);
|
||||
throw new CompletionException(cause);
|
||||
// None language server was found for current path
|
||||
return new ServerCapabilities();
|
||||
} else {
|
||||
return serverCapabilitiesSet
|
||||
.stream()
|
||||
|
|
|
|||
Loading…
Reference in New Issue