Пример #1
0
  /*
   * Method declared on SelectionChangedAction.
   */
  @Override
  public void run(final ITextSelection selection) {
    // if (!ActionUtil.isProcessable(fEditor)) {
    // return;
    // }
    IErlModule module = fEditor.getModule();
    if (module == null) {
      return;
    }
    final Backend b = ErlangCore.getBackendManager().getIdeBackend();
    final ISelection sel = getSelection();
    final ITextSelection textSel = (ITextSelection) sel;
    final int offset = textSel.getOffset();
    try {
      String scannerModuleName = ErlangToolkit.createScannerModuleName(module);
      final OpenResult res =
          ErlideOpen.open(b, scannerModuleName, offset, "", ErlangCore.getModel().getPathVars());
      ErlLogger.debug("open " + res);

      // final String title =
      // "SearchMessages.SearchElementSelectionDialog_title";
      // final String message =
      // "SearchMessages.SearchElementSelectionDialog_message";

      if (res.isExternalCall()) {
        performNewSearch(SearchUtil.getRefFromOpenRes(res));
      }
    } catch (final Exception e) {
      // final String title = "SearchMessages.Search_Error_search_title";
      // final String message = "SearchMessages.Search_Error_codeResolve";
      // ExceptionHandler.handle(e, getShell(), title, message);
      ErlLogger.debug(e);
    }
  }
Пример #2
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);
   }
 }
Пример #3
0
 public static void addDialyzerWarningMarkersFromResultList(
     final IErlProject project, final Backend backend, final OtpErlangList result) {
   if (result == null) {
     return;
   }
   final IProject p = project.getProject();
   for (final OtpErlangObject i : result) {
     final OtpErlangTuple t = (OtpErlangTuple) i;
     final OtpErlangTuple fileLine = (OtpErlangTuple) t.elementAt(1);
     final String filename = Util.stringValue(fileLine.elementAt(0));
     final OtpErlangLong lineL = (OtpErlangLong) fileLine.elementAt(1);
     int line = 1;
     try {
       line = lineL.intValue();
     } catch (final OtpErlangRangeException e) {
       ErlLogger.error(e);
     }
     String s = ErlideDialyze.formatWarning(backend, t).trim();
     final int j = s.indexOf(": ");
     if (j != -1) {
       s = s.substring(j + 1);
     }
     addDialyzerWarningMarker(p, filename, line, s);
   }
 }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org
  * .eclipse.core.resources.IResourceChangeEvent)
  */
 public void resourceChanged(final IResourceChangeEvent event) {
   final IResourceDelta delta = event.getDelta();
   try {
     if (delta != null) {
       // ErlLogger.debug("change " + event.toString());
       delta.accept(this);
     }
   } catch (final CoreException e) {
     ErlLogger.warn(e);
   }
 }
Пример #5
0
 public static void removeDialyzerWarningMarkers(final IProject project) {
   try {
     final IMarker[] markers =
         project.findMarkers(DIALYZE_WARNING_MARKER, true, IResource.DEPTH_INFINITE);
     for (final IMarker m : markers) {
       m.delete();
     }
   } catch (final CoreException e) {
     ErlLogger.error(e);
   }
 }
Пример #6
0
 public static void createTaskMarkers(final IProject project, final IResource resource) {
   final IErlProject p = ErlangCore.getModel().findProject(project);
   if (p != null) {
     try {
       if (BuilderUtils.isDebugging()) {
         ErlLogger.debug("Creating task markers " + resource.getName());
       }
       // getMarkersFor(resource, p);
       getNoScanMarkersFor(resource, p);
     } catch (final ErlModelException e) {
     }
   }
 }
Пример #7
0
 /*
  * (non-Javadoc) Method declared on SelectionDispatchAction.
  */
 @Override
 public void run(final IStructuredSelection selection) {
   if (!checkEnabled(selection)) {
     return;
   }
   for (final Object i : selection.toArray()) {
     if (i instanceof IErlElement) {
       try {
         ErlModelUtils.openElement((IErlElement) i);
       } catch (final CoreException e) {
         ErlLogger.error(e);
       }
     }
   }
 }
 /**
  * Load the model from the given file, if possible.
  *
  * @param modelFile The IFile which contains the persisted model
  */
 public Object getParent(final Object element) {
   if (element instanceof IErlElement) {
     final IErlElement elt = (IErlElement) element;
     final IErlElement parent = elt.getParent();
     if (parent instanceof IErlModule) {
       final IErlModule mod = (IErlModule) parent;
       try {
         return mod.getCorrespondingResource();
       } catch (final ErlModelException e) {
         ErlLogger.warn(e);
       }
     }
   }
   return null;
 }
 /** Return the model elements for a *.erl IFile or NO_CHILDREN for otherwise. */
 public Object[] getChildren(Object parentElement) {
   try {
     if (parentElement instanceof IFile) {
       parentElement = ModelUtils.getModule((IFile) parentElement);
     }
     if (parentElement instanceof IOpenable) {
       final IOpenable openable = (IOpenable) parentElement;
       openable.open(null);
     }
     if (parentElement instanceof IParent) {
       final IParent parent = (IParent) parentElement;
       final List<IErlElement> children = parent.getChildren();
       return children.toArray(new IErlElement[children.size()]);
     }
   } catch (final ErlModelException e) {
     ErlLogger.warn(e);
   }
   return NO_CHILDREN;
 }
Пример #10
0
 void sendToDisk(final String location, final ProblemData data) {
   final File report = new File(location);
   try {
     report.createNewFile();
     final OutputStream out = new FileOutputStream(report);
     final PrintWriter pw = new PrintWriter(out);
     try {
       pw.println(data.summary);
       pw.println(data.reporter);
       pw.println(data.description);
       pw.println("\n==================================\n");
       pw.println(data.platformLog);
       pw.println("\n==================================\n");
       pw.println(data.erlideLog);
     } finally {
       pw.flush();
       out.close();
     }
   } catch (final IOException e) {
     ErlLogger.warn(e);
   }
 }
Пример #11
0
  /**
   * Add error markers from a list of error tuples
   *
   * @param resource
   * @param errorList
   */
  public static void addErrorMarkers(final IResource resource, final OtpErlangList errorList) {
    for (final OtpErlangObject odata : errorList.elements()) {
      try {
        final OtpErlangTuple data = (OtpErlangTuple) odata;

        String msg = ErlUtils.asString(data.elementAt(2));
        if (msg.length() > 1000) {
          msg = msg.substring(0, 1000) + "......";
        }
        final String fileName = (String) TypeConverter.erlang2java(data.elementAt(1), String.class);
        IResource res = resource;
        if (!BuilderUtils.samePath(resource.getLocation().toString(), fileName)) {
          final IProject project = resource.getProject();
          res = BuilderUtils.findResourceByLocation(project, fileName);
          if (res == null) {
            try {
              final IErlModel model = ErlangCore.getModel();
              final String includeFile =
                  ModelUtils.findIncludeFile(
                      project,
                      fileName,
                      model.getExternal(model.findProject(project), ErlangCore.EXTERNAL_INCLUDES));
              if (includeFile != null) {
                res = ResourceUtil.openExternal(includeFile);
              }
            } catch (final Exception e) {
              ErlLogger.warn(e);
            }
          }
        }
        int line = 0;
        if (data.elementAt(0) instanceof OtpErlangLong) {
          try {
            line = ((OtpErlangLong) data.elementAt(0)).intValue();
          } catch (final OtpErlangRangeException e) {
          }
        }
        int sev = IMarker.SEVERITY_INFO;
        try {
          switch (((OtpErlangLong) data.elementAt(3)).intValue()) {
            case 0:
              sev = IMarker.SEVERITY_ERROR;
              break;
            case 1:
              sev = IMarker.SEVERITY_WARNING;
              break;
            default:
              sev = IMarker.SEVERITY_INFO;
              break;
          }
        } catch (final OtpErlangRangeException e) {
        }

        if (res != null) {
          addMarker(res, resource, msg, line, sev, "");
        } else {
          addMarker(
              resource.getProject(), null, "can't find " + fileName, 0, IMarker.SEVERITY_ERROR, "");
          addMarker(resource, null, "?? " + msg, line, sev, "");
        }
      } catch (final Exception e) {
        ErlLogger.warn(e);
        ErlLogger.warn("got: %s", odata);
      }
    }
  }
Пример #12
0
 private static void fetchErlangSystemInfo() {
   final ErlideBackend ideBackend = ErlangCore.getBackendManager().getIdeBackend();
   String info = ErlBackend.getSystemInfo(ideBackend);
   ErlLogger.info("\n++++++++++++++++++++++\n" + info);
 }