@Override public int getLineNumber() { return node.getBeginLine(); }
private static boolean isAfter(Node n1, Node n2) { return n1.getBeginLine() > n2.getBeginLine() || n1.getBeginLine() == n2.getBeginLine() && n1.getBeginColumn() >= n2.getEndColumn(); }
@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."); }
public AbstractDataFlowNode(List<DataFlowNode> dataFlow, Node node) { this(dataFlow); this.node = node; node.setDataFlowNode(this); this.line = node.getBeginLine(); }
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()); } }
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; }
private void addDeclarations(SortedMap<Integer, Node> map, List<? extends Node> nodes) { for (Node node : nodes) { map.put((node.getBeginLine() << 16) + node.getBeginColumn(), node); } } }
private boolean useInlineHighlight(Node node) { return node.getBeginLine() == node.getEndLine(); }
public String getToolTipText() { String tooltip = "Line: " + node.getBeginLine() + " Column: " + node.getBeginColumn(); tooltip += " " + label(); return tooltip; }
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()); } }
private boolean isCommentBefore(FormalComment n1, Node n2) { return n1.getEndLine() < n2.getBeginLine() || n1.getEndLine() == n2.getBeginLine() && n1.getEndColumn() < n2.getBeginColumn(); }
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); } }
/** 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())); } }
@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); }
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(); } }
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); } }
/** * 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); }
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; }
@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()); } } });
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; }; }