This commit is contained in:
Tim Bell 2009-02-21 09:58:08 -08:00
commit ea24f38417
6 changed files with 96 additions and 19 deletions

View File

@ -125,7 +125,7 @@ public class PrintingProcessor extends AbstractProcessor {
return this;
defaultAction(e, true);
printFormalTypeParameters(e);
printFormalTypeParameters(e, true);
switch(kind) {
case CONSTRUCTOR:
@ -207,7 +207,7 @@ public class PrintingProcessor extends AbstractProcessor {
writer.print(" ");
writer.print(e.getSimpleName());
printFormalTypeParameters(e);
printFormalTypeParameters(e, false);
// Print superclass information if informative
if (kind == CLASS) {
@ -364,16 +364,9 @@ public class PrintingProcessor extends AbstractProcessor {
}
}
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("<");

View File

@ -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 @@ import javax.lang.model.type.*;
* @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.

View File

@ -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 @@ package javax.lang.model.element;
* @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.

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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 @@ import javax.lang.model.util.*;
* @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.