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

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

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

Node.getBeginColumn介绍

暂无

代码示例

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

  1. @Override
  2. public int getColumnNumber() {
  3. return node.getBeginColumn();
  4. }

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

  1. @Override
  2. public int getBeginColumn() {
  3. if (beginColumn != -1) {
  4. return beginColumn;
  5. } else {
  6. if (children != null && children.length > 0) {
  7. return children[0].getBeginColumn();
  8. } else {
  9. throw new RuntimeException("Unable to determine beginning line of Node.");
  10. }
  11. }
  12. }

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

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

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

  1. private static int compareNodes(Node n1, Node n2) {
  2. int l1 = n1.getBeginLine();
  3. int l2 = n2.getBeginLine();
  4. if (l1 == l2) {
  5. return n1.getBeginColumn() - n2.getBeginColumn();
  6. }
  7. return l1 - l2;
  8. }

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

  1. @Override
  2. public int getBeginColumn() {
  3. if (this.beginColumn > 0) {
  4. return this.beginColumn;
  5. }
  6. Node parent = jjtGetParent();
  7. if (parent != null) {
  8. return parent.getBeginColumn();
  9. }
  10. throw new RuntimeException("Unable to determine beginning column of Node.");
  11. }

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

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

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

  1. private void checkIndentation(Object data, Node node, int indentation, String name) {
  2. if (node.getBeginColumn() != indentation) {
  3. addViolationWithMessage(data, node, name + " should begin at column " + indentation);
  4. }
  5. }

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

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

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

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

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

  1. @Override
  2. public Object visit(ASTBulkCollectIntoClause node, Object data) {
  3. Node parent = node.jjtGetParent();
  4. checkIndentation(data, node, parent.getBeginColumn() + indentation, "BULK COLLECT INTO");
  5. checkEachChildOnNextLine(data, node, node.getBeginLine(), parent.getBeginColumn() + 7);
  6. return super.visit(node, data);
  7. }

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

  1. @Override
  2. public Object visit(ASTFromClause node, Object data) {
  3. checkIndentation(data, node, node.jjtGetParent().getBeginColumn() + indentation, "FROM");
  4. return super.visit(node, data);
  5. }

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

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

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

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

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

  1. @Override
  2. public Object visit(ASTFormalParameters node, Object data) {
  3. int parameterIndentation = node.jjtGetParent().getBeginColumn() + indentation;
  4. checkEachChildOnNextLine(data, node, node.getBeginLine() + 1, parameterIndentation);
  5. // check the data type alignment
  6. List<ASTFormalParameter> parameters = node.findChildrenOfType(ASTFormalParameter.class);
  7. if (parameters.size() > 1) {
  8. ASTDatatype first = parameters.get(0).getFirstChildOfType(ASTDatatype.class);
  9. for (int i = 1; first != null && i < parameters.size(); i++) {
  10. ASTDatatype nextType = parameters.get(i).getFirstChildOfType(ASTDatatype.class);
  11. if (nextType != null) {
  12. checkIndentation(data, nextType, first.getBeginColumn(), "Type " + nextType.getImage());
  13. }
  14. }
  15. }
  16. return super.visit(node, data);
  17. }

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

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

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

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

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

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

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

  1. private int checkEachChildOnNextLine(Object data, Node parent, int firstLine, int indentation) {
  2. int currentLine = firstLine;
  3. for (int i = 0; i < parent.jjtGetNumChildren(); i++) {
  4. Node child = parent.jjtGetChild(i);
  5. if (child.getBeginLine() != currentLine) {
  6. addViolationWithMessage(data, child, child.getImage() + " should be on line " + currentLine);
  7. } else if (i > 0 && child.getBeginColumn() != indentation) {
  8. addViolationWithMessage(data, child, child.getImage() + " should begin at column " + indentation);
  9. }
  10. // next entry needs to be on the next line
  11. currentLine++;
  12. }
  13. return currentLine;
  14. }

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

  1. public void select(Node node) {
  2. String[] lines = getLines();
  3. if (node.getBeginLine() >= 0) {
  4. setSelectionStart(getPosition(lines, node.getBeginLine(), node.getBeginColumn()));
  5. setSelectionEnd(getPosition(lines, node.getEndLine(), node.getEndColumn()) + 1);
  6. }
  7. requestFocus();
  8. }
  9. }

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

  1. @Override
  2. public Object visit(ASTSubqueryOperation node, Object data) {
  3. // get previous sibling
  4. int thisIndex = node.jjtGetChildIndex();
  5. Node prevSibling = node.jjtGetParent().jjtGetChild(thisIndex - 1);
  6. checkIndentation(data, node, prevSibling.getBeginColumn(), node.getImage());
  7. // it should also be on the next line
  8. if (node.getBeginLine() != prevSibling.getEndLine() + 1) {
  9. addViolationWithMessage(data, node,
  10. node.getImage() + " should be on line " + (prevSibling.getEndLine() + 1));
  11. }
  12. return super.visit(node, data);
  13. }

相关文章