<s> package org . eclipse . jdt . core . dom ; import java . util . AbstractList ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; import java . util . Iterator ; import java . util . List ; import java . util . Map ; import org . eclipse . jdt . internal . core . dom . NaiveASTFlattener ; public abstract class ASTNode { public static final int ANONYMOUS_CLASS_DECLARATION = 1 ; public static final int ARRAY_ACCESS = 2 ; public static final int ARRAY_CREATION = 3 ; public static final int ARRAY_INITIALIZER = 4 ; public static final int ARRAY_TYPE = 5 ; public static final int ASSERT_STATEMENT = 6 ; public static final int ASSIGNMENT = 7 ; public static final int BLOCK = 8 ; public static final int BOOLEAN_LITERAL = 9 ; public static final int BREAK_STATEMENT = 10 ; public static final int CAST_EXPRESSION = 11 ; public static final int CATCH_CLAUSE = 12 ; public static final int CHARACTER_LITERAL = 13 ; public static final int CLASS_INSTANCE_CREATION = 14 ; public static final int COMPILATION_UNIT = 15 ; public static final int CONDITIONAL_EXPRESSION = 16 ; public static final int CONSTRUCTOR_INVOCATION = 17 ; public static final int CONTINUE_STATEMENT = 18 ; public static final int DO_STATEMENT = 19 ; public static final int EMPTY_STATEMENT = 20 ; public static final int EXPRESSION_STATEMENT = 21 ; public static final int FIELD_ACCESS = 22 ; public static final int FIELD_DECLARATION = 23 ; public static final int FOR_STATEMENT = 24 ; public static final int IF_STATEMENT = 25 ; public static final int IMPORT_DECLARATION = 26 ; public static final int INFIX_EXPRESSION = 27 ; public static final int INITIALIZER = 28 ; public static final int JAVADOC = 29 ; public static final int LABELED_STATEMENT = 30 ; public static final int METHOD_DECLARATION = 31 ; public static final int METHOD_INVOCATION = 32 ; public static final int NULL_LITERAL = 33 ; public static final int NUMBER_LITERAL = 34 ; public static final int PACKAGE_DECLARATION = 35 ; public static final int PARENTHESIZED_EXPRESSION = 36 ; public static final int POSTFIX_EXPRESSION = 37 ; public static final int PREFIX_EXPRESSION = 38 ; public static final int PRIMITIVE_TYPE = 39 ; public static final int QUALIFIED_NAME = 40 ; public static final int RETURN_STATEMENT = 41 ; public static final int SIMPLE_NAME = 42 ; public static final int SIMPLE_TYPE = 43 ; public static final int SINGLE_VARIABLE_DECLARATION = 44 ; public static final int STRING_LITERAL = 45 ; public static final int SUPER_CONSTRUCTOR_INVOCATION = 46 ; public static final int SUPER_FIELD_ACCESS = 47 ; public static final int SUPER_METHOD_INVOCATION = 48 ; public static final int SWITCH_CASE = 49 ; public static final int SWITCH_STATEMENT = 50 ; public static final int SYNCHRONIZED_STATEMENT = 51 ; public static final int THIS_EXPRESSION = 52 ; public static final int THROW_STATEMENT = 53 ; public static final int TRY_STATEMENT = 54 ; public static final int TYPE_DECLARATION = 55 ; public static final int TYPE_DECLARATION_STATEMENT = 56 ; public static final int TYPE_LITERAL = 57 ; public static final int VARIABLE_DECLARATION_EXPRESSION = 58 ; public static final int VARIABLE_DECLARATION_FRAGMENT = 59 ; public static final int VARIABLE_DECLARATION_STATEMENT = 60 ; public static final int WHILE_STATEMENT = 61 ; public static final int INSTANCEOF_EXPRESSION = 62 ; public static final int LINE_COMMENT = 63 ; public static final int BLOCK_COMMENT = 64 ; public static final int TAG_ELEMENT = 65 ; public static final int TEXT_ELEMENT = 66 ; public static final int MEMBER_REF = 67 ; public static final int METHOD_REF = 68 ; public static final int METHOD_REF_PARAMETER = 69 ; public static final int ENHANCED_FOR_STATEMENT = 70 ; public static final int ENUM_DECLARATION = 71 ; public static final int ENUM_CONSTANT_DECLARATION = 72 ; public static final int TYPE_PARAMETER = 73 ; public static final int PARAMETERIZED_TYPE = 74 ; public static final int QUALIFIED_TYPE = 75 ; public static final int WILDCARD_TYPE = 76 ; public static final int NORMAL_ANNOTATION = 77 ; public static final int MARKER_ANNOTATION = 78 ; public static final int SINGLE_MEMBER_ANNOTATION = 79 ; public static final int MEMBER_VALUE_PAIR = 80 ; public static final int ANNOTATION_TYPE_DECLARATION = 81 ; public static final int ANNOTATION_TYPE_MEMBER_DECLARATION = 82 ; public static final int MODIFIER = 83 ; public static final int UNION_TYPE = 84 ; public static Class nodeClassForType ( int nodeType ) { switch ( nodeType ) { case ANNOTATION_TYPE_DECLARATION : return AnnotationTypeDeclaration . class ; case ANNOTATION_TYPE_MEMBER_DECLARATION : return AnnotationTypeMemberDeclaration . class ; case ANONYMOUS_CLASS_DECLARATION : return AnonymousClassDeclaration . class ; case ARRAY_ACCESS : return ArrayAccess . class ; case ARRAY_CREATION : return ArrayCreation . class ; case ARRAY_INITIALIZER : return ArrayInitializer . class ; case ARRAY_TYPE : return ArrayType . class ; case ASSERT_STATEMENT : return AssertStatement . class ; case ASSIGNMENT : return Assignment . class ; case BLOCK : return Block . class ; case BLOCK_COMMENT : return BlockComment . class ; case BOOLEAN_LITERAL : return BooleanLiteral . class ; case BREAK_STATEMENT : return BreakStatement . class ; case CAST_EXPRESSION : return CastExpression . class ; case CATCH_CLAUSE : return CatchClause . class ; case CHARACTER_LITERAL : return CharacterLiteral . class ; case CLASS_INSTANCE_CREATION : return ClassInstanceCreation . class ; case COMPILATION_UNIT : return CompilationUnit . class ; case CONDITIONAL_EXPRESSION : return ConditionalExpression . class ; case CONSTRUCTOR_INVOCATION : return ConstructorInvocation . class ; case CONTINUE_STATEMENT : return ContinueStatement . class ; case UNION_TYPE : return UnionType . class ; case DO_STATEMENT : return DoStatement . class ; case EMPTY_STATEMENT : return EmptyStatement . class ; case ENHANCED_FOR_STATEMENT : return EnhancedForStatement . class ; case ENUM_CONSTANT_DECLARATION : return EnumConstantDeclaration . class ; case ENUM_DECLARATION : return EnumDeclaration . class ; case EXPRESSION_STATEMENT : return ExpressionStatement . class ; case FIELD_ACCESS : return FieldAccess . class ; case FIELD_DECLARATION : return FieldDeclaration . class ; case FOR_STATEMENT : return ForStatement . class ; case IF_STATEMENT : return IfStatement . class ; case IMPORT_DECLARATION : return ImportDeclaration . class ; case INFIX_EXPRESSION : return InfixExpression . class ; case INITIALIZER : return Initializer . class ; case INSTANCEOF_EXPRESSION : return InstanceofExpression . class ; case JAVADOC : return Javadoc . class ; case LABELED_STATEMENT : return LabeledStatement . class ; case LINE_COMMENT : return LineComment . class ; case MARKER_ANNOTATION : return MarkerAnnotation . class ; case MEMBER_REF : return MemberRef . class ; case MEMBER_VALUE_PAIR : return MemberValuePair . class ; case METHOD_DECLARATION : return MethodDeclaration . class ; case METHOD_INVOCATION : return MethodInvocation . class ; case METHOD_REF : return MethodRef . class ; case METHOD_REF_PARAMETER : return MethodRefParameter . class ; case MODIFIER : return Modifier . class ; case NORMAL_ANNOTATION : return NormalAnnotation . class ; case NULL_LITERAL : return NullLiteral . class ; case NUMBER_LITERAL : return NumberLiteral . class ; case PACKAGE_DECLARATION : return PackageDeclaration . class ; case PARAMETERIZED_TYPE : return ParameterizedType . class ; case PARENTHESIZED_EXPRESSION : return ParenthesizedExpression . class ; case POSTFIX_EXPRESSION : return PostfixExpression . class ; case PREFIX_EXPRESSION : return PrefixExpression . class ; case PRIMITIVE_TYPE : return PrimitiveType . class ; case QUALIFIED_NAME : return QualifiedName . class ; case QUALIFIED_TYPE : return QualifiedType . class ; case RETURN_STATEMENT : return ReturnStatement . class ; case SIMPLE_NAME : return SimpleName . class ; case SIMPLE_TYPE : return SimpleType . class ; case SINGLE_MEMBER_ANNOTATION : return SingleMemberAnnotation . class ; case SINGLE_VARIABLE_DECLARATION : return SingleVariableDeclaration . class ; case STRING_LITERAL : return StringLiteral . class ; case SUPER_CONSTRUCTOR_INVOCATION : return SuperConstructorInvocation . class ; case SUPER_FIELD_ACCESS : return SuperFieldAccess . class ; case SUPER_METHOD_INVOCATION : return SuperMethodInvocation . class ; case SWITCH_CASE : return SwitchCase . class ; case SWITCH_STATEMENT : return SwitchStatement . class ; case SYNCHRONIZED_STATEMENT : return SynchronizedStatement . class ; case TAG_ELEMENT : return TagElement . class ; case TEXT_ELEMENT : return TextElement . class ; case THIS_EXPRESSION : return ThisExpression . class ; case THROW_STATEMENT : return ThrowStatement . class ; case TRY_STATEMENT : return TryStatement . class ; case TYPE_DECLARATION : return TypeDeclaration . class ; case TYPE_DECLARATION_STATEMENT : return TypeDeclarationStatement . class ; case TYPE_LITERAL : return TypeLiteral . class ; case TYPE_PARAMETER : return TypeParameter . class ; case VARIABLE_DECLARATION_EXPRESSION : return VariableDeclarationExpression . class ; case VARIABLE_DECLARATION_FRAGMENT : return VariableDeclarationFragment . class ; case VARIABLE_DECLARATION_STATEMENT : return VariableDeclarationStatement . class ; case WHILE_STATEMENT : return WhileStatement . class ; case WILDCARD_TYPE : return WildcardType . class ; } throw new IllegalArgumentException ( ) ; } final AST ast ; private ASTNode parent = null ; private static final Map UNMODIFIABLE_EMPTY_MAP = Collections . unmodifiableMap ( new HashMap ( 1 ) ) ; private Object property1 = null ; private Object property2 = null ; private int startPosition = - 1 ; private int length = 0 ; public static final int MALFORMED = 1 ; public static final int ORIGINAL = 2 ; public static final int PROTECT = 4 ; public static final int RECOVERED = 8 ; int typeAndFlags = 0 ; private StructuralPropertyDescriptor location = null ; static final boolean CYCLE_RISK = true ; static final boolean NO_CYCLE_RISK = false ; static final boolean MANDATORY = true ; static final boolean OPTIONAL = false ; class NodeList extends AbstractList { ArrayList store = new ArrayList ( 0 ) ; ChildListPropertyDescriptor propertyDescriptor ; class Cursor implements Iterator { private int position = 0 ; public boolean hasNext ( ) { return this . position < NodeList . this . store . size ( ) ; } public Object next ( ) { Object result = NodeList . this . store . get ( this . position ) ; this . position ++ ; return result ; } public void remove ( ) { throw new UnsupportedOperationException ( ) ; } void update ( int index , int delta ) { if ( this . position > index ) { this . position += delta ; } } } private List cursors = null ; NodeList ( ChildListPropertyDescriptor property ) { super ( ) ; this . propertyDescriptor = property ; } public int size ( ) { return this . store . size ( ) ; } public Object get ( int index ) { return this . store . get ( index ) ; } public Object set ( int index , Object element ) { if ( element == null ) { throw new IllegalArgumentException ( ) ; } if ( ( ASTNode . this . typeAndFlags & PROTECT ) != 0 ) { throw new IllegalArgumentException ( "" ) ; } ASTNode newChild = ( ASTNode ) element ; ASTNode oldChild = ( ASTNode ) this . store . get ( index ) ; if ( oldChild == newChild ) { return oldChild ; } if ( ( oldChild . typeAndFlags & PROTECT ) != 0 ) { throw new IllegalArgumentException ( "" ) ; } ASTNode . checkNewChild ( ASTNode . this , newChild , this . propertyDescriptor . cycleRisk , this . propertyDescriptor . elementType ) ; ASTNode . this . ast . preReplaceChildEvent ( ASTNode . this , oldChild , newChild , this . propertyDescriptor ) ; Object result = this . store . set ( index , newChild ) ; oldChild . setParent ( null , null ) ; newChild . setParent ( ASTNode . this , this . propertyDescriptor ) ; ASTNode . this . ast . postReplaceChildEvent ( ASTNode . this , oldChild , newChild , this . propertyDescriptor ) ; return result ; } public void add ( int index , Object element ) { if ( element == null ) { throw new IllegalArgumentException ( ) ; } if ( ( ASTNode . this . typeAndFlags & PROTECT ) != 0 ) { throw new IllegalArgumentException ( "" ) ; } ASTNode newChild = ( ASTNode ) element ; ASTNode . checkNewChild ( ASTNode . this , newChild , this . propertyDescriptor . cycleRisk , this . propertyDescriptor . elementType ) ; ASTNode . this . ast . preAddChildEvent ( ASTNode . this , newChild , this . propertyDescriptor ) ; this . store . add ( index , element ) ; updateCursors ( index , + 1 ) ; newChild . setParent ( ASTNode . this , this . propertyDescriptor ) ; ASTNode . this . ast . postAddChildEvent ( ASTNode . this , newChild , this . propertyDescriptor ) ; } public Object remove ( int index ) { if ( ( ASTNode . this . typeAndFlags & PROTECT ) != 0 ) { throw new IllegalArgumentException ( "" ) ; } ASTNode oldChild = ( ASTNode ) this . store . get ( index ) ; if ( ( oldChild . typeAndFlags & PROTECT ) != 0 ) { throw new IllegalArgumentException ( "" ) ; } ASTNode . this . ast . preRemoveChildEvent ( ASTNode . this , oldChild , this . propertyDescriptor ) ; oldChild . setParent ( null , null ) ; Object result = this . store . remove ( index ) ; updateCursors ( index , - 1 ) ; ASTNode . this . ast . postRemoveChildEvent ( ASTNode . this , oldChild , this . propertyDescriptor ) ; return result ; } Cursor newCursor ( ) { synchronized ( this ) { if ( this . cursors == null ) { this . cursors = new ArrayList ( 1 ) ; } Cursor result = new Cursor ( ) ; this . cursors . add ( result ) ; return result ; } } void releaseCursor ( Cursor cursor ) { synchronized ( this ) { this . cursors . remove ( cursor ) ; if ( this . cursors . isEmpty ( ) ) { this . cursors = null ; } } } private synchronized void updateCursors ( int index , int delta ) { if ( this . cursors == null ) { return ; } for ( Iterator it = this . cursors . iterator ( ) ; it . hasNext ( ) ; ) { Cursor c = ( Cursor ) it . next ( ) ; c . update ( index , delta ) ; } } int memSize ( ) { int result = HEADERS + 5 * 4 ; result += HEADERS + 2 * 4 ; result += HEADERS + 4 * size ( ) ; return result ; } int listSize ( ) { int result = memSize ( ) ; for ( Iterator it = iterator ( ) ; it . hasNext ( ) ; ) { ASTNode child = ( ASTNode ) it . next ( ) ; result += child . treeSize ( ) ; } return result ; } } ASTNode ( AST ast ) { if ( ast == null ) { throw new IllegalArgumentException ( ) ; } this . ast = ast ; setNodeType ( getNodeType0 ( ) ) ; setFlags ( ast . getDefaultNodeFlag ( ) ) ; } public final AST getAST ( ) { return this . ast ; } public final ASTNode getParent ( ) { return this . parent ; } public final StructuralPropertyDescriptor getLocationInParent ( ) { return this . location ; } public final ASTNode getRoot ( ) { ASTNode candidate = this ; while ( true ) { ASTNode p = candidate . getParent ( ) ; if ( p == null ) { return candidate ; } candidate = p ; } } public final Object getStructuralProperty ( StructuralPropertyDescriptor property ) { if ( property instanceof SimplePropertyDescriptor ) { SimplePropertyDescriptor p = ( SimplePropertyDescriptor ) property ; if ( p . getValueType ( ) == int . class ) { int result = internalGetSetIntProperty ( p , true , 0 ) ; return new Integer ( result ) ; } else if ( p . getValueType ( ) == boolean . class ) { boolean result = internalGetSetBooleanProperty ( p , true , false ) ; return Boolean . valueOf ( result ) ; } else { return internalGetSetObjectProperty ( p , true , null ) ; } } if ( property instanceof ChildPropertyDescriptor ) { return internalGetSetChildProperty ( ( ChildPropertyDescriptor ) property , true , null ) ; } if ( property instanceof ChildListPropertyDescriptor ) { return internalGetChildListProperty ( ( ChildListPropertyDescriptor ) property ) ; } throw new IllegalArgumentException ( ) ; } public final void setStructuralProperty ( StructuralPropertyDescriptor property , Object value ) { if ( property instanceof SimplePropertyDescriptor ) { SimplePropertyDescriptor p = ( SimplePropertyDescriptor ) property ; if ( p . getValueType ( ) == int . class ) { int arg = ( ( Integer ) value ) . intValue ( ) ; internalGetSetIntProperty ( p , false , arg ) ; return ; } else if ( p . getValueType ( ) == boolean . class ) { boolean arg = ( ( Boolean ) value ) . booleanValue ( ) ; internalGetSetBooleanProperty ( p , false , arg ) ; return ; } else { if ( value == null && p . isMandatory ( ) ) { throw new IllegalArgumentException ( ) ; } internalGetSetObjectProperty ( p , false , value ) ; return ; } } if ( property instanceof ChildPropertyDescriptor ) { ChildPropertyDescriptor p = ( ChildPropertyDescriptor ) property ; ASTNode child = ( ASTNode ) value ; if ( child == null && p . isMandatory ( ) ) { throw new IllegalArgumentException ( ) ; } internalGetSetChildProperty ( p , false , child ) ; return ; } if ( property instanceof ChildListPropertyDescriptor ) { throw new IllegalArgumentException ( "" ) ; } } int internalGetSetIntProperty ( SimplePropertyDescriptor property , boolean get , int value ) { throw new RuntimeException ( "" ) ; } boolean internalGetSetBooleanProperty ( SimplePropertyDescriptor property , boolean get , boolean value ) { throw new RuntimeException ( "" ) ; } Object internalGetSetObjectProperty ( SimplePropertyDescriptor property , boolean get , Object value ) { throw new RuntimeException ( "" ) ; } ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { throw new RuntimeException ( "" ) ; } List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { throw new RuntimeException ( "" ) ; } public final List structuralPropertiesForType ( ) { return internalStructuralPropertiesForType ( this . ast . apiLevel ) ; } abstract List internalStructuralPropertiesForType ( int apiLevel ) ; static void createPropertyList ( Class nodeClass , List propertyList ) { propertyList . add ( nodeClass ) ; } static void addProperty ( StructuralPropertyDescriptor property , List propertyList ) { Class nodeClass = ( Class ) propertyList . get ( 0 ) ; if ( property . getNodeClass ( ) != nodeClass ) { throw new RuntimeException ( "" ) ; } propertyList . add ( property ) ; } static List reapPropertyList ( List propertyList ) { propertyList . remove ( 0 ) ; ArrayList a = new ArrayList ( propertyList . size ( ) ) ; a . addAll ( propertyList ) ; return Collections . unmodifiableList ( a ) ; } final void unsupportedIn2 ( ) { if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { throw new UnsupportedOperationException ( "" ) ; } } final void unsupportedIn2_3 ( ) { if ( this . ast . apiLevel <= AST . JLS3 ) { throw new UnsupportedOperationException ( "" ) ; } } final void supportedOnlyIn2 ( ) { if ( this . ast . apiLevel != AST . JLS2_INTERNAL ) { throw new UnsupportedOperationException ( "" ) ; } } final void setParent ( ASTNode parent , StructuralPropertyDescriptor property ) { this . ast . modifying ( ) ; this . parent = parent ; this . location = property ; } public final void delete ( ) { StructuralPropertyDescriptor p = getLocationInParent ( ) ; if ( p == null ) { return ; } if ( p . isChildProperty ( ) ) { getParent ( ) . setStructuralProperty ( this . location , null ) ; return ; } if ( p . isChildListProperty ( ) ) { List l = ( List ) getParent ( ) . getStructuralProperty ( this . location ) ; l . remove ( this ) ; } } static void checkNewChild ( ASTNode node , ASTNode newChild , boolean cycleCheck , Class nodeType ) { if ( newChild . ast != node . ast ) { throw new IllegalArgumentException ( ) ; } if ( newChild . getParent ( ) != null ) { throw new IllegalArgumentException ( ) ; } if ( cycleCheck && newChild == node . getRoot ( ) ) { throw new IllegalArgumentException ( ) ; } Class childClass = newChild . getClass ( ) ; if ( nodeType != null && ! nodeType . isAssignableFrom ( childClass ) ) { throw new ClassCastException ( ) ; } if ( ( newChild . typeAndFlags & PROTECT ) != 0 ) { throw new IllegalArgumentException ( "" ) ; } } final void preReplaceChild ( ASTNode oldChild , ASTNode newChild , ChildPropertyDescriptor property ) { if ( ( this . typeAndFlags & PROTECT ) != 0 ) { throw new IllegalArgumentException ( "" ) ; } if ( newChild != null ) { checkNewChild ( this , newChild , property . cycleRisk , null ) ; } if ( oldChild != null ) { if ( ( oldChild . typeAndFlags & PROTECT ) != 0 ) { throw new IllegalArgumentException ( "" ) ; } if ( newChild != null ) { this . ast . preReplaceChildEvent ( this , oldChild , newChild , property ) ; } else { this . ast . preRemoveChildEvent ( this , oldChild , property ) ; } oldChild . setParent ( null , null ) ; } else { if ( newChild != null ) { this . ast . preAddChildEvent ( this , newChild , property ) ; } } if ( newChild != null ) { newChild . setParent ( this , property ) ; } } final void postReplaceChild ( ASTNode oldChild , ASTNode newChild , ChildPropertyDescriptor property ) { if ( newChild != null ) { if ( oldChild != null ) { this . ast . postReplaceChildEvent ( this , oldChild , newChild , property ) ; } else { this . ast . postAddChildEvent ( this , newChild , property ) ; } } else { this . ast . postRemoveChildEvent ( this , oldChild , property ) ; } } final void preValueChange ( SimplePropertyDescriptor property ) { if ( ( this . typeAndFlags & PROTECT ) != 0 ) { throw new IllegalArgumentException ( "" ) ; } this . ast . preValueChangeEvent ( this , property ) ; this . ast . modifying ( ) ; } final void postValueChange ( SimplePropertyDescriptor property ) { this . ast . postValueChangeEvent ( this , property ) ; } final void checkModifiable ( ) { if ( ( this . typeAndFlags & PROTECT ) != 0 ) { throw new IllegalArgumentException ( "" ) ; } this . ast . modifying ( ) ; } final void preLazyInit ( ) { this . ast . disableEvents ( ) ; } final void postLazyInit ( ASTNode newChild , ChildPropertyDescriptor property ) { newChild . setParent ( this , property ) ; this . ast . reenableEvents ( ) ; } public final Object getProperty ( String propertyName ) { if ( propertyName == null ) { throw new IllegalArgumentException ( ) ; } if ( this . property1 == null ) { return null ; } if ( this . property1 instanceof String ) { if ( propertyName . equals ( this . property1 ) ) { return this . property2 ; } else { return null ; } } Map m = ( Map ) this . property1 ; return m . get ( propertyName ) ; } public final void setProperty ( String propertyName , Object data ) { if ( propertyName == null ) { throw new IllegalArgumentException ( ) ; } if ( this . property1 == null ) { if ( data == null ) { return ; } this . property1 = propertyName ; this . property2 = data ; return ; } if ( this . property1 instanceof String ) { if ( propertyName . equals ( this . property1 ) ) { if ( data == null ) { this . property1 = null ; this . property2 = null ; } else { this . property2 = data ; } return ; } if ( data == null ) { return ; } Map m = new HashMap ( 3 ) ; m . put ( this . property1 , this . property2 ) ; m . put ( propertyName , data ) ; this . property1 = m ; this . property2 = null ; return ; } Map m = ( Map ) this . property1 ; if ( data == null ) { m . remove ( propertyName ) ; if ( m . size ( ) == 1 ) { Map . Entry [ ] entries = ( Map . Entry [ ] ) m . entrySet ( ) . toArray ( new Map . Entry [ 1 ] ) ; this . property1 = entries [ 0 ] . getKey ( ) ; this . property2 = entries [ 0 ] . getValue ( ) ; } return ; } else { m . put ( propertyName , data ) ; return ; } } public final Map properties ( ) { if ( this . property1 == null ) { return UNMODIFIABLE_EMPTY_MAP ; } if ( this . property1 instanceof String ) { return Collections . singletonMap ( this . property1 , this . property2 ) ; } if ( this . property2 == null ) { this . property2 = Collections . unmodifiableMap ( ( Map ) this . property1 ) ; } return ( Map ) this . property2 ; } public final int getFlags ( ) { return this . typeAndFlags & 0xFFFF ; } public final void setFlags ( int flags ) { this . ast . modifying ( ) ; int old = this . typeAndFlags & 0xFFFF0000 ; this . typeAndFlags = old | ( flags & 0xFFFF ) ; } public final int getNodeType ( ) { return this . typeAndFlags >>> 16 ; } private void setNodeType ( int nodeType ) { int old = this . typeAndFlags & 0xFFFF0000 ; this . typeAndFlags = old | ( nodeType << 16 ) ; } abstract int getNodeType0 ( ) ; public final boolean equals ( Object obj ) { return this == obj ; } public final int hashCode ( ) { return super . hashCode ( ) ; } public final boolean subtreeMatch ( ASTMatcher matcher , Object other ) { return subtreeMatch0 ( matcher , other ) ; } abstract boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) ; public static ASTNode copySubtree ( AST target , ASTNode node ) { if ( node == null ) { return null ; } if ( target == null ) { throw new IllegalArgumentException ( ) ; } if ( target . apiLevel ( ) != node . getAST ( ) . apiLevel ( ) ) { throw new UnsupportedOperationException ( ) ; } ASTNode newNode = node . clone ( target ) ; return newNode ; } public static List copySubtrees ( AST target , List nodes ) { List result = new ArrayList ( nodes . size ( ) ) ; for ( Iterator it = nodes . iterator ( ) ; it . hasNext ( ) ; ) { ASTNode oldNode = ( ASTNode ) it . next ( ) ; ASTNode newNode = oldNode . clone ( target ) ; result . add ( newNode ) ; } return result ; } final ASTNode clone ( AST target ) { this . ast . preCloneNodeEvent ( this ) ; ASTNode c = clone0 ( target ) ; this . ast . postCloneNodeEvent ( this , c ) ; return c ; } abstract ASTNode clone0 ( AST target ) ; public final void accept ( ASTVisitor visitor ) { if ( visitor == null ) { throw new IllegalArgumentException ( ) ; } if ( visitor . preVisit2 ( this ) ) { accept0 ( visitor ) ; } visitor . postVisit ( this ) ; } abstract void accept0 ( ASTVisitor visitor ) ; final void acceptChild ( ASTVisitor visitor , ASTNode child ) { if ( child == null ) { return ; } child . accept ( visitor ) ; } final void acceptChildren ( ASTVisitor visitor , ASTNode . NodeList children ) { NodeList . Cursor cursor = children . newCursor ( ) ; try { while ( cursor . hasNext ( ) ) { ASTNode child = ( ASTNode ) cursor . next ( ) ; child . accept ( visitor ) ; } } finally { children . releaseCursor ( cursor ) ; } } public final int getStartPosition ( ) { return this . startPosition ; } public final int getLength ( ) { return this . length ; } public final void setSourceRange ( int startPosition , int length ) { if ( startPosition >= 0 && length < 0 ) { throw new IllegalArgumentException ( ) ; } if ( startPosition < 0 && length != 0 ) { throw new IllegalArgumentException ( ) ; } checkModifiable ( ) ; this . startPosition = startPosition ; this . length = length ; } public final String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; int p = buffer . length ( ) ; try { appendDebugString ( buffer ) ; } catch ( RuntimeException e ) { buffer . setLength ( p ) ; buffer . append ( "!" ) ; buffer . append ( standardToString ( ) ) ; } return buffer . toString ( ) ; } final String standardToString ( ) { return super . toString ( ) ; } void appendDebugString ( StringBuffer buffer ) { appendPrintString ( buffer ) ; } final void appendPrintString ( StringBuffer buffer ) { NaiveASTFlattener printer = new NaiveASTFlattener ( ) ; accept ( printer ) ; buffer . append ( printer . getResult ( ) ) ; } static final int HEADERS = 12 ; static final int BASE_NODE_SIZE = HEADERS + 7 * 4 ; static int stringSize ( String string ) { int size = 0 ; if ( string != null ) { size += HEADERS + 4 * 4 ; size += HEADERS + 2 * string . length ( ) ; } return size ; } public final int subtreeBytes ( ) { return treeSize ( ) ; } abstract int treeSize ( ) ; abstract int memSize ( ) ; } </s>