]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/OpenDeclaration.java
Fix annoying editor focus jumping with Ctrl+Shift+D/M
[simantics/platform.git] / bundles / org.simantics.scl.ui / src / org / simantics / scl / ui / editor2 / OpenDeclaration.java
index 878d8e24fcf0d86821db1d4b85af70fa88480e71..421328c164222346da2c9eb073f222afe841c601 100644 (file)
@@ -9,15 +9,18 @@ import org.eclipse.swt.widgets.Control;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.PlatformUI;
 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
-import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.module.InvalidModulePathException;
 import org.simantics.scl.compiler.module.ModuleUtils;
 import org.simantics.scl.compiler.source.ModuleSource;
 import org.simantics.scl.osgi.SCLOsgi;
 import org.simantics.scl.ui.editor.completion.SCLTextEditorEnvironment;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class OpenDeclaration extends AbstractHandler {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(OpenDeclaration.class);
+
     private static boolean isIdentifierPart(char c) {
         return Character.isJavaIdentifierPart(c) || c=='.';
     }
@@ -93,10 +96,10 @@ public class OpenDeclaration extends AbstractHandler {
                    String moduleName = ModuleUtils.resolveAbsolutePath(input.getModuleName(), lineAtCaret.substring(p1+1, p2));
                ModuleSource source = SCLOsgi.SOURCE_REPOSITORY.getModuleSource(moduleName, null);
                 if (source != null) {
-                       OpenSCLModule.openModule(moduleName);
+                       OpenSCLModule.scheduleOpenModule(moduleName);
                 }
             } catch (InvalidModulePathException e) {
-               // Nothing to do
+                LOGGER.error("Could not open declaration {} {}", input.getModuleName(), lineAtCaret, e);
             }
         }
         else {
@@ -109,7 +112,7 @@ public class OpenDeclaration extends AbstractHandler {
             SCLValue value = editorEnvironment.getValue(identifierAtCaret);
             //System.out.println("identifierAtCaret = " + identifierAtCaret + " [" + Locations.beginOf(value.definitionLocation) + ", " + Locations.endOf(value.definitionLocation) + "]");
             if(value != null)
-                OpenSCLDefinition.openDefinition(value);
+                OpenSCLDefinition.scheduleOpenDefinition(value.getName().module, value.definitionLocation);
         }
         return null;
     }