1 /*******************************************************************************
 
   2  * Copyright (c) 2000, 2008 IBM Corporation and others.
 
   3  * All rights reserved. This program and the accompanying materials
 
   4  * are made available under the terms of the Eclipse Public License v1.0
 
   5  * which accompanies this distribution, and is available at
 
   6  * http://www.eclipse.org/legal/epl-v10.html
 
   9  *     IBM Corporation - initial API and implementation
 
  10  *******************************************************************************/
 
  12 package net.sourceforge.phpdt.core.dom;
 
  14 import java.util.ArrayList;
 
  15 import java.util.Iterator;
 
  16 import java.util.List;
 
  19  * Type declaration AST node type. A type declaration
 
  20  * is the union of a class declaration and an interface declaration.
 
  25  *              InterfaceDeclaration
 
  27  *      [ Javadoc ] { Modifier } <b>class</b> Identifier
 
  28  *                      [ <b>extends</b> Type]
 
  29  *                      [ <b>implements</b> Type { <b>,</b> Type } ]
 
  30  *                      <b>{</b> { ClassBodyDeclaration | <b>;</b> } <b>}</b>
 
  31  * InterfaceDeclaration:
 
  32  *      [ Javadoc ] { Modifier } <b>interface</b> Identifier
 
  33  *                      [ <b>extends</b> Type { <b>,</b> Type } ]
 
  34  *                      <b>{</b> { InterfaceBodyDeclaration | <b>;</b> } <b>}</b>
 
  36  * For JLS3, type parameters and reified modifiers
 
  37  * (and annotations) were added, and the superclass type name and superinterface 
 
  38  * types names are generalized to type so that parameterized types can be 
 
  43  *              InterfaceDeclaration
 
  45  *      [ Javadoc ] { ExtendedModifier } <b>class</b> Identifier
 
  46  *                      [ <b><</b> TypeParameter { <b>,</b> TypeParameter } <b>></b> ]
 
  47  *                      [ <b>extends</b> Type ]
 
  48  *                      [ <b>implements</b> Type { <b>,</b> Type } ]
 
  49  *                      <b>{</b> { ClassBodyDeclaration | <b>;</b> } <b>}</b>
 
  50  * InterfaceDeclaration:
 
  51  *      [ Javadoc ] { ExtendedModifier } <b>interface</b> Identifier
 
  52  *                      [ <b><</b> TypeParameter { <b>,</b> TypeParameter } <b>></b> ]
 
  53  *                      [ <b>extends</b> Type { <b>,</b> Type } ]
 
  54  *                      <b>{</b> { InterfaceBodyDeclaration | <b>;</b> } <b>}</b>
 
  57  * When a Javadoc comment is present, the source
 
  58  * range begins with the first character of the "/**" comment delimiter.
 
  59  * When there is no Javadoc comment, the source range begins with the first
 
  60  * character of the first modifier or annotation (if any), or the
 
  61  * first character of the "class" or "interface" keyword (if no
 
  62  * modifiers or annotations). The source range extends through the last character of the "}"
 
  63  * token following the body declarations.
 
  67  * @noinstantiate This class is not intended to be instantiated by clients.
 
  69 public class TypeDeclaration extends AbstractTypeDeclaration {
 
  72          * The "javadoc" structural property of this node type.
 
  75         public static final ChildPropertyDescriptor JAVADOC_PROPERTY = 
 
  76                 internalJavadocPropertyFactory(TypeDeclaration.class);
 
  79          * The "modifiers" structural property of this node type (JLS2 API only).
 
  82         public static final SimplePropertyDescriptor MODIFIERS_PROPERTY = 
 
  83                 internalModifiersPropertyFactory(TypeDeclaration.class);
 
  86          * The "modifiers" structural property of this node type (added in JLS3 API).
 
  89         public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = 
 
  90                 internalModifiers2PropertyFactory(TypeDeclaration.class);
 
  93          * The "interface" structural property of this node type.
 
  96         public static final SimplePropertyDescriptor INTERFACE_PROPERTY = 
 
  97                 new SimplePropertyDescriptor(TypeDeclaration.class, "interface", boolean.class, MANDATORY); //$NON-NLS-1$
 
 100          * The "name" structural property of this node type.
 
 103         public static final ChildPropertyDescriptor NAME_PROPERTY =
 
 104                 internalNamePropertyFactory(TypeDeclaration.class);
 
 107          * The "superclass" structural property of this node type (JLS2 API only).
 
 110         public static final ChildPropertyDescriptor SUPERCLASS_PROPERTY = 
 
 111                 new ChildPropertyDescriptor(TypeDeclaration.class, "superclass", Name.class, OPTIONAL, NO_CYCLE_RISK); //$NON-NLS-1$
 
 114          * The "superInterfaces" structural property of this node type (JLS2 API only).
 
 117         public static final ChildListPropertyDescriptor SUPER_INTERFACES_PROPERTY = 
 
 118                 new ChildListPropertyDescriptor(TypeDeclaration.class, "superInterfaces", Name.class, NO_CYCLE_RISK); //$NON-NLS-1$
 
 121          * The "superclassType" structural property of this node type (added in JLS3 API).
 
 124         public static final ChildPropertyDescriptor SUPERCLASS_TYPE_PROPERTY = 
 
 125                 new ChildPropertyDescriptor(TypeDeclaration.class, "superclassType", Type.class, OPTIONAL, NO_CYCLE_RISK); //$NON-NLS-1$
 
 128          * The "superInterfaceTypes" structural property of this node type (added in JLS3 API).
 
 131         public static final ChildListPropertyDescriptor SUPER_INTERFACE_TYPES_PROPERTY = 
 
 132                 new ChildListPropertyDescriptor(TypeDeclaration.class, "superInterfaceTypes", Type.class, NO_CYCLE_RISK); //$NON-NLS-1$
 
 135          * The "typeParameters" structural property of this node type (added in JLS3 API).
 
 138         public static final ChildListPropertyDescriptor TYPE_PARAMETERS_PROPERTY = 
 
 139                 new ChildListPropertyDescriptor(TypeDeclaration.class, "typeParameters", TypeParameter.class, NO_CYCLE_RISK); //$NON-NLS-1$
 
 142          * The "bodyDeclarations" structural property of this node type (added in JLS3 API).
 
 145         public static final ChildListPropertyDescriptor BODY_DECLARATIONS_PROPERTY = 
 
 146                 internalBodyDeclarationPropertyFactory(TypeDeclaration.class);
 
 149          * A list of property descriptors (element type: 
 
 150          * {@link StructuralPropertyDescriptor}),
 
 151          * or null if uninitialized.
 
 154         private static final List PROPERTY_DESCRIPTORS_2_0;
 
 157          * A list of property descriptors (element type: 
 
 158          * {@link StructuralPropertyDescriptor}),
 
 159          * or null if uninitialized.
 
 162         private static final List PROPERTY_DESCRIPTORS_3_0;
 
 165                 List propertyList = new ArrayList(8);
 
 166                 createPropertyList(TypeDeclaration.class, propertyList);
 
 167                 addProperty(JAVADOC_PROPERTY, propertyList);
 
 168                 addProperty(MODIFIERS_PROPERTY, propertyList);
 
 169                 addProperty(INTERFACE_PROPERTY, propertyList);
 
 170                 addProperty(NAME_PROPERTY, propertyList);
 
 171                 addProperty(SUPERCLASS_PROPERTY, propertyList);
 
 172                 addProperty(SUPER_INTERFACES_PROPERTY, propertyList);
 
 173                 addProperty(BODY_DECLARATIONS_PROPERTY, propertyList);
 
 174                 PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList);
 
 176                 propertyList = new ArrayList(9);
 
 177                 createPropertyList(TypeDeclaration.class, propertyList);
 
 178                 addProperty(JAVADOC_PROPERTY, propertyList);
 
 179                 addProperty(MODIFIERS2_PROPERTY, propertyList);
 
 180                 addProperty(INTERFACE_PROPERTY, propertyList);
 
 181                 addProperty(NAME_PROPERTY, propertyList);
 
 182                 addProperty(TYPE_PARAMETERS_PROPERTY, propertyList);
 
 183                 addProperty(SUPERCLASS_TYPE_PROPERTY, propertyList);
 
 184                 addProperty(SUPER_INTERFACE_TYPES_PROPERTY, propertyList);
 
 185                 addProperty(BODY_DECLARATIONS_PROPERTY, propertyList);
 
 186                 PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList);
 
 190          * Returns a list of structural property descriptors for this node type.
 
 191          * Clients must not modify the result.
 
 193          * @param apiLevel the API level; one of the
 
 194          * <code>AST.JLS*</code> constants
 
 196          * @return a list of property descriptors (element type: 
 
 197          * {@link StructuralPropertyDescriptor})
 
 200         public static List propertyDescriptors(int apiLevel) {
 
 201                 if (apiLevel == AST.JLS2_INTERNAL) {
 
 202                         return PROPERTY_DESCRIPTORS_2_0;
 
 204                         return PROPERTY_DESCRIPTORS_3_0;
 
 209          * <code>true</code> for an interface, <code>false</code> for a class.
 
 212         private boolean isInterface = false;
 
 215          * The type paramters (element type: <code>TypeParameter</code>). 
 
 216          * Null in JLS2. Added in JLS3; defaults to an empty list
 
 220         private ASTNode.NodeList typeParameters = null;
 
 223          * The optional superclass name; <code>null</code> if none.
 
 224          * Defaults to none. Note that this field is not used for
 
 225          * interface declarations. Not used in 3.0.
 
 227         private Name optionalSuperclassName = null;
 
 230          * The superinterface names (element type: <code>Name</code>). 
 
 231          * JLS2 only; defaults to an empty list. Not used in JLS3.
 
 235         private ASTNode.NodeList superInterfaceNames = null;
 
 238          * The optional superclass type; <code>null</code> if none.
 
 239          * Defaults to none. Note that this field is not used for
 
 240          * interface declarations. Null in JLS2. Added in JLS3.
 
 243         private Type optionalSuperclassType = null;
 
 246          * The superinterface types (element type: <code>Type</code>). 
 
 247          * Null in JLS2. Added in JLS3; defaults to an empty list
 
 251         private ASTNode.NodeList superInterfaceTypes = null;
 
 254          * Creates a new AST node for a type declaration owned by the given 
 
 255          * AST. By default, the type declaration is for a class of an
 
 256          * unspecified, but legal, name; no modifiers; no javadoc; 
 
 257          * no type parameters; no superclass or superinterfaces; and an empty list
 
 258          * of body declarations.
 
 260          * N.B. This constructor is package-private; all subclasses must be 
 
 261          * declared in the same package; clients are unable to declare 
 
 262          * additional subclasses.
 
 265          * @param ast the AST that is to own this node
 
 267         TypeDeclaration(AST ast) {
 
 269                 if (ast.apiLevel == AST.JLS2_INTERNAL) {
 
 270                         this.superInterfaceNames = new ASTNode.NodeList(SUPER_INTERFACES_PROPERTY);
 
 272                 if (ast.apiLevel >= AST.JLS3) {
 
 273                         this.typeParameters = new ASTNode.NodeList(TYPE_PARAMETERS_PROPERTY);
 
 274                         this.superInterfaceTypes = new ASTNode.NodeList(SUPER_INTERFACE_TYPES_PROPERTY);
 
 278         /* (omit javadoc for this method)
 
 279          * Method declared on ASTNode.
 
 282         final List internalStructuralPropertiesForType(int apiLevel) {
 
 283                 return propertyDescriptors(apiLevel);
 
 286         /* (omit javadoc for this method)
 
 287          * Method declared on ASTNode.
 
 289         final int internalGetSetIntProperty(SimplePropertyDescriptor property, boolean get, int value) {
 
 290                 if (property == MODIFIERS_PROPERTY) {
 
 292                                 return getModifiers();
 
 294                                 internalSetModifiers(value);
 
 298                 // allow default implementation to flag the error
 
 299                 return super.internalGetSetIntProperty(property, get, value);
 
 302         /* (omit javadoc for this method)
 
 303          * Method declared on ASTNode.
 
 305         final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean value) {
 
 306                 if (property == INTERFACE_PROPERTY) {
 
 308                                 return isInterface();
 
 314                 // allow default implementation to flag the error
 
 315                 return super.internalGetSetBooleanProperty(property, get, value);
 
 318         /* (omit javadoc for this method)
 
 319          * Method declared on ASTNode.
 
 321         final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
 
 322                 if (property == JAVADOC_PROPERTY) {
 
 326                                 setJavadoc((Javadoc) child);
 
 330                 if (property == NAME_PROPERTY) {
 
 334                                 setName((SimpleName) child);
 
 338                 if (property == SUPERCLASS_PROPERTY) {
 
 340                                 return getSuperclass();
 
 342                                 setSuperclass((Name) child);
 
 346                 if (property == SUPERCLASS_TYPE_PROPERTY) {
 
 348                                 return getSuperclassType();
 
 350                                 setSuperclassType((Type) child);
 
 354                 // allow default implementation to flag the error
 
 355                 return super.internalGetSetChildProperty(property, get, child);
 
 358         /* (omit javadoc for this method)
 
 359          * Method declared on ASTNode.
 
 361         final List internalGetChildListProperty(ChildListPropertyDescriptor property) {
 
 362                 if (property == MODIFIERS2_PROPERTY) {
 
 365                 if (property == TYPE_PARAMETERS_PROPERTY) {
 
 366                         return typeParameters();
 
 368                 if (property == SUPER_INTERFACES_PROPERTY) {
 
 369                         return superInterfaces();
 
 371                 if (property == SUPER_INTERFACE_TYPES_PROPERTY) {
 
 372                         return superInterfaceTypes();
 
 374                 if (property == BODY_DECLARATIONS_PROPERTY) {
 
 375                         return bodyDeclarations();
 
 377                 // allow default implementation to flag the error
 
 378                 return super.internalGetChildListProperty(property);
 
 381         /* (omit javadoc for this method)
 
 382          * Method declared on BodyDeclaration.
 
 384         final ChildPropertyDescriptor internalJavadocProperty() {
 
 385                 return JAVADOC_PROPERTY;
 
 388         /* (omit javadoc for this method)
 
 389          * Method declared on BodyDeclaration.
 
 391         final ChildListPropertyDescriptor internalModifiers2Property() {
 
 392                 return MODIFIERS2_PROPERTY;
 
 395         /* (omit javadoc for this method)
 
 396          * Method declared on BodyDeclaration.
 
 398         final SimplePropertyDescriptor internalModifiersProperty() {
 
 399                 return MODIFIERS_PROPERTY;
 
 402         /* (omit javadoc for this method)
 
 403          * Method declared on AbstractTypeDeclaration.
 
 405         final ChildPropertyDescriptor internalNameProperty() {
 
 406                 return NAME_PROPERTY;
 
 409         /* (omit javadoc for this method)
 
 410          * Method declared on AbstractTypeDeclaration.
 
 412         final ChildListPropertyDescriptor internalBodyDeclarationsProperty() {
 
 413                 return BODY_DECLARATIONS_PROPERTY;
 
 417         /* (omit javadoc for this method)
 
 418          * Method declared on ASTNode.
 
 420         final int getNodeType0() {
 
 421                 return TYPE_DECLARATION;
 
 424         /* (omit javadoc for this method)
 
 425          * Method declared on ASTNode.
 
 427         ASTNode clone0(AST target) {
 
 428                 TypeDeclaration result = new TypeDeclaration(target);
 
 429                 result.setSourceRange(this.getStartPosition(), this.getLength());
 
 431                         (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
 
 432                 if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
 
 433                         result.internalSetModifiers(getModifiers());
 
 434                         result.setSuperclass(
 
 435                                         (Name) ASTNode.copySubtree(target, getSuperclass()));
 
 436                         result.superInterfaces().addAll(
 
 437                                         ASTNode.copySubtrees(target, superInterfaces()));
 
 439                 result.setInterface(isInterface());
 
 440                 result.setName((SimpleName) getName().clone(target));
 
 441                 if (this.ast.apiLevel >= AST.JLS3) {
 
 442                         result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers()));
 
 443                         result.typeParameters().addAll(
 
 444                                         ASTNode.copySubtrees(target, typeParameters()));
 
 445                         result.setSuperclassType(
 
 446                                         (Type) ASTNode.copySubtree(target, getSuperclassType()));
 
 447                         result.superInterfaceTypes().addAll(
 
 448                                         ASTNode.copySubtrees(target, superInterfaceTypes()));
 
 450                 result.bodyDeclarations().addAll(
 
 451                         ASTNode.copySubtrees(target, bodyDeclarations()));
 
 455         /* (omit javadoc for this method)
 
 456          * Method declared on ASTNode.
 
 458         final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
 
 459                 // dispatch to correct overloaded match method
 
 460                 return matcher.match(this, other);
 
 463         /* (omit javadoc for this method)
 
 464          * Method declared on ASTNode.
 
 466         void accept0(ASTVisitor visitor) {
 
 467                 boolean visitChildren = visitor.visit(this);
 
 469                         // visit children in normal left to right reading order
 
 470                         if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
 
 471                                 acceptChild(visitor, getJavadoc());
 
 472                                 acceptChild(visitor, getName());
 
 473                                 acceptChild(visitor, getSuperclass());
 
 474                                 acceptChildren(visitor, this.superInterfaceNames);
 
 475                                 acceptChildren(visitor, this.bodyDeclarations);
 
 477                         if (this.ast.apiLevel >= AST.JLS3) {
 
 478                                 acceptChild(visitor, getJavadoc());
 
 479                                 acceptChildren(visitor, this.modifiers);
 
 480                                 acceptChild(visitor, getName());
 
 481                                 acceptChildren(visitor, this.typeParameters);
 
 482                                 acceptChild(visitor, getSuperclassType());
 
 483                                 acceptChildren(visitor, this.superInterfaceTypes);
 
 484                                 acceptChildren(visitor, this.bodyDeclarations);
 
 487                 visitor.endVisit(this);
 
 491          * Returns whether this type declaration declares a class or an 
 
 494          * @return <code>true</code> if this is an interface declaration,
 
 495          *    and <code>false</code> if this is a class declaration
 
 497         public boolean isInterface() {
 
 498                 return this.isInterface;
 
 502          * Sets whether this type declaration declares a class or an 
 
 505          * @param isInterface <code>true</code> if this is an interface
 
 506          *    declaration, and <code>false</code> if this is a class
 
 509         public void setInterface(boolean isInterface) {
 
 510                 preValueChange(INTERFACE_PROPERTY);
 
 511                 this.isInterface = isInterface;
 
 512                 postValueChange(INTERFACE_PROPERTY);
 
 516          * Returns the live ordered list of type parameters of this type 
 
 517          * declaration (added in JLS3 API). This list is non-empty for parameterized types.
 
 519          * @return the live list of type parameters
 
 520          *    (element type: <code>TypeParameter</code>)
 
 521          * @exception UnsupportedOperationException if this operation is used in
 
 525         public List typeParameters() {
 
 526                 // more efficient than just calling unsupportedIn2() to check
 
 527                 if (this.typeParameters == null) {
 
 530                 return this.typeParameters;
 
 534          * Returns the name of the superclass declared in this type
 
 535          * declaration, or <code>null</code> if there is none (JLS2 API only).
 
 537          * Note that this child is not relevant for interface 
 
 538          * declarations (although it does still figure in subtree
 
 539          * equality comparisons).
 
 542          * @return the superclass name node, or <code>null</code> if 
 
 544          * @exception UnsupportedOperationException if this operation is used in
 
 545          * an AST later than JLS2
 
 546          * @deprecated In the JLS3 API, this method is replaced by
 
 547          * {@link #getSuperclassType()}, which returns a <code>Type</code>
 
 548          * instead of a <code>Name</code>.
 
 550         public Name getSuperclass() {
 
 551                 return internalGetSuperclass();
 
 555          * Internal synonym for deprecated method. Used to avoid
 
 556          * deprecation warnings.
 
 559         /*package*/ final Name internalGetSuperclass() {
 
 561                 return this.optionalSuperclassName;
 
 565         * Returns the superclass declared in this type
 
 566         * declaration, or <code>null</code> if there is none (added in JLS3 API).
 
 568         * Note that this child is not relevant for interface 
 
 569         * declarations (although it does still figure in subtree
 
 570         * equality comparisons).
 
 573         * @return the superclass type node, or <code>null</code> if 
 
 575         * @exception UnsupportedOperationException if this operation is used in
 
 579         public Type getSuperclassType() {
 
 581                 return this.optionalSuperclassType;
 
 585          * Sets or clears the name of the superclass declared in this type
 
 586          * declaration (JLS2 API only).
 
 588          * Note that this child is not relevant for interface 
 
 589          * declarations (although it does still figure in subtree
 
 590          * equality comparisons).
 
 593          * @param superclassName the superclass name node, or <code>null</code> if 
 
 595          * @exception IllegalArgumentException if:
 
 597          * <li>the node belongs to a different AST</li>
 
 598          * <li>the node already has a parent</li>
 
 600          * @exception UnsupportedOperationException if this operation is used in
 
 601          * an AST later than JLS2
 
 602          * @deprecated In the JLS3 API, this method is replaced by 
 
 603          * {@link #setSuperclassType(Type)}, which expects a
 
 604          * <code>Type</code> instead of a <code>Name</code>.
 
 606         public void setSuperclass(Name superclassName) {
 
 607                 internalSetSuperclass(superclassName);
 
 611          * Internal synonym for deprecated method. Used to avoid
 
 612          * deprecation warnings.
 
 615         /*package*/ final void internalSetSuperclass(Name superclassName) {
 
 617                 ASTNode oldChild = this.optionalSuperclassName;
 
 618                 preReplaceChild(oldChild, superclassName, SUPERCLASS_PROPERTY);
 
 619                 this.optionalSuperclassName = superclassName;
 
 620                 postReplaceChild(oldChild, superclassName, SUPERCLASS_PROPERTY);
 
 624          * Sets or clears the superclass declared in this type
 
 625          * declaration (added in JLS3 API).
 
 627          * Note that this child is not relevant for interface declarations
 
 628          * (although it does still figure in subtree equality comparisons).
 
 631          * @param superclassType the superclass type node, or <code>null</code> if 
 
 633          * @exception IllegalArgumentException if:
 
 635          * <li>the node belongs to a different AST</li>
 
 636          * <li>the node already has a parent</li>
 
 638          * @exception UnsupportedOperationException if this operation is used in
 
 642         public void setSuperclassType(Type superclassType) {
 
 644                 ASTNode oldChild = this.optionalSuperclassType;
 
 645                 preReplaceChild(oldChild, superclassType, SUPERCLASS_TYPE_PROPERTY);
 
 646                 this.optionalSuperclassType = superclassType;
 
 647                 postReplaceChild(oldChild, superclassType, SUPERCLASS_TYPE_PROPERTY);
 
 651          * Returns the live ordered list of names of superinterfaces of this type 
 
 652          * declaration (JLS2 API only). For a class declaration, these are the names
 
 653          * of the interfaces that this class implements; for an interface
 
 654          * declaration, these are the names of the interfaces that this interface
 
 657          * @return the live list of interface names
 
 658          *    (element type: <code>Name</code>)
 
 659          * @exception UnsupportedOperationException if this operation is used in
 
 660          * an AST later than JLS2
 
 661          * @deprecated In the JLS3 API, this method is replaced by 
 
 662          * {@link #superInterfaceTypes()}.
 
 664         public List superInterfaces() {
 
 665                 return internalSuperInterfaces();
 
 669          * Internal synonym for deprecated method. Used to avoid
 
 670          * deprecation warnings.
 
 673         /*package*/ final List internalSuperInterfaces() {
 
 674                 // more efficient than just calling supportedOnlyIn2() to check
 
 675                 if (this.superInterfaceNames == null) {
 
 678                 return this.superInterfaceNames;
 
 682          * Returns the live ordered list of superinterfaces of this type 
 
 683          * declaration (added in JLS3 API). For a class declaration, these are the interfaces
 
 684          * that this class implements; for an interface declaration,
 
 685          * these are the interfaces that this interface extends.
 
 687          * @return the live list of interface types
 
 688          *    (element type: <code>Type</code>)
 
 689          * @exception UnsupportedOperationException if this operation is used in
 
 693         public List superInterfaceTypes() {
 
 694                 // more efficient than just calling unsupportedIn2() to check
 
 695                 if (this.superInterfaceTypes == null) {
 
 698                 return this.superInterfaceTypes;
 
 702          * Returns the ordered list of field declarations of this type 
 
 703          * declaration. For a class declaration, these are the
 
 704          * field declarations; for an interface declaration, these are
 
 705          * the constant declarations.
 
 707          * This convenience method returns this node's body declarations
 
 708          * with non-fields filtered out. Unlike <code>bodyDeclarations</code>,
 
 709          * this method does not return a live result.
 
 712          * @return the (possibly empty) list of field declarations
 
 714         public FieldDeclaration[] getFields() {
 
 715                 List bd = bodyDeclarations();
 
 717                 for (Iterator it = bd.listIterator(); it.hasNext(); ) {
 
 718                         if (it.next() instanceof FieldDeclaration) {
 
 722                 FieldDeclaration[] fields = new FieldDeclaration[fieldCount];
 
 724                 for (Iterator it = bd.listIterator(); it.hasNext(); ) {
 
 725                         Object decl = it.next();
 
 726                         if (decl instanceof FieldDeclaration) {
 
 727                                 fields[next++] = (FieldDeclaration) decl;
 
 734          * Returns the ordered list of method declarations of this type 
 
 737          * This convenience method returns this node's body declarations
 
 738          * with non-methods filtered out. Unlike <code>bodyDeclarations</code>,
 
 739          * this method does not return a live result.
 
 742          * @return the (possibly empty) list of method (and constructor) 
 
 745         public MethodDeclaration[] getMethods() {
 
 746                 List bd = bodyDeclarations();
 
 748                 for (Iterator it = bd.listIterator(); it.hasNext(); ) {
 
 749                         if (it.next() instanceof MethodDeclaration) {
 
 753                 MethodDeclaration[] methods = new MethodDeclaration[methodCount];
 
 755                 for (Iterator it = bd.listIterator(); it.hasNext(); ) {
 
 756                         Object decl = it.next();
 
 757                         if (decl instanceof MethodDeclaration) {
 
 758                                 methods[next++] = (MethodDeclaration) decl;
 
 765          * Returns the ordered list of member type declarations of this type 
 
 768          * This convenience method returns this node's body declarations
 
 769          * with non-types filtered out. Unlike <code>bodyDeclarations</code>,
 
 770          * this method does not return a live result.
 
 773          * @return the (possibly empty) list of member type declarations
 
 775         public TypeDeclaration[] getTypes() {
 
 776                 List bd = bodyDeclarations();
 
 778                 for (Iterator it = bd.listIterator(); it.hasNext(); ) {
 
 779                         if (it.next() instanceof TypeDeclaration) {
 
 783                 TypeDeclaration[] memberTypes = new TypeDeclaration[typeCount];
 
 785                 for (Iterator it = bd.listIterator(); it.hasNext(); ) {
 
 786                         Object decl = it.next();
 
 787                         if (decl instanceof TypeDeclaration) {
 
 788                                 memberTypes[next++] = (TypeDeclaration) decl;
 
 794         /* (omit javadoc for this method)
 
 795          * Method declared on AsbtractTypeDeclaration.
 
 797         ITypeBinding internalResolveBinding() {
 
 798                 return this.ast.getBindingResolver().resolveType(this);
 
 801         /* (omit javadoc for this method)
 
 802          * Method declared on ASTNode.
 
 805                 return super.memSize() + 6 * 4;
 
 808         /* (omit javadoc for this method)
 
 809          * Method declared on ASTNode.
 
 813                         + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize())
 
 814                         + (this.modifiers == null ? 0 : this.modifiers.listSize())
 
 815                         + (this.typeName == null ? 0 : getName().treeSize())
 
 816                         + (this.typeParameters == null ? 0 : this.typeParameters.listSize())
 
 817                         + (this.optionalSuperclassName == null ? 0 : getSuperclass().treeSize())
 
 818                         + (this.optionalSuperclassType == null ? 0 : getSuperclassType().treeSize())
 
 819                         + (this.superInterfaceNames == null ? 0 : this.superInterfaceNames.listSize())
 
 820                         + (this.superInterfaceTypes == null ? 0 : this.superInterfaceTypes.listSize())
 
 821                         + this.bodyDeclarations.listSize();