/* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */
  public void selectionChanged(SelectionChangedEvent event) {

    RuleViolation violation = selectedViolationFrom(event);
    if (violation == null) return;

    String varName = violation.getVariableName();
    if (StringUtil.isEmpty(varName)) return;

    int beginLine = violation.getBeginLine();
    int endLine = violation.getEndLine();

    if (beginLine != 0 && endLine != 0) {
      try {
        int offset = getDocument().getLineOffset(violation.getBeginLine() - 1);
        int length = getDocument().getLineOffset(violation.getEndLine()) - offset;
        highlight(offset, length);
      } catch (BadLocationException ble) {
        logError(
            StringKeys.ERROR_RUNTIME_EXCEPTION + "Exception when selecting a line in the editor",
            ble);
      }

      // showMethodToMarker(marker);
      showMethodToViolation(violation);

      // then we calculate and color _a possible_ Path
      // for this Error in the Dataflow
      DataflowGraph graph = graphViewer.getGraph();
      if (!graphViewer.isDisposed() && graph != null) {
        graph.markPath(beginLine, endLine, varName);
      }
    }
  }
Example #2
0
  private static boolean hasRealText(String line) {

    if (StringUtil.isEmpty(line)) {
      return false;
    }

    return !StringUtil.isAnyOf(line.trim(), "//", "/*", "/**", "*", "*/");
  }