Exemple #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;
  }
  /**
   * 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();
  }
    private void findRefs(
        final IErlModule theModule, final ITextSelection aSelection, final boolean hasChanged) {
      final IBackend ideBackend = BackendCore.getBackendManager().getIdeBackend();
      fRefs = null;

      if (fCanceled) {
        return;
      }
      try {
        final int offset = aSelection.getOffset();
        final OpenResult res =
            ErlideOpen.open(
                ideBackend.getRpcSite(),
                theModule,
                offset,
                ModelUtils.getImportsAsList(theModule),
                "",
                ErlModelManager.getErlangModel().getPathVars());
        final ErlangSearchPattern pattern =
            SearchUtil.getSearchPatternFromOpenResultAndLimitTo(
                theModule, offset, res, LimitTo.ALL_OCCURRENCES, false);
        if (fCanceled) {
          return;
        }
        if (pattern != null) {
          final ErlSearchScope scope = new ErlSearchScope();
          scope.addModule(theModule);
          final List<ModuleLineFunctionArityRef> findRefs = Lists.newArrayList();
          // TODO: run in background? for large files, this can take
          // seconds
          final OtpErlangObject refs =
              ErlideSearchServer.findRefs(
                  ideBackend.getRpcSite(), pattern, scope, erlangEditor.getStateDir(), true);
          if (refs != null) {
            SearchUtil.addSearchResult(findRefs, refs);
            fRefs = erlangEditor.markOccurencesHandler.getErlangRefs(theModule, findRefs);
          }
        }
      } catch (final RpcTimeoutException e) {
        if (!ideBackend.isStopped()) {
          ErlLogger.warn(e);
        }
      } catch (final RpcException e) {
        ErlLogger.debug(e);
      } catch (final ErlModelException e) {
        ErlLogger.debug(e);
      } catch (final OtpErlangRangeException e) {
        ErlLogger.debug(e);
      }
      if (fRefs == null) {
        if (!erlangEditor.markOccurencesHandler.fStickyOccurrenceAnnotations) {
          erlangEditor.markOccurencesHandler.removeOccurrenceAnnotations();
        } else if (hasChanged) {
          erlangEditor.markOccurencesHandler.removeOccurrenceAnnotations();
        }
      }
    }
Exemple #4
0
 public static OtpErlangPid start(final IBackend backend) {
   try {
     final OtpErlangObject r = backend.call("erlide_shell", "start", "p", backend.getEventPid());
     final OtpErlangPid server = (OtpErlangPid) BackendUtils.ok(r);
     return server;
   } catch (final RpcException e) {
     return null;
   }
 }