disable lsp4e go to symbol in workspace keybinding altogether as long as there is no fix in LSP4E

This commit is contained in:
Martin Lippert
2017-11-01 16:29:19 +01:00
parent 1ce27595f1
commit 49c9517b8a

View File

@@ -10,6 +10,13 @@
*******************************************************************************/
package org.springframework.tooling.boot.java.ls;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.bindings.Binding;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.keys.IBindingService;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -22,6 +29,8 @@ import org.osgi.framework.BundleContext;
public class BootJavaLanguageServerPlugin extends AbstractUIPlugin {
public static final String ID = "org.springframework.tooling.boot.java.ls";
private static final Object LSP4E_COMMAND_SYMBOL_IN_WORKSPACE = "org.eclipse.lsp4e.symbolinworkspace";
// The shared instance
private static BootJavaLanguageServerPlugin plugin;
@@ -34,6 +43,8 @@ public class BootJavaLanguageServerPlugin extends AbstractUIPlugin {
public void start(BundleContext context) throws Exception {
plugin = this;
super.start(context);
deactivateDuplicateKeybindings();
}
@Override
@@ -46,4 +57,42 @@ public class BootJavaLanguageServerPlugin extends AbstractUIPlugin {
return plugin;
}
private void deactivateDuplicateKeybindings() {
IBindingService service = PlatformUI.getWorkbench().getService(IBindingService.class);
if (service != null) {
List<Binding> newBindings = new ArrayList<>();
Binding[] bindings = service.getBindings();
for (Binding binding : bindings) {
String commandId = null;
if (binding != null && binding.getParameterizedCommand() != null && binding.getParameterizedCommand().getCommand() != null) {
commandId = binding.getParameterizedCommand().getCommand().getId();
if (commandId == null) {
newBindings.add(binding);
}
else if (!commandId.equals(LSP4E_COMMAND_SYMBOL_IN_WORKSPACE)) {
newBindings.add(binding);
}
}
else {
newBindings.add(binding);
}
}
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
try {
service.savePreferences(service.getActiveScheme(),
newBindings.toArray(new Binding[newBindings.size()]));
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
}
}