예제 #1
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();
  }
예제 #2
0
 @Override
 public void terminate() throws DebugException {
   ErlLogger.debug(
       "ErtsProcess will be terminated: %s, called from: %s",
       getLabel(), new Throwable().getStackTrace()[1]);
   try {
     super.terminate();
   } finally {
     if (!isTerminated()) {
       ErlLogger.debug("Could not terminate process %s", getLabel());
     }
   }
 }
예제 #3
0
 public SearchPatternData tryErlangTextSelection(
     final SearchPatternData initData0, final IEditorPart activePart) throws ErlModelException {
   final AbstractErlangEditor erlangEditor = (AbstractErlangEditor) activePart;
   final IErlModule module = erlangEditor.getModule();
   SearchPatternData initData = initData0;
   if (module != null) {
     final ISelection ssel = erlangEditor.getSite().getSelectionProvider().getSelection();
     final ITextSelection textSel = (ITextSelection) ssel;
     final int offset = textSel.getOffset();
     OpenResult res;
     try {
       res =
           ErlangEngine.getInstance()
               .getService(OpenService.class)
               .open(
                   module.getScannerName(),
                   offset,
                   ErlangEngine.getInstance().getModelUtilService().getImportsAsList(module),
                   "",
                   ErlangEngine.getInstance().getModel().getPathVars());
     } catch (final RpcException e) {
       res = null;
     }
     ErlLogger.debug("searchPage(open) " + res);
     initData = determineInitValuesFrom(module, offset, res);
   }
   return initData;
 }
예제 #4
0
 @Override
 protected void terminated() {
   ErlLogger.debug("ErtsProcess terminated: %s", getLabel());
   try {
     getLaunch().terminate();
   } catch (final DebugException e) {
     ErlLogger.error(e);
   }
   super.terminated();
 }
예제 #5
0
  public void start() throws CoreException {
    final String version = getFeatureVersionImpl();

    ErlLogger.debug("Starting CORE " + Thread.currentThread());
    String dev = "(" + EncodingUtils.getEncoding() + ") ";
    if (SystemConfiguration.getInstance().isDeveloper()) {
      dev += " developer version ***";
    }
    if (SystemConfiguration.getInstance().isTest()) {
      dev += " test ***";
    }
    final String versionBanner = "*** starting Erlide v" + version + " *** " + dev;
    logger.log(Level.INFO, versionBanner);
    featureVersion = version;

    workspace.addSaveParticipant(plugin.getBundle().getSymbolicName(), getSaveParticipant());

    ErlangDebugOptionsManager.getDefault().start();
    ErlLogger.debug("Started CORE");
  }
  private void contextActivated(final ISelection selection) {
    if (!isAvailable() || !isVisible()) {
      return;
    }
    erlangDebugTarget = null;
    if (selection instanceof IStructuredSelection) {
      final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
      final Object o = structuredSelection.getFirstElement();
      if (o instanceof ErlangDebugElement) {
        final ErlangDebugElement e = (ErlangDebugElement) o;
        erlangDebugTarget = e.getErlangDebugTarget();
      } else if (o instanceof ILaunch) {
        final ILaunch launch = (ILaunch) o;
        final IDebugTarget target = launch.getDebugTarget();
        if (target instanceof IErlangDebugNode) {
          final IErlangDebugNode edn = (IErlangDebugNode) target;
          erlangDebugTarget = edn.getErlangDebugTarget();
        }
      } else if (o instanceof RuntimeProcess) {
        final RuntimeProcess ep = (RuntimeProcess) o;
        final ILaunch launch = ep.getLaunch();
        final IDebugTarget target = launch.getDebugTarget();
        if (target instanceof IErlangDebugNode) {
          final IErlangDebugNode edn = (IErlangDebugNode) target;
          erlangDebugTarget = edn.getErlangDebugTarget();
        }
      }
      if (erlangDebugTarget == null) {
        ErlLogger.debug("no debug target found for " + selection);
        return;
      }
      final ILaunchConfiguration launchConfiguration =
          erlangDebugTarget.getLaunch().getLaunchConfiguration();
      setViewerInput(launchConfiguration);
      try {
        final EnumSet<ErlDebugFlags> debugFlags =
            ErlDebugFlags.makeSet(
                launchConfiguration.getAttribute(
                    ErlRuntimeAttributes.DEBUG_FLAGS,
                    ErlDebugFlags.getFlag(ErlDebugFlags.DEFAULT_DEBUG_FLAGS)));
        distributed = debugFlags.contains(ErlDebugFlags.DISTRIBUTED_DEBUG);
      } catch (final CoreException e1) {
        distributed = false;
      }
    }
    listViewer.refresh();
    showViewer();

    // updateAction(VARIABLES_FIND_ELEMENT_ACTION);
    // updateAction(FIND_ACTION);
  }
예제 #7
0
 private String getFeatureVersionImpl() {
   String version = "?";
   try {
     final IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
     if (providers != null) {
       version = findErlideFeatureVersion(providers);
     } else {
       ErlLogger.debug("***: no bundle group providers");
     }
   } catch (final Throwable e) {
     // ignore
   }
   final Version coreVersion = getBundle().getVersion();
   version = version + " (core=" + coreVersion.toString() + ")";
   return version;
 }
예제 #8
0
  private Process startRuntimeProcess(final RuntimeData rtData) {
    final String[] cmds = rtData.getCmdLine();
    final File workingDirectory = new File(rtData.getWorkingDir());

    try {
      ErlLogger.debug(
          "START node :> " + Arrays.toString(cmds) + " *** " + workingDirectory.getCanonicalPath());
    } catch (final IOException e1) {
      ErlLogger.error("START ERROR node :> " + e1.getMessage());
    }

    final ProcessBuilder builder = new ProcessBuilder(cmds);
    builder.directory(workingDirectory);
    setEnvironment(rtData, builder);
    try {
      final Process aProcess = builder.start();
      return aProcess;
    } catch (final IOException e) {
      ErlLogger.error("Could not create runtime: %s", Arrays.toString(cmds));
      ErlLogger.error(e);
      return null;
    }
  }
예제 #9
0
 public static void debug(final String message) {
   if (getDefault().isDebugging()) {
     ErlLogger.debug(message);
   }
 }
예제 #10
0
 public ErtsProcess(
     final ILaunch launch, final Process process, final String nodeName, final String workingDir) {
   super(launch, process, nodeName, null);
   ErlLogger.debug("# create ErtsProcess: " + nodeName);
 }