Fri, 20 Feb 2009 11:56:09 -0800
6460529: Provide mixin interfaces for getQualifiedName and getTypeParameters
Reviewed-by: jjg
1.1 --- a/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Wed Feb 18 13:47:27 2009 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Fri Feb 20 11:56:09 2009 -0800 1.3 @@ -125,7 +125,7 @@ 1.4 return this; 1.5 1.6 defaultAction(e, true); 1.7 - printFormalTypeParameters(e); 1.8 + printFormalTypeParameters(e, true); 1.9 1.10 switch(kind) { 1.11 case CONSTRUCTOR: 1.12 @@ -207,7 +207,7 @@ 1.13 writer.print(" "); 1.14 writer.print(e.getSimpleName()); 1.15 1.16 - printFormalTypeParameters(e); 1.17 + printFormalTypeParameters(e, false); 1.18 1.19 // Print superclass information if informative 1.20 if (kind == CLASS) { 1.21 @@ -364,16 +364,9 @@ 1.22 } 1.23 } 1.24 1.25 - private void printFormalTypeParameters(ExecutableElement executable) { 1.26 - printFormalTypeParameters(executable.getTypeParameters(), true); 1.27 - } 1.28 - 1.29 - private void printFormalTypeParameters(TypeElement type) { 1.30 - printFormalTypeParameters(type.getTypeParameters(), false); 1.31 - } 1.32 - 1.33 - private void printFormalTypeParameters(List<? extends TypeParameterElement> typeParams, 1.34 + private void printFormalTypeParameters(Parameterizable e, 1.35 boolean pad) { 1.36 + List<? extends TypeParameterElement> typeParams = e.getTypeParameters(); 1.37 if (typeParams.size() > 0) { 1.38 writer.print("<"); 1.39
2.1 --- a/src/share/classes/javax/lang/model/element/ExecutableElement.java Wed Feb 18 13:47:27 2009 -0800 2.2 +++ b/src/share/classes/javax/lang/model/element/ExecutableElement.java Fri Feb 20 11:56:09 2009 -0800 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. 2.6 + * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -40,7 +40,7 @@ 2.11 * @see ExecutableType 2.12 * @since 1.6 2.13 */ 2.14 -public interface ExecutableElement extends Element { 2.15 +public interface ExecutableElement extends Element, Parameterizable { 2.16 /** 2.17 * Returns the formal type parameters of this executable 2.18 * in declaration order.
3.1 --- a/src/share/classes/javax/lang/model/element/PackageElement.java Wed Feb 18 13:47:27 2009 -0800 3.2 +++ b/src/share/classes/javax/lang/model/element/PackageElement.java Fri Feb 20 11:56:09 2009 -0800 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. 3.6 + * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -25,7 +25,6 @@ 3.11 3.12 package javax.lang.model.element; 3.13 3.14 - 3.15 /** 3.16 * Represents a package program element. Provides access to information 3.17 * about the package and its members. 3.18 @@ -36,8 +35,7 @@ 3.19 * @see javax.lang.model.util.Elements#getPackageOf 3.20 * @since 1.6 3.21 */ 3.22 - 3.23 -public interface PackageElement extends Element { 3.24 +public interface PackageElement extends Element, QualifiedNameable { 3.25 3.26 /** 3.27 * Returns the fully qualified name of this package.
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/src/share/classes/javax/lang/model/element/Parameterizable.java Fri Feb 20 11:56:09 2009 -0800 4.3 @@ -0,0 +1,45 @@ 4.4 +/* 4.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.7 + * 4.8 + * This code is free software; you can redistribute it and/or modify it 4.9 + * under the terms of the GNU General Public License version 2 only, as 4.10 + * published by the Free Software Foundation. Sun designates this 4.11 + * particular file as subject to the "Classpath" exception as provided 4.12 + * by Sun in the LICENSE file that accompanied this code. 4.13 + * 4.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 4.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4.17 + * version 2 for more details (a copy is included in the LICENSE file that 4.18 + * accompanied this code). 4.19 + * 4.20 + * You should have received a copy of the GNU General Public License version 4.21 + * 2 along with this work; if not, write to the Free Software Foundation, 4.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4.23 + * 4.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 4.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 4.26 + * have any questions. 4.27 + */ 4.28 + 4.29 +package javax.lang.model.element; 4.30 + 4.31 +import java.util.List; 4.32 + 4.33 +/** 4.34 + * A mixin interface for an element that has type parameters. 4.35 + * 4.36 + * @author Joseph D. Darcy 4.37 + * @since 1.7 4.38 + */ 4.39 +public interface Parameterizable extends Element { 4.40 + /** 4.41 + * Returns the formal type parameters of the type element in 4.42 + * declaration order. 4.43 + * 4.44 + * @return the formal type parameters, or an empty list 4.45 + * if there are none 4.46 + */ 4.47 + List<? extends TypeParameterElement> getTypeParameters(); 4.48 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/src/share/classes/javax/lang/model/element/QualifiedNameable.java Fri Feb 20 11:56:09 2009 -0800 5.3 @@ -0,0 +1,41 @@ 5.4 +/* 5.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.7 + * 5.8 + * This code is free software; you can redistribute it and/or modify it 5.9 + * under the terms of the GNU General Public License version 2 only, as 5.10 + * published by the Free Software Foundation. Sun designates this 5.11 + * particular file as subject to the "Classpath" exception as provided 5.12 + * by Sun in the LICENSE file that accompanied this code. 5.13 + * 5.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 5.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 5.17 + * version 2 for more details (a copy is included in the LICENSE file that 5.18 + * accompanied this code). 5.19 + * 5.20 + * You should have received a copy of the GNU General Public License version 5.21 + * 2 along with this work; if not, write to the Free Software Foundation, 5.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5.23 + * 5.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 5.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 5.26 + * have any questions. 5.27 + */ 5.28 + 5.29 +package javax.lang.model.element; 5.30 + 5.31 +/** 5.32 + * A mixin interface for an element that has a qualified name. 5.33 + * 5.34 + * @author Joseph D. Darcy 5.35 + * @since 1.7 5.36 + */ 5.37 +public interface QualifiedNameable extends Element { 5.38 + /** 5.39 + * Returns the fully qualified name of an element. 5.40 + * 5.41 + * @return the fully qualified name of an element 5.42 + */ 5.43 + Name getQualifiedName(); 5.44 +}
6.1 --- a/src/share/classes/javax/lang/model/element/TypeElement.java Wed Feb 18 13:47:27 2009 -0800 6.2 +++ b/src/share/classes/javax/lang/model/element/TypeElement.java Fri Feb 20 11:56:09 2009 -0800 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. 6.6 + * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -59,7 +59,7 @@ 6.11 * @see DeclaredType 6.12 * @since 1.6 6.13 */ 6.14 -public interface TypeElement extends Element { 6.15 +public interface TypeElement extends Element, Parameterizable, QualifiedNameable { 6.16 6.17 /** 6.18 * Returns the <i>nesting kind</i> of this type element.