Index: dom/org/eclipse/jdt/core/dom/AST.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java,v retrieving revision 1.49 diff -u -r1.49 AST.java --- dom/org/eclipse/jdt/core/dom/AST.java 4 Apr 2003 19:58:13 -0000 1.49 +++ dom/org/eclipse/jdt/core/dom/AST.java 14 Apr 2003 18:47:37 -0000 @@ -693,7 +693,7 @@ * type (Type) by wrapping it. *

* - * @param typeName the name of the class or interface + * @param typeName the name of the class, interface, or type variable * @return a new unparented simple type node * @exception IllegalArgumentException if: * + * @deprecated Replaced by setType, which expects + * a Type instead of a Name. */ public void setName(Name name) { + // implement deprecated method in terms of get/setType if (name == null) { throw new IllegalArgumentException(); } - replaceChild(this.typeName, name, false); - this.typeName = name; + Type t = getType(); + if (t instanceof SimpleType) { + // if possible edit name in SimpleType + SimpleType s = (SimpleType) t; + s.setName(name); + // give type node same range as name node + s.setSourceRange(name.getStartPosition(), name.getLength()); + // note that only s will be modified(), not the ClassInst node + } else { + // all other cases - wrap name in a SimpleType and replace superclassType + Type newT = getAST().newSimpleType(name); + // give new type node same range as name node + newT.setSourceRange(name.getStartPosition(), name.getLength()); + setType(newT); + } + } + + /** + * Returns the type instantiated in this class instance creation expression. + * + * @return the type node + * @since 2.2 + */ + public Type getType() { + if (this.type == null) { + // lazy initialize - use setter to ensure parent link set too + long count = getAST().modificationCount(); + setType(new SimpleType(getAST())); + getAST().setModificationCount(count); + } + return this.type; + } + + /** + * Sets the type instantiated in this class instance creation expression. + * + * @param name the new type + * @exception IllegalArgumentException if: + * + * @since 2.2 + */ + public void setType(Type type) { + if (type == null) { + throw new IllegalArgumentException(); + } + replaceChild(this.type, type, false); + this.type = type; } /** @@ -243,7 +336,7 @@ int treeSize() { return memSize() - + (typeName == null ? 0 : getName().treeSize()) + + (type == null ? 0 : getName().treeSize()) + (optionalExpression == null ? 0 : getExpression().treeSize()) + arguments.listSize() + (optionalAnonymousClassDeclaration == null ? 0 : getAnonymousClassDeclaration().treeSize()); Index: dom/org/eclipse/jdt/core/dom/ITypeBinding.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ITypeBinding.java,v retrieving revision 1.12 diff -u -r1.12 ITypeBinding.java --- dom/org/eclipse/jdt/core/dom/ITypeBinding.java 11 Mar 2003 15:03:51 -0000 1.12 +++ dom/org/eclipse/jdt/core/dom/ITypeBinding.java 14 Apr 2003 18:47:46 -0000 @@ -13,11 +13,17 @@ /** * A type binding represents a class type, interface type, array type, a - * primitive type (including the special return type void), or the - * null type. + * primitive type (including the special return type void), the + * null type, or a type variable. *

* This interface is not intended to be implemented by clients. *

+ *

+ * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. + *

* * @see ITypeBinding#getDeclaredTypes() * @since 2.0 @@ -34,7 +40,8 @@ *

*

* The set of primitive types is mutually exclusive with the sets of - * array types, with the sets of class and interface types, and with the null type. + * array types, with the sets of class and interface types, with the null + * type, and with type variables. *

* * @return true if this type binding is for a primitive type, @@ -53,8 +60,8 @@ *

*

* The null type is mutually exclusive with the sets of - * array types, with the sets of class and interface types, and - * with the set of primitive types . + * array types, with the sets of class and interface types, + * with the set of primitive types, and with the set of type variables. *

* * @return true if this type binding is for the null type, @@ -66,7 +73,8 @@ * Returns whether this type binding represents an array type. *

* The set of array types is mutually exclusive with the sets of - * primitive types and with the sets of class and interface types. + * primitive types, with the sets of class and interface types, + * with the null type, and with the set of type variables. *

* * @return true if this type binding is for an array type, @@ -78,6 +86,29 @@ public boolean isArray(); /** + * Returns whether this type binding represents a type variable. + *

+ * A type variables is declared in TypeParameter node. + *

+ *

+ * Type variables are mutually exclusive with the sets of + * array types, with the sets of class and interface types, + * with the set of primitive types, and with the null type. + *

+ *

+ * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. + *

+ * + * @return true if this type binding is for a type variable, + * and false otherwise + * @since 2.2 + */ + public boolean isTypeVariable(); + + /** * Returns the binding representing the element type of this array type, * or null if this is not an array type binding. The element * type of an array is never itself an array type. @@ -100,7 +131,8 @@ * Returns whether this type binding represents a class type. *

* The set of class types is mutually exclusive with the sets of - * primive types, array types, interface types, and the null type. + * primive types, array types, interface types, the null type, + * and with the set of type variables. *

* * @return true if this object represents a class, @@ -116,7 +148,8 @@ * Returns whether this type binding represents an interface type. *

* The set of interface types is mutually exclusive with the sets of - * primive types, array types, class types, and the null type. + * primive types, array types, class types, the null type, + * and with the set of type variables. *

* * @return true if this object represents an interface, @@ -137,6 +170,7 @@ * If this represents an anonymous class, it returns an empty string (note that * it is impossible to have an array type with an anonymous class as element type). * For the null type, it returns "null". + * For type variables, this is the name of the type variable. *

* * @return the unqualified name of the type represented by this binding, an @@ -151,7 +185,7 @@ * * @return the binding for the package in which this class or interface is * declared, or null if this type binding represents a - * primitive type, an array type, or the null type. + * primitive type, an array type, the null type, or a type variable */ public IPackageBinding getPackage(); @@ -163,8 +197,8 @@ * interface of which it is a member. The declaring class of a local class * or interface (including anonymous classes) is the innermost class or * interface containing the expression or statement in which this type is - * declared. Array types, primitive types, the null type, and top-level types - * have no declaring class. + * declared. Array types, primitive types, the null type, top-level types, + * and type variables have no declaring class. *

* * @return the binding of the class or interface that declares this type, @@ -190,7 +224,8 @@ *

*

* If this type binding represents an interface, an array type, a - * primitive type, or the null type, then null is returned. + * primitive type, the null type, or a type variable, then null + * is returned. *

* * @return the superclass of the class represented by this type binding, @@ -219,7 +254,8 @@ *

* If the class implements no interfaces, or the interface extends no * interfaces, or if this type binding represents an array type, a - * primitive type, or the null type, this method returns an array of length 0. + * primitive type, the null type, or a type variable, this method returns + * an array of length 0. *

* * @return the list of type bindings for the interfaces extended by this @@ -365,8 +401,9 @@ * protected, default (package-private) access, and private methods. * Synthetic methods and constructors may or may not be included. Returns * an empty list if the class or interface declares no methods or - * constructors, or if this type binding represents an array type or a - * primitive type. The resulting bindings are in no particular order. + * constructors, or if this type binding represents an array type, a + * primitive type, the null type, or a type variable. + * The resulting bindings are in no particular order. * * @return the list of method bindings for the methods and constructors * declared by this class or interface, or the empty list if this type does @@ -377,8 +414,8 @@ /** * Returns whether this type binding originated in source code. * Returns false for primitive types, the null type, array types, - * and classes and interfaces whose information came from a pre-compiled binary - * class file. + * and classes, interfaces, and type variables whose information came from + * a pre-compiled binary class file. * * @return true if the type is in source code, * and false otherwise @@ -409,6 +446,9 @@ *
  • Local types (including anonymous classes) and members of local * types do not have a fully qualified name. For these types, and array * types thereof, this method returns an empty string.
  • + *
  • For type variables, the fully qualified name is just the name of the + * type variable. + * Example: "X".
  • * * * @return the fully qualified name of the type represented by this Index: dom/org/eclipse/jdt/core/dom/MethodDeclaration.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodDeclaration.java,v retrieving revision 1.24 diff -u -r1.24 MethodDeclaration.java --- dom/org/eclipse/jdt/core/dom/MethodDeclaration.java 11 Mar 2003 15:03:51 -0000 1.24 +++ dom/org/eclipse/jdt/core/dom/MethodDeclaration.java 14 Apr 2003 18:47:47 -0000 @@ -20,7 +20,9 @@ * *
      * MethodDeclaration:
    - *    [ Javadoc ] { Modifier } ( Type | void ) Identifier (
    + *    [ Javadoc ] { Modifier }
    + *		  [ < TypeParameter { , TypeParameter } > ]
    + *        ( Type | void ) Identifier (
      *        [ FormalParameter 
      * 		     { , FormalParameter } ] ) {[ ] }
      *        [ throws TypeName { , TypeName } ] ( Block | ; )
    @@ -35,10 +37,17 @@
      * range begins with the first character of the "/**" comment delimiter.
      * When there is no Javadoc comment, the source range begins with the first
      * character of the first modifier keyword (if modifiers), or the
    - * first character of the return type (method, no modifiers), or the
    - * first character of the identifier (constructor, no modifiers).
    - * The source range extends through the last character of the ";" token (if
    - * no body), or the last character of the block (if body).
    + * first character of the "<" token (method, no modifiers, type parameters), 
    + * or the first character of the return type (method, no modifiers, no type
    + * parameters), or the first character of the identifier (constructor, 
    + * no modifiers). The source range extends through the last character of the
    + * ";" token (if no body), or the last character of the block (if body).
    + * 

    + *

    + * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. *

    * * @since 2.0 @@ -66,6 +75,14 @@ private int modifiers = Modifier.NONE; /** + * The type paramters (element type: TypeParameter). + * Defaults to an empty list. + * @since 2.2 + */ + private ASTNode.NodeList typeParameters = + new ASTNode.NodeList(false, TypeParameter.class); + + /** * The method name; lazily initialized; defaults to an unspecified, * legal Java identifier. */ @@ -109,9 +126,10 @@ /** * Creates a new AST node for a method declaration owned * by the given AST. By default, the declaration is for a method of an - * unspecified, but legal, name; no modifiers; no javadoc; no parameters; - * void return type; no array dimensions after the parameters; no thrown - * exceptions; and no body (as opposed to an empty body). + * unspecified, but legal, name; no modifiers; no javadoc; no type + * parameters; void return type; no parameters; no array dimensions after + * the parameters; no thrown exceptions; and no body (as opposed to an + * empty body). *

    * N.B. This constructor is package-private; all subclasses must be * declared in the same package; clients are unable to declare @@ -141,6 +159,8 @@ (Javadoc) ASTNode.copySubtree(target,(ASTNode) getJavadoc())); result.setModifiers(getModifiers()); result.setConstructor(isConstructor()); + result.typeParameters().addAll( + ASTNode.copySubtrees(target, typeParameters())); result.setReturnType( (Type) ASTNode.copySubtree(target, getReturnType())); result.setExtraDimensions(getExtraDimensions()); @@ -170,6 +190,7 @@ if (visitChildren) { // visit children in normal left to right reading order acceptChild(visitor, getJavadoc()); + acceptChildren(visitor, typeParameters); // n.b. visit return type even for constructors acceptChild(visitor, getReturnType()); acceptChild(visitor, getName()); @@ -234,8 +255,30 @@ this.modifiers = modifiers; } -// public List typeParameters(); // JSR-014 - + /** + * Returns the live ordered list of type parameters of this method + * declaration. This list is non-empty for parameterized methods. + *

    + * Note that these children are not relevant for constructor declarations + * (although it does still figure in subtree equality comparisons + * and visits), and is devoid of the binding information ordinarily + * available. + *

    + *

    + * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. + *

    + * + * @return the live list of type parameters + * (element type: TypeParameter) + * @since 2.2 + */ + public List typeParameters() { + return typeParameters; + } + /** * Returns the name of the method declared in this method declaration. * For a constructor declaration, this should be the same as the name @@ -467,7 +510,7 @@ * Method declared on ASTNode. */ int memSize() { - return super.memSize() + 8 * 4; + return super.memSize() + 9 * 4; } /* (omit javadoc for this method) @@ -477,6 +520,7 @@ return memSize() + (getJavadoc() == null ? 0 : getJavadoc().treeSize()) + + typeParameters.listSize() + (methodName == null ? 0 : getName().treeSize()) + (returnType == null ? 0 : getReturnType().treeSize()) + parameters.listSize() Index: dom/org/eclipse/jdt/core/dom/NaiveASTFlattener.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NaiveASTFlattener.java,v retrieving revision 1.9 diff -u -r1.9 NaiveASTFlattener.java --- dom/org/eclipse/jdt/core/dom/NaiveASTFlattener.java 11 Mar 2003 15:03:51 -0000 1.9 +++ dom/org/eclipse/jdt/core/dom/NaiveASTFlattener.java 14 Apr 2003 18:47:48 -0000 @@ -280,7 +280,7 @@ buffer.append(".");//$NON-NLS-1$ } buffer.append("new ");//$NON-NLS-1$ - node.getName().accept(this); + node.getType().accept(this); buffer.append("(");//$NON-NLS-1$ for (Iterator it = node.arguments().iterator(); it.hasNext(); ) { Expression e = (Expression) it.next(); @@ -610,6 +610,28 @@ } /* + * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. + * @see ASTVisitor#visit(ParameterizedType) + * @since 2.2 + */ + public boolean visit(ParameterizedType node) { + node.getName().accept(this); + buffer.append("<");//$NON-NLS-1$ + for (Iterator it = node.typeArguments().iterator(); it.hasNext(); ) { + Type t = (Type) it.next(); + t.accept(this); + if (it.hasNext()) { + buffer.append(",");//$NON-NLS-1$ + } + } + buffer.append(">");//$NON-NLS-1$ + return false; + } + + /* * @see ASTVisitor#visit(ParenthesizedExpression) */ public boolean visit(ParenthesizedExpression node) { @@ -656,6 +678,17 @@ } /* + * @see ASTVisitor#visit(QualifiedType) + * @since 2.2 + */ + public boolean visit(QualifiedType node) { + node.getQualifier().accept(this); + buffer.append(".");//$NON-NLS-1$ + node.getName().accept(this); + return false; + } + + /* * @see ASTVisitor#visit(ReturnStatement) */ public boolean visit(ReturnStatement node) { @@ -851,17 +884,28 @@ printModifiers(node.getModifiers()); buffer.append(node.isInterface() ? "interface " : "class ");//$NON-NLS-2$//$NON-NLS-1$ node.getName().accept(this); + if (!node.typeParameters().isEmpty()) { + buffer.append("<");//$NON-NLS-1$ + for (Iterator it = node.typeParameters().iterator(); it.hasNext(); ) { + TypeParameter t = (TypeParameter) it.next(); + t.accept(this); + if (it.hasNext()) { + buffer.append(",");//$NON-NLS-1$ + } + } + buffer.append(">");//$NON-NLS-1$ + } buffer.append(" ");//$NON-NLS-1$ - if (node.getSuperclass() != null) { + if (node.getSuperclassType() != null) { buffer.append("extends ");//$NON-NLS-1$ - node.getSuperclass().accept(this); + node.getSuperclassType().accept(this); buffer.append(" ");//$NON-NLS-1$ } - if (!node.superInterfaces().isEmpty()) { + if (!node.superInterfaceTypes().isEmpty()) { buffer.append(node.isInterface() ? "extends " : "implements ");//$NON-NLS-2$//$NON-NLS-1$ - for (Iterator it = node.superInterfaces().iterator(); it.hasNext(); ) { - Name n = (Name) it.next(); - n.accept(this); + for (Iterator it = node.superInterfaceTypes().iterator(); it.hasNext(); ) { + Type t = (Type) it.next(); + t.accept(this); if (it.hasNext()) { buffer.append(", ");//$NON-NLS-1$ } @@ -892,6 +936,29 @@ public boolean visit(TypeLiteral node) { node.getType().accept(this); buffer.append(".class");//$NON-NLS-1$ + return false; + } + + /* + * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. + * @see ASTVisitor#visit(TypeParameter) + * @since 2.2 + */ + public boolean visit(TypeParameter node) { + node.getName().accept(this); + if (!node.typeBounds().isEmpty()) { + buffer.append(" extends ");//$NON-NLS-1$ + for (Iterator it = node.typeBounds().iterator(); it.hasNext(); ) { + Type t = (Type) it.next(); + t.accept(this); + if (it.hasNext()) { + buffer.append(" & ");//$NON-NLS-1$ + } + } + } return false; } Index: dom/org/eclipse/jdt/core/dom/ParameterizedType.java =================================================================== RCS file: dom/org/eclipse/jdt/core/dom/ParameterizedType.java diff -N dom/org/eclipse/jdt/core/dom/ParameterizedType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ dom/org/eclipse/jdt/core/dom/ParameterizedType.java 14 Apr 2003 18:47:49 -0000 @@ -0,0 +1,162 @@ +/******************************************************************************* + * Copyright (c) 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.jdt.core.dom; + +import java.util.List; + +/** + * Type node for a parameterized type. + *
    + * ParameterizedType:
    + *    Name < Type { , Type } >
    + * 
    + *

    + * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. + *

    + * + * @since 2.2 + */ +public class ParameterizedType extends Type { + /** + * The type name node; lazily initialized; defaults to a type with + * an unspecfied, but legal, name. + */ + private Name typeName = null; + + /** + * The type arguments (element type: Type). + * Defaults to an empty list. + */ + private ASTNode.NodeList typeArguments = + new ASTNode.NodeList(true, Type.class); + + /** + * Creates a new unparented node for a parameterized type owned by the + * given AST. By default, an unspecified, but legal, name, and no type + * arguments. + *

    + * N.B. This constructor is package-private. + *

    + * + * @param ast the AST that is to own this node + */ + ParameterizedType(AST ast) { + super(ast); + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + public int getNodeType() { + return PARAMETERIZED_TYPE; + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + ASTNode clone(AST target) { + ParameterizedType result = new ParameterizedType(target); + result.setSourceRange(this.getStartPosition(), this.getLength()); + result.setName((Name) ((ASTNode) getName()).clone(target)); + result.typeArguments().addAll( + ASTNode.copySubtrees(target, typeArguments())); + return result; + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + public boolean subtreeMatch(ASTMatcher matcher, Object other) { + // dispatch to correct overloaded match method + return matcher.match(this, other); + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + void accept0(ASTVisitor visitor) { + boolean visitChildren = visitor.visit(this); + if (visitChildren) { + // visit children in normal left to right reading order + acceptChild(visitor, getName()); + acceptChildren(visitor, typeArguments); + } + visitor.endVisit(this); + } + + /** + * Returns the name of this parameterized type. + * + * @return the name of this parameterized type + */ + public Name getName() { + if (typeName == null) { + // lazy initialize - use setter to ensure parent link set too + long count = getAST().modificationCount(); + setName(new SimpleName(getAST())); + getAST().setModificationCount(count); + } + return typeName; + } + + /** + * Sets the name of this parameterized type to the given name. + * + * @param typeName the new name of this parameterized type + * @exception IllegalArgumentException if: + * + */ + public void setName(Name typeName) { + if (typeName == null) { + throw new IllegalArgumentException(); + } + replaceChild((ASTNode) this.typeName, (ASTNode) typeName, false); + this.typeName = typeName; + } + + /** + * Returns the live ordered list of type arguments of this parameterized + * type. For the parameterized type to be plausible, the list should contain + * at least one element and not contain primitive types. + * + * @return the live list of type arguments + * (element type: Type) + */ + public List typeArguments() { + return typeArguments; + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + int memSize() { + // treat Code as free + return BASE_NODE_SIZE + 2 * 4; + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + int treeSize() { + return + memSize() + + (typeName == null ? 0 : getName().treeSize()) + + typeArguments.listSize(); + } +} + Index: dom/org/eclipse/jdt/core/dom/QualifiedType.java =================================================================== RCS file: dom/org/eclipse/jdt/core/dom/QualifiedType.java diff -N dom/org/eclipse/jdt/core/dom/QualifiedType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ dom/org/eclipse/jdt/core/dom/QualifiedType.java 14 Apr 2003 18:47:49 -0000 @@ -0,0 +1,198 @@ +/******************************************************************************* + * Copyright (c) 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.jdt.core.dom; + +/** + * Type node for a qualified type. + *
    + * QualifiedType:
    + *    Type . SimpleName
    + * 
    + *

    + * Not all node arragements will represent legal Java constructs. In particular, + * it is nonsense if the type is an array type or primitive type. The normal use + * is when the type is a simple or parameterized type. + *

    + *

    + * A type like "A.B" can be represented either of two ways: + *

      + *
    1. + * QualifiedType(SimpleType(SimpleName("A")),SimpleName("B")) + *
    2. + *
    3. + * SimpleType(QualifiedName(SimpleName("A"),SimpleName("B"))) + *
    4. + *
    + * The first form is preferred when "A" is known to be a type. However, a + * parser cannot always determine this. Clients should be prepared to handle + * either rather than make assumptions. (Note also that the first form + * became possible as of 2.2; only the second form existed in 2.0 and 2.1.) + *

    + *

    + * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. + *

    + * + * @since 2.2 + */ +public class QualifiedType extends Type { + /** + * The type node; lazily initialized; defaults to a type with + * an unspecfied, but legal, simple name. + */ + private Type qualifier = null; + + /** + * The name being qualified; lazily initialized; defaults to a unspecified, + * legal Java identifier. + */ + private SimpleName name = null; + + /** + * Creates a new unparented node for a qualified type owned by the + * given AST. By default, an unspecified, but legal, qualifier and name. + *

    + * N.B. This constructor is package-private. + *

    + * + * @param ast the AST that is to own this node + */ + QualifiedType(AST ast) { + super(ast); + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + public int getNodeType() { + return QUALIFIED_TYPE; + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + ASTNode clone(AST target) { + QualifiedType result = new QualifiedType(target); + result.setSourceRange(this.getStartPosition(), this.getLength()); + result.setQualifier((Type) ((ASTNode) getQualifier()).clone(target)); + result.setName((SimpleName) ((ASTNode) getName()).clone(target)); + return result; + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + public boolean subtreeMatch(ASTMatcher matcher, Object other) { + // dispatch to correct overloaded match method + return matcher.match(this, other); + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + void accept0(ASTVisitor visitor) { + boolean visitChildren = visitor.visit(this); + if (visitChildren) { + // visit children in normal left to right reading order + acceptChild(visitor, getQualifier()); + acceptChild(visitor, getName()); + } + visitor.endVisit(this); + } + + /** + * Returns the qualifier of this qualified type. + * + * @return the qualifier of this qualified type + */ + public Type getQualifier() { + if (this.qualifier == null) { + // lazy initialize - use setter to ensure parent link set too + long count = getAST().modificationCount(); + setQualifier(new SimpleType(getAST())); + getAST().setModificationCount(count); + } + return this.qualifier; + } + + /** + * Sets the qualifier of this qualified type to the given type. + * + * @param type the new qualifier of this qualified type + * @exception IllegalArgumentException if: + * + */ + public void setQualifier(Type type) { + if (type == null) { + throw new IllegalArgumentException(); + } + replaceChild(this.qualifier, type, true); + this.qualifier = type; + } + + /** + * Returns the name part of this qualified type. + * + * @return the name being qualified + */ + public SimpleName getName() { + if (this.name == null) { + // lazy initialize - use setter to ensure parent link set too + long count = getAST().modificationCount(); + setName(new SimpleName(getAST())); + getAST().setModificationCount(count); + } + return this.name; + } + + /** + * Sets the name part of this qualified type to the given simple name. + * + * @param name the identifier of this qualified name + * @exception IllegalArgumentException if: + * + */ + public void setName(SimpleName name) { + if (name == null) { + throw new IllegalArgumentException(); + } + replaceChild(this.name, name, false); + this.name = name; + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + int memSize() { + // treat Code as free + return BASE_NODE_SIZE + 2 * 4; + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + int treeSize() { + return + memSize() + + (qualifier == null ? 0 : getQualifier().treeSize()) + + (name == null ? 0 : getName().treeSize()); + } +} + Index: dom/org/eclipse/jdt/core/dom/SimpleName.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleName.java,v retrieving revision 1.25 diff -u -r1.25 SimpleName.java --- dom/org/eclipse/jdt/core/dom/SimpleName.java 11 Mar 2003 15:03:51 -0000 1.25 +++ dom/org/eclipse/jdt/core/dom/SimpleName.java 14 Apr 2003 18:47:49 -0000 @@ -140,6 +140,8 @@ * providing isConstructor is false. *
  • The variable name in any type of VariableDeclaration * node.
  • + *
  • The type variable name in a TypeParameter + * node.
  • * *

    * Note that this is a convenience method that simply checks whether @@ -174,6 +176,10 @@ VariableDeclarationFragment p = (VariableDeclarationFragment) parent; // make sure its the name of the variable (not the initializer) return (p.getName() == this); + } + if (parent instanceof TypeParameter) { + // could only be the type variable name + return true; } return false; } Index: dom/org/eclipse/jdt/core/dom/SimpleType.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleType.java,v retrieving revision 1.12 diff -u -r1.12 SimpleType.java --- dom/org/eclipse/jdt/core/dom/SimpleType.java 11 Mar 2003 15:03:51 -0000 1.12 +++ dom/org/eclipse/jdt/core/dom/SimpleType.java 14 Apr 2003 18:47:50 -0000 @@ -12,10 +12,16 @@ package org.eclipse.jdt.core.dom; /** - * Type node for a named class or interface type. + * Type node for a named class type, a named interface type, or a type variable. *

    * This kind of node is used to convert a name (Name) into a type * (Type) by wrapping it. + *

    + *

    + * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. *

    * * @since 2.0 Index: dom/org/eclipse/jdt/core/dom/Type.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Type.java,v retrieving revision 1.4 diff -u -r1.4 Type.java --- dom/org/eclipse/jdt/core/dom/Type.java 11 Mar 2003 15:03:51 -0000 1.4 +++ dom/org/eclipse/jdt/core/dom/Type.java 14 Apr 2003 18:47:50 -0000 @@ -13,14 +13,17 @@ /** * Abstract base class of all type AST node types. A type node represents a - * reference to a primitive type (including void), to a named class or - * interface type, or to an array type. + * reference to a primitive type (including void), to an array type, or to a + * simple named type (or type variable), to a qualified type, or to a + * parameterized type. *

    *

      * Type:
      *    PrimitiveType
    - *    SimpleType
      *    ArrayType
    + *    SimpleType
    + *    QualifiedType
    + *    ParameterizedType
      * PrimitiveType:
      *    byte
      *    short
    @@ -31,12 +34,22 @@
      *    double
      *    boolean
      *    void
    - * SimpleType:
    - *    TypeName
      * ArrayType:
      *    Type [ ]
    + * SimpleType:
    + *    TypeName
    + * ParameterizedType:
    + *    Name < Type { , Type } >
    + * QualifiedType:
    + *    Type . SimpleName
      * 
    *

    + *

    + * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. + *

    * * @since 2.0 */ @@ -88,6 +101,57 @@ } /** + * Returns whether this type is a parameterized type + * (ParameterizedType). + *

    + * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. + *

    + * + * @return true if this is a parameterized type, and + * false otherwise + * @since 2.2 + */ + public final boolean isParameterizedType() { + return (this instanceof ParameterizedType); + } + + /** + * Returns whether this type is a qualified type + * (QualifiedType). + *

    + * Note that a type like "A.B" can be represented either of two ways: + *

      + *
    1. + * QualifiedType(SimpleType(SimpleName("A")),SimpleName("B")) + *
    2. + *
    3. + * SimpleType(QualifiedName(SimpleName("A"),SimpleName("B"))) + *
    4. + *
    + * The first form is preferred when "A" is known to be a type. However, a + * parser cannot always determine this. Clients should be prepared to handle + * either rather than make assumptions. (Note also that the first form + * became possible as of 2.2; only the second form existed in 2.0 and 2.1.) + *

    + *

    + * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. + *

    + * + * @return true if this is a qualified type, and + * false otherwise + * @since 2.2 + */ + public final boolean isQualifiedType() { + return (this instanceof QualifiedType); + } + + /** * Resolves and returns the binding for this type. *

    * Note that bindings are generally unavailable unless requested when the @@ -100,31 +164,4 @@ public final ITypeBinding resolveBinding() { return getAST().getBindingResolver().resolveType(this); } - -// JSR-014 -// /** -// * Returns whether this type is a parameterized type -// * (ParameterizedType). -// * -// * @return true if this is a parameterized type, and -// * false otherwise -// */ -// public final boolean isParameterizedType() { -// return (this instanceof ParameterizedType); -// } - -// public IBinding resolvedType(); -} - -//// JSR-014 -//public class ParameterizedType extends Type { -// public ParameterizedType(AST ast) { -// super(ast); -// } -// -// public Type getGenericType(); -// public void setGenericType(Type genericType); -// -// public NodeList parameters(); -//} - +} \ No newline at end of file Index: dom/org/eclipse/jdt/core/dom/TypeDeclaration.java =================================================================== RCS file: /data/cvs/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclaration.java,v retrieving revision 1.20 diff -u -r1.20 TypeDeclaration.java --- dom/org/eclipse/jdt/core/dom/TypeDeclaration.java 7 Apr 2003 18:28:42 -0000 1.20 +++ dom/org/eclipse/jdt/core/dom/TypeDeclaration.java 14 Apr 2003 18:47:52 -0000 @@ -11,6 +11,7 @@ package org.eclipse.jdt.core.dom; +import java.util.AbstractList; import java.util.Iterator; import java.util.List; @@ -24,11 +25,13 @@ * InterfaceDeclaration * ClassDeclaration: * [ Javadoc ] { Modifier } class Identifier - * [ extends Type] + * [ < TypeParameter { , TypeParameter } > ] + * [ extends Type ] * [ implements Type { , Type } ] * { { ClassBodyDeclaration | ; } } * InterfaceDeclaration: * [ Javadoc ] { Modifier } interface Identifier + * [ < TypeParameter { , TypeParameter } > ] * [ extends Type { , Type } ] * { { InterfaceBodyDeclaration | ; } } *

    @@ -42,6 +45,12 @@ * no body), or the last character of the "}" token following the body * declarations. *

    + *

    + * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. + *

    * * @since 2.0 */ @@ -74,18 +83,28 @@ private SimpleName typeName = null; /** - * The optional superclass name; null if none. + * The type paramters (element type: TypeParameter). + * Defaults to an empty list. + * @since 2.2 + */ + private ASTNode.NodeList typeParameters = + new ASTNode.NodeList(false, TypeParameter.class); + + /** + * The optional superclass type; null if none. * Defaults to none. Note that this field is not used for * interface declarations. + * @since 2.2 */ - private Name optionalSuperclassName = null; + private Type optionalSuperclassType = null; /** - * The superinterface names (element type: Name). + * The superinterface types (element type: Type). * Defaults to an empty list. + * @since 2.2 */ - private ASTNode.NodeList superInterfaceNames = - new ASTNode.NodeList(false, Name.class); + private ASTNode.NodeList superInterfaceTypes = + new ASTNode.NodeList(false, Type.class); /** * The body declarations (element type: BodyDeclaration). @@ -98,8 +117,8 @@ * Creates a new AST node for a type declaration owned by the given * AST. By default, the type declaration is for a class of an * unspecified, but legal, name; no modifiers; no javadoc; - * no superclass or superinterfaces; and an empty list of body - * declarations. + * no type parameters; no superclass or superinterfaces; and an empty list + * of body declarations. *

    * N.B. This constructor is package-private; all subclasses must be * declared in the same package; clients are unable to declare @@ -130,10 +149,12 @@ (Javadoc) ASTNode.copySubtree(target,(ASTNode) getJavadoc())); result.setInterface(isInterface()); result.setName((SimpleName) getName().clone(target)); - result.setSuperclass( - (Name) ASTNode.copySubtree(target,(ASTNode) getSuperclass())); - result.superInterfaces().addAll( - ASTNode.copySubtrees(target, superInterfaces())); + result.typeParameters().addAll( + ASTNode.copySubtrees(target, typeParameters())); + result.setSuperclassType( + (Type) ASTNode.copySubtree(target,(ASTNode) getSuperclassType())); + result.superInterfaceTypes().addAll( + ASTNode.copySubtrees(target, superInterfaceTypes())); result.bodyDeclarations().addAll( ASTNode.copySubtrees(target, bodyDeclarations())); return result; @@ -156,8 +177,9 @@ // visit children in normal left to right reading order acceptChild(visitor, getJavadoc()); acceptChild(visitor, getName()); - acceptChild(visitor, getSuperclass()); - acceptChildren(visitor, superInterfaceNames); + acceptChildren(visitor, typeParameters); + acceptChild(visitor, getSuperclassType()); + acceptChildren(visitor, superInterfaceTypes); acceptChildren(visitor, bodyDeclarations); } visitor.endVisit(this); @@ -257,11 +279,24 @@ this.typeName = typeName; } -// JSR-014 feature -// public List typeParameters() { -// throw RuntimeException("not implemented yet"); -// } - + /** + * Returns the live ordered list of type parameters of this type + * declaration. This list is non-empty for parameterized types. + *

    + * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. + *

    + * + * @return the live list of type parameters + * (element type: TypeParameter) + * @since 2.2 + */ + public List typeParameters() { + return typeParameters; + } + /** * Returns the name of the superclass declared in this type * declaration, or null if there is none. @@ -272,9 +307,31 @@ * * @return the superclass name node, or null if * there is none + * @deprecated Replaced by getSuperclassType, which returns + * a Type instead of a Name. */ public Name getSuperclass() { - return optionalSuperclassName; + // implement deprecated method in terms of get/setSuperclassType + Type superclassType = getSuperclassType(); + if (superclassType == null) { + // return null if no superclass type + return null; + } else if (superclassType instanceof SimpleType) { + // no problem - extract name from SimpleType + SimpleType t = (SimpleType) superclassType; + return t.getName(); + } else if ((superclassType instanceof ParameterizedType) + || (superclassType instanceof QualifiedType)) { + // compatibility issue + // back-level clients know nothing of new node types added in 2.1 + // take this opportunity to inform client of problem + throw new RuntimeException("Deprecated AST API method cannot handle newer node types"); //$NON-NLS-1$ + } else { + // compatibility issue + // AST is bogus - illegal for type to be array or primitive type + // take this opportunity to inform client of problem + throw new RuntimeException("Deprecated AST API method cannot handle malformed AST"); //$NON-NLS-1$ + } } /** @@ -292,12 +349,72 @@ *
  • the node belongs to a different AST
  • *
  • the node already has a parent
  • * + * @deprecated Replaced by setSuperclassType, which expects + * a Type instead of a Name. */ public void setSuperclass(Name superclassName) { - replaceChild( - (ASTNode) this.optionalSuperclassName, - (ASTNode) superclassName, false); - this.optionalSuperclassName = superclassName; + // implement deprecated method in terms of get/setSuperclassType + if (superclassName == null) { + setSuperclassType(null); + } else { + Type superclassType = getSuperclassType(); + if (superclassType instanceof SimpleType) { + // if possible edit name in SimpleType + SimpleType s = (SimpleType) superclassType; + s.setName(superclassName); + // give type node same range as name node + s.setSourceRange( + superclassName.getStartPosition(), + superclassName.getLength()); + // note that only s will be modified(), not the TypeDecl node + } else { + // all other cases - wrap name in a SimpleType and replace superclassType + Type newT = getAST().newSimpleType(superclassName); + // give new type node same range as name node + newT.setSourceRange( + superclassName.getStartPosition(), + superclassName.getLength()); + setSuperclassType(newT); + } + } + } + + /** + * Returns the superclass declared in this type + * declaration, or null if there is none. + *

    + * Note that this child is not relevant for interface declarations + * (although it does still figure in subtree equality comparisons). + *

    + * + * @return the superclass type node, or null if + * there is none + * @since 2.2 + */ + public Type getSuperclassType() { + return this.optionalSuperclassType; + } + + /** + * Sets or clears the superclass declared in this type + * declaration. + *

    + * Note that this child is not relevant for interface declarations + * (although it does still figure in subtree equality comparisons). + *

    + * + * @param superclassType the superclass type node, or null if + * there is none + * @exception IllegalArgumentException if: + * + * @since 2.2 + */ + public void setSuperclassType(Type superclassType) { + replaceChild(this.optionalSuperclassType, superclassType, true); + this.optionalSuperclassType = superclassType; } /** @@ -308,9 +425,126 @@ * * @return the live list of interface names * (element type: Name) + * @deprecated Replaced by superInterfaceTypes, which contains + * a list of Types instead of Names. */ public List superInterfaces() { - return superInterfaceNames; + // implement deprecated method in terms of superInterfaceTypes() + // return special implementation of List in terms of List + return new AbstractList() { + /** + * @see java.util.AbstractCollection#size() + */ + public int size() { + return superInterfaceTypes().size(); + } + + /** + * @see AbstractList#get(int) + */ + public Object get(int index) { + Type t = (Type) superInterfaceTypes().get(index); + if (t instanceof SimpleType) { + // old client reading an old style element + SimpleType s = (SimpleType) t; + return s.getName(); + } else if ((t instanceof ParameterizedType) + || (t instanceof QualifiedType)) { + // compatibility issue + // back-level clients know nothing of new node types added in 2.1 + // take this opportunity to inform client of problem + throw new RuntimeException("Deprecated AST API method (TypeDeclaration.superinterfaces()) cannot handle newer node types"); //$NON-NLS-1$ + } else { + // compatibility issue + // AST is bogus - illegal for type to be array or primitive type + // take this opportunity to inform client of problem + throw new RuntimeException("Deprecated AST API method (TypeDeclaration.superinterfaces()) cannot handle malformed AST"); //$NON-NLS-1$ + } + } + + /** + * @see List#set(int, java.lang.Object) + */ + public Object set(int index, Object element) { + if (!(element instanceof Name)) { + throw new IllegalArgumentException(); + } + Type oldType = (Type) superInterfaceTypes().get(index); + Name newName = (Name) element; + if (oldType instanceof SimpleType) { + // old client operating on old style element + SimpleType s = (SimpleType) oldType; + Name oldName = s.getName(); + if (oldName != element) { + s.setName(newName); + // give type node same range as name node + s.setSourceRange( + newName.getStartPosition(), + newName.getLength()); + } + return oldName; + } else { + // old client replaced a new-fangled element + Type newType = getAST().newSimpleType(newName); + // give new type node same range as name node + newType.setSourceRange( + newName.getStartPosition(), + newName.getLength()); + superInterfaceTypes().set(index, newType); + // no choice but to return old new-fangled element + return oldType; + } + } + + /** + * @see List#add(int, java.lang.Object) + */ + public void add(int index, Object element) { + if (!(element instanceof Name)) { + throw new IllegalArgumentException(); + } + Name newName = (Name) element; + Type newType = getAST().newSimpleType(newName); + // give new type node same range as name node + newType.setSourceRange( + newName.getStartPosition(), + newName.getLength()); + superInterfaceTypes().add(index, newType); + } + + /** + * @see List#remove(int) + */ + public Object remove(int index) { + Object result = superInterfaceTypes().remove(index); + if (result instanceof SimpleType) { + // old client operating on old style element + SimpleType s = (SimpleType) result; + Name oldName = s.getName(); + // make sure that oldName has no parent afterwards + s.setName(getAST().newSimpleName("deleted")); //$NON-NLS-1$ + return oldName; + } else { + // old client removing a new-fangled element + // take a chance that they ignore result + return result; + } + } + }; + } + + /** + * Returns the live ordered list of superinterfaces of this type + * declaration. For a class declaration, these are the interfaces + * that this class implements; for an interface declaration, + * these are the interfaces that this interface extends. + * + * @return the live list of interface types + * (element type: Type) + * @since 2.2 + */ + public List superInterfaceTypes() { + return superInterfaceTypes; } /** @@ -506,7 +740,7 @@ * Method declared on ASTNode. */ int memSize() { - return super.memSize() + 6 * 4; + return super.memSize() + 7 * 4; } /* (omit javadoc for this method) @@ -517,8 +751,9 @@ memSize() + (getJavadoc() == null ? 0 : getJavadoc().treeSize()) + (typeName == null ? 0 : getName().treeSize()) - + (optionalSuperclassName == null ? 0 : getSuperclass().treeSize()) - + superInterfaceNames.listSize() + + typeParameters.listSize() + + (optionalSuperclassType == null ? 0 : getSuperclassType().treeSize()) + + superInterfaceTypes.listSize() + bodyDeclarations.listSize(); } } Index: dom/org/eclipse/jdt/core/dom/TypeParameter.java =================================================================== RCS file: dom/org/eclipse/jdt/core/dom/TypeParameter.java diff -N dom/org/eclipse/jdt/core/dom/TypeParameter.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ dom/org/eclipse/jdt/core/dom/TypeParameter.java 14 Apr 2003 18:47:52 -0000 @@ -0,0 +1,165 @@ +/******************************************************************************* + * Copyright (c) 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.jdt.core.dom; + +import java.util.List; + +/** + * Type parameter node. + *
    + * TypeParameter:
    + *    TypeVariable [ extends Type { & Type } ]
    + * 
    + *

    + * Note: Support for generic types is an experimental language feature + * under discussion in JSR-014 and under consideration for inclusion + * in the 1.5 release of J2SE. The support here is therefore tentative + * and subject to change. + *

    + * + * @since 2.2 + */ +public class TypeParameter extends ASTNode { + /** + * The type variable node; lazily initialized; defaults to an unspecfied, + * but legal, name. + */ + private SimpleName typeVariableName = null; + + /** + * The type bounds (element type: Type). + * Defaults to an empty list. + */ + private ASTNode.NodeList typeBounds = + new ASTNode.NodeList(false, Type.class); + + /** + * Creates a new unparented node for a parameterized type owned by the + * given AST. By default, an unspecified, but legal, type variable name, + * and no type bounds. + *

    + * N.B. This constructor is package-private. + *

    + * + * @param ast the AST that is to own this node + */ + TypeParameter(AST ast) { + super(ast); + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + public int getNodeType() { + return TYPE_PARAMETER; + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + ASTNode clone(AST target) { + TypeParameter result = new TypeParameter(target); + result.setSourceRange(this.getStartPosition(), this.getLength()); + result.setName((SimpleName) ((ASTNode) getName()).clone(target)); + result.typeBounds().addAll( + ASTNode.copySubtrees(target, typeBounds())); + return result; + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + public boolean subtreeMatch(ASTMatcher matcher, Object other) { + // dispatch to correct overloaded match method + return matcher.match(this, other); + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + void accept0(ASTVisitor visitor) { + boolean visitChildren = visitor.visit(this); + if (visitChildren) { + // visit children in normal left to right reading order + acceptChild(visitor, getName()); + acceptChildren(visitor, typeBounds); + } + visitor.endVisit(this); + } + + /** + * Returns the name of the type variable declared in this type parameter. + * + * @return the name of the type variable + */ + public SimpleName getName() { + if (typeVariableName == null) { + // lazy initialize - use setter to ensure parent link set too + long count = getAST().modificationCount(); + setName(new SimpleName(getAST())); + getAST().setModificationCount(count); + } + return typeVariableName; + } + + /** + * Sets the name of the type variable of this type parameter to the given + * name. + * + * @param typeName the new name of this type parameter + * @exception IllegalArgumentException if: + * + */ + public void setName(SimpleName typeName) { + if (typeName == null) { + throw new IllegalArgumentException(); + } + replaceChild(this.typeVariableName, typeName, false); + this.typeVariableName = typeName; + } + + /** + * Returns the live ordered list of type bounds of this type parameter. + * For the type parameter to be plausible, there can be at most one + * class in the list, and it must be first, and the remaining ones must be + * interfaces; the list should not contain primitive types (but array types + * and parameterized types are allowed). + * + * @return the live list of type bounds + * (element type: Type) + */ + public List typeBounds() { + return typeBounds; + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + int memSize() { + // treat Code as free + return BASE_NODE_SIZE + 2 * 4; + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + int treeSize() { + return + memSize() + + (typeVariableName == null ? 0 : getName().treeSize()) + + typeBounds.listSize(); + } +} +