6460529: Provide mixin interfaces for getQualifiedName and getTypeParameters
Reviewed-by: jjg
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Wed Feb 18 13:47:27 2009 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Fri Feb 20 11:56:09 2009 -0800
@@ -125,7 +125,7 @@
return this;
defaultAction(e, true);
- printFormalTypeParameters(e);
+ printFormalTypeParameters(e, true);
switch(kind) {
case CONSTRUCTOR:
@@ -207,7 +207,7 @@
writer.print(" ");
writer.print(e.getSimpleName());
- printFormalTypeParameters(e);
+ printFormalTypeParameters(e, false);
// Print superclass information if informative
if (kind == CLASS) {
@@ -364,16 +364,9 @@
}
}
- private void printFormalTypeParameters(ExecutableElement executable) {
- printFormalTypeParameters(executable.getTypeParameters(), true);
- }
-
- private void printFormalTypeParameters(TypeElement type) {
- printFormalTypeParameters(type.getTypeParameters(), false);
- }
-
- private void printFormalTypeParameters(List<? extends TypeParameterElement> typeParams,
+ private void printFormalTypeParameters(Parameterizable e,
boolean pad) {
+ List<? extends TypeParameterElement> typeParams = e.getTypeParameters();
if (typeParams.size() > 0) {
writer.print("<");
--- a/langtools/src/share/classes/javax/lang/model/element/ExecutableElement.java Wed Feb 18 13:47:27 2009 -0800
+++ b/langtools/src/share/classes/javax/lang/model/element/ExecutableElement.java Fri Feb 20 11:56:09 2009 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@
* @see ExecutableType
* @since 1.6
*/
-public interface ExecutableElement extends Element {
+public interface ExecutableElement extends Element, Parameterizable {
/**
* Returns the formal type parameters of this executable
* in declaration order.
--- a/langtools/src/share/classes/javax/lang/model/element/PackageElement.java Wed Feb 18 13:47:27 2009 -0800
+++ b/langtools/src/share/classes/javax/lang/model/element/PackageElement.java Fri Feb 20 11:56:09 2009 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
package javax.lang.model.element;
-
/**
* Represents a package program element. Provides access to information
* about the package and its members.
@@ -36,8 +35,7 @@
* @see javax.lang.model.util.Elements#getPackageOf
* @since 1.6
*/
-
-public interface PackageElement extends Element {
+public interface PackageElement extends Element, QualifiedNameable {
/**
* Returns the fully qualified name of this package.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/javax/lang/model/element/Parameterizable.java Fri Feb 20 11:56:09 2009 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package javax.lang.model.element;
+
+import java.util.List;
+
+/**
+ * A mixin interface for an element that has type parameters.
+ *
+ * @author Joseph D. Darcy
+ * @since 1.7
+ */
+public interface Parameterizable extends Element {
+ /**
+ * Returns the formal type parameters of the type element in
+ * declaration order.
+ *
+ * @return the formal type parameters, or an empty list
+ * if there are none
+ */
+ List<? extends TypeParameterElement> getTypeParameters();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/javax/lang/model/element/QualifiedNameable.java Fri Feb 20 11:56:09 2009 -0800
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package javax.lang.model.element;
+
+/**
+ * A mixin interface for an element that has a qualified name.
+ *
+ * @author Joseph D. Darcy
+ * @since 1.7
+ */
+public interface QualifiedNameable extends Element {
+ /**
+ * Returns the fully qualified name of an element.
+ *
+ * @return the fully qualified name of an element
+ */
+ Name getQualifiedName();
+}
--- a/langtools/src/share/classes/javax/lang/model/element/TypeElement.java Wed Feb 18 13:47:27 2009 -0800
+++ b/langtools/src/share/classes/javax/lang/model/element/TypeElement.java Fri Feb 20 11:56:09 2009 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -59,7 +59,7 @@
* @see DeclaredType
* @since 1.6
*/
-public interface TypeElement extends Element {
+public interface TypeElement extends Element, Parameterizable, QualifiedNameable {
/**
* Returns the <i>nesting kind</i> of this type element.