private boolean isCovered(ASTNode node) { int begin = node.getStartPosition(); int end = begin + node.getLength(); return begin >= selectionBegin && end <= selectionEnd; } });
protected boolean found(ASTNode node, ASTNode name) { if (name.getStartPosition() == this.rangeStart && name.getLength() == this.rangeLength) { this.foundNode = node; return true; } return false; }
private int findFieldInsertIndex(List<BodyDeclaration> decls, int currPos) { for (int i= decls.size() - 1; i >= 0; i--) { ASTNode curr= decls.get(i); if (curr instanceof FieldDeclaration && currPos > curr.getStartPosition() + curr.getLength()) { return i + 1; } } return 0; }
private boolean isCovered(ASTNode node) { int begin= node.getStartPosition(); int end= begin + node.getLength(); return begin >= selectionBegin && end <= selectionEnd; } });
private int findMethodInsertIndex(List decls, int currPos) { int nDecls= decls.size(); for (int i= 0; i < nDecls; i++) { ASTNode curr= (ASTNode) decls.get(i); if (curr instanceof MethodDeclaration && currPos < curr.getStartPosition() + curr.getLength()) { return i + 1; } } return nDecls; }
private int endPosition(List<ASTNode> list) { if (list.isEmpty()) return 0; ASTNode n = list.get(list.size() - 1); return n.getStartPosition() + n.getLength(); } // /***************BODY VISITOR*************************
protected void recordSourceReference( final ASTNode astNode, final Node jcrNode ) throws Exception { jcrNode.setProperty(ClassFileSequencerLexicon.START_POSITION, astNode.getStartPosition()); jcrNode.setProperty(ClassFileSequencerLexicon.LENGTH, astNode.getLength()); }
private int getEndPositionExclusive() { List<Expression> operands = getOperands(); ASTNode lastNode = operands.get(operands.size() - 1); return lastNode.getStartPosition() + lastNode.getLength(); }
private int getEndPositionExclusive() { List operands= getOperands(); ASTNode lastNode= (ASTNode) operands.get(operands.size() - 1); return lastNode.getStartPosition() + lastNode.getLength(); }
private CodeScopeBuilder(ASTNode node, IBinding ignore) { fScope = new Scope(null, node.getStartPosition(), node.getLength()); fScopes = new ArrayList<>(); fIgnoreBinding = ignore; }
private CodeScopeBuilder(ASTNode node, Selection ignore) { fScope = new Scope(null, node.getStartPosition(), node.getLength()); fScopes = new ArrayList<>(); fIgnoreRange = ignore; }
public int getEndVisitSelectionMode(ASTNode node) { int nodeStart= node.getStartPosition(); int nodeEnd= nodeStart + node.getLength(); if (nodeEnd <= fStart) return BEFORE; else if (covers(node)) return SELECTED; else if (nodeEnd >= fExclusiveEnd) return AFTER; return INTERSECTS; }
private static boolean rangeEndsBetween(ISourceRange range, ASTNode first, ASTNode next) { int pos= Util.getEndExclusive(range); return first.getStartPosition() + first.getLength() <= pos && pos <= next.getStartPosition(); }
private void searchNode(ASTNode node, String contents, String label, ArrayList<TextEditGroup> textedits) { int start= node.getStartPosition(); int length= node.getLength(); int trailing = findTrailingSemicolons(contents, start + length); if (trailing > 0) { ReplaceEdit edit = new ReplaceEdit(start + length, trailing, ""); //$NON-NLS-1$ textedits.add(new TextEditGroup(label, edit)); } }
protected static ISourceRange getSelectedNodeSourceRange(ISourceReference sr, ASTNode nodeToSelect) throws JavaModelException { int offset= nodeToSelect.getStartPosition(); int end= Math.min(sr.getSourceRange().getLength(), nodeToSelect.getStartPosition() + nodeToSelect.getLength() - 1); return createSourceRange(offset, end); }
@Override public void endVisit(TypeDeclaration node) { if (node.getParent().getLength() == 0) return; // this is a fake block created by parsing in statements mode tryKeepOnOneLine(node, node.getName(), node.bodyDeclarations(), this.options.keep_type_declaration_on_one_line); }
/** * Returns the extended source range for a node. * * @return an extended source range (never null) * @since 3.1 */ final SourceRange getExtendedRange(ASTNode node) { if (this.eventStore.isRangeCopyPlaceholder(node)) { return new SourceRange(node.getStartPosition(), node.getLength()); } return this.extendedSourceRangeComputer.computeSourceRange(node); }
protected static String getNewText(final ASTNode node, final ICompilationUnit declaringCu, final boolean removeIndentation) throws JavaModelException { final String result= declaringCu.getBuffer().getText(node.getStartPosition(), node.getLength()); if (removeIndentation) return getUnindentedText(result, declaringCu); return result; }
@Override public void updateNode() throws JavaModelException { int start= fNode.getStartPosition(); int length= fNode.getLength(); String msg= "Cannot update found node: nodeType=" + fNode.getNodeType() + "; " //$NON-NLS-1$//$NON-NLS-2$ + fNode.toString() + "[" + start + ", " + length + "] in " + fCuRewrite.getCu(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ JavaPlugin.log(new Exception(msg + ":\n" + fCuRewrite.getCu().getSource().substring(start, start + length))); //$NON-NLS-1$ fResult.addError(msg, JavaStatusContext.create(fCuRewrite.getCu(), fNode)); } @Override