Пример #1
0
  @Override
  public IBackend createBackend(final BackendData data) {
    ErlLogger.debug("Create backend " + data.getNodeName());
    if (!data.isManaged() && !data.isAutostart()) {
      ErlLogger.info("Not creating backend for %s", data.getNodeName());
      return null;
    }

    final IBackend b;
    final String erlangHostName = HostnameUtils.getErlangHostName(data.isLongName());
    try {
      String nodeName = data.getNodeName();
      final boolean hasHost = nodeName.contains("@");
      nodeName = hasHost ? nodeName : nodeName + "@" + erlangHostName;
      ILaunch launch = data.getLaunch();
      if (launch == null) {
        launch = launchPeer(data);
      }
      final IProcess mainProcess =
          launch.getProcesses().length == 0 ? null : launch.getProcesses()[0];
      final IErlRuntime runtime =
          new ErlRuntime(
              nodeName, data.getCookie(), mainProcess, !data.isTransient(), data.isLongName());
      b =
          data.isInternal()
              ? new InternalBackend(data, runtime)
              : new ExternalBackend(data, runtime);
      b.initialize();
      return b;
    } catch (final BackendException e) {
      e.printStackTrace();
    }
    return null;
  }
Пример #2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt
   * .events.SelectionEvent)
   */
  public void widgetSelected(final SelectionEvent e) {
    ErlLogger.debug("widgetSelected: e.item = " + e.item);
    ErlLogger.debug("widgetSelected: e.widget = " + e.widget);

    if (e.widget == removeFunctionBtn) {
      final TableItem itemsToRemove[] = fTable.getSelection();
      for (final TableItem element : itemsToRemove) {
        fTable.remove(fTable.indexOf(element));
        if (element == fEditingItem) {
          fEditingItem = null;
        }
      }

    } else if (e.widget == editFunctionBtn) {
      if (fEditingItem != null) {
        removeEdit();
      }
      final int selectedIndex = fTable.getSelectionIndex();
      final TableItem selectedItem = fTable.getItem(selectedIndex);
      if (!"".equals(selectedItem.getText(0))) {
        fEditingItem = selectedItem;
        functionNameText.setText(selectedItem.getText(0));
        arityText.setText(selectedItem.getText(1));
        exportButtonBtn.setSelection(selectedItem.getChecked());
        fEditingItem.setText(0, selectedItem.getText(0) + "<<Being Edited>>");
      }
      // } else if (e.widget == addState) {

    }
    dialogChanged();
  }
Пример #3
0
 private Set<String> getResourcesToBuild(
     final int kind, @SuppressWarnings("rawtypes") final Map args, final IProject project)
     throws CoreException {
   Set<BuildResource> result = Sets.newHashSet();
   final IProgressMonitor submon = new NullProgressMonitor();
   // new SubProgressMonitor(monitor, 10);
   submon.beginTask("retrieving resources to build", IProgressMonitor.UNKNOWN);
   if (kind == FULL_BUILD) {
     result = helper.getAffectedResources(args, project, submon);
   } else {
     final IResourceDelta delta = getDelta(project);
     final Path path = new Path(".settings/org.erlide.core.prefs");
     if (delta.findMember(path) != null) {
       ErlLogger.info("project configuration changed: doing full rebuild");
       result = helper.getAffectedResources(args, project, submon);
     } else {
       result = helper.getAffectedResources(args, delta, submon);
     }
   }
   if (BuilderHelper.isDebugging()) {
     ErlLogger.debug(
         "Will compile %d resource(s): %s", Integer.valueOf(result.size()), result.toString());
   }
   submon.done();
   final Set<String> paths = new HashSet<String>();
   for (final BuildResource res : result) {
     paths.add(res.getResource().getLocation().toPortableString());
   }
   return paths;
 }
Пример #4
0
  @Override
  @SuppressWarnings("boxing")
  public void run() {
    do {
      try {
        final int v = process.waitFor();
        final String msg = String.format("Backend '%s' terminated with exit code %d.", nodeName, v);

        String report = null;
        if (shouldCreateReport(v)) {
          ErlLogger.error(msg);
          report = createReport(v, msg);
          final String reportMsg =
              report != null
                  ? "\n\n"
                      + "An error log has been created at "
                      + report
                      + ".\nPlease report the problem so that we can fix it."
                  : "";
          final String bigMsg =
              msg
                  + "\n\n"
                  + "This error is not recoverable, please restart your Eclipse instance."
                  + reportMsg;
          MessageReporter.showError(bigMsg, ReporterPosition.MODAL);
        } else {
          ErlLogger.info(msg);
        }
        // FIXME backend.setExitStatus(v);
        return;
      } catch (final InterruptedException e) {
      }
    } while (true);
  }
Пример #5
0
 public static String fetchErlideLog() {
   final StringBuffer result = new StringBuffer();
   final File log = new File(ErlLogger.getInstance().getLogLocation());
   try {
     final BufferedReader reader =
         new BufferedReader(new InputStreamReader(new FileInputStream(log), "UTF-8"));
     try {
       for (; ; ) {
         String line = reader.readLine();
         if (line == null) {
           break;
         }
         line = line.trim();
         if (line.length() == 0) {
           continue;
         }
         result.append(line).append('\n');
       }
     } finally {
       reader.close();
     }
   } catch (final Exception e) {
     ErlLogger.warn(e);
   }
   return result.toString();
 }
Пример #6
0
  public IRpcFuture startCompileErl(
      final IProject project,
      final BuildResource bres,
      final String outputDir0,
      final IBackend backend,
      final OtpErlangList compilerOptions,
      final boolean force) {
    final IPath projectPath = project.getLocation();
    final IResource res = bres.getResource();
    final String s = res.getFileExtension();
    if (!"erl".equals(s)) {
      ErlLogger.warn("trying to compile " + res.getName() + "?!?!");
    }

    MarkerUtils.deleteMarkers(res);

    String outputDir;
    outputDir = getRealOutputDir(bres, outputDir0, projectPath);

    final Collection<IPath> includeDirs = getAllIncludeDirs(project);

    // delete beam file
    final IPath beamPath = getBeamForErl(res);
    final IResource beam = project.findMember(beamPath);

    try {
      final boolean shouldCompile = force || shouldCompile(project, res, beam);

      if (shouldCompile) {
        if (beam != null) {
          try {
            beam.delete(true, null);
          } catch (final Exception e) {
            ErlLogger.warn(e);
          }
        }
        if (isDebugging()) {
          ErlLogger.debug("compiling %s", res.getName());
        }

        createTaskMarkers(project, res);
        return InternalErlideBuilder.compileErl(
            backend, res.getLocation(), outputDir, includeDirs, compilerOptions);

      } else {
        return null;
      }
    } catch (final Exception e) {
      ErlLogger.warn(e);
      return null;
    }
  }
Пример #7
0
  @Override
  protected void clean(final IProgressMonitor monitor) throws CoreException {
    final IProject currentProject = getProject();
    if (currentProject == null || !currentProject.isAccessible()) {
      return;
    }

    if (BuilderHelper.isDebugging()) {
      ErlLogger.debug(
          "Cleaning "
              + currentProject.getName() // $NON-NLS-1$
              + " @ "
              + new Date(System.currentTimeMillis()));
    }

    try {
      initializeBuilder(monitor);
      MarkerUtils.removeProblemsAndTasksFor(currentProject);
      final IErlProject erlProject = CoreScope.getModel().getErlangProject(currentProject);
      final IFolder bf = currentProject.getFolder(erlProject.getOutputLocation());
      if (bf.exists()) {
        final IResource[] beams = bf.members();
        monitor.beginTask("Cleaning Erlang files", beams.length);
        if (beams.length > 0) {
          final float delta = 1.0f / beams.length;
          for (final IResource element : beams) {
            if ("beam".equals(element.getFileExtension())) {
              element.delete(true, monitor);
              notifier.updateProgressDelta(delta);
            }
          }
        }
      }

    } catch (final Exception e) {
      ErlLogger.error(e);
      final String msg =
          NLS.bind(BuilderMessages.build_inconsistentProject, e.getLocalizedMessage());
      MarkerUtils.addProblemMarker(currentProject, null, null, msg, 0, IMarker.SEVERITY_ERROR);
    } finally {
      cleanup();
      if (BuilderHelper.isDebugging()) {
        ErlLogger.debug(
            "Finished cleaning "
                + currentProject.getName() // $NON-NLS-1$
                + " @ "
                + new Date(System.currentTimeMillis()));
      }
    }
  }
Пример #8
0
  public void completeCompile(
      final IProject project,
      final IResource source,
      final OtpErlangObject compilationResult,
      final IBackend backend,
      final OtpErlangList compilerOptions) {
    if (compilationResult == null) {
      MarkerUtils.addProblemMarker(
          source, null, null, "Could not compile file", 0, IMarker.SEVERITY_ERROR);
      return;
    }
    final OtpErlangTuple t = (OtpErlangTuple) compilationResult;
    // ErlLogger.debug("** " + t);

    if ("ok".equals(((OtpErlangAtom) t.elementAt(0)).atomValue())) {
      final String beamf = source.getFullPath().removeFileExtension().lastSegment();
      InternalErlideBuilder.loadModule(project, beamf);
      refreshDirs(project, t.elementAt(2));
    } else {
      // ErlLogger.debug(">>>> compile error... %s\n   %s",
      // resource.getName(), t);
    }

    // process compilation messages
    if (t.elementAt(1) instanceof OtpErlangList) {
      final OtpErlangList l = (OtpErlangList) t.elementAt(1);
      MarkerUtils.addErrorMarkers(source, l);
    } else {
      ErlLogger.warn("bad result from builder: %s", t);
    }

    completeCompileForYrl(project, source, backend, compilerOptions);
  }
Пример #9
0
    public boolean handleEvent(final OtpErlangObject msg) {
      notifier.checkCancel();

      ErlLogger.debug(">>> %s", msg);
      if (msg instanceof OtpErlangTuple) {
        try {
          final OtpErlangTuple tuple = (OtpErlangTuple) msg;
          final OtpErlangAtom akey = (OtpErlangAtom) tuple.elementAt(0);
          final String key = akey.atomValue();
          // final OtpErlangObject value = tuple.elementAt(1);

          if ("compile".equals(key)) {
            // value = {ok, Messages, Files} | {error, Messages}
            // TODO create markers for messages
            // TODO refresh Files and mark as derived
          }
          if ("tasks".equals(key)) {
            // value = [Task]
            // TODO create tasks for Tasks
          }
          if ("clash".equals(key)) {
            // value = [Clash]
            // TODO create markers for clashes
          }
        } catch (final Exception e) {
          // ignore?
        }
      }
      return msg.equals(new OtpErlangAtom("stop"));
    }
Пример #10
0
 public static String fetchPlatformLog() {
   final List<String> result = new ArrayList<String>();
   final File log = Platform.getLogFileLocation().toFile();
   try {
     final BufferedReader reader =
         new BufferedReader(new InputStreamReader(new FileInputStream(log), "UTF-8"));
     try {
       for (; ; ) {
         String line = reader.readLine();
         if (line == null) {
           break;
         }
         line = line.trim();
         if (line.length() == 0) {
           continue;
         }
         if (line.startsWith("!SESSION ")) {
           result.clear();
         }
         result.add(line);
       }
     } finally {
       reader.close();
     }
   } catch (final Exception e) {
     ErlLogger.warn(e);
   }
   final StringBuffer buf = new StringBuffer();
   for (final String s : result) {
     buf.append(s).append('\n');
   }
   return buf.toString();
 }
Пример #11
0
 private String createReport(final int v, final String msg) {
   final String plog = LogUtil.fetchPlatformLog();
   final String elog = LogUtil.fetchErlideLog();
   final String slog = LogUtil.fetchStraceLog(workingDir + "/" + nodeName + ".strace");
   final String delim = "\n==================================\n";
   final String reportFile = LogUtil.getReportFile();
   final File report = new File(reportFile);
   try {
     report.createNewFile();
     final OutputStream out = new FileOutputStream(report);
     final PrintWriter pw = new PrintWriter(out);
     try {
       pw.println(String.format(msg, nodeName, v));
       pw.println(System.getProperty("user.name"));
       pw.println(delim);
       pw.println(plog);
       pw.println(delim);
       pw.println(elog);
       if (slog.length() > 0) {
         pw.println(delim);
         pw.println(elog);
       }
     } finally {
       pw.flush();
       pw.close();
       out.close();
     }
   } catch (final IOException e) {
     ErlLogger.warn(e);
   }
   return reportFile;
 }
Пример #12
0
 public Collection<IPath> getIncludeDirs(
     final IProject project, final Collection<IPath> includeDirs) {
   final IErlProject erlProject = ErlModelManager.getErlangModel().getErlangProject(project);
   if (erlProject == null) {
     return includeDirs;
   }
   final Collection<IPath> projectIncludeDirs = erlProject.getIncludeDirs();
   final IPathVariableManager pvm = ResourcesPlugin.getWorkspace().getPathVariableManager();
   for (IPath inc : projectIncludeDirs) {
     inc = PluginUtils.resolvePVMPath(pvm, inc);
     if (inc.isAbsolute()) {
       includeDirs.add(inc);
     } else {
       final IFolder folder = project.getFolder(inc);
       if (folder != null) {
         final IPath location = folder.getLocation();
         if (location != null) {
           includeDirs.add(location);
         } else {
           ErlLogger.warn("No location for %s", folder);
         }
       }
     }
   }
   return includeDirs;
 }
Пример #13
0
 private void setFunctionTracePatterns() {
   for (final TracePattern tracePattern : tracePatterns) {
     if (tracePattern.isEnabled()) {
       final String function = tracePattern.isLocal() ? FUN_TPL : FUN_TP;
       try {
         OtpErlangObject matchSpec = null;
         if (tracePattern.getMatchSpec().getMsObject() != null) {
           matchSpec = tracePattern.getMatchSpec().getMsObject();
         } else {
           matchSpec = new OtpErlangList();
         }
         if (tracePattern.getArity() < 0) {
           tracerBackend.call(
               Constants.TTB_MODULE,
               function,
               "aax",
               tracePattern.getModuleName(),
               tracePattern.getFunctionName(),
               matchSpec);
         } else {
           tracerBackend.call(
               Constants.TTB_MODULE,
               function,
               "aaxx",
               tracePattern.getModuleName(),
               tracePattern.getFunctionName(),
               new OtpErlangInt(tracePattern.getArity()),
               matchSpec);
         }
       } catch (final RpcException e) {
         ErlLogger.error("Could not add pattern: " + e.getMessage());
       }
     }
   }
 }
Пример #14
0
 /**
  * Loads traces from active result set ( {@link #setActiveResultSet(TracingResultsNode)}). Index
  * of last trace which will be loaded is <code>max(number_of_traces, endIndex)</code>.
  *
  * @param theStartIndex number of first trace
  * @param endIndex number of last trace
  */
 public void loadDataFromFile(final long theStartIndex, final long endIndex) {
   if (!tracing && !loading) {
     synchronized (this) {
       if (!tracing && !loading) {
         try {
           loading = true;
           loadingFileInfo = false;
           startIndex = theStartIndex;
           handler = new TraceEventHandler();
           getBackend(true);
           TraceCollections.getTracesList().clear();
           tracerBackend.getEventDaemon().addHandler(handler);
           final OtpErlangLong start = new OtpErlangLong(theStartIndex);
           final OtpErlangLong stop = new OtpErlangLong(endIndex);
           tracerBackend.call(
               Constants.ERLANG_HELPER_MODULE,
               FUN_LOAD,
               "sii",
               new OtpErlangString(activeResultSet.getFileName()),
               start,
               stop);
         } catch (final RpcException e) {
           ErlLogger.error(e);
           errorObject = e;
           finishLoading(TracingStatus.EXCEPTION_THROWN);
         }
       }
     }
   }
 }
Пример #15
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.ui.texteditor.IMarkerUpdater#updateMarker(org.eclipse.core
  * .resources.IMarker, org.eclipse.jface.text.IDocument,
  * org.eclipse.jface.text.Position)
  */
 public boolean updateMarker(
     final IMarker marker, final IDocument document, final Position position) {
   if (position.isDeleted()) {
     return false;
   }
   try {
     final int line = MarkerUtilities.getLineNumber(marker);
     final int newLine = document.getLineOfOffset(position.getOffset()) + 1;
     if (line == newLine) {
       return true;
     }
     final IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
     final IBreakpoint breakpoint = manager.getBreakpoint(marker);
     if (breakpoint == null) {
       return false;
     }
     if (breakpoint instanceof ErlangLineBreakpoint) {
       final ErlangLineBreakpoint erlangLineBreakpoint = (ErlangLineBreakpoint) breakpoint;
       final ErlangDebugTarget target = erlangLineBreakpoint.getTarget();
       erlangLineBreakpoint.remove(target);
       MarkerUtilities.setLineNumber(marker, newLine);
       erlangLineBreakpoint.install(target);
       return true;
     }
     // if there exists a breakpoint on the line remove this one
     if (isLineBreakpointMarker(marker)) {
       ensureRanges(document, marker, line);
       return lineBreakpointExists(marker.getResource(), line, marker) == null;
     }
     // if the line info is a valid location with an invalid line
     // number,
     // a line breakpoint must be removed
     if (isLineBreakpointMarker(marker) && line == -1) {
       return false;
     }
     MarkerUtilities.setLineNumber(marker, line);
     if (isLineBreakpointMarker(marker)) {
       ensureRanges(document, marker, line);
     }
     return true;
   } catch (final BadLocationException e) {
     ErlLogger.error(e);
   } catch (final CoreException e) {
     ErlLogger.error(e);
   }
   return false;
 }
Пример #16
0
 /**
  * Displays an error that occured during the project creation. *
  *
  * @param e details on the error
  */
 private void reportError(final Exception e) {
   ErlLogger.error(e);
   ErrorDialog.openError(
       getShell(),
       ErlideUIPlugin.getResourceString("wizards.errors.projecterrordesc"),
       ErlideUIPlugin.getResourceString("wizards.errors.projecterrortitle"),
       PluginUtils.makeStatus(e));
 }
Пример #17
0
 public void compileYrl(
     final IProject project,
     final BuildResource resource,
     final IBackend b,
     final OtpErlangList compilerOptions) {
   final IRpcFuture res = startCompileYrl(project, resource.getResource(), b, compilerOptions);
   if (res == null) {
     ErlLogger.warn(
         "error compiling yrl file: " + resource.getResource().getProjectRelativePath());
     return;
   }
   try {
     completeCompile(project, resource.getResource(), res.get(), b, compilerOptions);
   } catch (final RpcException e) {
     ErlLogger.warn(e);
   }
 }
Пример #18
0
 public synchronized void removeTracePattern(final TracePattern pattern) {
   tracePatterns.remove(pattern);
   for (final ITraceNodeObserver listener : listeners) {
     try {
       listener.updateTracePatterns();
     } catch (final Exception e) {
       ErlLogger.error(e);
     }
   }
 }
Пример #19
0
 public void loadTracePatterns(final TracePattern[] patterns) {
   tracePatterns.clear();
   tracePatterns.addAll(Arrays.asList(patterns));
   for (final ITraceNodeObserver listener : listeners) {
     try {
       listener.updateTracePatterns();
     } catch (final Exception e) {
       ErlLogger.error(e);
     }
   }
 }
Пример #20
0
 private ILaunch launchPeer(final BackendData data) {
   final ILaunchConfiguration launchConfig = data.asLaunchConfiguration();
   try {
     final boolean registerForDebug =
         data.getLaunch() != null || SystemConfiguration.getInstance().isDeveloper();
     return launchConfig.launch(
         ILaunchManager.RUN_MODE, new NullProgressMonitor(), false, registerForDebug);
   } catch (final CoreException e) {
     ErlLogger.error(e);
     return null;
   }
 }
Пример #21
0
 /**
  * Removes selected tracing result from list.
  *
  * @param tracingResult tracing result to be removed
  */
 public synchronized void removeTracingResult(final TracingResultsNode tracingResult) {
   activeResultSet = null;
   TraceCollections.getFilesList().remove(tracingResult);
   TraceCollections.getTracesList().clear();
   for (final ITraceNodeObserver listener : listeners) {
     try {
       listener.removeFile();
     } catch (final Exception e) {
       ErlLogger.error(e);
     }
   }
 }
Пример #22
0
  public void checkForClashes(final IBackend backend, final IProject project) {
    try {
      final OtpErlangList res = InternalErlideBuilder.getCodeClashes(backend);
      for (final OtpErlangObject elem : res) {
        final OtpErlangTuple t = (OtpErlangTuple) elem;
        final String f1 = ((OtpErlangString) t.elementAt(0)).stringValue();
        final String f2 = ((OtpErlangString) t.elementAt(1)).stringValue();

        // add marker only for modules belonging to this project!
        final IResource r1 = project.findMember(f1);
        final IResource r2 = project.findMember(f2);
        if (r1 != null || r2 != null) {
          MarkerUtils.addMarker(
              project,
              null,
              project,
              "Code clash between " + f1 + " and " + f2,
              0,
              IMarker.SEVERITY_WARNING,
              "");
        }
      }

    } catch (final Exception e) {
    }
    try {
      final IErlProject erlProject = ErlModelManager.getErlangModel().getErlangProject(project);
      final Collection<IPath> sd = erlProject.getSourceDirs();
      final String[] dirList = new String[sd.size()];
      int j = 0;
      for (final IPath sp : sd) {
        dirList[j++] = project.getLocation().toPortableString() + "/" + sp;
      }
      final OtpErlangList res = InternalErlideBuilder.getSourceClashes(backend, dirList);
      for (int i = 0; i < res.arity(); i++) {
        final OtpErlangTuple t = (OtpErlangTuple) res.elementAt(i);
        final String f1 = ((OtpErlangString) t.elementAt(0)).stringValue();
        final String f2 = ((OtpErlangString) t.elementAt(1)).stringValue();
        MarkerUtils.addMarker(
            project,
            null,
            project,
            "Duplicated module name in " + f1 + " and " + f2,
            0,
            IMarker.SEVERITY_WARNING,
            "");
      }
    } catch (final Exception e) {
      ErlLogger.debug(e);
    }
  }
 @Override
 public boolean performOk() {
   try {
     prefs.setAutoActivate(autoActivateButton.getSelection());
     final Integer i = new Integer(delayText.getText());
     prefs.setDelayInMS(i.intValue());
     prefs.setErlangTriggers(erlangTriggersText.getText());
     prefs.seteDocTriggers(eDocTriggersText.getText());
     prefs.store();
   } catch (final BackingStoreException e) {
     ErlLogger.warn(e);
   }
   return super.performOk();
 }
Пример #24
0
 /**
  * Performs actions after loading file or trace data.
  *
  * @param status status
  */
 private void finishLoading(final TracingStatus status) {
   tracerBackend.getEventDaemon().removeHandler(handler);
   for (final ITraceNodeObserver listener : listeners) {
     try {
       if (loadingFileInfo) {
         listener.finishLoadingFile(status);
       } else {
         listener.finishLoadingTraces(status);
       }
     } catch (final Exception e) {
       ErlLogger.error(e);
     }
   }
   loading = false;
   tracing = false;
 }
Пример #25
0
 /** Stops tracing. */
 public void stop() {
   if (tracing && !loading) {
     synchronized (this) {
       if (tracing && !loading) {
         try {
           loading = true;
           tracerBackend.call(Constants.ERLANG_HELPER_MODULE, FUN_STOP, "");
         } catch (final RpcException e) {
           ErlLogger.error("Could not stop tracing tool: " + e.getMessage());
           errorObject = e;
           finishLoading(TracingStatus.EXCEPTION_THROWN);
         }
       }
     }
   }
 }
 @Override
 protected void performDefaults() {
   prefs = new CodeAssistPreferences();
   try {
     prefs.load();
     if (autoActivateButton == null) {
       return;
     }
     autoActivateButton.setSelection(prefs.isAutoActivate());
     delayText.setText(Integer.toString(prefs.getDelayInMS()));
     erlangTriggersText.setText(prefs.getErlangTriggers());
     eDocTriggersText.setText(prefs.geteDocTriggers());
   } catch (final BackingStoreException e) {
     ErlLogger.warn(e);
   }
   super.performDefaults();
 }
Пример #27
0
 /**
  * Loads information about given file.
  *
  * @param path path
  */
 public void loadFile(final String path) {
   if (!tracing && !loading) {
     synchronized (this) {
       if (!tracing && !loading) {
         try {
           loading = true;
           loadingFileInfo = true;
           handler = new TraceEventHandler();
           getBackend(true);
           tracerBackend.getEventDaemon().addHandler(handler);
           tracerBackend.call(
               Constants.ERLANG_HELPER_MODULE, FUN_FILE_INFO, "s", new OtpErlangString(path));
         } catch (final RpcException e) {
           ErlLogger.error(e);
           errorObject = e;
           finishLoading(TracingStatus.EXCEPTION_THROWN);
         }
       }
     }
   }
 }
Пример #28
0
  public IRpcFuture startCompileYrl(
      final IProject project,
      final IResource resource,
      final IBackend backend,
      final OtpErlangList compilerOptions) {
    // final IPath projectPath = project.getLocation();
    // final OldErlangProjectProperties prefs = new
    // OldErlangProjectProperties(project);

    MarkerUtils.deleteMarkers(resource);
    // try {
    // resource.deleteMarkers(PROBLEM_MARKER, true,
    // IResource.DEPTH_INFINITE);
    // } catch (final CoreException e1) {
    // }

    final IPath erl = getErlForYrl(resource);
    final IResource br = project.findMember(erl);

    // we should check timestamps, but yrl files are rare, so it doesn't
    // matter much

    try {
      if (br != null && br.exists()) {
        try {
          br.delete(true, null);
        } catch (final Exception e) {
          ErlLogger.warn(e);
        }
      }

      final String input = resource.getLocation().toString();
      final String output = resource.getLocation().removeFileExtension().toString();
      return InternalErlideBuilder.compileYrl(backend, input, output);
    } catch (final Exception e) {
      e.printStackTrace();
      return null;
    }
  }
Пример #29
0
 boolean addAllErlangModules(final IErlElement elem) {
   if (elem instanceof IErlModule) {
     children.add(new DebugTreeItem(elem, this));
     return true;
   } else if (elem instanceof ErlOtpExternalReferenceEntryList) {
     return false;
   } else if (elem instanceof ErlExternalReferenceEntryList) {
     return false;
   } else if (elem instanceof ErlExternalReferenceEntry) {
     return false;
   } else if (elem instanceof IParent) {
     try {
       if (elem instanceof IErlFolder) {
         final IErlFolder f = (IErlFolder) elem;
         if (!f.isSourcePathParent()) {
           return false;
         }
       }
       if (elem instanceof IOpenable) {
         final IOpenable o = (IOpenable) elem;
         o.open(null);
       }
       final DebugTreeItem dti = new DebugTreeItem(elem, this);
       final IParent p = (IParent) elem;
       boolean addedAny = false;
       for (final IErlElement i : p.getChildren()) {
         addedAny |= dti.addAllErlangModules(i);
       }
       if (addedAny) {
         children.add(dti);
       }
       return true;
     } catch (final ErlModelException e) {
       ErlLogger.warn(e);
     }
   }
   return false;
 }
Пример #30
0
 private void completeCompileForYrl(
     final IProject project,
     final IResource source,
     final IBackend backend,
     final OtpErlangList compilerOptions) {
   final IPath erl = getErlForYrl(source);
   if (erl != null) {
     try {
       source.getParent().refreshLocal(IResource.DEPTH_ONE, null);
       final IResource br = project.findMember(erl);
       if (br != null) {
         br.setDerived(true, null);
         final BuildResource bbr = new BuildResource(br);
         // br.touch() doesn't work...
         final IErlProject erlProject = ErlModelManager.getErlangModel().getErlangProject(project);
         compileErl(
             project, bbr, erlProject.getOutputLocation().toString(), backend, compilerOptions);
       }
     } catch (final CoreException e) {
       ErlLogger.warn(e);
     }
   }
 }