예제 #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
  /**
   * This method is called when the plug-in is stopped
   *
   * @param context the context
   * @throws Exception if a problem occurs
   */
  @Override
  public void stop(final BundleContext context) throws Exception {
    erlConsoleManager.dispose();
    super.stop(context);
    BackendCore.getBackendManager().removeBackendListener(erlangDebuggerBackendListener);
    BackendCore.getBackendManager().dispose();

    if (ErlideImage.isInstalled()) {
      ErlideImage.dispose();
    }
    SWTResourceManager.dispose();
    plugin = null;
  }
예제 #3
0
 /**
  * @param length
  * @param aSelection
  * @param aText
  * @return
  * @throws RpcException
  */
 protected OtpErlangObject callErlang(final int offset, final int length, final String aText)
     throws RpcException {
   final IRpcCallSite b = BackendCore.getBackendManager().getIdeBackend();
   final OtpErlangObject r1 =
       ErlideIndent.call(b, fErlModule, fErlFunction, offset, length, aText);
   return r1;
 }
예제 #4
0
    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();
        }
      }
    }
예제 #5
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);
    }
  }
예제 #6
0
  /** @wbp.parser.entryPoint */
  @Override
  public void createControl(final Composite parent) {
    runtimes = BackendCore.getRuntimeInfoManager().getRuntimes();

    final Composite comp = new Composite(parent, SWT.NONE);
    setControl(comp);
    final GridLayout topLayout = new GridLayout();
    topLayout.numColumns = 3;
    comp.setLayout(topLayout);

    final Label runtimeLabel = new Label(comp, SWT.NONE);
    runtimeLabel.setText("Name");

    final List<String> rtl = new ArrayList<String>();
    for (final RuntimeInfo r : runtimes) {
      rtl.add(r.getName());
    }
    final String[] rts = rtl.toArray(new String[] {});
    final RuntimeInfo defaultRuntime = BackendCore.getRuntimeInfoManager().getDefaultRuntime();
    final int db = defaultRuntime == null ? 0 : Arrays.binarySearch(rts, defaultRuntime.getName());

    runtimesCombo = new Combo(comp, SWT.READ_ONLY);
    final GridData gd_runtimesCombo = new GridData(174, SWT.DEFAULT);
    gd_runtimesCombo.horizontalAlignment = SWT.FILL;
    runtimesCombo.setLayoutData(gd_runtimesCombo);
    runtimesCombo.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("synthetic-access")
          @Override
          public void widgetSelected(final SelectionEvent e) {
            updateLaunchConfigurationDialog();
          }
        });
    runtimesCombo.setItems(rts);
    runtimesCombo.select(db);
    new Label(comp, SWT.NONE);
    new Label(comp, SWT.NONE);
    new Label(comp, SWT.NONE);
    new Label(comp, SWT.NONE);

    final Label nodeNameLabel = new Label(comp, SWT.NONE);
    nodeNameLabel.setText("Node name");

    nameText = new Text(comp, SWT.BORDER);
    final GridData gd_nameText = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_nameText.widthHint = 241;
    nameText.setLayoutData(gd_nameText);
    nameText.addModifyListener(
        new ModifyListener() {
          @Override
          @SuppressWarnings("synthetic-access")
          public void modifyText(final ModifyEvent e) {
            updateLaunchConfigurationDialog();
          }
        });

    nodeHostLabel = new Label(comp, SWT.NONE);
    nodeHostLabel.setText("@");
    new Label(comp, SWT.NONE);

    longNameButton = new Button(comp, SWT.RADIO);
    longNameButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    longNameButton.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("synthetic-access")
          @Override
          public void widgetSelected(final SelectionEvent e) {
            updateLaunchConfigurationDialog();
          }
        });
    longNameButton.setSelection(true);
    longNameButton.setText("long name (-name)");
    new Label(comp, SWT.NONE);

    shortNameButton = new Button(comp, SWT.RADIO);
    shortNameButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    shortNameButton.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("synthetic-access")
          @Override
          public void widgetSelected(final SelectionEvent e) {
            updateLaunchConfigurationDialog();
          }
        });
    shortNameButton.setText("short name (-sname)");

    final Label cookieLabel = new Label(comp, SWT.NONE);
    cookieLabel.setToolTipText("Leave empty to use default one");
    cookieLabel.setText("Cookie");

    cookieText = new Text(comp, SWT.BORDER);
    final GridData gd_cookieText = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
    gd_cookieText.widthHint = 232;
    cookieText.setLayoutData(gd_cookieText);
    cookieText.addModifyListener(
        new ModifyListener() {
          @Override
          @SuppressWarnings("synthetic-access")
          public void modifyText(final ModifyEvent e) {
            updateLaunchConfigurationDialog();
          }
        });
    cookieText.setToolTipText("Leave empty to use default one");

    startNodeCheckbox = new Button(comp, SWT.CHECK);
    startNodeCheckbox.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    startNodeCheckbox.setSelection(true);
    startNodeCheckbox.setText("Start the Erlang node if not running already");
    startNodeCheckbox.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("synthetic-access")
          @Override
          public void widgetSelected(final SelectionEvent e) {
            updateLaunchConfigurationDialog();
          }
        });

    final Label workingDirectoryLabel = new Label(comp, SWT.NONE);
    workingDirectoryLabel.setText("Working directory");

    workingDirText = new Text(comp, SWT.BORDER);
    workingDirText.setToolTipText("may be relative to the workspace");
    workingDirText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    workingDirText.addModifyListener(
        new ModifyListener() {
          @Override
          @SuppressWarnings("synthetic-access")
          public void modifyText(final ModifyEvent e) {
            updateLaunchConfigurationDialog();
          }
        });

    final Label extraArgumentsLabel = new Label(comp, SWT.NONE);
    extraArgumentsLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
    extraArgumentsLabel.setText("Extra arguments");

    argsText = new Text(comp, SWT.BORDER | SWT.MULTI);
    argsText.setToolTipText("as on the command line\nBe careful about proper quoting!");
    final GridData gd_argsText = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
    gd_argsText.heightHint = 35;
    argsText.setLayoutData(gd_argsText);
    argsText.addModifyListener(
        new ModifyListener() {
          @Override
          @SuppressWarnings("synthetic-access")
          public void modifyText(final ModifyEvent e) {
            updateLaunchConfigurationDialog();
          }
        });
    new Label(comp, SWT.NONE);
    final Label extraArgumentsLabel2 = new Label(comp, SWT.NONE);
    extraArgumentsLabel2.setText("(overrides runtime settings)");
    extraArgumentsLabel2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    distributedLoadCheck = new Button(comp, SWT.CHECK);
    distributedLoadCheck.setText("Load project code on all connected nodes");
    distributedLoadCheck.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    new Label(comp, SWT.NONE);
    distributedLoadCheck.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(final SelectionEvent e) {
            updateLaunchConfigurationDialog();
          }

          @Override
          public void widgetSelected(final SelectionEvent e) {
            updateLaunchConfigurationDialog();
          }
        });

    updateLaunchConfigurationDialog();
  }