Esempio n. 1
0
 @Override
 protected void waitForExit() throws ErlRuntimeException {
   if (process != null) {
     int i = 500;
     // may have to wait for crash dump to be written
     while (i-- > 0 && exitCode < 0) {
       exitCode = -1;
       try {
         Thread.sleep(POLL_INTERVAL * 2);
         exitCode = process.exitValue();
       } catch (final IllegalThreadStateException e) {
       } catch (final InterruptedException e) {
       }
       if (exitCode > 0) {
         throw new ErlRuntimeException(
             String.format("Runtime %s died with exit code %d", getNodeName(), exitCode));
       }
     }
     if (exitCode < 0) {
       ErlLogger.warn("Runtime %s died, but process is still running; killing it", getNodeName());
       throw new ErlRuntimeException(
           String.format("Runtime %s died with exit code unknown", getNodeName()));
     }
   }
 }
Esempio n. 2
0
  /**
   * This method is called upon plug-in activation
   *
   * @param context The context
   * @throws Exception if a problem occurs
   */
  @Override
  public void start(final BundleContext context) throws Exception {
    ErlLogger.debug("Starting UI " + Thread.currentThread());
    super.start(context);

    if (SystemConfiguration.getInstance().isDeveloper()) {
      BackendManagerPopup.init();
    }

    loadDefaultEditorColors();

    ErlLogger.debug("Started UI");

    erlConsoleManager = new ErlConsoleManager();
    if (SystemConfiguration.getInstance().isDeveloper()) {
      try {
        final IBackend ideBackend = BackendCore.getBackendManager().getIdeBackend();
        if (!ideBackend.getData().hasConsole()) {
          erlConsoleManager.runtimeAdded(ideBackend);
        }
      } catch (final Exception e) {
        ErlLogger.warn(e);
      }
    }

    erlangDebuggerBackendListener = new ErlangDebuggerBackendListener();
    BackendCore.getBackendManager().addBackendListener(erlangDebuggerBackendListener);

    startPeriodicCacheCleaner();
  }
Esempio n. 3
0
 private void autoIndentAfterNewLine(final IDocument d, final DocumentCommand c) {
   try {
     indentAfterNewLine(d, c);
   } catch (final BadLocationException e) {
     ErlLogger.warn(e);
   }
 }
Esempio n. 4
0
 /** Selects and reveals the given offset and length in the given editor part. */
 public static void revealInEditor(final IEditorPart editor, final int offset, final int length) {
   if (editor instanceof ITextEditor) {
     ((ITextEditor) editor).selectAndReveal(offset, length);
     return;
   }
   ErlLogger.warn(
       "EditorUtility.revealInEditor should only be called on an ErlangEditor; it was an %s",
       editor.getClass().getName());
 }
  public void interpretOrDeinterpret(final IErlModule module, final boolean checked) {
    if (erlangDebugTarget == null) {
      ErlLogger.warn("erlangDebugTarget is null ?!?!");
      return;
    }
    final String moduleWoExtension = module.getModuleName();
    final IProject project =
        ErlangEngine.getInstance().getModelUtilService().getProject(module).getWorkspaceProject();
    final boolean interpret = checked;

    if (erlangDebugTarget.getInterpretedModules().contains(moduleWoExtension) != interpret) {
      // FIXME this isn't correct!!!
      erlangDebugTarget.interpret(project, moduleWoExtension, distributed, interpret);
    }
    addRemove(module, checked);
  }
 @Override
 public void handleDebugEvents(final DebugEvent[] events) {
   boolean changed = false;
   for (final DebugEvent debugEvent : events) {
     if (debugEvent.getKind() == DebugEvent.MODEL_SPECIFIC
         && debugEvent.getDetail() == ErlangDebugTarget.INTERPRETED_MODULES_CHANGED) {
       changed = true;
       break;
     }
   }
   if (changed) {
     if (erlangDebugTarget == null) {
       ErlLogger.warn("erlangDebugTarget is null ?!?!");
       return;
     }
     final Set<String> interpret = erlangDebugTarget.getInterpretedModules();
     contentProvider.setModules(interpret);
     refreshList();
   }
 }
Esempio n. 7
0
 private static IFile resolveFile(final IFile file) {
   IFile result = file;
   if (file.getResourceAttributes().isSymbolicLink()) {
     try {
       final File f = new File(file.getLocation().toString());
       final IFileInfo info = EFS.getFileSystem(EFS.SCHEME_FILE).fromLocalFile(f).fetchInfo();
       final String target = info.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET);
       if (target != null) {
         // FIXME this is wrong in the general case
         // find the file in the externals!
         result = (IFile) file.getParent().findMember(target);
         if (result == null) {
           result = file;
         }
       }
     } catch (final Exception e) {
       ErlLogger.warn(e);
     }
   }
   return result;
 }
Esempio n. 8
0
  protected void indentAfterNewLine(final IDocument d, final DocumentCommand c)
      throws BadLocationException {
    final int offset = c.offset;
    String txt = null;
    editor.reconcileNow();
    final IErlElement element = editor.getElementAt(offset, false);
    final IErlMember member = (IErlMember) element;
    if (member != null) {
      final int start = member.getSourceRange().getOffset();
      if (offset >= start) {
        txt = d.get(start, offset - start);
      }
    }
    if (txt == null) {
      txt = "";
    }
    final int lineN = d.getLineOfOffset(offset);
    final int lineOffset = d.getLineOffset(lineN);
    final int lineLength = d.getLineLength(lineN);
    final String oldLine = d.get(offset, lineLength + lineOffset - offset);
    try {
      final IRpcSite b = BackendCore.getBackendManager().getIdeBackend().getRpcSite();
      final int tabw = getTabWidthFromPreferences();

      final Map<String, String> prefs = new TreeMap<String, String>();
      IndentationPreferencePage.addKeysAndPrefs(prefs);
      SmartTypingPreferencePage.addAutoNLKeysAndPrefs(prefs);
      final boolean useTabs = getUseTabsFromPreferences();
      final IndentResult res =
          ErlideIndent.indentLine(b, oldLine, txt, c.text, tabw, useTabs, prefs);

      if (res.isAddNewLine()) {
        c.text += "\n";
      }
      c.text += res.getText();
      c.length += res.getRemoveNext();
    } catch (final Exception e) {
      ErlLogger.warn(e);
    }
  }