net.sourceforge.pmd.lang.ast.Node.getBeginLine()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中net.sourceforge.pmd.lang.ast.Node.getBeginLine()方法的一些代码示例,展示了Node.getBeginLine()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getBeginLine()方法的具体详情如下:
包路径:net.sourceforge.pmd.lang.ast.Node
类名称:Node
方法名:getBeginLine

Node.getBeginLine介绍

暂无

代码示例

代码示例来源:origin: pmd/pmd

@Override
public int getLineNumber() {
  return node.getBeginLine();
}

代码示例来源:origin: pmd/pmd

private static boolean isAfter(Node n1, Node n2) {
  return n1.getBeginLine() > n2.getBeginLine()
      || n1.getBeginLine() == n2.getBeginLine() && n1.getBeginColumn() >= n2.getEndColumn();
}

代码示例来源:origin: pmd/pmd

@Override
public int getBeginLine() {
  if (this.beginLine > 0) {
    return this.beginLine;
  }
  Node parent = jjtGetParent();
  if (parent != null) {
    return parent.getBeginLine();
  }
  throw new RuntimeException("Unable to determine beginning line of Node.");
}

代码示例来源:origin: pmd/pmd

public AbstractDataFlowNode(List<DataFlowNode> dataFlow, Node node) {
  this(dataFlow);
  this.node = node;
  node.setDataFlowNode(this);
  this.line = node.getBeginLine();
}

代码示例来源:origin: pmd/pmd

private void tryToLog(String tag, NodeType type, Node node) {
  if (LOGGER.isLoggable(Level.FINEST)) {
    LOGGER.finest("pushOnStack " + tag + " " + type + ": line " + node.getBeginLine()
      + ", column " + node.getBeginColumn());
  }
}

代码示例来源:origin: pmd/pmd

private static int compareNodes(Node n1, Node n2) {
  int l1 = n1.getBeginLine();
  int l2 = n2.getBeginLine();
  if (l1 == l2) {
    return n1.getBeginColumn() - n2.getBeginColumn();
  }
  return l1 - l2;
}

代码示例来源:origin: pmd/pmd

private void addDeclarations(SortedMap<Integer, Node> map, List<? extends Node> nodes) {
    for (Node node : nodes) {
      map.put((node.getBeginLine() << 16) + node.getBeginColumn(), node);
    }
  }
}

代码示例来源:origin: pmd/pmd

private boolean useInlineHighlight(Node node) {
  return node.getBeginLine() == node.getEndLine();
}

代码示例来源:origin: pmd/pmd

public String getToolTipText() {
  String tooltip = "Line: " + node.getBeginLine() + " Column: " + node.getBeginColumn();
  tooltip += " " + label();
  return tooltip;
}

代码示例来源:origin: pmd/pmd

protected void tryToLog(String tag, DataFlowNode node) {
  if (LOGGER.isLoggable(Level.FINEST)) {
    LOGGER.finest(tag + ": line" + node.getNode().getBeginLine() + ", column "
      + node.getNode().getBeginColumn() + " - " + node.toString());
  }
}

代码示例来源:origin: pmd/pmd

private boolean isCommentBefore(FormalComment n1, Node n2) {
  return n1.getEndLine() < n2.getBeginLine()
      || n1.getEndLine() == n2.getBeginLine() && n1.getEndColumn() < n2.getBeginColumn();
}

代码示例来源:origin: pmd/pmd

private void checkLineAndIndentation(Object data, Node node, int line, int indentation, String name) {
  if (node.getBeginLine() != line) {
    addViolationWithMessage(data, node, name + " should be on line " + line);
  } else if (node.getBeginColumn() != indentation) {
    addViolationWithMessage(data, node, name + " should begin at column " + indentation);
  }
}

代码示例来源:origin: pmd/pmd

/** Scroll the editor to a node and makes it visible. */
private void scrollEditorToNode(Node node) {
  codeEditorArea.moveTo(node.getBeginLine() - 1, 0);
  if (codeEditorArea.getVisibleParagraphs().size() < 1) {
    return;
  }
  int visibleLength = codeEditorArea.lastVisibleParToAllParIndex() - codeEditorArea.firstVisibleParToAllParIndex();
  if (node.getEndLine() - node.getBeginLine() > visibleLength
      || node.getBeginLine() < codeEditorArea.firstVisibleParToAllParIndex()) {
    codeEditorArea.showParagraphAtTop(Math.max(node.getBeginLine() - 2, 0));
  } else if (node.getEndLine() > codeEditorArea.lastVisibleParToAllParIndex()) {
    codeEditorArea.showParagraphAtBottom(Math.min(node.getEndLine(), codeEditorArea.getParagraphs().size()));
  }
}

代码示例来源:origin: pmd/pmd

@Override
public Object visit(ASTSelectList node, Object data) {
  Node parent = node.jjtGetParent();
  checkEachChildOnNextLine(data, node, parent.getBeginLine(), parent.getBeginColumn() + 7);
  return super.visit(node, data);
}

代码示例来源:origin: pmd/pmd

public void select(Node node) {
    String[] lines = getLines();
    if (node.getBeginLine() >= 0) {
      setSelectionStart(getPosition(lines, node.getBeginLine(), node.getBeginColumn()));
      setSelectionEnd(getPosition(lines, node.getEndLine(), node.getEndColumn()) + 1);
    }
    requestFocus();
  }
}

代码示例来源:origin: pmd/pmd

public ParametricRuleViolation(Rule theRule, RuleContext ctx, T node, String message) {
  rule = theRule;
  description = message;
  filename = ctx.getSourceCodeFilename();
  if (filename == null) {
    filename = "";
  }
  if (node != null) {
    beginLine = node.getBeginLine();
    beginColumn = node.getBeginColumn();
    endLine = node.getEndLine();
    endColumn = node.getEndColumn();
  }
  // Apply Rule specific suppressions
  if (node != null && rule != null) {
    setSuppression(rule, node);
  }
}

代码示例来源:origin: pmd/pmd

/**
 * Snapshots the absolute coordinates of the node in the code area
 * for the duration of the layering algorithm.
 */
// TODO I don't think there's any good reason for this laziness,
// if anything, it may cause trouble if the layering algorithm uses
// a snapshot taken too late, with outdated line and column coordinates
// I originally wrote it like that because I didn't think enough about it,
// and I don't have time to simplify it before 6.5.0
public PositionSnapshot snapshot() {
  int lastKnownStart = getAbsolutePosition(node.getBeginLine(), node.getBeginColumn() - 1);
  int lastKnownEnd = getAbsolutePosition(node.getEndLine(), node.getEndColumn());
  return new PositionSnapshot(lastKnownStart, lastKnownEnd);
}

代码示例来源:origin: pmd/pmd

private int checkEachChildOnNextLine(Object data, Node parent, int firstLine, int indentation) {
  int currentLine = firstLine;
  for (int i = 0; i < parent.jjtGetNumChildren(); i++) {
    Node child = parent.jjtGetChild(i);
    if (child.getBeginLine() != currentLine) {
      addViolationWithMessage(data, child, child.getImage() + " should be on line " + currentLine);
    } else if (i > 0 && child.getBeginColumn() != indentation) {
      addViolationWithMessage(data, child, child.getImage() + " should begin at column " + indentation);
    }
    // next entry needs to be on the next line
    currentLine++;
  }
  return currentLine;
}

代码示例来源:origin: pmd/pmd

@Override
  public void run() {
    try {
      sourceCodeArea.getHighlighter().removeAllHighlights();
      if (node == null) {
        return;
      }
      int startOffset = sourceCodeArea.getLineStartOffset(node.getBeginLine() - 1)
          + node.getBeginColumn() - 1;
      int end = sourceCodeArea.getLineStartOffset(node.getEndLine() - 1) + node.getEndColumn();
      sourceCodeArea.getHighlighter().addHighlight(startOffset, end,
          new DefaultHighlighter.DefaultHighlightPainter(HIGHLIGHT_COLOR));
      sourceCodeArea.moveCaretPosition(startOffset);
    } catch (BadLocationException exc) {
      throw new IllegalStateException(exc.getMessage());
    }
  }
});

代码示例来源:origin: pmd/pmd

private IntFunction<javafx.scene.Node> lineNumberFactory() {
  IntFunction<javafx.scene.Node> base = LineNumberFactory.get(codeEditorArea);
  Val<Integer> activePar = Val.wrap(codeEditorArea.currentParagraphProperty());
  return idx -> {
    javafx.scene.Node label = base.apply(idx);
    activePar.conditionOnShowing(label)
         .values()
         .subscribe(p -> label.pseudoClassStateChanged(PseudoClass.getPseudoClass("has-caret"), idx == p));
    // adds a pseudo class if part of the focus node appears on this line
    currentFocusNode.conditionOnShowing(label)
            .values()
            .subscribe(n -> label.pseudoClassStateChanged(PseudoClass.getPseudoClass("is-focus-node"),
                                   n != null && idx + 1 <= n.getEndLine() && idx + 1 >= n.getBeginLine()));
    return label;
  };
}

相关文章