/** * Returns an estimate of the memory footprint in bytes of this node * list and all its subtrees. * * @return the size of this list of subtrees in bytes */ int listSize() { int result = memSize(); for (Iterator it = iterator(); it.hasNext(); ) { ASTNode child = (ASTNode) it.next(); result += child.treeSize(); } return result; } }
public Object remove(int index) { if ((ASTNode.this.typeAndFlags & PROTECT) != 0) { // this node is protected => cannot gain or lose children throw new IllegalArgumentException("AST node cannot be modified"); //$NON-NLS-1$ } // delink old child from parent ASTNode oldChild = (ASTNode) this.store.get(index); if ((oldChild.typeAndFlags & PROTECT) != 0) { // old child is protected => cannot be unparented throw new IllegalArgumentException("AST node cannot be modified"); //$NON-NLS-1$ } ASTNode.this.ast.preRemoveChildEvent(ASTNode.this, oldChild, this.propertyDescriptor); // n.b. setParent will call ast.modifying() oldChild.setParent(null, null); Object result = this.store.remove(index); updateCursors(index, -1); ASTNode.this.ast.postRemoveChildEvent(ASTNode.this, oldChild, this.propertyDescriptor); return result; }
/** * Returns the number of extra array dimensions over and above the * explicitly-specified type. * <p> * For example, <code>int x[][]</code> has a type of * <code>int</code> and two extra array dimensions; * <code>int[][] x</code> has a type of <code>int[][]</code> * and zero extra array dimensions. The two constructs have different * ASTs, even though there are really syntactic variants of the same * variable declaration. * </p> * <p> * In the JLS8 API, this method is a convenience method that * counts {@link #extraDimensions()}. * </p> * * @return the number of extra array dimensions * @since 2.1 */ public int getExtraDimensions() { // more efficient than checking getAST().API_LEVEL if (this.extraDimensions == null) { // JLS2,3,4 behavior - bona fide property return this.extraArrayDimensions; } else { return this.extraDimensions.size(); } }
/** * Returns the number of extra array dimensions over and above the * explicitly-specified return type. * <p> * For example, <code>int foo()[][]</code> has a return type of * <code>int</code> and two extra array dimensions; * <code>int[][] foo()</code> has a return type of <code>int[][]</code> * and zero extra array dimensions. The two constructs have different * ASTs, even though there are really syntactic variants of the same * method declaration. * </p> * <p> * In the JLS8 API, this method is a convenience method that * counts {@link #extraDimensions()}. * </p> * * @return the number of extra array dimensions * @since 2.1 */ public int getExtraDimensions() { // more efficient than checking getAST().API_LEVEL if (this.extraDimensions == null) { // JLS2,3,4 behavior - bona fide property return this.extraArrayDimensions; } else { return this.extraDimensions.size(); } }
/** * Returns the number of extra array dimensions over and above the * explicitly-specified type. * <p> * For example, <code>int x[][]</code> has a type of * <code>int</code> and two extra array dimensions; * <code>int[][] x</code> has a type of <code>int[][]</code> * and zero extra array dimensions. The two constructs have different * ASTs, even though there are really syntactic variants of the same * variable declaration. * </p> * <p> * In the JLS8 API, this method is a convenience method that * counts {@link #extraDimensions()}. * </p> * * @return the number of extra array dimensions * @since 2.1 */ public int getExtraDimensions() { // more efficient than checking getAST().API_LEVEL if (this.extraDimensions == null) { // JLS2,3,4 behavior - bona fide property return this.extraArrayDimensions; } else { return this.extraDimensions.size(); } }
/** * Returns the number of extra array dimensions over and above the * explicitly-specified return type. * <p> * For example, <code>int foo()[][]</code> has a return type of * <code>int</code> and two extra array dimensions; * <code>int[][] foo()</code> has a return type of <code>int[][]</code> * and zero extra array dimensions. The two constructs have different * ASTs, even though there are really syntactic variants of the same * method declaration. * </p> * <p> * In the JLS8 API, this method is a convenience method that * counts {@link #extraDimensions()}. * </p> * * @return the number of extra array dimensions * @since 2.1 */ public int getExtraDimensions() { // more efficient than checking getAST().API_LEVEL if (this.extraDimensions == null) { // JLS2,3,4 behavior - bona fide property return this.extraArrayDimensions; } else { return this.extraDimensions.size(); } }
/** * Returns the number of extra array dimensions over and above the * explicitly-specified return type. * <p> * For example, <code>int foo()[][]</code> has a return type of * <code>int</code> and two extra array dimensions; * <code>int[][] foo()</code> has a return type of <code>int[][]</code> * and zero extra array dimensions. The two constructs have different * ASTs, even though there are really syntactic variants of the same * method declaration. * </p> * <p> * In the JLS8 API, this method is a convenience method that * counts {@link #extraDimensions()}. * </p> * * @return the number of extra array dimensions * @since 2.1 */ public int getExtraDimensions() { // more efficient than checking getAST().API_LEVEL if (this.extraDimensions == null) { // JLS2,3,4 behavior - bona fide property return this.extraArrayDimensions; } else { return this.extraDimensions.size(); } }
/** * Returns the number of extra array dimensions over and above the * explicitly-specified type. * <p> * For example, <code>int x[][]</code> has a type of * <code>int</code> and two extra array dimensions; * <code>int[][] x</code> has a type of <code>int[][]</code> * and zero extra array dimensions. The two constructs have different * ASTs, even though there are really syntactic variants of the same * variable declaration. * </p> * <p> * In the JLS8 API, this method is a convenience method that * counts {@link #extraDimensions()}. * </p> * * @return the number of extra array dimensions * @since 2.1 */ public int getExtraDimensions() { // more efficient than checking getAST().API_LEVEL if (this.extraDimensions == null) { // JLS2,3,4 behavior - bona fide property return this.extraArrayDimensions; } else { return this.extraDimensions.size(); } }
/** * Accepts the given visitor on a visit of the given live list of * child nodes. * <p> * This method must be used by the concrete implementations of * <code>accept</code> to traverse list-values properties; it * encapsulates the proper handling of on-the-fly changes to the list. * </p> * * @param visitor the visitor object * @param children the child AST node to dispatch too, or <code>null</code> * if none */ final void acceptChildren(ASTVisitor visitor, ASTNode.NodeList children) { // use a cursor to keep track of where we are up to // (the list may be changing under foot) NodeList.Cursor cursor = children.newCursor(); try { while (cursor.hasNext()) { ASTNode child = (ASTNode) cursor.next(); child.accept(visitor); } } finally { children.releaseCursor(cursor); } }
/** * Returns the number of extra array dimensions over and above the * explicitly-specified return type. * <p> * For example, <code>int foo()[][]</code> has a return type of * <code>int</code> and two extra array dimensions; * <code>int[][] foo()</code> has a return type of <code>int[][]</code> * and zero extra array dimensions. The two constructs have different * ASTs, even though there are really syntactic variants of the same * method declaration. * </p> * <p> * In the JLS8 API, this method is a convenience method that * counts {@link #extraDimensions()}. * </p> * * @return the number of extra array dimensions * @since 2.1 */ public int getExtraDimensions() { // more efficient than checking getAST().API_LEVEL if (this.extraDimensions == null) { // JLS2,3,4 behavior - bona fide property return this.extraArrayDimensions; } else { return this.extraDimensions.size(); } }
/** * Returns the number of extra array dimensions over and above the * explicitly-specified return type. * <p> * For example, <code>int foo()[][]</code> has a return type of * <code>int</code> and two extra array dimensions; * <code>int[][] foo()</code> has a return type of <code>int[][]</code> * and zero extra array dimensions. The two constructs have different * ASTs, even though there are really syntactic variants of the same * method declaration. * </p> * <p> * In the JLS8 API, this method is a convenience method that * counts {@link #extraDimensions()}. * </p> * * @return the number of extra array dimensions * @since 2.1 */ public int getExtraDimensions() { // more efficient than checking getAST().API_LEVEL if (this.extraDimensions == null) { // JLS2,3,4 behavior - bona fide property return this.extraArrayDimensions; } else { return this.extraDimensions.size(); } }
/** * Returns the number of extra array dimensions over and above the * explicitly-specified type. * <p> * For example, <code>int x[][]</code> has a type of * <code>int</code> and two extra array dimensions; * <code>int[][] x</code> has a type of <code>int[][]</code> * and zero extra array dimensions. The two constructs have different * ASTs, even though there are really syntactic variants of the same * variable declaration. * </p> * <p> * In the JLS8 API, this method is a convenience method that * counts {@link #extraDimensions()}. * </p> * * @return the number of extra array dimensions * @since 2.1 */ public int getExtraDimensions() { // more efficient than checking getAST().API_LEVEL if (this.extraDimensions == null) { // JLS2,3,4 behavior - bona fide property return this.extraArrayDimensions; } else { return this.extraDimensions.size(); } }
/** * Accepts the given visitor on a visit of the given live list of * child nodes. * <p> * This method must be used by the concrete implementations of * <code>accept</code> to traverse list-values properties; it * encapsulates the proper handling of on-the-fly changes to the list. * </p> * * @param visitor the visitor object * @param children the child AST node to dispatch too, or <code>null</code> * if none */ final void acceptChildren(ASTVisitor visitor, ASTNode.NodeList children) { // use a cursor to keep track of where we are up to // (the list may be changing under foot) NodeList.Cursor cursor = children.newCursor(); try { while (cursor.hasNext()) { ASTNode child = (ASTNode) cursor.next(); child.accept(visitor); } } finally { children.releaseCursor(cursor); } }
/** * Accepts the given visitor on a visit of the given live list of * child nodes. * <p> * This method must be used by the concrete implementations of * <code>accept</code> to traverse list-values properties; it * encapsulates the proper handling of on-the-fly changes to the list. * </p> * * @param visitor the visitor object * @param children the child AST node to dispatch too, or <code>null</code> * if none */ final void acceptChildren(ASTVisitor visitor, ASTNode.NodeList children) { // use a cursor to keep track of where we are up to // (the list may be changing under foot) NodeList.Cursor cursor = children.newCursor(); try { while (cursor.hasNext()) { ASTNode child = (ASTNode) cursor.next(); child.accept(visitor); } } finally { children.releaseCursor(cursor); } }
/** * Returns the number of extra array dimensions over and above the * explicitly-specified type. * <p> * For example, <code>int x[][]</code> has a type of * <code>int</code> and two extra array dimensions; * <code>int[][] x</code> has a type of <code>int[][]</code> * and zero extra array dimensions. The two constructs have different * ASTs, even though there are really syntactic variants of the same * variable declaration. * </p> * <p> * In the JLS8 API, this method is a convenience method that * counts {@link #extraDimensions()}. * </p> * * @return the number of extra array dimensions * @since 2.1 */ public int getExtraDimensions() { // more efficient than checking getAST().API_LEVEL if (this.extraDimensions == null) { // JLS2,3,4 behavior - bona fide property return this.extraArrayDimensions; } else { return this.extraDimensions.size(); } }
/** * Accepts the given visitor on a visit of the given live list of * child nodes. * <p> * This method must be used by the concrete implementations of * <code>accept</code> to traverse list-values properties; it * encapsulates the proper handling of on-the-fly changes to the list. * </p> * * @param visitor the visitor object * @param children the child AST node to dispatch too, or <code>null</code> * if none */ final void acceptChildren(ASTVisitor visitor, ASTNode.NodeList children) { // use a cursor to keep track of where we are up to // (the list may be changing under foot) NodeList.Cursor cursor = children.newCursor(); try { while (cursor.hasNext()) { ASTNode child = (ASTNode) cursor.next(); child.accept(visitor); } } finally { children.releaseCursor(cursor); } }
/** * Accepts the given visitor on a visit of the given live list of * child nodes. * <p> * This method must be used by the concrete implementations of * <code>accept</code> to traverse list-values properties; it * encapsulates the proper handling of on-the-fly changes to the list. * </p> * * @param visitor the visitor object * @param children the child AST node to dispatch too, or <code>null</code> * if none */ final void acceptChildren(ASTVisitor visitor, ASTNode.NodeList children) { // use a cursor to keep track of where we are up to // (the list may be changing under foot) NodeList.Cursor cursor = children.newCursor(); try { while (cursor.hasNext()) { ASTNode child = (ASTNode) cursor.next(); child.accept(visitor); } } finally { children.releaseCursor(cursor); } }
/** * Accepts the given visitor on a visit of the given live list of * child nodes. * <p> * This method must be used by the concrete implementations of * <code>accept</code> to traverse list-values properties; it * encapsulates the proper handling of on-the-fly changes to the list. * </p> * * @param visitor the visitor object * @param children the child AST node to dispatch too, or <code>null</code> * if none */ final void acceptChildren(ASTVisitor visitor, ASTNode.NodeList children) { // use a cursor to keep track of where we are up to // (the list may be changing under foot) NodeList.Cursor cursor = children.newCursor(); try { while (cursor.hasNext()) { ASTNode child = (ASTNode) cursor.next(); child.accept(visitor); } } finally { children.releaseCursor(cursor); } }
/** * Returns an estimate of the memory footprint of this node list * instance in bytes. * <ul> * <li>1 object header for the NodeList instance</li> * <li>5 4-byte fields of the NodeList instance</li> * <li>0 for cursors since null unless walk in progress</li> * <li>1 object header for the ArrayList instance</li> * <li>2 4-byte fields of the ArrayList instance</li> * <li>1 object header for an Object[] instance</li> * <li>4 bytes in array for each element</li> * </ul> * * @return the size of this node list in bytes */ int memSize() { int result = HEADERS + 5 * 4; result += HEADERS + 2 * 4; result += HEADERS + 4 * size(); return result; }
/** * Returns an estimate of the memory footprint of this node list * instance in bytes. * <ul> * <li>1 object header for the NodeList instance</li> * <li>5 4-byte fields of the NodeList instance</li> * <li>0 for cursors since null unless walk in progress</li> * <li>1 object header for the ArrayList instance</li> * <li>2 4-byte fields of the ArrayList instance</li> * <li>1 object header for an Object[] instance</li> * <li>4 bytes in array for each element</li> * </ul> * * @return the size of this node list in bytes */ int memSize() { int result = HEADERS + 5 * 4; result += HEADERS + 2 * 4; result += HEADERS + 4 * size(); return result; }