Beispiel #1
0
 /*
  * (non-Javadoc) Method declared on SelectionDispatchAction.
  */
 @Override
 public void run(final ITextSelection selection) {
   final ErlangEditor editor = (ErlangEditor) getSite().getPage().getActiveEditor();
   editor.reconcileNow();
   final IErlModule module = editor.getModule();
   if (module == null) {
     return;
   }
   final Backend b = ErlangCore.getBackendManager().getIdeBackend();
   final int offset = selection.getOffset();
   try {
     final IErlProject erlProject = module.getErlProject();
     final IErlModel model = ErlangCore.getModel();
     final OpenResult res =
         ErlideOpen.open(
             b,
             ErlangToolkit.createScannerModuleName(module),
             offset,
             ErlModelUtils.getImportsAsList(module),
             model.getExternalModules(erlProject),
             model.getPathVars());
     ErlLogger.debug("open " + res);
     openOpenResult(editor, module, b, offset, erlProject, res);
   } catch (final Exception e) {
     ErlLogger.warn(e);
   }
 }
Beispiel #2
0
 private static IErlElement findLocalCall(
     final IErlModule module,
     final Backend backend,
     final IErlProject erlProject,
     final OpenResult res,
     final IProject project,
     final IErlElement element,
     final boolean checkAllProjects)
     throws ErlModelException, BackendException {
   if (ErlModelUtils.isTypeDefOrRecordDef(element)) {
     return ModelUtils.findTypespec(module, res.getFun());
   }
   final IErlFunction foundElement = ModelUtils.findFunction(module, res.getFunction());
   if (foundElement != null) {
     return foundElement;
   }
   // not local imports
   OtpErlangObject res2 = null;
   String moduleName = null;
   if (module != null) {
     final IErlImport ei = module.findImport(res.getFunction());
     if (ei != null) {
       moduleName = ei.getImportModule();
       final IErlModel model = ErlangCore.getModel();
       res2 =
           ErlideOpen.getSourceFromModule(
               backend, model.getPathVars(), moduleName, model.getExternalModules(erlProject));
     }
   }
   if (res2 instanceof OtpErlangString && moduleName != null) {
     final OtpErlangString otpErlangString = (OtpErlangString) res2;
     final String modulePath = otpErlangString.stringValue();
     return ErlModelUtils.findExternalFunction(
         moduleName, res.getFunction(), modulePath, project, checkAllProjects, module);
   } else {
     return ErlModelUtils.findExternalFunction(
         moduleName, res.getFunction(), null, project, checkAllProjects, module);
   }
 }