<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class MethodDeclaration extends BodyDeclaration { public static final ChildPropertyDescriptor JAVADOC_PROPERTY = internalJavadocPropertyFactory ( MethodDeclaration . class ) ; public static final SimplePropertyDescriptor MODIFIERS_PROPERTY = internalModifiersPropertyFactory ( MethodDeclaration . class ) ; public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = internalModifiers2PropertyFactory ( MethodDeclaration . class ) ; public static final SimplePropertyDescriptor CONSTRUCTOR_PROPERTY = new SimplePropertyDescriptor ( MethodDeclaration . class , "constructor" , boolean . class , MANDATORY ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( MethodDeclaration . class , "name" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor RETURN_TYPE_PROPERTY = new ChildPropertyDescriptor ( MethodDeclaration . class , "returnType" , Type . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor RETURN_TYPE2_PROPERTY = new ChildPropertyDescriptor ( MethodDeclaration . class , "returnType2" , Type . class , OPTIONAL , NO_CYCLE_RISK ) ; public static final SimplePropertyDescriptor EXTRA_DIMENSIONS_PROPERTY = new SimplePropertyDescriptor ( MethodDeclaration . class , "" , int . class , MANDATORY ) ; public static final ChildListPropertyDescriptor TYPE_PARAMETERS_PROPERTY = new ChildListPropertyDescriptor ( MethodDeclaration . class , "" , TypeParameter . class , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor PARAMETERS_PROPERTY = new ChildListPropertyDescriptor ( MethodDeclaration . class , "parameters" , SingleVariableDeclaration . class , CYCLE_RISK ) ; public static final ChildListPropertyDescriptor THROWN_EXCEPTIONS_PROPERTY = new ChildListPropertyDescriptor ( MethodDeclaration . class , "" , Name . class , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor BODY_PROPERTY = new ChildPropertyDescriptor ( MethodDeclaration . class , "body" , Block . class , OPTIONAL , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List propertyList = new ArrayList ( 10 ) ; createPropertyList ( MethodDeclaration . class , propertyList ) ; addProperty ( JAVADOC_PROPERTY , propertyList ) ; addProperty ( MODIFIERS_PROPERTY , propertyList ) ; addProperty ( CONSTRUCTOR_PROPERTY , propertyList ) ; addProperty ( RETURN_TYPE_PROPERTY , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; addProperty ( PARAMETERS_PROPERTY , propertyList ) ; addProperty ( EXTRA_DIMENSIONS_PROPERTY , propertyList ) ; addProperty ( THROWN_EXCEPTIONS_PROPERTY , propertyList ) ; addProperty ( BODY_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( propertyList ) ; propertyList = new ArrayList ( 11 ) ; createPropertyList ( MethodDeclaration . class , propertyList ) ; addProperty ( JAVADOC_PROPERTY , propertyList ) ; addProperty ( MODIFIERS2_PROPERTY , propertyList ) ; addProperty ( CONSTRUCTOR_PROPERTY , propertyList ) ; addProperty ( TYPE_PARAMETERS_PROPERTY , propertyList ) ; addProperty ( RETURN_TYPE2_PROPERTY , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; addProperty ( PARAMETERS_PROPERTY , propertyList ) ; addProperty ( EXTRA_DIMENSIONS_PROPERTY , propertyList ) ; addProperty ( THROWN_EXCEPTIONS_PROPERTY , propertyList ) ; addProperty ( BODY_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private boolean isConstructor = false ; private SimpleName methodName = null ; private ASTNode . NodeList parameters = new ASTNode . NodeList ( PARAMETERS_PROPERTY ) ; private Type returnType = null ; private boolean returnType2Initialized = false ; private ASTNode . NodeList typeParameters = null ; private int extraArrayDimensions = 0 ; private ASTNode . NodeList thrownExceptions = new ASTNode . NodeList ( THROWN_EXCEPTIONS_PROPERTY ) ; private Block optionalBody = null ; MethodDeclaration ( AST ast ) { super ( ast ) ; if ( ast . apiLevel >= AST . JLS3 ) { this . typeParameters = new ASTNode . NodeList ( TYPE_PARAMETERS_PROPERTY ) ; } } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final int internalGetSetIntProperty ( SimplePropertyDescriptor property , boolean get , int value ) { if ( property == MODIFIERS_PROPERTY ) { if ( get ) { return getModifiers ( ) ; } else { internalSetModifiers ( value ) ; return 0 ; } } if ( property == EXTRA_DIMENSIONS_PROPERTY ) { if ( get ) { return getExtraDimensions ( ) ; } else { setExtraDimensions ( value ) ; return 0 ; } } return super . internalGetSetIntProperty ( property , get , value ) ; } final boolean internalGetSetBooleanProperty ( SimplePropertyDescriptor property , boolean get , boolean value ) { if ( property == CONSTRUCTOR_PROPERTY ) { if ( get ) { return isConstructor ( ) ; } else { setConstructor ( value ) ; return false ; } } return super . internalGetSetBooleanProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == JAVADOC_PROPERTY ) { if ( get ) { return getJavadoc ( ) ; } else { setJavadoc ( ( Javadoc ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } if ( property == RETURN_TYPE_PROPERTY ) { if ( get ) { return getReturnType ( ) ; } else { setReturnType ( ( Type ) child ) ; return null ; } } if ( property == RETURN_TYPE2_PROPERTY ) { if ( get ) { return getReturnType2 ( ) ; } else { setReturnType2 ( ( Type ) child ) ; return null ; } } if ( property == BODY_PROPERTY ) { if ( get ) { return getBody ( ) ; } else { setBody ( ( Block ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == MODIFIERS2_PROPERTY ) { return modifiers ( ) ; } if ( property == TYPE_PARAMETERS_PROPERTY ) { return typeParameters ( ) ; } if ( property == PARAMETERS_PROPERTY ) { return parameters ( ) ; } if ( property == THROWN_EXCEPTIONS_PROPERTY ) { return thrownExceptions ( ) ; } return super . internalGetChildListProperty ( property ) ; } final ChildPropertyDescriptor internalJavadocProperty ( ) { return JAVADOC_PROPERTY ; } final ChildListPropertyDescriptor internalModifiers2Property ( ) { return MODIFIERS2_PROPERTY ; } final SimplePropertyDescriptor internalModifiersProperty ( ) { return MODIFIERS_PROPERTY ; } final int getNodeType0 ( ) { return METHOD_DECLARATION ; } ASTNode clone0 ( AST target ) { MethodDeclaration result = new MethodDeclaration ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setJavadoc ( ( Javadoc ) ASTNode . copySubtree ( target , getJavadoc ( ) ) ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { result . internalSetModifiers ( getModifiers ( ) ) ; result . setReturnType ( ( Type ) ASTNode . copySubtree ( target , getReturnType ( ) ) ) ; } if ( this . ast . apiLevel >= AST . JLS3 ) { result . modifiers ( ) . addAll ( ASTNode . copySubtrees ( target , modifiers ( ) ) ) ; result . typeParameters ( ) . addAll ( ASTNode . copySubtrees ( target , typeParameters ( ) ) ) ; result . setReturnType2 ( ( Type ) ASTNode . copySubtree ( target , getReturnType2 ( ) ) ) ; } result . setConstructor ( isConstructor ( ) ) ; result . setExtraDimensions ( getExtraDimensions ( ) ) ; result . setName ( ( SimpleName ) getName ( ) . clone ( target ) ) ; result . parameters ( ) . addAll ( ASTNode . copySubtrees ( target , parameters ( ) ) ) ; result . thrownExceptions ( ) . addAll ( ASTNode . copySubtrees ( target , thrownExceptions ( ) ) ) ; result . setBody ( ( Block ) ASTNode . copySubtree ( target , getBody ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getJavadoc ( ) ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { acceptChild ( visitor , getReturnType ( ) ) ; } else { acceptChildren ( visitor , this . modifiers ) ; acceptChildren ( visitor , this . typeParameters ) ; acceptChild ( visitor , getReturnType2 ( ) ) ; } acceptChild ( visitor , getName ( ) ) ; acceptChildren ( visitor , this . parameters ) ; acceptChildren ( visitor , this . thrownExceptions ) ; acceptChild ( visitor , getBody ( ) ) ; } visitor . endVisit ( this ) ; } public boolean isConstructor ( ) { return this . isConstructor ; } public void setConstructor ( boolean isConstructor ) { preValueChange ( CONSTRUCTOR_PROPERTY ) ; this . isConstructor = isConstructor ; postValueChange ( CONSTRUCTOR_PROPERTY ) ; } public List typeParameters ( ) { if ( this . typeParameters == null ) { unsupportedIn2 ( ) ; } return this . typeParameters ; } public SimpleName getName ( ) { if ( this . methodName == null ) { synchronized ( this ) { if ( this . methodName == null ) { preLazyInit ( ) ; this . methodName = new SimpleName ( this . ast ) ; postLazyInit ( this . methodName , NAME_PROPERTY ) ; } } } return this . methodName ; } public void setName ( SimpleName methodName ) { if ( methodName == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . methodName ; preReplaceChild ( oldChild , methodName , NAME_PROPERTY ) ; this . methodName = methodName ; postReplaceChild ( oldChild , methodName , NAME_PROPERTY ) ; } public List parameters ( ) { return this . parameters ; } public boolean isVarargs ( ) { if ( this . modifiers == null ) { unsupportedIn2 ( ) ; } if ( parameters ( ) . isEmpty ( ) ) { return false ; } else { SingleVariableDeclaration v = ( SingleVariableDeclaration ) parameters ( ) . get ( parameters ( ) . size ( ) - 1 ) ; return v . isVarargs ( ) ; } } public List thrownExceptions ( ) { return this . thrownExceptions ; } public Type getReturnType ( ) { return internalGetReturnType ( ) ; } final Type internalGetReturnType ( ) { supportedOnlyIn2 ( ) ; if ( this . returnType == null ) { synchronized ( this ) { if ( this . returnType == null ) { preLazyInit ( ) ; this . returnType = this . ast . newPrimitiveType ( PrimitiveType . VOID ) ; postLazyInit ( this . returnType , RETURN_TYPE_PROPERTY ) ; } } } return this . returnType ; } public void setReturnType ( Type type ) { internalSetReturnType ( type ) ; } void internalSetReturnType ( Type type ) { supportedOnlyIn2 ( ) ; if ( type == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . returnType ; preReplaceChild ( oldChild , type , RETURN_TYPE_PROPERTY ) ; this . returnType = type ; postReplaceChild ( oldChild , type , RETURN_TYPE_PROPERTY ) ; } public Type getReturnType2 ( ) { unsupportedIn2 ( ) ; if ( this . returnType == null && ! this . returnType2Initialized ) { synchronized ( this ) { if ( this . returnType == null && ! this . returnType2Initialized ) { preLazyInit ( ) ; this . returnType = this . ast . newPrimitiveType ( PrimitiveType . VOID ) ; this . returnType2Initialized = true ; postLazyInit ( this . returnType , RETURN_TYPE2_PROPERTY ) ; } } } return this . returnType ; } public void setReturnType2 ( Type type ) { unsupportedIn2 ( ) ; this . returnType2Initialized = true ; ASTNode oldChild = this . returnType ; preReplaceChild ( oldChild , type , RETURN_TYPE2_PROPERTY ) ; this . returnType = type ; postReplaceChild ( oldChild , type , RETURN_TYPE2_PROPERTY ) ; } public int getExtraDimensions ( ) { return this . extraArrayDimensions ; } public void setExtraDimensions ( int dimensions ) { if ( dimensions < 0 ) { throw new IllegalArgumentException ( ) ; } preValueChange ( EXTRA_DIMENSIONS_PROPERTY ) ; this . extraArrayDimensions = dimensions ; postValueChange ( EXTRA_DIMENSIONS_PROPERTY ) ; } public Block getBody ( ) { return this . optionalBody ; } public void setBody ( Block body ) { ASTNode oldChild = this . optionalBody ; preReplaceChild ( oldChild , body , BODY_PROPERTY ) ; this . optionalBody = body ; postReplaceChild ( oldChild , body , BODY_PROPERTY ) ; } public IMethodBinding resolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveMethod ( this ) ; } int memSize ( ) { return super . memSize ( ) + 9 * 4 ; } int treeSize ( ) { return memSize ( ) + ( this . optionalDocComment == null ? 0 : getJavadoc ( ) . treeSize ( ) ) + ( this . modifiers == null ? 0 : this . modifiers . listSize ( ) ) + ( this . typeParameters == null ? 0 : this . typeParameters . listSize ( ) ) + ( this . methodName == null ? 0 : getName ( ) . treeSize ( ) ) + ( this . returnType == null ? 0 : this . returnType . treeSize ( ) ) + this . parameters . listSize ( ) + this . thrownExceptions . listSize ( ) + ( this . optionalBody == null ? 0 : getBody ( ) . treeSize ( ) ) ; } } </s>