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

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

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

Node.getEndLine介绍

暂无

代码示例

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

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

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

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

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

private boolean isCommentNotWithin(FormalComment n1, Node n2, Node node) {
  if (n1 == null || n2 == null || node == null) {
    return true;
  }
  boolean isNotWithinNode2 = !(n1.getEndLine() < n2.getEndLine()
      || n1.getEndLine() == n2.getEndLine() && n1.getEndColumn() < n2.getEndColumn());
  boolean isNotSameClass = node.getFirstParentOfType(ASTClassOrInterfaceBody.class) != n2
      .getFirstParentOfType(ASTClassOrInterfaceBody.class);
  boolean isNodeWithinNode2 = node.getEndLine() < n2.getEndLine()
      || node.getEndLine() == n2.getEndLine() && node.getEndColumn() < n2.getEndColumn();
  return isNotWithinNode2 || isNotSameClass || isNodeWithinNode2;
}

代码示例来源: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(ASTSubqueryOperation node, Object data) {
  // get previous sibling
  int thisIndex = node.jjtGetChildIndex();
  Node prevSibling = node.jjtGetParent().jjtGetChild(thisIndex - 1);
  checkIndentation(data, node, prevSibling.getBeginColumn(), node.getImage());
  // it should also be on the next line
  if (node.getBeginLine() != prevSibling.getEndLine() + 1) {
    addViolationWithMessage(data, node,
        node.getImage() + " should be on line " + (prevSibling.getEndLine() + 1));
  }
  return super.visit(node, data);
}

代码示例来源: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

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

@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;
  };
}

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

if (primaryExpression.getEndLine() != node.getEndLine() + 1) {
  addViolationWithMessage(data, primaryExpression, "Closing paranthesis should be on a new line.");

代码示例来源:origin: net.sourceforge.pmd/pmd-apex

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

代码示例来源:origin: net.sourceforge.pmd/pmd-java

private boolean isCommentNotWithin(FormalComment n1, Node n2, Node node) {
  if (n1 == null || n2 == null || node == null) {
    return true;
  }
  boolean isNotWithinNode2 = !(n1.getEndLine() < n2.getEndLine()
      || n1.getEndLine() == n2.getEndLine() && n1.getEndColumn() < n2.getEndColumn());
  boolean isNotSameClass = node.getFirstParentOfType(ASTClassOrInterfaceBody.class) != n2
      .getFirstParentOfType(ASTClassOrInterfaceBody.class);
  boolean isNodeWithinNode2 = node.getEndLine() < n2.getEndLine()
      || node.getEndLine() == n2.getEndLine() && node.getEndColumn() < n2.getEndColumn();
  return isNotWithinNode2 || isNotSameClass || isNodeWithinNode2;
}

代码示例来源:origin: com.alibaba.p3c/p3c-pmd

if (lastNode != null && lastNode.getEndLine() == lastComment.getEndLine()) {
  return false;
    lastEndLine = value.getEndLine();

代码示例来源:origin: net.sourceforge.pmd/pmd-core

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: net.sourceforge.pmd/pmd-core

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: net.sourceforge.pmd/pmd-core

@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());
    }
  }
});

相关文章