7041249: Remove apt tool and API from the JDK
Reviewed-by: jjg, ohair
This commit is contained in:
parent
da83df8bb7
commit
f30ca2fd58
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2007, 2012 Oracle and/or its affiliates. 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
|
||||
@ -115,7 +115,6 @@ JAVAC_JAR = $(LIB_DIR)/javac.jar
|
||||
JAVADOC_JAR = $(LIB_DIR)/javadoc.jar
|
||||
JAVAH_JAR = $(LIB_DIR)/javah.jar
|
||||
JAVAP_JAR = $(LIB_DIR)/javap.jar
|
||||
APT_JAR = $(LIB_DIR)/apt.jar
|
||||
|
||||
CLASSES_JAR = $(DIST_DIR)/classes.jar
|
||||
SRC_ZIP = $(DIST_DIR)/src.zip
|
||||
@ -163,7 +162,7 @@ endif
|
||||
|
||||
#----- useful macros
|
||||
|
||||
TOOLS = javac javadoc javah javap apt
|
||||
TOOLS = javac javadoc javah javap
|
||||
|
||||
SOURCE_LEVEL = 5
|
||||
BOOTSTRAP_TARGET_LEVEL = 5
|
||||
@ -319,28 +318,6 @@ $(JAVAP_JAR): $(JAVAP_JAVA_FILES) \
|
||||
( $(ECHO) Main-Class: sun.tools.javap.Main ) > $(BUILD_DIR)/javap.mf
|
||||
$(BOOTJAR) -cfm $@ $(BUILD_DIR)/javap.mf $(patsubst %,-C $(CLASSES_DIR) %, $(JAVAP_DIRS))
|
||||
|
||||
#----- apt
|
||||
|
||||
APT_DIRS = \
|
||||
com/sun/mirror \
|
||||
com/sun/tools/apt
|
||||
|
||||
APT_RESOURCE_FILES = \
|
||||
$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(APT_DIRS)) -name SCCS -prune -o -name \*.properties -print )
|
||||
|
||||
APT_JAVA_FILES = \
|
||||
$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(APT_DIRS)) -name SCCS -prune -o -name \*.java -print ) \
|
||||
$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(APT_RESOURCE_FILES))
|
||||
|
||||
$(APT_JAR): $(APT_JAVA_FILES) $(JAVAC_JAR) \
|
||||
$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(APT_RESOURCE_FILES))
|
||||
$(MKDIR) -p $(CLASSES_DIR) $(@D)
|
||||
$(BOOT_JAVAC) -sourcepath "" -classpath $(CLASSES_DIR) -d $(CLASSES_DIR) -target $(TARGET_LEVEL) $(NO_PROPRIETARY_API_WARNINGS) \
|
||||
$(APT_JAVA_FILES) \
|
||||
$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(APT_RESOURCE_FILES))
|
||||
( $(ECHO) Main-Class: com.sun.tools.apt.Main ; $(ECHO) Class-Path: javac.jar ) > $(BUILD_DIR)/apt.mf
|
||||
$(BOOTJAR) -cfm $@ $(BUILD_DIR)/apt.mf $(patsubst %,-C $(CLASSES_DIR) %, $(APT_DIRS))
|
||||
|
||||
#-----
|
||||
|
||||
build-tools: $(BUILDTOOLCLASSES_DIR)/CompileProperties/CompileProperties.class
|
||||
@ -366,7 +343,7 @@ $(BUILDTOOLCLASSES_DIR)/%.class : $(BUILDTOOLSRC_DIR)/%.java
|
||||
|
||||
#----- all classes
|
||||
|
||||
$(DIST_DIR)/%/classes.jar: $(JAVAC_JAR) $(JAVADOC_JAR) $(JAVAH_JAR) $(JAVAP_JAR) $(APT_JAR)
|
||||
$(DIST_DIR)/%/classes.jar: $(JAVAC_JAR) $(JAVADOC_JAR) $(JAVAH_JAR) $(JAVAP_JAR)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(BOOTJAR) -cf $@ -C $(CLASSES_DIR) .
|
||||
|
||||
@ -401,7 +378,6 @@ quick-check: $(patsubst %, $(DIST_LIB_DIR)/%.jar, $(TOOLS))
|
||||
- $(TESTJAVA) -jar $(JAVADOC_JAR) -version
|
||||
$(TESTJAVA) -jar $(JAVAH_JAR) -version
|
||||
- $(TESTJAVA) -jar $(JAVAP_JAR) -version
|
||||
$(TESTJAVA) -jar $(APT_JAR) -version
|
||||
|
||||
#-----
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2007, 2012, Oracle and/or its affiliates. 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
|
||||
@ -159,15 +159,6 @@ javap.tests = \
|
||||
|
||||
#
|
||||
|
||||
apt.includes = \
|
||||
com/sun/mirror/ \
|
||||
com/sun/tools/apt/
|
||||
|
||||
apt.tests = \
|
||||
tools/apt/
|
||||
|
||||
#
|
||||
|
||||
# The following files require the latest JDK to be available.
|
||||
# The API can be provided by using a suitable boot.java.home
|
||||
# or by setting import.jdk
|
||||
|
@ -83,7 +83,7 @@
|
||||
- global property definitions
|
||||
- general top level targets
|
||||
- general diagnostic/debugging targets
|
||||
- groups of targets for each tool: javac, javadoc, doclets, javah, javap, apt
|
||||
- groups of targets for each tool: javac, javadoc, doclets, javah, javap
|
||||
Within each group, the following targets are provided, where applicable
|
||||
build-bootstrap-TOOL build the bootstrap version of the tool
|
||||
build-classes-TOOL build the classes for the tool
|
||||
@ -245,11 +245,11 @@
|
||||
/>
|
||||
|
||||
<target name="build-all-tools"
|
||||
depends="build-javac,build-javadoc,build-doclets,build-javah,build-javap,build-apt"
|
||||
depends="build-javac,build-javadoc,build-doclets,build-javah,build-javap"
|
||||
/>
|
||||
|
||||
<target name="build-all-classes" depends="build-bootstrap-javac,-create-import-jdk-stubs">
|
||||
<build-classes includes="${javac.includes} ${javadoc.includes} ${doclets.includes} ${javah.includes} ${javap.includes} ${apt.includes}"/>
|
||||
<build-classes includes="${javac.includes} ${javadoc.includes} ${doclets.includes} ${javah.includes} ${javap.includes}"/>
|
||||
</target>
|
||||
|
||||
<!-- clean -->
|
||||
@ -656,42 +656,6 @@
|
||||
<target name="javap" depends="build-javap,jtreg-javap,findbugs-javap"/>
|
||||
|
||||
|
||||
<!--
|
||||
**** apt targets.
|
||||
-->
|
||||
|
||||
<target name="build-bootstrap-apt" depends="build-bootstrap-javac">
|
||||
<build-bootstrap-classes includes="${apt.includes}"/>
|
||||
<build-bootstrap-jar name="apt" includes="${apt.includes}"
|
||||
jarclasspath="javac.jar"/>
|
||||
<build-bootstrap-tool name="apt"/>
|
||||
</target>
|
||||
|
||||
<target name="build-apt" depends="build-javac,build-classes-apt">
|
||||
<build-jar name="apt" includes="${apt.includes}" jarclasspath="javac.jar"/>
|
||||
<build-tool name="apt"/>
|
||||
</target>
|
||||
|
||||
<target name="build-classes-apt" depends="build-classes-javac">
|
||||
<build-classes includes="${apt.includes}"/>
|
||||
</target>
|
||||
|
||||
<target name="javadoc-apt" depends="build-apt,-def-javadoc-tool">
|
||||
<javadoc-tool name="apt" includes="${apt.includes}"/>
|
||||
</target>
|
||||
|
||||
|
||||
<target name="jtreg-apt" depends="build-apt,-def-jtreg">
|
||||
<jtreg-tool name="apt" tests="${apt.tests}"/>
|
||||
</target>
|
||||
|
||||
<target name="findbugs-apt" depends="build-apt,-def-findbugs">
|
||||
<findbugs-tool name="apt"/>
|
||||
</target>
|
||||
|
||||
<target name="apt" depends="build-apt,jtreg-apt,findbugs-apt"/>
|
||||
|
||||
|
||||
<!--
|
||||
**** Create import JDK stubs.
|
||||
-->
|
||||
@ -967,7 +931,6 @@
|
||||
<filename name="java/"/>
|
||||
<filename name="javax/"/>
|
||||
<filename name="com/sun/javadoc/"/>
|
||||
<filename name="com/sun/mirror/"/>
|
||||
<filename name="com/sun/source/"/>
|
||||
</or>
|
||||
</packageset>
|
||||
|
@ -7,7 +7,7 @@ edit, run, test and debug the tools in the OpenJDK langtools
|
||||
repository.
|
||||
|
||||
The repository contains a number of tools:
|
||||
apt, javac, javadoc and its doclets, javah and javap.
|
||||
javac, javadoc and its doclets, javah and javap.
|
||||
|
||||
Build Properties.
|
||||
|
||||
|
@ -1,42 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2002, 2007, Oracle and/or its affiliates. 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.
|
||||
#
|
||||
# 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# @test
|
||||
# @summary Verify the basic execution of the apt classes in classes.jar.
|
||||
|
||||
TESTSRC=${TESTSRC:-.}
|
||||
TOPDIR=${TESTSRC}/../../..
|
||||
TESTJAVAEXE="${TESTJAVA:+${TESTJAVA}/bin/}java"
|
||||
|
||||
"${TESTJAVAEXE}" -Xbootclasspath/p:${TOPDIR}/dist/lib/classes.jar \
|
||||
com.sun.tools.apt.Main \
|
||||
-print "${TESTSRC}"/../HelloWorld.java > apt.tmp
|
||||
|
||||
if diff ${TESTSRC}/../HelloWorld.apt.gold.txt apt.tmp ; then
|
||||
echo "Test passed."
|
||||
else
|
||||
echo "Test failed."
|
||||
exit 1
|
||||
fi
|
@ -1,14 +1,4 @@
|
||||
com/sun/javadoc/package.html
|
||||
com/sun/mirror/apt/package.html
|
||||
com/sun/mirror/declaration/package.html
|
||||
com/sun/mirror/overview.html
|
||||
com/sun/mirror/type/package.html
|
||||
com/sun/mirror/util/package.html
|
||||
com/sun/tools/apt/Main.java
|
||||
com/sun/tools/apt/main/Main.java
|
||||
com/sun/tools/apt/resources/apt.properties
|
||||
com/sun/tools/apt/resources/apt_ja.properties
|
||||
com/sun/tools/apt/resources/apt_zh_CN.properties
|
||||
com/sun/tools/doclets/formats/html/markup/package.html
|
||||
com/sun/tools/doclets/formats/html/package.html
|
||||
com/sun/tools/doclets/formats/html/resources/standard.properties
|
||||
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.apt;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
* An annotation processor, used to examine and process the
|
||||
* annotations of program elements. An annotation processor may,
|
||||
* for example, create new source files and XML documents to be used
|
||||
* in conjunction with the original code.
|
||||
*
|
||||
* <p> An annotation processor is constructed by a
|
||||
* {@linkplain AnnotationProcessorFactory factory}, which provides it with an
|
||||
* {@linkplain AnnotationProcessorEnvironment environment} that
|
||||
* encapsulates the state it needs.
|
||||
* Messages regarding warnings and errors encountered during processing
|
||||
* should be directed to the environment's {@link Messager},
|
||||
* and new files may be created using the environment's {@link Filer}.
|
||||
*
|
||||
* <p> Each annotation processor is created to process annotations
|
||||
* of a particular annotation type or set of annotation types.
|
||||
* It may use its environment to find the program elements with
|
||||
* annotations of those types. It may freely examine any other program
|
||||
* elements in the course of its processing.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.annotation.processing.Processor}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface AnnotationProcessor {
|
||||
|
||||
/**
|
||||
* Process all program elements supported by this annotation processor.
|
||||
*/
|
||||
void process();
|
||||
}
|
@ -1,182 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.apt;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* The environment encapsulating the state needed by an annotation processor.
|
||||
* An annotation processing tool makes this environment available
|
||||
* to all annotation processors.
|
||||
*
|
||||
* <p> When an annotation processing tool is invoked, it is given a
|
||||
* set of type declarations on which to operate. These
|
||||
* are refered to as the <i>specified</i> types.
|
||||
* The type declarations said to be <i>included</i> in this invocation
|
||||
* consist of the specified types and any types nested within them.
|
||||
*
|
||||
* <p> {@link DeclarationFilter}
|
||||
* provides a simple way to select just the items of interest
|
||||
* when a method returns a collection of declarations.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.annotation.processing.ProcessingEnvironment}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface AnnotationProcessorEnvironment {
|
||||
|
||||
/**
|
||||
* Returns the options passed to the annotation processing tool.
|
||||
* Options are returned in the form of a map from option name
|
||||
* (such as <tt>"-encoding"</tt>) to option value.
|
||||
* For an option with no value (such as <tt>"-help"</tt>), the
|
||||
* corresponding value in the map is <tt>null</tt>.
|
||||
*
|
||||
* <p> Options beginning with <tt>"-A"</tt> are <i>processor-specific.</i>
|
||||
* Such options are unrecognized by the tool, but intended to be used by
|
||||
* some annotation processor.
|
||||
*
|
||||
* @return the options passed to the tool
|
||||
*/
|
||||
Map<String,String> getOptions();
|
||||
|
||||
/**
|
||||
* Returns the messager used to report errors, warnings, and other
|
||||
* notices.
|
||||
*
|
||||
* @return the messager
|
||||
*/
|
||||
Messager getMessager();
|
||||
|
||||
/**
|
||||
* Returns the filer used to create new source, class, or auxiliary
|
||||
* files.
|
||||
*
|
||||
* @return the filer
|
||||
*/
|
||||
Filer getFiler();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the declarations of the types specified when the
|
||||
* annotation processing tool was invoked.
|
||||
*
|
||||
* @return the types specified when the tool was invoked, or an
|
||||
* empty collection if there were none
|
||||
*/
|
||||
Collection<TypeDeclaration> getSpecifiedTypeDeclarations();
|
||||
|
||||
/**
|
||||
* Returns the declaration of a package given its fully qualified name.
|
||||
*
|
||||
* @param name fully qualified package name, or "" for the unnamed package
|
||||
* @return the declaration of the named package, or null if it cannot
|
||||
* be found
|
||||
*/
|
||||
PackageDeclaration getPackage(String name);
|
||||
|
||||
/**
|
||||
* Returns the declaration of a type given its fully qualified name.
|
||||
*
|
||||
* @param name fully qualified type name
|
||||
* @return the declaration of the named type, or null if it cannot be
|
||||
* found
|
||||
*/
|
||||
TypeDeclaration getTypeDeclaration(String name);
|
||||
|
||||
/**
|
||||
* A convenience method that returns the declarations of the types
|
||||
* {@linkplain AnnotationProcessorEnvironment <i>included</i>}
|
||||
* in this invocation of the annotation processing tool.
|
||||
*
|
||||
* @return the declarations of the types included in this invocation
|
||||
* of the tool, or an empty collection if there are none
|
||||
*/
|
||||
Collection<TypeDeclaration> getTypeDeclarations();
|
||||
|
||||
/**
|
||||
* Returns the declarations annotated with the given annotation type.
|
||||
* Only declarations of the types
|
||||
* {@linkplain AnnotationProcessorEnvironment <i>included</i>}
|
||||
* in this invocation of the annotation processing tool, or
|
||||
* declarations of members, parameters, or type parameters
|
||||
* declared within those, are returned.
|
||||
*
|
||||
* @param a annotation type being requested
|
||||
* @return the declarations annotated with the given annotation type,
|
||||
* or an empty collection if there are none
|
||||
*/
|
||||
Collection<Declaration> getDeclarationsAnnotatedWith(
|
||||
AnnotationTypeDeclaration a);
|
||||
|
||||
/**
|
||||
* Returns an implementation of some utility methods for
|
||||
* operating on declarations.
|
||||
*
|
||||
* @return declaration utilities
|
||||
*/
|
||||
Declarations getDeclarationUtils();
|
||||
|
||||
/**
|
||||
* Returns an implementation of some utility methods for
|
||||
* operating on types.
|
||||
*
|
||||
* @return type utilities
|
||||
*/
|
||||
Types getTypeUtils();
|
||||
|
||||
/**
|
||||
* Add a listener. If the listener is currently registered to listen,
|
||||
* adding it again will have no effect.
|
||||
*
|
||||
* @param listener The listener to add.
|
||||
* @throws NullPointerException if the listener is null
|
||||
*/
|
||||
void addListener(AnnotationProcessorListener listener);
|
||||
|
||||
|
||||
/**
|
||||
* Remove a listener. If the listener is not currently listening,
|
||||
* the method call does nothing.
|
||||
*
|
||||
* @param listener The listener to remove.
|
||||
* @throws NullPointerException if the listener is null
|
||||
*/
|
||||
void removeListener(AnnotationProcessorListener listener);
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.apt;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
|
||||
|
||||
|
||||
/**
|
||||
* A factory for creating annotation processors.
|
||||
* Each factory is responsible for creating processors for one or more
|
||||
* annotation types.
|
||||
* The factory is said to <i>support</i> these types.
|
||||
*
|
||||
* <p> Each implementation of an <tt>AnnotationProcessorFactory</tt>
|
||||
* must provide a public no-argument constructor to be used by tools to
|
||||
* instantiate the factory.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.annotation.processing.Processor}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface AnnotationProcessorFactory {
|
||||
|
||||
/**
|
||||
* Returns the options recognized by this factory or by any of the
|
||||
* processors it may create.
|
||||
* Only {@linkplain AnnotationProcessorEnvironment#getOptions()
|
||||
* processor-specific} options are included, each of which begins
|
||||
* with <tt>"-A"</tt>. For example, if this factory recognizes
|
||||
* options such as <tt>-Adebug -Aloglevel=3</tt>, it will
|
||||
* return the strings <tt>"-Adebug"</tt> and <tt>"-Aloglevel"</tt>.
|
||||
*
|
||||
* <p> A tool might use this information to determine if any
|
||||
* options provided by a user are unrecognized by any processor,
|
||||
* in which case it may wish to report an error.
|
||||
*
|
||||
* @return the options recognized by this factory or by any of the
|
||||
* processors it may create, or an empty collection if none
|
||||
*/
|
||||
Collection<String> supportedOptions();
|
||||
|
||||
/**
|
||||
* Returns the names of the annotation types supported by this factory.
|
||||
* An element of the result may be the canonical (fully qualified) name
|
||||
* of a supported annotation type. Alternately it may be of the form
|
||||
* <tt>"<i>name</i>.*"</tt>
|
||||
* representing the set of all annotation types
|
||||
* with canonical names beginning with <tt>"<i>name</i>."</tt>
|
||||
* Finally, <tt>"*"</tt> by itself represents the set of all
|
||||
* annotation types.
|
||||
*
|
||||
* @return the names of the annotation types supported by this factory
|
||||
*/
|
||||
Collection<String> supportedAnnotationTypes();
|
||||
|
||||
/**
|
||||
* Returns an annotation processor for a set of annotation
|
||||
* types. The set will be empty if the factory supports
|
||||
* "<tt>*</tt>" and the specified type declarations have
|
||||
* no annotations. Note that the set of annotation types may be
|
||||
* empty for other reasons, such as giving the factory an
|
||||
* opportunity to register a listener. An
|
||||
* <tt>AnnotationProcessorFactory</tt> must gracefully handle an
|
||||
* empty set of annotations; an appropriate response to an empty
|
||||
* set will often be returning {@link AnnotationProcessors#NO_OP}.
|
||||
*
|
||||
* @param atds type declarations of the annotation types to be processed
|
||||
* @param env environment to use during processing
|
||||
* @return an annotation processor for the given annotation types,
|
||||
* or <tt>null</tt> if the types are not supported or the
|
||||
* processor cannot be created
|
||||
*/
|
||||
AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
|
||||
AnnotationProcessorEnvironment env);
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.apt;
|
||||
|
||||
/**
|
||||
* Superinterface for all annotation processor event listeners.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. This interface has no
|
||||
* direct analog in the standardized API because the different round
|
||||
* model renders it unnecessary.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface AnnotationProcessorListener extends java.util.EventListener {}
|
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.apt;
|
||||
|
||||
import com.sun.mirror.apt.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Utilities to create specialized annotation processors.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. There is no direct analog
|
||||
* of the functionality of this class in the standardized API.
|
||||
*
|
||||
* @since 1.5
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AnnotationProcessors {
|
||||
static class NoOpAP implements AnnotationProcessor {
|
||||
NoOpAP() {}
|
||||
public void process(){}
|
||||
}
|
||||
|
||||
/**
|
||||
* Combines multiple annotation processors into a simple composite
|
||||
* processor.
|
||||
* The composite processor functions by invoking each of its component
|
||||
* processors in sequence.
|
||||
*/
|
||||
static class CompositeAnnotationProcessor implements AnnotationProcessor {
|
||||
|
||||
private List<AnnotationProcessor> aps =
|
||||
new LinkedList<AnnotationProcessor>();
|
||||
|
||||
/**
|
||||
* Constructs a new composite annotation processor.
|
||||
* @param aps the component annotation processors
|
||||
*/
|
||||
public CompositeAnnotationProcessor(Collection<AnnotationProcessor> aps) {
|
||||
this.aps.addAll(aps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new composite annotation processor.
|
||||
* @param aps the component annotation processors
|
||||
*/
|
||||
public CompositeAnnotationProcessor(AnnotationProcessor... aps) {
|
||||
for(AnnotationProcessor ap: aps)
|
||||
this.aps.add(ap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes the <tt>process</tt> method of each component processor,
|
||||
* in the order in which the processors were passed to the constructor.
|
||||
*/
|
||||
public void process() {
|
||||
for(AnnotationProcessor ap: aps)
|
||||
ap.process();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An annotation processor that does nothing and has no state.
|
||||
* May be used multiple times.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public final static AnnotationProcessor NO_OP = new NoOpAP();
|
||||
|
||||
/**
|
||||
* Constructs a new composite annotation processor. A composite
|
||||
* annotation processor combines multiple annotation processors
|
||||
* into one and functions by invoking each of its component
|
||||
* processors' process methods in sequence.
|
||||
*
|
||||
* @param aps The processors to create a composite of
|
||||
* @since 1.5
|
||||
*/
|
||||
public static AnnotationProcessor getCompositeAnnotationProcessor(AnnotationProcessor... aps) {
|
||||
return new CompositeAnnotationProcessor(aps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new composite annotation processor. A composite
|
||||
* annotation processor combines multiple annotation processors
|
||||
* into one and functions by invoking each of its component
|
||||
* processors' process methods in the sequence the processors are
|
||||
* returned by the collection's iterator.
|
||||
*
|
||||
* @param aps A collection of processors to create a composite of
|
||||
* @since 1.5
|
||||
*/
|
||||
public static AnnotationProcessor getCompositeAnnotationProcessor(Collection<AnnotationProcessor> aps) {
|
||||
return new CompositeAnnotationProcessor(aps);
|
||||
}
|
||||
}
|
@ -1,162 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.apt;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
|
||||
|
||||
/**
|
||||
* This interface supports the creation of new files by an
|
||||
* annotation processor.
|
||||
* Files created in this way will be known to the annotation processing
|
||||
* tool implementing this interface, better enabling the tool to manage them.
|
||||
* Four kinds of files are distinguished:
|
||||
* source files, class files, other text files, and other binary files.
|
||||
* The latter two are collectively referred to as <i>auxiliary</i> files.
|
||||
*
|
||||
* <p> There are two distinguished locations (subtrees within the
|
||||
* file system) where newly created files are placed:
|
||||
* one for new source files, and one for new class files.
|
||||
* (These might be specified on a tool's command line, for example,
|
||||
* using flags such as <tt>-s</tt> and <tt>-d</tt>.)
|
||||
* Auxiliary files may be created in either location.
|
||||
*
|
||||
* <p> During each run of an annotation processing tool, a file
|
||||
* with a given pathname may be created only once. If that file already
|
||||
* exists before the first attempt to create it, the old contents will
|
||||
* be deleted. Any subsequent attempt to create the same file during
|
||||
* a run will fail.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.annotation.processing.Filer}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface Filer {
|
||||
|
||||
/**
|
||||
* Creates a new source file and returns a writer for it.
|
||||
* The file's name and path (relative to the root of all newly created
|
||||
* source files) is based on the type to be declared in that file.
|
||||
* If more than one type is being declared, the name of the principal
|
||||
* top-level type (the public one, for example) should be used.
|
||||
*
|
||||
* <p> The {@linkplain java.nio.charset.Charset charset} used to
|
||||
* encode the file is determined by the implementation.
|
||||
* An annotation processing tool may have an <tt>-encoding</tt>
|
||||
* flag or the like for specifying this. It will typically use
|
||||
* the platform's default encoding if none is specified.
|
||||
*
|
||||
* @param name canonical (fully qualified) name of the principal type
|
||||
* being declared in this file
|
||||
* @return a writer for the new file
|
||||
* @throws IOException if the file cannot be created
|
||||
*/
|
||||
PrintWriter createSourceFile(String name) throws IOException;
|
||||
|
||||
/**
|
||||
* Creates a new class file, and returns a stream for writing to it.
|
||||
* The file's name and path (relative to the root of all newly created
|
||||
* class files) is based on the name of the type being written.
|
||||
*
|
||||
* @param name canonical (fully qualified) name of the type being written
|
||||
* @return a stream for writing to the new file
|
||||
* @throws IOException if the file cannot be created
|
||||
*/
|
||||
OutputStream createClassFile(String name) throws IOException;
|
||||
|
||||
/**
|
||||
* Creates a new text file, and returns a writer for it.
|
||||
* The file is located along with either the
|
||||
* newly created source or newly created binary files. It may be
|
||||
* named relative to some package (as are source and binary files),
|
||||
* and from there by an arbitrary pathname. In a loose sense, the
|
||||
* pathname of the new file will be the concatenation of
|
||||
* <tt>loc</tt>, <tt>pkg</tt>, and <tt>relPath</tt>.
|
||||
*
|
||||
* <p> A {@linkplain java.nio.charset.Charset charset} for
|
||||
* encoding the file may be provided. If none is given, the
|
||||
* charset used to encode source files
|
||||
* (see {@link #createSourceFile(String)}) will be used.
|
||||
*
|
||||
* @param loc location of the new file
|
||||
* @param pkg package relative to which the file should be named,
|
||||
* or the empty string if none
|
||||
* @param relPath final pathname components of the file
|
||||
* @param charsetName the name of the charset to use, or null if none
|
||||
* is being explicitly specified
|
||||
* @return a writer for the new file
|
||||
* @throws IOException if the file cannot be created
|
||||
*/
|
||||
PrintWriter createTextFile(Location loc,
|
||||
String pkg,
|
||||
File relPath,
|
||||
String charsetName) throws IOException;
|
||||
|
||||
/**
|
||||
* Creates a new binary file, and returns a stream for writing to it.
|
||||
* The file is located along with either the
|
||||
* newly created source or newly created binary files. It may be
|
||||
* named relative to some package (as are source and binary files),
|
||||
* and from there by an arbitrary pathname. In a loose sense, the
|
||||
* pathname of the new file will be the concatenation of
|
||||
* <tt>loc</tt>, <tt>pkg</tt>, and <tt>relPath</tt>.
|
||||
*
|
||||
* @param loc location of the new file
|
||||
* @param pkg package relative to which the file should be named,
|
||||
* or the empty string if none
|
||||
* @param relPath final pathname components of the file
|
||||
* @return a stream for writing to the new file
|
||||
* @throws IOException if the file cannot be created
|
||||
*/
|
||||
OutputStream createBinaryFile(Location loc,
|
||||
String pkg,
|
||||
File relPath) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Locations (subtrees within the file system) where new files are created.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by
|
||||
* the standardized annotation processing API. The replacement
|
||||
* for the functionality of this enum is {@link
|
||||
* javax.tools.StandardLocation}.
|
||||
*/
|
||||
@Deprecated
|
||||
enum Location {
|
||||
/** The location of new source files. */
|
||||
SOURCE_TREE,
|
||||
/** The location of new class files. */
|
||||
CLASS_TREE
|
||||
}
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.apt;
|
||||
|
||||
import com.sun.mirror.util.SourcePosition;
|
||||
|
||||
/**
|
||||
* A <tt>Messager</tt> provides the way for
|
||||
* an annotation processor to report error messages, warnings, and
|
||||
* other notices.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.annotation.processing.Messager}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface Messager {
|
||||
|
||||
/**
|
||||
* Prints an error message.
|
||||
* Equivalent to <tt>printError(null, msg)</tt>.
|
||||
* @param msg the message, or an empty string if none
|
||||
*/
|
||||
void printError(String msg);
|
||||
|
||||
/**
|
||||
* Prints an error message.
|
||||
* @param pos the position where the error occured, or null if it is
|
||||
* unknown or not applicable
|
||||
* @param msg the message, or an empty string if none
|
||||
*/
|
||||
void printError(SourcePosition pos, String msg);
|
||||
|
||||
/**
|
||||
* Prints a warning message.
|
||||
* Equivalent to <tt>printWarning(null, msg)</tt>.
|
||||
* @param msg the message, or an empty string if none
|
||||
*/
|
||||
void printWarning(String msg);
|
||||
|
||||
/**
|
||||
* Prints a warning message.
|
||||
* @param pos the position where the warning occured, or null if it is
|
||||
* unknown or not applicable
|
||||
* @param msg the message, or an empty string if none
|
||||
*/
|
||||
void printWarning(SourcePosition pos, String msg);
|
||||
|
||||
/**
|
||||
* Prints a notice.
|
||||
* Equivalent to <tt>printNotice(null, msg)</tt>.
|
||||
* @param msg the message, or an empty string if none
|
||||
*/
|
||||
void printNotice(String msg);
|
||||
|
||||
/**
|
||||
* Prints a notice.
|
||||
* @param pos the position where the noticed occured, or null if it is
|
||||
* unknown or not applicable
|
||||
* @param msg the message, or an empty string if none
|
||||
*/
|
||||
void printNotice(SourcePosition pos, String msg);
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.apt;
|
||||
|
||||
/**
|
||||
* Event for the completion of a round of annotation processing.
|
||||
*
|
||||
* <p>While this class extends the serializable <tt>EventObject</tt>, it
|
||||
* cannot meaningfully be serialized because all of the annotation
|
||||
* processing tool's internal state would potentially be needed.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. This class has no direct
|
||||
* analog in the standardized API because the different round model
|
||||
* renders it unnecessary.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class RoundCompleteEvent extends java.util.EventObject {
|
||||
private RoundState rs;
|
||||
|
||||
/**
|
||||
* The current <tt>AnnotationProcessorEnvironment</tt> is regarded
|
||||
* as the source of events.
|
||||
*
|
||||
* @param source The source of events
|
||||
* @param rs The state of the round
|
||||
*/
|
||||
protected RoundCompleteEvent(AnnotationProcessorEnvironment source,
|
||||
RoundState rs) {
|
||||
super(source);
|
||||
this.rs = rs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return round state.
|
||||
*/
|
||||
public RoundState getRoundState() {
|
||||
return rs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return source.
|
||||
*/
|
||||
public AnnotationProcessorEnvironment getSource() {
|
||||
return (AnnotationProcessorEnvironment)super.getSource();
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.apt;
|
||||
|
||||
/**
|
||||
* Listener for the completion of a round of annotation processing.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. This interface has no
|
||||
* direct analog in the standardized API because the different round
|
||||
* model renders it unnecessary.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface RoundCompleteListener extends AnnotationProcessorListener {
|
||||
/**
|
||||
* Invoked after all processors for a round have run to completion.
|
||||
*
|
||||
* @param event An event for round completion
|
||||
*/
|
||||
void roundComplete(RoundCompleteEvent event);
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.apt;
|
||||
|
||||
/**
|
||||
* Represents the status of a completed round of annotation processing.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.annotation.processing.RoundEnvironment}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface RoundState {
|
||||
/**
|
||||
* Returns <tt>true</tt> if this was the last round of annotation
|
||||
* processing; returns <tt>false</tt> if there will be a subsequent round.
|
||||
*/
|
||||
boolean finalRound();
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if an error was raised in this round of processing;
|
||||
* returns <tt>false</tt> otherwise.
|
||||
*/
|
||||
boolean errorRaised();
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if new source files were created in this round of
|
||||
* processing; returns <tt>false</tt> otherwise.
|
||||
*/
|
||||
boolean sourceFilesCreated();
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if new class files were created in this round of
|
||||
* processing; returns <tt>false</tt> otherwise.
|
||||
*/
|
||||
boolean classFilesCreated();
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Classes used to communicate information between {@linkplain
|
||||
* com.sun.mirror.apt.AnnotationProcessor annotation processors} and
|
||||
* an annotation processing tool.
|
||||
*
|
||||
* <p>The {@code apt} tool and its associated API have been superseded
|
||||
* by the standardized annotation processing API. The replacement for
|
||||
* the functionality in this package is {@link
|
||||
* javax.annotation.processing}.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
package com.sun.mirror.apt;
|
@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
import java.util.Map;
|
||||
import com.sun.mirror.type.AnnotationType;
|
||||
import com.sun.mirror.util.SourcePosition;
|
||||
|
||||
|
||||
/**
|
||||
* Represents an annotation. An annotation associates a value with
|
||||
* each element of an annotation type.
|
||||
*
|
||||
* <p> Annotations should not be compared using reference-equality
|
||||
* ("<tt>==</tt>"). There is no guarantee that any particular
|
||||
* annotation will always be represented by the same object.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.element.AnnotationMirror}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface AnnotationMirror {
|
||||
|
||||
/**
|
||||
* Returns the annotation type of this annotation.
|
||||
*
|
||||
* @return the annotation type of this annotation
|
||||
*/
|
||||
AnnotationType getAnnotationType();
|
||||
|
||||
/**
|
||||
* Returns the source position of the beginning of this annotation.
|
||||
* Returns null if the position is unknown or not applicable.
|
||||
*
|
||||
* <p>This source position is intended for use in providing diagnostics,
|
||||
* and indicates only approximately where an annotation begins.
|
||||
*
|
||||
* @return the source position of the beginning of this annotation or
|
||||
* null if the position is unknown or not applicable
|
||||
*/
|
||||
SourcePosition getPosition();
|
||||
|
||||
/**
|
||||
* Returns this annotation's elements and their values.
|
||||
* This is returned in the form of a map that associates elements
|
||||
* with their corresponding values.
|
||||
* Only those elements and values explicitly present in the
|
||||
* annotation are included, not those that are implicitly assuming
|
||||
* their default values.
|
||||
* The order of the map matches the order in which the
|
||||
* elements appear in the annotation's source.
|
||||
*
|
||||
* @return this annotation's elements and their values,
|
||||
* or an empty map if there are none
|
||||
*/
|
||||
Map<AnnotationTypeElementDeclaration, AnnotationValue> getElementValues();
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the declaration of an annotation type.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.element.TypeElement}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface AnnotationTypeDeclaration extends InterfaceDeclaration {
|
||||
|
||||
/**
|
||||
* Returns the annotation type elements of this annotation type.
|
||||
* These are the methods that are directly declared in the type's
|
||||
* declaration.
|
||||
*
|
||||
* @return the annotation type elements of this annotation type,
|
||||
* or an empty collection if there are none
|
||||
*/
|
||||
Collection<AnnotationTypeElementDeclaration> getMethods();
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
/**
|
||||
* Represents an element of an annotation type.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.element.ExecutableElement}.
|
||||
*
|
||||
* @author Joe Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface AnnotationTypeElementDeclaration extends MethodDeclaration {
|
||||
|
||||
/**
|
||||
* Returns the default value of this element.
|
||||
*
|
||||
* @return the default value of this element, or null if this element
|
||||
* has no default.
|
||||
*/
|
||||
AnnotationValue getDefaultValue();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
AnnotationTypeDeclaration getDeclaringType();
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
import com.sun.mirror.util.SourcePosition;
|
||||
|
||||
/**
|
||||
* Represents a value of an annotation type element.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.element.AnnotationValue}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface AnnotationValue {
|
||||
|
||||
/**
|
||||
* Returns the value.
|
||||
* The result has one of the following types:
|
||||
* <ul><li> a wrapper class (such as {@link Integer}) for a primitive type
|
||||
* <li> {@code String}
|
||||
* <li> {@code TypeMirror}
|
||||
* <li> {@code EnumConstantDeclaration}
|
||||
* <li> {@code AnnotationMirror}
|
||||
* <li> {@code Collection<AnnotationValue>}
|
||||
* (representing the elements, in order, if the value is an array)
|
||||
* </ul>
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
Object getValue();
|
||||
|
||||
/**
|
||||
* Returns the source position of the beginning of this annotation value.
|
||||
* Returns null if the position is unknown or not applicable.
|
||||
*
|
||||
* <p>This source position is intended for use in providing diagnostics,
|
||||
* and indicates only approximately where an annotation value begins.
|
||||
*
|
||||
* @return the source position of the beginning of this annotation value or
|
||||
* null if the position is unknown or not applicable
|
||||
*/
|
||||
SourcePosition getPosition();
|
||||
|
||||
/**
|
||||
* Returns a string representation of this value.
|
||||
* This is returned in a form suitable for representing this value
|
||||
* in the source code of an annotation.
|
||||
*
|
||||
* @return a string representation of this value
|
||||
*/
|
||||
String toString();
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.type.ClassType;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the declaration of a class.
|
||||
* For the declaration of an interface, see {@link InterfaceDeclaration}.
|
||||
* Provides access to information about the class, its members, and
|
||||
* its constructors.
|
||||
* Note that an {@linkplain EnumDeclaration enum} is a kind of class.
|
||||
*
|
||||
* <p> While a <tt>ClassDeclaration</tt> represents the <i>declaration</i>
|
||||
* of a class, a {@link ClassType} represents a class <i>type</i>.
|
||||
* See {@link TypeDeclaration} for more on this distinction.
|
||||
*
|
||||
* <p> {@link com.sun.mirror.util.DeclarationFilter}
|
||||
* provides a simple way to select just the items of interest
|
||||
* when a method returns a collection of declarations.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.element.TypeElement}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
*
|
||||
* @see ClassType
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface ClassDeclaration extends TypeDeclaration {
|
||||
|
||||
/**
|
||||
* Returns the class type directly extended by this class.
|
||||
* The only class with no superclass is <tt>java.lang.Object</tt>,
|
||||
* for which this method returns null.
|
||||
*
|
||||
* @return the class type directly extended by this class, or null
|
||||
* if there is none
|
||||
*/
|
||||
ClassType getSuperclass();
|
||||
|
||||
/**
|
||||
* Returns the constructors of this class.
|
||||
* This includes the default constructor if this class has
|
||||
* no constructors explicitly declared.
|
||||
*
|
||||
* @return the constructors of this class
|
||||
*
|
||||
* @see com.sun.mirror.util.DeclarationFilter
|
||||
*/
|
||||
Collection<ConstructorDeclaration> getConstructors();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
Collection<MethodDeclaration> getMethods();
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a constructor of a class or interface.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.element.ExecutableElement}.
|
||||
*
|
||||
* @author Joe Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface ConstructorDeclaration extends ExecutableDeclaration {
|
||||
}
|
@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the declaration of a program element such as a package,
|
||||
* class, or method. Each declaration represents a static, language-level
|
||||
* construct (and not, for example, a runtime construct of the virtual
|
||||
* machine), and typically corresponds one-to-one with a particular
|
||||
* fragment of source code.
|
||||
*
|
||||
* <p> Declarations should be compared using the {@link #equals(Object)}
|
||||
* method. There is no guarantee that any particular declaration will
|
||||
* always be represented by the same object.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.element.Element}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
*
|
||||
* @see Declarations
|
||||
* @see TypeMirror
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface Declaration {
|
||||
|
||||
/**
|
||||
* Tests whether an object represents the same declaration as this.
|
||||
*
|
||||
* @param obj the object to be compared with this declaration
|
||||
* @return <tt>true</tt> if the specified object represents the same
|
||||
* declaration as this
|
||||
*/
|
||||
boolean equals(Object obj);
|
||||
|
||||
/**
|
||||
* Returns the text of the documentation ("javadoc") comment of
|
||||
* this declaration.
|
||||
*
|
||||
* @return the documentation comment of this declaration, or <tt>null</tt>
|
||||
* if there is none
|
||||
*/
|
||||
String getDocComment();
|
||||
|
||||
/**
|
||||
* Returns the annotations that are directly present on this declaration.
|
||||
*
|
||||
* @return the annotations directly present on this declaration;
|
||||
* an empty collection if there are none
|
||||
*/
|
||||
Collection<AnnotationMirror> getAnnotationMirrors();
|
||||
|
||||
/**
|
||||
* Returns the annotation of this declaration having the specified
|
||||
* type. The annotation may be either inherited or directly
|
||||
* present on this declaration.
|
||||
*
|
||||
* <p> The annotation returned by this method could contain an element
|
||||
* whose value is of type <tt>Class</tt>.
|
||||
* This value cannot be returned directly: information necessary to
|
||||
* locate and load a class (such as the class loader to use) is
|
||||
* not available, and the class might not be loadable at all.
|
||||
* Attempting to read a <tt>Class</tt> object by invoking the relevant
|
||||
* method on the returned annotation
|
||||
* will result in a {@link MirroredTypeException},
|
||||
* from which the corresponding {@link TypeMirror} may be extracted.
|
||||
* Similarly, attempting to read a <tt>Class[]</tt>-valued element
|
||||
* will result in a {@link MirroredTypesException}.
|
||||
*
|
||||
* <blockquote>
|
||||
* <i>Note:</i> This method is unlike
|
||||
* others in this and related interfaces. It operates on run-time
|
||||
* reflective information -- representations of annotation types
|
||||
* currently loaded into the VM -- rather than on the mirrored
|
||||
* representations defined by and used throughout these
|
||||
* interfaces. It is intended for callers that are written to
|
||||
* operate on a known, fixed set of annotation types.
|
||||
* </blockquote>
|
||||
*
|
||||
* @param <A> the annotation type
|
||||
* @param annotationType the <tt>Class</tt> object corresponding to
|
||||
* the annotation type
|
||||
* @return the annotation of this declaration having the specified type
|
||||
*
|
||||
* @see #getAnnotationMirrors()
|
||||
*/
|
||||
<A extends Annotation> A getAnnotation(Class<A> annotationType);
|
||||
|
||||
/**
|
||||
* Returns the modifiers of this declaration, excluding annotations.
|
||||
* Implicit modifiers, such as the <tt>public</tt> and <tt>static</tt>
|
||||
* modifiers of interface members, are included.
|
||||
*
|
||||
* @return the modifiers of this declaration in undefined order;
|
||||
* an empty collection if there are none
|
||||
*/
|
||||
Collection<Modifier> getModifiers();
|
||||
|
||||
/**
|
||||
* Returns the simple (unqualified) name of this declaration.
|
||||
* The name of a generic type does not include any reference
|
||||
* to its formal type parameters.
|
||||
* For example, the simple name of the interface declaration
|
||||
* {@code java.util.Set<E>} is <tt>"Set"</tt>.
|
||||
* If this declaration represents the empty package, an empty
|
||||
* string is returned.
|
||||
* If it represents a constructor, the simple name of its
|
||||
* declaring class is returned.
|
||||
*
|
||||
* @return the simple name of this declaration
|
||||
*/
|
||||
String getSimpleName();
|
||||
|
||||
/**
|
||||
* Returns the source position of the beginning of this declaration.
|
||||
* Returns <tt>null</tt> if the position is unknown or not applicable.
|
||||
*
|
||||
* <p> This source position is intended for use in providing
|
||||
* diagnostics, and indicates only approximately where a declaration
|
||||
* begins.
|
||||
*
|
||||
* @return the source position of the beginning of this declaration,
|
||||
* or null if the position is unknown or not applicable
|
||||
*/
|
||||
SourcePosition getPosition();
|
||||
|
||||
/**
|
||||
* Applies a visitor to this declaration.
|
||||
*
|
||||
* @param v the visitor operating on this declaration
|
||||
*/
|
||||
void accept(DeclarationVisitor v);
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
/**
|
||||
* Represents an enum constant declaration.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.element.VariableElement}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface EnumConstantDeclaration extends FieldDeclaration {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
EnumDeclaration getDeclaringType();
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the declaration of an enum type.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.element.TypeElement}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface EnumDeclaration extends ClassDeclaration {
|
||||
|
||||
/**
|
||||
* Returns the enum constants defined for this enum.
|
||||
*
|
||||
* @return the enum constants defined for this enum,
|
||||
* or an empty collection if there are none
|
||||
*/
|
||||
Collection<EnumConstantDeclaration> getEnumConstants();
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.type.ReferenceType;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a method or constructor of a class or interface.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.element.ExecutableElement}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface ExecutableDeclaration extends MemberDeclaration {
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this method or constructor accepts a variable
|
||||
* number of arguments.
|
||||
*
|
||||
* @return <tt>true</tt> if this method or constructor accepts a variable
|
||||
* number of arguments
|
||||
*/
|
||||
boolean isVarArgs();
|
||||
|
||||
/**
|
||||
* Returns the formal type parameters of this method or constructor.
|
||||
* They are returned in declaration order.
|
||||
*
|
||||
* @return the formal type parameters of this method or constructor,
|
||||
* or an empty collection if there are none
|
||||
*/
|
||||
Collection<TypeParameterDeclaration> getFormalTypeParameters();
|
||||
|
||||
/**
|
||||
* Returns the formal parameters of this method or constructor.
|
||||
* They are returned in declaration order.
|
||||
*
|
||||
* @return the formal parameters of this method or constructor,
|
||||
* or an empty collection if there are none
|
||||
*/
|
||||
Collection<ParameterDeclaration> getParameters();
|
||||
|
||||
/**
|
||||
* Returns the exceptions and other throwables listed in this
|
||||
* method or constructor's <tt>throws</tt> clause.
|
||||
*
|
||||
* @return the exceptions and other throwables listed in the
|
||||
* <tt>throws</tt> clause, or an empty collection if there are none
|
||||
*/
|
||||
Collection<ReferenceType> getThrownTypes();
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
import com.sun.mirror.type.TypeMirror;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a field of a type declaration.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.element.VariableElement}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface FieldDeclaration extends MemberDeclaration {
|
||||
|
||||
/**
|
||||
* Returns the type of this field.
|
||||
*
|
||||
* @return the type of this field
|
||||
*/
|
||||
TypeMirror getType();
|
||||
|
||||
/**
|
||||
* Returns the value of this field if this field is a compile-time
|
||||
* constant. Returns <tt>null</tt> otherwise.
|
||||
* The value will be of a primitive type or <tt>String</tt>.
|
||||
* If the value is of a primitive type, it is wrapped in the
|
||||
* appropriate wrapper class (such as {@link Integer}).
|
||||
*
|
||||
* @return the value of this field if this field is a compile-time
|
||||
* constant, or <tt>null</tt> otherwise
|
||||
*/
|
||||
Object getConstantValue();
|
||||
|
||||
/**
|
||||
* Returns the text of a <i>constant expression</i> representing the
|
||||
* value of this field if this field is a compile-time constant.
|
||||
* Returns <tt>null</tt> otherwise.
|
||||
* The value will be of a primitive type or <tt>String</tt>.
|
||||
* The text returned is in a form suitable for representing the value
|
||||
* in source code.
|
||||
*
|
||||
* @return the text of a constant expression if this field is a
|
||||
* compile-time constant, or <tt>null</tt> otherwise
|
||||
*/
|
||||
String getConstantExpression();
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
import com.sun.mirror.type.InterfaceType;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the declaration of an interface.
|
||||
* Provides access to information about the interface and its members.
|
||||
* Note that an {@linkplain AnnotationTypeDeclaration annotation type} is
|
||||
* a kind of interface.
|
||||
*
|
||||
* <p> While an <tt>InterfaceDeclaration</tt> represents the
|
||||
* <i>declaration</i> of an interface, an {@link InterfaceType}
|
||||
* represents an interface <i>type</i>.
|
||||
* See {@link TypeDeclaration} for more on this distinction.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.element.TypeElement}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
*
|
||||
* @see InterfaceType
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface InterfaceDeclaration extends TypeDeclaration {
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a declaration that may be a member or constructor of a declared
|
||||
* type. This includes fields, constructors, methods, and (since they
|
||||
* may be nested) declared types themselves.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.element.Element}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface MemberDeclaration extends Declaration {
|
||||
|
||||
/**
|
||||
* Returns the type declaration within which this member or constructor
|
||||
* is declared.
|
||||
* If this is the declaration of a top-level type (a non-nested class
|
||||
* or interface), returns null.
|
||||
*
|
||||
* @return the type declaration within which this member or constructor
|
||||
* is declared, or null if there is none
|
||||
*/
|
||||
TypeDeclaration getDeclaringType();
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
import com.sun.mirror.type.TypeMirror;
|
||||
import com.sun.mirror.type.VoidType;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a method of a class or interface.
|
||||
* Note that an
|
||||
* {@linkplain AnnotationTypeElementDeclaration annotation type element}
|
||||
* is a kind of method.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.element.ExecutableElement}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface MethodDeclaration extends ExecutableDeclaration {
|
||||
|
||||
/**
|
||||
* Returns the formal return type of this method.
|
||||
* Returns {@link VoidType} if this method does not return a value.
|
||||
*
|
||||
* @return the formal return type of this method
|
||||
*/
|
||||
TypeMirror getReturnType();
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a modifier on the declaration of a program element such
|
||||
* as a class, method, or field.
|
||||
*
|
||||
* <p> Not all modifiers are applicable to all kinds of declarations.
|
||||
* When two or more modifiers appear in the source code of a declaration,
|
||||
* then it is customary, though not required, that they appear in the same
|
||||
* order as the constants listed in the detail section below.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this enum is {@link javax.lang.model.element.Modifier}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public enum Modifier {
|
||||
|
||||
// See JLS2 sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1.
|
||||
// java.lang.reflect.Modifier includes INTERFACE, but that's a VMism.
|
||||
|
||||
/** The modifier <tt>public</tt> */ PUBLIC,
|
||||
/** The modifier <tt>protected</tt> */ PROTECTED,
|
||||
/** The modifier <tt>private</tt> */ PRIVATE,
|
||||
/** The modifier <tt>abstract</tt> */ ABSTRACT,
|
||||
/** The modifier <tt>static</tt> */ STATIC,
|
||||
/** The modifier <tt>final</tt> */ FINAL,
|
||||
/** The modifier <tt>transient</tt> */ TRANSIENT,
|
||||
/** The modifier <tt>volatile</tt> */ VOLATILE,
|
||||
/** The modifier <tt>synchronized</tt> */ SYNCHRONIZED,
|
||||
/** The modifier <tt>native</tt> */ NATIVE,
|
||||
/** The modifier <tt>strictfp</tt> */ STRICTFP;
|
||||
|
||||
|
||||
private String lowercase = null; // modifier name in lowercase
|
||||
|
||||
/**
|
||||
* Returns this modifier's name in lowercase.
|
||||
*/
|
||||
public String toString() {
|
||||
if (lowercase == null) {
|
||||
lowercase = name().toLowerCase(java.util.Locale.US);
|
||||
}
|
||||
return lowercase;
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the declaration of a package. Provides access to information
|
||||
* about the package and its members.
|
||||
*
|
||||
* <p> {@link com.sun.mirror.util.DeclarationFilter}
|
||||
* provides a simple way to select just the items of interest
|
||||
* when a method returns a collection of declarations.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.element.PackageElement}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface PackageDeclaration extends Declaration {
|
||||
|
||||
/**
|
||||
* Returns the fully qualified name of this package.
|
||||
* This is also known as the package's <i>canonical</i> name.
|
||||
*
|
||||
* @return the fully qualified name of this package, or the
|
||||
* empty string if this is the unnamed package
|
||||
*/
|
||||
String getQualifiedName();
|
||||
|
||||
/**
|
||||
* Returns the declarations of the top-level classes in this package.
|
||||
* Interfaces are not included, but enum types are.
|
||||
*
|
||||
* @return the declarations of the top-level classes in this package
|
||||
*
|
||||
* @see com.sun.mirror.util.DeclarationFilter
|
||||
*/
|
||||
Collection<ClassDeclaration> getClasses();
|
||||
|
||||
/**
|
||||
* Returns the declarations of the top-level enum types in this package.
|
||||
*
|
||||
* @return the declarations of the top-level enum types in this package
|
||||
*
|
||||
* @see com.sun.mirror.util.DeclarationFilter
|
||||
*/
|
||||
Collection<EnumDeclaration> getEnums();
|
||||
|
||||
/**
|
||||
* Returns the declarations of the top-level interfaces in this package.
|
||||
* Annotation types are included.
|
||||
*
|
||||
* @return the declarations of the top-level interfaces in this package
|
||||
*
|
||||
* @see com.sun.mirror.util.DeclarationFilter
|
||||
*/
|
||||
Collection<InterfaceDeclaration> getInterfaces();
|
||||
|
||||
/**
|
||||
* Returns the declarations of the top-level annotation types in this
|
||||
* package.
|
||||
*
|
||||
* @return the declarations of the top-level annotation types in this
|
||||
* package
|
||||
*
|
||||
* @see com.sun.mirror.util.DeclarationFilter
|
||||
*/
|
||||
Collection<AnnotationTypeDeclaration> getAnnotationTypes();
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
import com.sun.mirror.type.TypeMirror;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a formal parameter of a method or constructor.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.element.VariableElement}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface ParameterDeclaration extends Declaration {
|
||||
|
||||
/**
|
||||
* Returns the type of this parameter.
|
||||
*
|
||||
* @return the type of this parameter
|
||||
*/
|
||||
TypeMirror getType();
|
||||
}
|
@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.type.*;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the declaration of a class or interface.
|
||||
* Provides access to information about the type and its members.
|
||||
* Note that an {@linkplain EnumDeclaration enum} is a kind of class,
|
||||
* and an {@linkplain AnnotationTypeDeclaration annotation type} is
|
||||
* a kind of interface.
|
||||
*
|
||||
* <p> <a name="DECL_VS_TYPE"></a>
|
||||
* While a <tt>TypeDeclaration</tt> represents the <i>declaration</i>
|
||||
* of a class or interface, a {@link DeclaredType} represents a class
|
||||
* or interface <i>type</i>, the latter being a use
|
||||
* (or <i>invocation</i>) of the former.
|
||||
* The distinction is most apparent with generic types,
|
||||
* for which a single declaration can define a whole
|
||||
* family of types. For example, the declaration of
|
||||
* {@code java.util.Set} corresponds to the parameterized types
|
||||
* {@code java.util.Set<String>} and {@code java.util.Set<Number>}
|
||||
* (and many others), and to the raw type {@code java.util.Set}.
|
||||
*
|
||||
* <p> {@link com.sun.mirror.util.DeclarationFilter}
|
||||
* provides a simple way to select just the items of interest
|
||||
* when a method returns a collection of declarations.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.element.TypeElement}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
*
|
||||
* @see DeclaredType
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface TypeDeclaration extends MemberDeclaration {
|
||||
|
||||
/**
|
||||
* Returns the package within which this type is declared.
|
||||
*
|
||||
* @return the package within which this type is declared
|
||||
*/
|
||||
PackageDeclaration getPackage();
|
||||
|
||||
/**
|
||||
* Returns the fully qualified name of this class or interface
|
||||
* declaration. More precisely, it returns the <i>canonical</i>
|
||||
* name.
|
||||
* The name of a generic type does not include any reference
|
||||
* to its formal type parameters.
|
||||
* For example, the the fully qualified name of the interface declaration
|
||||
* {@code java.util.Set<E>} is <tt>"java.util.Set"</tt>.
|
||||
*
|
||||
* @return the fully qualified name of this class or interface declaration
|
||||
*/
|
||||
String getQualifiedName();
|
||||
|
||||
/**
|
||||
* Returns the formal type parameters of this class or interface.
|
||||
*
|
||||
* @return the formal type parameters, or an empty collection
|
||||
* if there are none
|
||||
*/
|
||||
Collection<TypeParameterDeclaration> getFormalTypeParameters();
|
||||
|
||||
/**
|
||||
* Returns the interface types directly implemented by this class
|
||||
* or extended by this interface.
|
||||
*
|
||||
* @return the interface types directly implemented by this class
|
||||
* or extended by this interface, or an empty collection if there are none
|
||||
*
|
||||
* @see com.sun.mirror.util.DeclarationFilter
|
||||
*/
|
||||
Collection<InterfaceType> getSuperinterfaces();
|
||||
|
||||
/**
|
||||
* Returns the fields that are directly declared by this class or
|
||||
* interface. Includes enum constants.
|
||||
*
|
||||
* @return the fields that are directly declared,
|
||||
* or an empty collection if there are none
|
||||
*
|
||||
* @see com.sun.mirror.util.DeclarationFilter
|
||||
*/
|
||||
Collection<FieldDeclaration> getFields();
|
||||
|
||||
/**
|
||||
* Returns the methods that are directly declared by this class or
|
||||
* interface. Includes annotation type elements. Excludes
|
||||
* implicitly declared methods of an interface, such as
|
||||
* <tt>toString</tt>, that correspond to the methods of
|
||||
* <tt>java.lang.Object</tt>.
|
||||
*
|
||||
* @return the methods that are directly declared,
|
||||
* or an empty collection if there are none
|
||||
*
|
||||
* @see com.sun.mirror.util.DeclarationFilter
|
||||
*/
|
||||
Collection<? extends MethodDeclaration> getMethods();
|
||||
|
||||
/**
|
||||
* Returns the declarations of the nested classes and interfaces
|
||||
* that are directly declared by this class or interface.
|
||||
*
|
||||
* @return the declarations of the nested classes and interfaces,
|
||||
* or an empty collection if there are none
|
||||
*
|
||||
* @see com.sun.mirror.util.DeclarationFilter
|
||||
*/
|
||||
Collection<TypeDeclaration> getNestedTypes();
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.type.*;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a formal type parameter of a generic type, method,
|
||||
* or constructor declaration.
|
||||
* A type parameter declares a {@link TypeVariable}.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.element.TypeParameterElement}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface TypeParameterDeclaration extends Declaration {
|
||||
|
||||
/**
|
||||
* Returns the bounds of this type parameter.
|
||||
* These are the types given by the <i>extends</i> clause.
|
||||
* If there is no explicit <i>extends</i> clause, then
|
||||
* <tt>java.lang.Object</tt> is considered to be the sole bound.
|
||||
*
|
||||
* @return the bounds of this type parameter
|
||||
*/
|
||||
Collection<ReferenceType> getBounds();
|
||||
|
||||
/**
|
||||
* Returns the type, method, or constructor declaration within which
|
||||
* this type parameter is declared.
|
||||
*
|
||||
* @return the declaration within which this type parameter is declared
|
||||
*/
|
||||
Declaration getOwner();
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interfaces used to model program element declarations. A
|
||||
* declaration is represented by the appropriate subinterface of
|
||||
* {@link com.sun.mirror.declaration.Declaration}, and an annotation
|
||||
* is represented as an {@link
|
||||
* com.sun.mirror.declaration.AnnotationMirror}.
|
||||
*
|
||||
* <p>The {@code apt} tool and its associated API have been superseded
|
||||
* by the standardized annotation processing API. The replacement for
|
||||
* the functionality in this package is {@link
|
||||
* javax.lang.model.element}.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
package com.sun.mirror.declaration;
|
@ -1,111 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
particular file as subject to the "Classpath" exception as provided
|
||||
by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
or visit www.oracle.com if you need additional information or have any
|
||||
questions.
|
||||
-->
|
||||
</head>
|
||||
|
||||
<body bgcolor="white">
|
||||
|
||||
The Mirror API is used to model the semantic structure of a program.
|
||||
It provides representations of the entities
|
||||
declared in a program, such as classes, methods, and fields.
|
||||
Constructs below the method level, such as
|
||||
individual statements and expressions, are not represented.
|
||||
|
||||
<p> Also included is support for writing
|
||||
{@linkplain com.sun.mirror.apt.AnnotationProcessor annotation processors}
|
||||
to examine and process the annotations
|
||||
of program elements. An annotation processor may, as an example, create
|
||||
new source files and XML documents to be used in conjunction with the
|
||||
original code.
|
||||
|
||||
|
||||
<h4> Characteristics of the API </h4>
|
||||
|
||||
A program is represented at the language level, rather than at the
|
||||
level of the virtual machine. Nested classes, for example, are
|
||||
handled as first-class constructs,
|
||||
rather than in the translated form understood by the VM.
|
||||
Both source code and compiled code (class files) may be modeled
|
||||
in this way.
|
||||
|
||||
<p> Programs are modeled in their static, or build-time, form.
|
||||
This differs from the {@linkplain java.lang.reflect reflection} API,
|
||||
which provides run-time information about classes and objects.
|
||||
|
||||
<p> The API does not provide direct support for generating new code.
|
||||
|
||||
|
||||
<h4> Declarations and Types </h4>
|
||||
|
||||
The mirror API represents program constructs principally through the
|
||||
{@link com.sun.mirror.declaration.Declaration} interface
|
||||
and its hierarchy of subinterfaces in the package {@link
|
||||
com.sun.mirror.declaration}. A <tt>Declaration</tt> represents a
|
||||
program element such as a package, class, or method.
|
||||
The interface hierarchy is depicted
|
||||
<a href="com/sun/mirror/declaration/package-tree.html"> here</a>.
|
||||
|
||||
<p> Types are represented by the {@link com.sun.mirror.type.TypeMirror}
|
||||
interface and its hierarchy of subinterfaces in the
|
||||
package {@link com.sun.mirror.type}. Types include primitive types,
|
||||
class and interface types, array types, type variables, and wildcards.
|
||||
The interface hierarchy is depicted
|
||||
<a href="com/sun/mirror/type/package-tree.html"> here</a>.
|
||||
|
||||
<p> The API makes a clear distinction between declarations and types.
|
||||
This is most significant for generic types, where a single declaration
|
||||
can define an infinite family of types. For example, the declaration of
|
||||
<tt>java.util.Set</tt> defines the raw type <tt>java.util.Set</tt>,
|
||||
the parameterized type {@code java.util.Set<String>},
|
||||
and much more. Only the declaration can be annotated, for example,
|
||||
and only a type can appear in a method signature.
|
||||
|
||||
<p> A program being modeled may be incomplete, in that
|
||||
it may depend on an unknown class or interface type.
|
||||
This may be the result of a processing error such as a missing class file,
|
||||
or perhaps the missing type is to be created by an annotation processor.
|
||||
See {@link com.sun.mirror.type.DeclaredType} for information on
|
||||
how such unknown types are handled.
|
||||
|
||||
|
||||
<h4> Utilities and Tool Support </h4>
|
||||
|
||||
The {@link com.sun.mirror.util} package provides
|
||||
utilities to assist in the processing of declarations and types.
|
||||
Included is support for using the visitor design pattern when
|
||||
operating on declaration and type objects.
|
||||
|
||||
<p> The {@link com.sun.mirror.apt} package supports the writing
|
||||
of annotation processors. It provides the mechanism for them to
|
||||
interact with an annotation processing tool.
|
||||
|
||||
|
||||
@since 1.5
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.type;
|
||||
|
||||
|
||||
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
|
||||
|
||||
|
||||
/**
|
||||
* Represents an annotation type.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.type.DeclaredType}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface AnnotationType extends InterfaceType {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
AnnotationTypeDeclaration getDeclaration();
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.type;
|
||||
|
||||
|
||||
/**
|
||||
* Represents an array type.
|
||||
* A multidimensional array type is represented as an array type
|
||||
* whose component type is also an array type.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.type.ArrayType}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface ArrayType extends ReferenceType {
|
||||
|
||||
/**
|
||||
* Returns the component type of this array type.
|
||||
*
|
||||
* @return the component type of this array type
|
||||
*/
|
||||
TypeMirror getComponentType();
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.type;
|
||||
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a class type.
|
||||
* Interface types are represented separately by {@link InterfaceType}.
|
||||
* Note that an {@linkplain EnumType enum} is a kind of class.
|
||||
*
|
||||
* <p> While a {@link ClassDeclaration} represents the <i>declaration</i>
|
||||
* of a class, a <tt>ClassType</tt> represents a class <i>type</i>.
|
||||
* See {@link TypeDeclaration} for more on this distinction.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.type.DeclaredType}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface ClassType extends DeclaredType {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
ClassDeclaration getDeclaration();
|
||||
|
||||
/**
|
||||
* Returns the class type that is a direct supertype of this one.
|
||||
* This is the superclass of this type's declaring class, with any
|
||||
* type arguments substituted in.
|
||||
* The only class with no superclass is <tt>java.lang.Object</tt>,
|
||||
* for which this method returns <tt>null</tt>.
|
||||
*
|
||||
* <p> For example, the class type extended by
|
||||
* {@code java.util.TreeSet<String>} is
|
||||
* {@code java.util.AbstractSet<String>}.
|
||||
*
|
||||
* @return the class type that is a direct supertype of this one,
|
||||
* or <tt>null</tt> if there is none
|
||||
*/
|
||||
ClassType getSuperclass();
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.type;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.declaration.TypeDeclaration;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a declared type, either a class type or an interface type.
|
||||
* This includes parameterized types such as {@code java.util.Set<String>}
|
||||
* as well as raw types.
|
||||
*
|
||||
* <p> While a <tt>TypeDeclaration</tt> represents the <i>declaration</i>
|
||||
* of a class or interface, a <tt>DeclaredType</tt> represents a class
|
||||
* or interface <i>type</i>, the latter being a use of the former.
|
||||
* See {@link TypeDeclaration} for more on this distinction.
|
||||
*
|
||||
* <p> A <tt>DeclaredType</tt> may represent a type
|
||||
* for which details (declaration, supertypes, <i>etc.</i>) are unknown.
|
||||
* This may be the result of a processing error, such as a missing class file,
|
||||
* and is indicated by {@link #getDeclaration()} returning <tt>null</tt>.
|
||||
* Other method invocations on such an unknown type will not, in general,
|
||||
* return meaningful results.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.type.DeclaredType}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface DeclaredType extends ReferenceType {
|
||||
|
||||
/**
|
||||
* Returns the declaration of this type.
|
||||
*
|
||||
* <p> Returns null if this type's declaration is unknown. This may
|
||||
* be the result of a processing error, such as a missing class file.
|
||||
*
|
||||
* @return the declaration of this type, or null if unknown
|
||||
*/
|
||||
TypeDeclaration getDeclaration();
|
||||
|
||||
/**
|
||||
* Returns the type that contains this type as a member.
|
||||
* Returns <tt>null</tt> if this is a top-level type.
|
||||
*
|
||||
* <p> For example, the containing type of {@code O.I<S>}
|
||||
* is the type {@code O}, and the containing type of
|
||||
* {@code O<T>.I<S>} is the type {@code O<T>}.
|
||||
*
|
||||
* @return the type that contains this type,
|
||||
* or <tt>null</tt> if this is a top-level type
|
||||
*/
|
||||
DeclaredType getContainingType();
|
||||
|
||||
/**
|
||||
* Returns (in order) the actual type arguments of this type.
|
||||
* For a generic type nested within another generic type
|
||||
* (such as {@code Outer<String>.Inner<Number>}), only the type
|
||||
* arguments of the innermost type are included.
|
||||
*
|
||||
* @return the actual type arguments of this type, or an empty collection
|
||||
* if there are none
|
||||
*/
|
||||
Collection<TypeMirror> getActualTypeArguments();
|
||||
|
||||
/**
|
||||
* Returns the interface types that are direct supertypes of this type.
|
||||
* These are the interface types implemented or extended
|
||||
* by this type's declaration, with any type arguments
|
||||
* substituted in.
|
||||
*
|
||||
* <p> For example, the interface type extended by
|
||||
* {@code java.util.Set<String>} is {@code java.util.Collection<String>}.
|
||||
*
|
||||
* @return the interface types that are direct supertypes of this type,
|
||||
* or an empty collection if there are none
|
||||
*/
|
||||
Collection<InterfaceType> getSuperinterfaces();
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.type;
|
||||
|
||||
|
||||
import com.sun.mirror.declaration.EnumDeclaration;
|
||||
|
||||
|
||||
/**
|
||||
* Represents an enum type.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.type.DeclaredType}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface EnumType extends ClassType {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
EnumDeclaration getDeclaration();
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.type;
|
||||
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
|
||||
|
||||
/**
|
||||
* Represents an interface type.
|
||||
* Note that an {@linkplain AnnotationType annotation type} is
|
||||
* a kind of interface.
|
||||
*
|
||||
* <p> While an {@link InterfaceDeclaration} represents the
|
||||
* <i>declaration</i> of an interface, an <tt>InterfaceType</tt>
|
||||
* represents an interface <i>type</i>.
|
||||
* See {@link TypeDeclaration} for more on this distinction.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.type.DeclaredType}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface InterfaceType extends DeclaredType {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
InterfaceDeclaration getDeclaration();
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.type;
|
||||
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
import com.sun.mirror.declaration.Declaration;
|
||||
|
||||
|
||||
/**
|
||||
* Thrown when an application attempts to access the {@link Class} object
|
||||
* corresponding to a {@link TypeMirror}.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this exception is {@link
|
||||
* javax.lang.model.type.MirroredTypeException}.
|
||||
*
|
||||
* @see MirroredTypesException
|
||||
* @see Declaration#getAnnotation(Class)
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MirroredTypeException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
private transient TypeMirror type; // cannot be serialized
|
||||
private String name; // type's qualified "name"
|
||||
|
||||
/**
|
||||
* Constructs a new MirroredTypeException for the specified type.
|
||||
*
|
||||
* @param type the type being accessed
|
||||
*/
|
||||
public MirroredTypeException(TypeMirror type) {
|
||||
super("Attempt to access Class object for TypeMirror " + type);
|
||||
this.type = type;
|
||||
name = type.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type mirror corresponding to the type being accessed.
|
||||
* The type mirror may be unavailable if this exception has been
|
||||
* serialized and then read back in.
|
||||
*
|
||||
* @return the type mirror, or <tt>null</tt> if unavailable
|
||||
*/
|
||||
public TypeMirror getTypeMirror() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fully qualified name of the type being accessed.
|
||||
* More precisely, returns the canonical name of a class,
|
||||
* interface, array, or primitive, and returns <tt>"void"</tt> for
|
||||
* the pseudo-type representing the type of <tt>void</tt>.
|
||||
*
|
||||
* @return the fully qualified name of the type being accessed
|
||||
*/
|
||||
public String getQualifiedName() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.type;
|
||||
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.sun.mirror.declaration.Declaration;
|
||||
|
||||
|
||||
/**
|
||||
* Thrown when an application attempts to access a sequence of {@link Class}
|
||||
* objects each corresponding to a {@link TypeMirror}.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this exception is {@link
|
||||
* javax.lang.model.type.MirroredTypesException}.
|
||||
*
|
||||
* @see MirroredTypeException
|
||||
* @see Declaration#getAnnotation(Class)
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MirroredTypesException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
private transient Collection<TypeMirror> types; // cannot be serialized
|
||||
private Collection<String> names; // types' qualified "names"
|
||||
|
||||
/**
|
||||
* Constructs a new MirroredTypesException for the specified types.
|
||||
*
|
||||
* @param types an ordered collection of the types being accessed
|
||||
*/
|
||||
public MirroredTypesException(Collection<TypeMirror> types) {
|
||||
super("Attempt to access Class objects for TypeMirrors " + types);
|
||||
this.types = types;
|
||||
names = new ArrayList<String>();
|
||||
for (TypeMirror t : types) {
|
||||
names.add(t.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type mirrors corresponding to the types being accessed.
|
||||
* The type mirrors may be unavailable if this exception has been
|
||||
* serialized and then read back in.
|
||||
*
|
||||
* @return the type mirrors in order, or <tt>null</tt> if unavailable
|
||||
*/
|
||||
public Collection<TypeMirror> getTypeMirrors() {
|
||||
return (types != null)
|
||||
? Collections.unmodifiableCollection(types)
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fully qualified names of the types being accessed.
|
||||
* More precisely, returns the canonical names of each class,
|
||||
* interface, array, or primitive, and <tt>"void"</tt> for
|
||||
* the pseudo-type representing the type of <tt>void</tt>.
|
||||
*
|
||||
* @return the fully qualified names, in order, of the types being
|
||||
* accessed
|
||||
*/
|
||||
public Collection<String> getQualifiedNames() {
|
||||
return Collections.unmodifiableCollection(names);
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.type;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a primitive type. These include
|
||||
* <tt>boolean</tt>, <tt>byte</tt>, <tt>short</tt>, <tt>int</tt>,
|
||||
* <tt>long</tt>, <tt>char</tt>, <tt>float</tt>, and <tt>double</tt>.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.type.PrimitiveType}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface PrimitiveType extends TypeMirror {
|
||||
|
||||
/**
|
||||
* Returns the kind of primitive type that this object represents.
|
||||
*
|
||||
* @return the kind of primitive type that this object represents
|
||||
*/
|
||||
Kind getKind();
|
||||
|
||||
/**
|
||||
* An enumeration of the different kinds of primitive types.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by
|
||||
* the standardized annotation processing API. The replacement
|
||||
* for the functionality of this enum is {@link
|
||||
* javax.lang.model.type.TypeKind}.
|
||||
*/
|
||||
@Deprecated
|
||||
enum Kind {
|
||||
/** The primitive type <tt>boolean</tt> */ BOOLEAN,
|
||||
/** The primitive type <tt>byte</tt> */ BYTE,
|
||||
/** The primitive type <tt>short</tt> */ SHORT,
|
||||
/** The primitive type <tt>int</tt> */ INT,
|
||||
/** The primitive type <tt>long</tt> */ LONG,
|
||||
/** The primitive type <tt>char</tt> */ CHAR,
|
||||
/** The primitive type <tt>float</tt> */ FLOAT,
|
||||
/** The primitive type <tt>double</tt> */ DOUBLE
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.type;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a reference type.
|
||||
* These include class and interface types, array types, and type variables.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.type.ReferenceType}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface ReferenceType extends TypeMirror {
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.type;
|
||||
|
||||
|
||||
import com.sun.mirror.declaration.Declaration;
|
||||
import com.sun.mirror.util.Types;
|
||||
import com.sun.mirror.util.TypeVisitor;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a type in the Java programming language.
|
||||
* Types include primitive types, class and interface types, array
|
||||
* types, and type variables. Wildcard type arguments, and the
|
||||
* pseudo-type representing the type of <tt>void</tt>, are represented
|
||||
* by type mirrors as well.
|
||||
*
|
||||
* <p> Types may be compared using the utility methods in
|
||||
* {@link Types}.
|
||||
* There is no guarantee that any particular type will
|
||||
* always be represented by the same object.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.type.TypeMirror}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
*
|
||||
* @see Declaration
|
||||
* @see Types
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface TypeMirror {
|
||||
|
||||
/**
|
||||
* Returns a string representation of this type.
|
||||
* Any names embedded in the expression are qualified.
|
||||
*
|
||||
* @return a string representation of this type
|
||||
*/
|
||||
String toString();
|
||||
|
||||
/**
|
||||
* Tests whether two types represent the same type.
|
||||
*
|
||||
* @param obj the object to be compared with this type
|
||||
* @return <tt>true</tt> if the specified object represents the same
|
||||
* type as this.
|
||||
*/
|
||||
boolean equals(Object obj);
|
||||
|
||||
/**
|
||||
* Applies a visitor to this type.
|
||||
*
|
||||
* @param v the visitor operating on this type
|
||||
*/
|
||||
void accept(TypeVisitor v);
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.type;
|
||||
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a type variable.
|
||||
* A type variable is declared by a
|
||||
* {@linkplain TypeParameterDeclaration type parameter} of a
|
||||
* type, method, or constructor.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.type.TypeVariable}.
|
||||
*
|
||||
* @author Joe Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface TypeVariable extends ReferenceType {
|
||||
|
||||
/**
|
||||
* Returns the type parameter that declared this type variable.
|
||||
*
|
||||
* @return the type parameter that declared this type variable
|
||||
*/
|
||||
TypeParameterDeclaration getDeclaration();
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.type;
|
||||
|
||||
|
||||
import com.sun.mirror.declaration.MethodDeclaration;
|
||||
|
||||
|
||||
/**
|
||||
* A pseudo-type representing the type of <tt>void</tt>.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is included in {@link
|
||||
* javax.lang.model.type.NoType}.
|
||||
*
|
||||
* @see MethodDeclaration#getReturnType()
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface VoidType extends TypeMirror {
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.type;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a wildcard type argument.
|
||||
* Examples include: <pre><tt>
|
||||
* ?
|
||||
* ? extends Number
|
||||
* ? super T
|
||||
* </tt></pre>
|
||||
*
|
||||
* <p> A wildcard may have its upper bound explicitly set by an
|
||||
* <tt>extends</tt> clause, its lower bound explicitly set by a
|
||||
* <tt>super</tt> clause, or neither (but not both).
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.type.WildcardType}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface WildcardType extends TypeMirror {
|
||||
|
||||
/**
|
||||
* Returns the upper bounds of this wildcard.
|
||||
* If no upper bound is explicitly declared, then
|
||||
* an empty collection is returned.
|
||||
*
|
||||
* @return the upper bounds of this wildcard
|
||||
*/
|
||||
Collection<ReferenceType> getUpperBounds();
|
||||
|
||||
/**
|
||||
* Returns the lower bounds of this wildcard.
|
||||
* If no lower bound is explicitly declared, then
|
||||
* an empty collection is returned.
|
||||
*
|
||||
* @return the lower bounds of this wildcard
|
||||
*/
|
||||
Collection<ReferenceType> getLowerBounds();
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interfaces used to model types. A type is represented by the
|
||||
* appropriate subinterface of {@link com.sun.mirror.type.TypeMirror}.
|
||||
*
|
||||
* <p>The {@code apt} tool and its associated API have been
|
||||
* superseded by the standardized annotation processing API. The
|
||||
* replacement for the functionality in this package is {@link
|
||||
* javax.lang.model.type}.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
package com.sun.mirror.type;
|
@ -1,319 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.util;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.declaration.Declaration;
|
||||
import com.sun.mirror.declaration.Modifier;
|
||||
|
||||
import static com.sun.mirror.declaration.Modifier.*;
|
||||
|
||||
|
||||
/**
|
||||
* A filter for selecting just the items of interest
|
||||
* from a collection of declarations.
|
||||
* The filter is said to <i>select</i> or to <i>match</i> those declarations.
|
||||
* Filters can be created in several ways:
|
||||
* by the static methods described below,
|
||||
* by negating or composing existing filters,
|
||||
* or by subclasses that implement arbitrary matching rules.
|
||||
*
|
||||
* <p> A subclass can create an arbitrary filter simply by implementing
|
||||
* the {@link #matches(Declaration)} method.
|
||||
*
|
||||
* <p> Examples.
|
||||
* <p> Selecting the <tt>public</tt> declarations from a collection:
|
||||
* <blockquote><pre>
|
||||
* result = FILTER_PUBLIC.filter(decls); </pre></blockquote>
|
||||
* Selecting class declarations (including enums):
|
||||
* <blockquote><pre>
|
||||
* classFilter = DeclarationFilter.getFilter(ClassDeclaration.class);
|
||||
* result = classFilter.filter(decls); </pre></blockquote>
|
||||
* Selecting class declarations but excluding enums:
|
||||
* <blockquote><pre>
|
||||
* enumFilter = DeclarationFilter.getFilter(EnumDeclaration.class);
|
||||
* compoundFilter = classFilter.and(enumFilter.not());
|
||||
* result = compoundFilter.filter(decls); </pre></blockquote>
|
||||
* Selecting declarations named "Bob":
|
||||
* <blockquote><pre>
|
||||
* nameFilter = new DeclarationFilter() {
|
||||
* public boolean matches(Declaration d) {
|
||||
* return d.getSimpleName().equals("Bob");
|
||||
* }
|
||||
* };
|
||||
* result = nameFilter.filter(decls); </pre></blockquote>
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this class is {@link
|
||||
* javax.lang.model.util.ElementFilter}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DeclarationFilter {
|
||||
|
||||
// Predefined filters for convenience.
|
||||
|
||||
/**
|
||||
* A filter that selects only <tt>public</tt> declarations.
|
||||
*/
|
||||
public static final DeclarationFilter FILTER_PUBLIC =
|
||||
new AccessFilter(PUBLIC);
|
||||
|
||||
/**
|
||||
* A filter that selects only <tt>protected</tt> declarations.
|
||||
*/
|
||||
public static final DeclarationFilter FILTER_PROTECTED =
|
||||
new AccessFilter(PROTECTED);
|
||||
|
||||
/**
|
||||
* A filter that selects only <tt>public</tt> or <tt>protected</tt>
|
||||
* declarations.
|
||||
*/
|
||||
public static final DeclarationFilter FILTER_PUBLIC_OR_PROTECTED =
|
||||
new AccessFilter(PUBLIC, PROTECTED);
|
||||
|
||||
/**
|
||||
* A filter that selects only package-private (<i>default</i>)
|
||||
* declarations.
|
||||
*/
|
||||
public static final DeclarationFilter FILTER_PACKAGE =
|
||||
new AccessFilter();
|
||||
|
||||
/**
|
||||
* A filter that selects only <tt>private</tt> declarations.
|
||||
*/
|
||||
public static final DeclarationFilter FILTER_PRIVATE =
|
||||
new AccessFilter(PRIVATE);
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an identity filter: one that selects all declarations.
|
||||
*/
|
||||
public DeclarationFilter() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Methods to create a filter.
|
||||
|
||||
/**
|
||||
* Returns a filter that selects declarations containing all of a
|
||||
* collection of modifiers.
|
||||
*
|
||||
* @param mods the modifiers to match (non-null)
|
||||
* @return a filter that matches declarations containing <tt>mods</tt>
|
||||
*/
|
||||
public static DeclarationFilter getFilter(
|
||||
final Collection<Modifier> mods) {
|
||||
return new DeclarationFilter() {
|
||||
public boolean matches(Declaration d) {
|
||||
return d.getModifiers().containsAll(mods);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a filter that selects declarations of a particular kind.
|
||||
* For example, there may be a filter that selects only class
|
||||
* declarations, or only fields.
|
||||
* The filter will select declarations of the specified kind,
|
||||
* and also any subtypes of that kind; for example, a field filter
|
||||
* will also select enum constants.
|
||||
*
|
||||
* @param kind the kind of declarations to select
|
||||
* @return a filter that selects declarations of a particular kind
|
||||
*/
|
||||
public static DeclarationFilter getFilter(
|
||||
final Class<? extends Declaration> kind) {
|
||||
return new DeclarationFilter() {
|
||||
public boolean matches(Declaration d) {
|
||||
return kind.isInstance(d);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a filter that selects those declarations selected
|
||||
* by both this filter and another.
|
||||
*
|
||||
* @param f filter to be composed with this one
|
||||
* @return a filter that selects those declarations selected by
|
||||
* both this filter and another
|
||||
*/
|
||||
public DeclarationFilter and(DeclarationFilter f) {
|
||||
final DeclarationFilter f1 = this;
|
||||
final DeclarationFilter f2 = f;
|
||||
return new DeclarationFilter() {
|
||||
public boolean matches(Declaration d) {
|
||||
return f1.matches(d) && f2.matches(d);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a filter that selects those declarations selected
|
||||
* by either this filter or another.
|
||||
*
|
||||
* @param f filter to be composed with this one
|
||||
* @return a filter that selects those declarations selected by
|
||||
* either this filter or another
|
||||
*/
|
||||
public DeclarationFilter or(DeclarationFilter f) {
|
||||
final DeclarationFilter f1 = this;
|
||||
final DeclarationFilter f2 = f;
|
||||
return new DeclarationFilter() {
|
||||
public boolean matches(Declaration d) {
|
||||
return f1.matches(d) || f2.matches(d);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a filter that selects those declarations not selected
|
||||
* by this filter.
|
||||
*
|
||||
* @return a filter that selects those declarations not selected
|
||||
* by this filter
|
||||
*/
|
||||
public DeclarationFilter not() {
|
||||
return new DeclarationFilter() {
|
||||
public boolean matches(Declaration d) {
|
||||
return !DeclarationFilter.this.matches(d);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Methods to apply a filter.
|
||||
|
||||
/**
|
||||
* Tests whether this filter matches a given declaration.
|
||||
* The default implementation always returns <tt>true</tt>;
|
||||
* subclasses should override this.
|
||||
*
|
||||
* @param decl the declaration to match
|
||||
* @return <tt>true</tt> if this filter matches the given declaration
|
||||
*/
|
||||
public boolean matches(Declaration decl) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the declarations matched by this filter.
|
||||
* The result is a collection of the same type as the argument;
|
||||
* the {@linkplain #filter(Collection, Class) two-parameter version}
|
||||
* of <tt>filter</tt> offers control over the result type.
|
||||
*
|
||||
* @param <D> type of the declarations being filtered
|
||||
* @param decls declarations being filtered
|
||||
* @return the declarations matched by this filter
|
||||
*/
|
||||
public <D extends Declaration> Collection<D> filter(Collection<D> decls) {
|
||||
ArrayList<D> res = new ArrayList<D>(decls.size());
|
||||
for (D d : decls) {
|
||||
if (matches(d)) {
|
||||
res.add(d);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the declarations matched by this filter, with the result
|
||||
* being restricted to declarations of a given kind.
|
||||
* Similar to the simpler
|
||||
* {@linkplain #filter(Collection) single-parameter version}
|
||||
* of <tt>filter</tt>, but the result type is specified explicitly.
|
||||
*
|
||||
* @param <D> type of the declarations being returned
|
||||
* @param decls declarations being filtered
|
||||
* @param resType type of the declarations being returned --
|
||||
* the reflective view of <tt>D</tt>
|
||||
* @return the declarations matched by this filter, restricted to those
|
||||
* of the specified type
|
||||
*/
|
||||
public <D extends Declaration> Collection<D>
|
||||
filter(Collection<? extends Declaration> decls, Class<D> resType) {
|
||||
ArrayList<D> res = new ArrayList<D>(decls.size());
|
||||
for (Declaration d : decls) {
|
||||
if (resType.isInstance(d) && matches(d)) {
|
||||
res.add(resType.cast(d));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* A filter based on access modifiers.
|
||||
*/
|
||||
private static class AccessFilter extends DeclarationFilter {
|
||||
|
||||
// The first access modifier to filter on, or null if we're looking
|
||||
// for declarations with no access modifiers.
|
||||
private Modifier mod1 = null;
|
||||
|
||||
// The second access modifier to filter on, or null if none.
|
||||
private Modifier mod2 = null;
|
||||
|
||||
// Returns a filter that matches declarations with no access
|
||||
// modifiers.
|
||||
AccessFilter() {
|
||||
}
|
||||
|
||||
// Returns a filter that matches m.
|
||||
AccessFilter(Modifier m) {
|
||||
mod1 = m;
|
||||
}
|
||||
|
||||
// Returns a filter that matches either m1 or m2.
|
||||
AccessFilter(Modifier m1, Modifier m2) {
|
||||
mod1 = m1;
|
||||
mod2 = m2;
|
||||
}
|
||||
|
||||
public boolean matches(Declaration d) {
|
||||
Collection<Modifier> mods = d.getModifiers();
|
||||
if (mod1 == null) { // looking for package private
|
||||
return !(mods.contains(PUBLIC) ||
|
||||
mods.contains(PROTECTED) ||
|
||||
mods.contains(PRIVATE));
|
||||
}
|
||||
return mods.contains(mod1) &&
|
||||
(mod2 == null || mods.contains(mod2));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,267 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.util;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
|
||||
/**
|
||||
* A visitor for declarations that scans declarations contained within
|
||||
* the given declaration. For example, when visiting a class, the
|
||||
* methods, fields, constructors, and nested types of the class are
|
||||
* also visited.
|
||||
*
|
||||
* <p> To control the processing done on a declaration, users of this
|
||||
* class pass in their own visitors for pre and post processing. The
|
||||
* preprocessing visitor is called before the contained declarations
|
||||
* are scanned; the postprocessing visitor is called after the
|
||||
* contained declarations are scanned.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this class is {@link
|
||||
* javax.lang.model.util.ElementScanner6}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
class DeclarationScanner implements DeclarationVisitor {
|
||||
protected DeclarationVisitor pre;
|
||||
protected DeclarationVisitor post;
|
||||
|
||||
DeclarationScanner(DeclarationVisitor pre, DeclarationVisitor post) {
|
||||
this.pre = pre;
|
||||
this.post = post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitDeclaration(Declaration d) {
|
||||
d.accept(pre);
|
||||
d.accept(post);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a package declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitPackageDeclaration(PackageDeclaration d) {
|
||||
d.accept(pre);
|
||||
|
||||
for(ClassDeclaration classDecl: d.getClasses()) {
|
||||
classDecl.accept(this);
|
||||
}
|
||||
|
||||
for(InterfaceDeclaration interfaceDecl: d.getInterfaces()) {
|
||||
interfaceDecl.accept(this);
|
||||
}
|
||||
|
||||
d.accept(post);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a member or constructor declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitMemberDeclaration(MemberDeclaration d) {
|
||||
visitDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a type declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitTypeDeclaration(TypeDeclaration d) {
|
||||
d.accept(pre);
|
||||
|
||||
for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
|
||||
tpDecl.accept(this);
|
||||
}
|
||||
|
||||
for(FieldDeclaration fieldDecl: d.getFields()) {
|
||||
fieldDecl.accept(this);
|
||||
}
|
||||
|
||||
for(MethodDeclaration methodDecl: d.getMethods()) {
|
||||
methodDecl.accept(this);
|
||||
}
|
||||
|
||||
for(TypeDeclaration typeDecl: d.getNestedTypes()) {
|
||||
typeDecl.accept(this);
|
||||
}
|
||||
|
||||
d.accept(post);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a class declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitClassDeclaration(ClassDeclaration d) {
|
||||
d.accept(pre);
|
||||
|
||||
for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
|
||||
tpDecl.accept(this);
|
||||
}
|
||||
|
||||
for(FieldDeclaration fieldDecl: d.getFields()) {
|
||||
fieldDecl.accept(this);
|
||||
}
|
||||
|
||||
for(MethodDeclaration methodDecl: d.getMethods()) {
|
||||
methodDecl.accept(this);
|
||||
}
|
||||
|
||||
for(TypeDeclaration typeDecl: d.getNestedTypes()) {
|
||||
typeDecl.accept(this);
|
||||
}
|
||||
|
||||
for(ConstructorDeclaration ctorDecl: d.getConstructors()) {
|
||||
ctorDecl.accept(this);
|
||||
}
|
||||
|
||||
d.accept(post);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an enum declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitEnumDeclaration(EnumDeclaration d) {
|
||||
visitClassDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an interface declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitInterfaceDeclaration(InterfaceDeclaration d) {
|
||||
visitTypeDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an annotation type declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {
|
||||
visitInterfaceDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a field declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitFieldDeclaration(FieldDeclaration d) {
|
||||
visitMemberDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an enum constant declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {
|
||||
visitFieldDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a method or constructor declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitExecutableDeclaration(ExecutableDeclaration d) {
|
||||
d.accept(pre);
|
||||
|
||||
for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
|
||||
tpDecl.accept(this);
|
||||
}
|
||||
|
||||
for(ParameterDeclaration pDecl: d.getParameters()) {
|
||||
pDecl.accept(this);
|
||||
}
|
||||
|
||||
d.accept(post);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a constructor declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitConstructorDeclaration(ConstructorDeclaration d) {
|
||||
visitExecutableDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a method declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitMethodDeclaration(MethodDeclaration d) {
|
||||
visitExecutableDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an annotation type element declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitAnnotationTypeElementDeclaration(
|
||||
AnnotationTypeElementDeclaration d) {
|
||||
visitMethodDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a parameter declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitParameterDeclaration(ParameterDeclaration d) {
|
||||
visitDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a type parameter declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitTypeParameterDeclaration(TypeParameterDeclaration d) {
|
||||
visitDeclaration(d);
|
||||
}
|
||||
}
|
@ -1,149 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.util;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
|
||||
|
||||
/**
|
||||
* A visitor for declarations, in the style of the standard visitor
|
||||
* design pattern. Classes implementing this interface are used to
|
||||
* operate on a declaration when the kind of declaration is unknown at
|
||||
* compile time. When a visitor is passed to a declaration's {@link
|
||||
* Declaration#accept accept} method, the most specific
|
||||
* <tt>visit<i>Xxx</i></tt> method applicable to that declaration is
|
||||
* invoked.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.element.ElementVisitor}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface DeclarationVisitor {
|
||||
|
||||
/**
|
||||
* Visits a declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitDeclaration(Declaration d);
|
||||
|
||||
/**
|
||||
* Visits a package declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitPackageDeclaration(PackageDeclaration d);
|
||||
|
||||
/**
|
||||
* Visits a member or constructor declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitMemberDeclaration(MemberDeclaration d);
|
||||
|
||||
/**
|
||||
* Visits a type declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitTypeDeclaration(TypeDeclaration d);
|
||||
|
||||
/**
|
||||
* Visits a class declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitClassDeclaration(ClassDeclaration d);
|
||||
|
||||
/**
|
||||
* Visits an enum declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitEnumDeclaration(EnumDeclaration d);
|
||||
|
||||
/**
|
||||
* Visits an interface declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitInterfaceDeclaration(InterfaceDeclaration d);
|
||||
|
||||
/**
|
||||
* Visits an annotation type declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d);
|
||||
|
||||
/**
|
||||
* Visits a field declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitFieldDeclaration(FieldDeclaration d);
|
||||
|
||||
/**
|
||||
* Visits an enum constant declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitEnumConstantDeclaration(EnumConstantDeclaration d);
|
||||
|
||||
/**
|
||||
* Visits a method or constructor declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitExecutableDeclaration(ExecutableDeclaration d);
|
||||
|
||||
/**
|
||||
* Visits a constructor declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitConstructorDeclaration(ConstructorDeclaration d);
|
||||
|
||||
/**
|
||||
* Visits a method declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitMethodDeclaration(MethodDeclaration d);
|
||||
|
||||
/**
|
||||
* Visits an annotation type element declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitAnnotationTypeElementDeclaration(
|
||||
AnnotationTypeElementDeclaration d);
|
||||
|
||||
/**
|
||||
* Visits a parameter declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitParameterDeclaration(ParameterDeclaration d);
|
||||
|
||||
/**
|
||||
* Visits a type parameter declaration.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitTypeParameterDeclaration(TypeParameterDeclaration d);
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.util;
|
||||
|
||||
/**
|
||||
* Utilities to create specialized <tt>DeclarationVisitor</tt> instances.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. There is no direct
|
||||
* replacement for the functionality of this class in the standardized
|
||||
* API due to that API's different visitor structure.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DeclarationVisitors {
|
||||
private DeclarationVisitors(){} // do not instantiate.
|
||||
|
||||
/**
|
||||
* A visitor that has no side effects and keeps no state.
|
||||
*/
|
||||
public static final DeclarationVisitor NO_OP = new SimpleDeclarationVisitor();
|
||||
|
||||
/**
|
||||
* Return a <tt>DeclarationVisitor</tt> that will scan the
|
||||
* declaration structure, visiting declarations contained in
|
||||
* another declaration. For example, when visiting a class, the
|
||||
* fields, methods, constructors, etc. of the class are also
|
||||
* visited. The order in which the contained declarations are scanned is
|
||||
* not specified.
|
||||
*
|
||||
* <p>The <tt>pre</tt> and <tt>post</tt>
|
||||
* <tt>DeclarationVisitor</tt> parameters specify,
|
||||
* respectively, the processing the scanner will do before or
|
||||
* after visiting the contained declarations. If only one of pre
|
||||
* and post processing is needed, use {@link
|
||||
* DeclarationVisitors#NO_OP DeclarationVisitors.NO_OP} for the
|
||||
* other parameter.
|
||||
*
|
||||
* @param pre visitor representing processing to do before
|
||||
* visiting contained declarations.
|
||||
*
|
||||
* @param post visitor representing processing to do after
|
||||
* visiting contained declarations.
|
||||
*/
|
||||
public static DeclarationVisitor getDeclarationScanner(DeclarationVisitor pre,
|
||||
DeclarationVisitor post) {
|
||||
return new DeclarationScanner(pre, post);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a <tt>DeclarationVisitor</tt> that will scan the
|
||||
* declaration structure, visiting declarations contained in
|
||||
* another declaration in source code order. For example, when
|
||||
* visiting a class, the fields, methods, constructors, etc. of
|
||||
* the class are also visited. The order in which the contained
|
||||
* declarations are visited is as close to source code order as
|
||||
* possible; declaration mirrors created from class files instead
|
||||
* of source code will not have source position information.
|
||||
*
|
||||
* <p>The <tt>pre</tt> and <tt>post</tt>
|
||||
* <tt>DeclarationVisitor</tt> parameters specify,
|
||||
* respectively, the processing the scanner will do before or
|
||||
* after visiting the contained declarations. If only one of pre
|
||||
* and post processing is needed, use {@link
|
||||
* DeclarationVisitors#NO_OP DeclarationVisitors.NO_OP} for the other parameter.
|
||||
*
|
||||
* @param pre visitor representing processing to do before
|
||||
* visiting contained declarations.
|
||||
*
|
||||
* @param post visitor representing processing to do after
|
||||
* visiting contained declarations.
|
||||
*/
|
||||
public static DeclarationVisitor getSourceOrderDeclarationScanner(DeclarationVisitor pre,
|
||||
DeclarationVisitor post) {
|
||||
return new SourceOrderDeclScanner(pre, post);
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.util;
|
||||
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
|
||||
|
||||
/**
|
||||
* Utility methods for operating on declarations.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.util.Elements}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface Declarations {
|
||||
|
||||
/**
|
||||
* Tests whether one type, method, or field declaration hides another.
|
||||
*
|
||||
* @param sub the first member
|
||||
* @param sup the second member
|
||||
* @return <tt>true</tt> if and only if the first member hides
|
||||
* the second
|
||||
*/
|
||||
boolean hides(MemberDeclaration sub, MemberDeclaration sup);
|
||||
|
||||
/**
|
||||
* Tests whether one method overrides another. When a
|
||||
* non-abstract method overrides an abstract one, the
|
||||
* former is also said to <i>implement</i> the latter.
|
||||
*
|
||||
* @param sub the first method
|
||||
* @param sup the second method
|
||||
* @return <tt>true</tt> if and only if the first method overrides
|
||||
* the second
|
||||
*/
|
||||
boolean overrides(MethodDeclaration sub, MethodDeclaration sup);
|
||||
}
|
@ -1,216 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.util;
|
||||
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
|
||||
|
||||
/**
|
||||
* A simple visitor for declarations.
|
||||
*
|
||||
* <p> The implementations of the methods of this class do nothing but
|
||||
* delegate up the declaration hierarchy. A subclass should override the
|
||||
* methods that correspond to the kinds of declarations on which it
|
||||
* will operate.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this class is {@link
|
||||
* javax.lang.model.util.SimpleElementVisitor6}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class SimpleDeclarationVisitor implements DeclarationVisitor {
|
||||
|
||||
/**
|
||||
* Creates a new <tt>SimpleDeclarationVisitor</tt>.
|
||||
*/
|
||||
public SimpleDeclarationVisitor(){}
|
||||
|
||||
/**
|
||||
* Visits a declaration.
|
||||
* The implementation does nothing.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitDeclaration(Declaration d) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a package declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitDeclaration visitDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitPackageDeclaration(PackageDeclaration d) {
|
||||
visitDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a member or constructor declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitDeclaration visitDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitMemberDeclaration(MemberDeclaration d) {
|
||||
visitDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a type declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitMemberDeclaration visitMemberDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitTypeDeclaration(TypeDeclaration d) {
|
||||
visitMemberDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a class declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitTypeDeclaration visitTypeDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitClassDeclaration(ClassDeclaration d) {
|
||||
visitTypeDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an enum declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitClassDeclaration visitClassDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitEnumDeclaration(EnumDeclaration d) {
|
||||
visitClassDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an interface declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitTypeDeclaration visitTypeDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitInterfaceDeclaration(InterfaceDeclaration d) {
|
||||
visitTypeDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an annotation type declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitInterfaceDeclaration visitInterfaceDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {
|
||||
visitInterfaceDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a field declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitMemberDeclaration visitMemberDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitFieldDeclaration(FieldDeclaration d) {
|
||||
visitMemberDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an enum constant declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitFieldDeclaration visitFieldDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {
|
||||
visitFieldDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a method or constructor declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitMemberDeclaration visitMemberDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitExecutableDeclaration(ExecutableDeclaration d) {
|
||||
visitMemberDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a constructor declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitExecutableDeclaration visitExecutableDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitConstructorDeclaration(ConstructorDeclaration d) {
|
||||
visitExecutableDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a method declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitExecutableDeclaration visitExecutableDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitMethodDeclaration(MethodDeclaration d) {
|
||||
visitExecutableDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an annotation type element declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitMethodDeclaration visitMethodDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitAnnotationTypeElementDeclaration(
|
||||
AnnotationTypeElementDeclaration d) {
|
||||
visitMethodDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a parameter declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitDeclaration visitDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitParameterDeclaration(ParameterDeclaration d) {
|
||||
visitDeclaration(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a type parameter declaration.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitDeclaration visitDeclaration}.
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitTypeParameterDeclaration(TypeParameterDeclaration d) {
|
||||
visitDeclaration(d);
|
||||
}
|
||||
}
|
@ -1,175 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.util;
|
||||
|
||||
|
||||
import com.sun.mirror.type.*;
|
||||
|
||||
|
||||
/**
|
||||
* A simple visitor for types.
|
||||
*
|
||||
* <p> The implementations of the methods of this class do nothing but
|
||||
* delegate up the type hierarchy. A subclass should override the
|
||||
* methods that correspond to the kinds of types on which it will
|
||||
* operate.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this class is {@link
|
||||
* javax.lang.model.util.SimpleTypeVisitor6}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class SimpleTypeVisitor implements TypeVisitor {
|
||||
|
||||
/**
|
||||
* Creates a new <tt>SimpleTypeVisitor</tt>.
|
||||
*/
|
||||
public SimpleTypeVisitor() {}
|
||||
|
||||
/**
|
||||
* Visits a type mirror.
|
||||
* The implementation does nothing.
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitTypeMirror(TypeMirror t) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a primitive type.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitTypeMirror visitTypeMirror}.
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitPrimitiveType(PrimitiveType t) {
|
||||
visitTypeMirror(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a void type.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitTypeMirror visitTypeMirror}.
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitVoidType(VoidType t) {
|
||||
visitTypeMirror(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a reference type.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitTypeMirror visitTypeMirror}.
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitReferenceType(ReferenceType t) {
|
||||
visitTypeMirror(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a declared type.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitReferenceType visitReferenceType}.
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitDeclaredType(DeclaredType t) {
|
||||
visitReferenceType(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a class type.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitDeclaredType visitDeclaredType}.
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitClassType(ClassType t) {
|
||||
visitDeclaredType(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an enum type.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitClassType visitClassType}.
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitEnumType(EnumType t) {
|
||||
visitClassType(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an interface type.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitDeclaredType visitDeclaredType}.
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitInterfaceType(InterfaceType t) {
|
||||
visitDeclaredType(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an annotation type.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitInterfaceType visitInterfaceType}.
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitAnnotationType(AnnotationType t) {
|
||||
visitInterfaceType(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an array type.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitReferenceType visitReferenceType}.
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitArrayType(ArrayType t) {
|
||||
visitReferenceType(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a type variable.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitReferenceType visitReferenceType}.
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitTypeVariable(TypeVariable t) {
|
||||
visitReferenceType(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a wildcard.
|
||||
* The implementation simply invokes
|
||||
* {@link #visitTypeMirror visitTypeMirror}.
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitWildcardType(WildcardType t) {
|
||||
visitTypeMirror(t);
|
||||
}
|
||||
}
|
@ -1,258 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.util;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* A visitor for declarations that scans declarations contained within
|
||||
* the given declaration in source code order. For example, when
|
||||
* visiting a class, the methods, fields, constructors, and nested
|
||||
* types of the class are also visited.
|
||||
*
|
||||
* To control the processing done on a declaration, users of this
|
||||
* class pass in their own visitors for pre and post processing. The
|
||||
* preprocessing visitor is called before the contained declarations
|
||||
* are scanned; the postprocessing visitor is called after the
|
||||
* contained declarations are scanned.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this class is {@link
|
||||
* javax.lang.model.util.SimpleElementVisitor6}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
class SourceOrderDeclScanner extends DeclarationScanner {
|
||||
static class SourceOrderComparator implements java.util.Comparator<Declaration> {
|
||||
SourceOrderComparator(){}
|
||||
|
||||
|
||||
static boolean equals(Declaration d1, Declaration d2) {
|
||||
return d1 == d2 || (d1 != null && d1.equals(d2));
|
||||
}
|
||||
|
||||
private static class DeclPartialOrder extends com.sun.mirror.util.SimpleDeclarationVisitor {
|
||||
private int value = 1000;
|
||||
private static int staticAdjust(Declaration d) {
|
||||
return d.getModifiers().contains(Modifier.STATIC)?0:1;
|
||||
}
|
||||
|
||||
DeclPartialOrder() {}
|
||||
|
||||
public int getValue() { return value; }
|
||||
|
||||
@Override
|
||||
public void visitTypeParameterDeclaration(TypeParameterDeclaration d) {value = 0;}
|
||||
|
||||
@Override
|
||||
public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {value = 1;}
|
||||
|
||||
@Override
|
||||
public void visitClassDeclaration(ClassDeclaration d) {value = 2 + staticAdjust(d);}
|
||||
|
||||
@Override
|
||||
public void visitInterfaceDeclaration(InterfaceDeclaration d) {value = 4;}
|
||||
|
||||
@Override
|
||||
public void visitEnumDeclaration(EnumDeclaration d) {value = 6;}
|
||||
|
||||
@Override
|
||||
public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {value = 8;}
|
||||
|
||||
@Override
|
||||
public void visitFieldDeclaration(FieldDeclaration d) {value = 10 + staticAdjust(d);}
|
||||
|
||||
@Override
|
||||
public void visitConstructorDeclaration(ConstructorDeclaration d) {value = 12;}
|
||||
|
||||
@Override
|
||||
public void visitMethodDeclaration(MethodDeclaration d) {value = 14 + staticAdjust(d);}
|
||||
}
|
||||
@SuppressWarnings("cast")
|
||||
private int compareEqualPosition(Declaration d1, Declaration d2) {
|
||||
assert
|
||||
(d1.getPosition() == d2.getPosition()) || // Handles two null positions.
|
||||
(d1.getPosition().file().compareTo(d2.getPosition().file()) == 0 &&
|
||||
d1.getPosition().line() == d2.getPosition().line() &&
|
||||
d1.getPosition().column() == d2.getPosition().column());
|
||||
|
||||
DeclPartialOrder dpo1 = new DeclPartialOrder();
|
||||
DeclPartialOrder dpo2 = new DeclPartialOrder();
|
||||
|
||||
d1.accept(dpo1);
|
||||
d2.accept(dpo2);
|
||||
|
||||
int difference = dpo1.getValue() - dpo2.getValue();
|
||||
if (difference != 0)
|
||||
return difference;
|
||||
else {
|
||||
int result = d1.getSimpleName().compareTo(d2.getSimpleName());
|
||||
if (result != 0)
|
||||
return result;
|
||||
return (int)( Long.signum((long)System.identityHashCode(d1) -
|
||||
(long)System.identityHashCode(d2)));
|
||||
}
|
||||
}
|
||||
|
||||
public int compare(Declaration d1, Declaration d2) {
|
||||
if (equals(d1, d2))
|
||||
return 0;
|
||||
|
||||
SourcePosition p1 = d1.getPosition();
|
||||
SourcePosition p2 = d2.getPosition();
|
||||
|
||||
if (p1 == null && p2 != null)
|
||||
return 1;
|
||||
else if (p1 != null && p2 == null)
|
||||
return -1;
|
||||
else if(p1 == null && p2 == null)
|
||||
return compareEqualPosition(d1, d2);
|
||||
else {
|
||||
assert p1 != null && p2 != null;
|
||||
int fileComp = p1.file().compareTo(p2.file()) ;
|
||||
if (fileComp == 0) {
|
||||
long diff = (long)p1.line() - (long)p2.line();
|
||||
if (diff == 0) {
|
||||
diff = Long.signum((long)p1.column() - (long)p2.column());
|
||||
if (diff != 0)
|
||||
return (int)diff;
|
||||
else {
|
||||
// declarations may be two
|
||||
// compiler-generated members with the
|
||||
// same source position
|
||||
return compareEqualPosition(d1, d2);
|
||||
}
|
||||
} else
|
||||
return (diff<0)? -1:1;
|
||||
} else
|
||||
return fileComp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final static java.util.Comparator<Declaration> comparator = new SourceOrderComparator();
|
||||
|
||||
SourceOrderDeclScanner(DeclarationVisitor pre, DeclarationVisitor post) {
|
||||
super(pre, post);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a type declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitTypeDeclaration(TypeDeclaration d) {
|
||||
d.accept(pre);
|
||||
|
||||
SortedSet<Declaration> decls = new
|
||||
TreeSet<Declaration>(SourceOrderDeclScanner.comparator) ;
|
||||
|
||||
for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
|
||||
decls.add(tpDecl);
|
||||
}
|
||||
|
||||
for(FieldDeclaration fieldDecl: d.getFields()) {
|
||||
decls.add(fieldDecl);
|
||||
}
|
||||
|
||||
for(MethodDeclaration methodDecl: d.getMethods()) {
|
||||
decls.add(methodDecl);
|
||||
}
|
||||
|
||||
for(TypeDeclaration typeDecl: d.getNestedTypes()) {
|
||||
decls.add(typeDecl);
|
||||
}
|
||||
|
||||
for(Declaration decl: decls )
|
||||
decl.accept(this);
|
||||
|
||||
d.accept(post);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a class declaration.
|
||||
*
|
||||
* @param d the declaration to visit
|
||||
*/
|
||||
public void visitClassDeclaration(ClassDeclaration d) {
|
||||
d.accept(pre);
|
||||
|
||||
SortedSet<Declaration> decls = new
|
||||
TreeSet<Declaration>(SourceOrderDeclScanner.comparator) ;
|
||||
|
||||
for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
|
||||
decls.add(tpDecl);
|
||||
}
|
||||
|
||||
for(FieldDeclaration fieldDecl: d.getFields()) {
|
||||
decls.add(fieldDecl);
|
||||
}
|
||||
|
||||
for(MethodDeclaration methodDecl: d.getMethods()) {
|
||||
decls.add(methodDecl);
|
||||
}
|
||||
|
||||
for(TypeDeclaration typeDecl: d.getNestedTypes()) {
|
||||
decls.add(typeDecl);
|
||||
}
|
||||
|
||||
for(ConstructorDeclaration ctorDecl: d.getConstructors()) {
|
||||
decls.add(ctorDecl);
|
||||
}
|
||||
|
||||
for(Declaration decl: decls )
|
||||
decl.accept(this);
|
||||
|
||||
d.accept(post);
|
||||
}
|
||||
|
||||
public void visitExecutableDeclaration(ExecutableDeclaration d) {
|
||||
d.accept(pre);
|
||||
|
||||
SortedSet<Declaration> decls = new
|
||||
TreeSet<Declaration>(SourceOrderDeclScanner.comparator) ;
|
||||
|
||||
for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters())
|
||||
decls.add(tpDecl);
|
||||
|
||||
for(ParameterDeclaration pDecl: d.getParameters())
|
||||
decls.add(pDecl);
|
||||
|
||||
for(Declaration decl: decls )
|
||||
decl.accept(this);
|
||||
|
||||
d.accept(post);
|
||||
}
|
||||
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.util;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a position in a source file.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. There is no direct
|
||||
* replacement for the functionality of this interface since the
|
||||
* standardized {@link javax.annotation.processing.Messager Messager}
|
||||
* API implicitly takes a source position argument via any element,
|
||||
* annotation mirror, or annotation value passed along with the
|
||||
* message.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface SourcePosition {
|
||||
|
||||
/**
|
||||
* Returns the source file containing this position.
|
||||
*
|
||||
* @return the source file containing this position; never null
|
||||
*/
|
||||
File file();
|
||||
|
||||
/**
|
||||
* Returns the line number of this position. Lines are numbered
|
||||
* starting with 1.
|
||||
*
|
||||
* @return the line number of this position, or 0 if the line
|
||||
* number is unknown or not applicable
|
||||
*/
|
||||
int line();
|
||||
|
||||
/**
|
||||
* Returns the column number of this position. Columns are numbered
|
||||
* starting with 1.
|
||||
*
|
||||
* @return the column number of this position, or 0 if the column
|
||||
* number is unknown or not applicable
|
||||
*/
|
||||
int column();
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.util;
|
||||
|
||||
|
||||
import com.sun.mirror.type.*;
|
||||
|
||||
|
||||
/**
|
||||
* A visitor for types, in the style of the standard visitor design pattern.
|
||||
* This is used to operate on a type when the kind
|
||||
* of type is unknown at compile time.
|
||||
* When a visitor is passed to a type's
|
||||
* {@link TypeMirror#accept accept} method,
|
||||
* the most specific <tt>visit<i>Xxx</i></tt> method applicable to
|
||||
* that type is invoked.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.element.TypeVisitor}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface TypeVisitor {
|
||||
|
||||
/**
|
||||
* Visits a type mirror.
|
||||
*
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitTypeMirror(TypeMirror t);
|
||||
|
||||
/**
|
||||
* Visits a primitive type.
|
||||
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitPrimitiveType(PrimitiveType t);
|
||||
|
||||
/**
|
||||
* Visits a void type.
|
||||
*
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitVoidType(VoidType t);
|
||||
|
||||
/**
|
||||
* Visits a reference type.
|
||||
*
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitReferenceType(ReferenceType t);
|
||||
|
||||
/**
|
||||
* Visits a declared type.
|
||||
*
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitDeclaredType(DeclaredType t);
|
||||
|
||||
/**
|
||||
* Visits a class type.
|
||||
*
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitClassType(ClassType t);
|
||||
|
||||
/**
|
||||
* Visits an enum type.
|
||||
*
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitEnumType(EnumType t);
|
||||
|
||||
/**
|
||||
* Visits an interface type.
|
||||
*
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitInterfaceType(InterfaceType t);
|
||||
|
||||
/**
|
||||
* Visits an annotation type.
|
||||
*
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitAnnotationType(AnnotationType t);
|
||||
|
||||
/**
|
||||
* Visits an array type.
|
||||
*
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitArrayType(ArrayType t);
|
||||
|
||||
/**
|
||||
* Visits a type variable.
|
||||
*
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitTypeVariable(TypeVariable t);
|
||||
|
||||
/**
|
||||
* Visits a wildcard.
|
||||
*
|
||||
* @param t the type to visit
|
||||
*/
|
||||
public void visitWildcardType(WildcardType t);
|
||||
}
|
@ -1,189 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.mirror.util;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
|
||||
|
||||
/**
|
||||
* Utility methods for operating on types.
|
||||
*
|
||||
* @deprecated All components of this API have been superseded by the
|
||||
* standardized annotation processing API. The replacement for the
|
||||
* functionality of this interface is {@link
|
||||
* javax.lang.model.util.Types}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @since 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface Types {
|
||||
|
||||
/**
|
||||
* Tests whether one type is a subtype of the another.
|
||||
* Any type is considered to be a subtype of itself.
|
||||
*
|
||||
* @param t1 the first type
|
||||
* @param t2 the second type
|
||||
* @return <tt>true</tt> if and only if the first type is a subtype
|
||||
* of the second
|
||||
*/
|
||||
boolean isSubtype(TypeMirror t1, TypeMirror t2);
|
||||
|
||||
/**
|
||||
* Tests whether one type is assignable to another.
|
||||
*
|
||||
* @param t1 the first type
|
||||
* @param t2 the second type
|
||||
* @return <tt>true</tt> if and only if the first type is assignable
|
||||
* to the second
|
||||
*/
|
||||
boolean isAssignable(TypeMirror t1, TypeMirror t2);
|
||||
|
||||
/**
|
||||
* Returns the erasure of a type.
|
||||
*
|
||||
* @param t the type to be erased
|
||||
* @return the erasure of the given type
|
||||
*/
|
||||
TypeMirror getErasure(TypeMirror t);
|
||||
|
||||
/**
|
||||
* Returns a primitive type.
|
||||
*
|
||||
* @param kind the kind of primitive type to return
|
||||
* @return a primitive type
|
||||
*/
|
||||
PrimitiveType getPrimitiveType(PrimitiveType.Kind kind);
|
||||
|
||||
/**
|
||||
* Returns the pseudo-type representing the type of <tt>void</tt>.
|
||||
*
|
||||
* @return the pseudo-type representing the type of <tt>void</tt>
|
||||
*/
|
||||
VoidType getVoidType();
|
||||
|
||||
/**
|
||||
* Returns an array type with the specified component type.
|
||||
*
|
||||
* @param componentType the component type
|
||||
* @return an array type with the specified component type.
|
||||
* @throws IllegalArgumentException if the component type is not valid for
|
||||
* an array
|
||||
*/
|
||||
ArrayType getArrayType(TypeMirror componentType);
|
||||
|
||||
/**
|
||||
* Returns the type variable declared by a type parameter.
|
||||
*
|
||||
* @param tparam the type parameter
|
||||
* @return the type variable declared by the type parameter
|
||||
*/
|
||||
TypeVariable getTypeVariable(TypeParameterDeclaration tparam);
|
||||
|
||||
/**
|
||||
* Returns a new wildcard.
|
||||
* Either the wildcards's upper bounds or lower bounds may be
|
||||
* specified, or neither, but not both.
|
||||
*
|
||||
* @param upperBounds the upper bounds of this wildcard,
|
||||
* or an empty collection if none
|
||||
* @param lowerBounds the lower bounds of this wildcard,
|
||||
* or an empty collection if none
|
||||
* @return a new wildcard
|
||||
* @throws IllegalArgumentException if bounds are not valid
|
||||
*/
|
||||
WildcardType getWildcardType(Collection<ReferenceType> upperBounds,
|
||||
Collection<ReferenceType> lowerBounds);
|
||||
|
||||
/**
|
||||
* Returns the type corresponding to a type declaration and
|
||||
* actual type arguments.
|
||||
* Given the declaration for <tt>String</tt>, for example, this
|
||||
* method may be used to get the <tt>String</tt> type. It may
|
||||
* then be invoked a second time, with the declaration for <tt>Set</tt>,
|
||||
* to make the parameterized type {@code Set<String>}.
|
||||
*
|
||||
* <p> The number of type arguments must either equal the
|
||||
* number of the declaration's formal type parameters, or must be
|
||||
* zero. If zero, and if the declaration is generic,
|
||||
* then the declaration's raw type is returned.
|
||||
*
|
||||
* <p> If a parameterized type is being returned, its declaration
|
||||
* must not be contained within a generic outer class.
|
||||
* The parameterized type {@code Outer<String>.Inner<Number>},
|
||||
* for example, may be constructed by first using this
|
||||
* method to get the type {@code Outer<String>}, and then invoking
|
||||
* {@link #getDeclaredType(DeclaredType, TypeDeclaration, TypeMirror...)}.
|
||||
*
|
||||
* @param decl the type declaration
|
||||
* @param typeArgs the actual type arguments
|
||||
* @return the type corresponding to the type declaration and
|
||||
* actual type arguments
|
||||
* @throws IllegalArgumentException if too many or too few
|
||||
* type arguments are given, or if an inappropriate type
|
||||
* argument or declaration is provided
|
||||
*/
|
||||
DeclaredType getDeclaredType(TypeDeclaration decl,
|
||||
TypeMirror... typeArgs);
|
||||
|
||||
/**
|
||||
* Returns the type corresponding to a type declaration
|
||||
* and actual arguments, given a
|
||||
* {@linkplain DeclaredType#getContainingType() containing type}
|
||||
* of which it is a member.
|
||||
* The parameterized type {@code Outer<String>.Inner<Number>},
|
||||
* for example, may be constructed by first using
|
||||
* {@link #getDeclaredType(TypeDeclaration, TypeMirror...)}
|
||||
* to get the type {@code Outer<String>}, and then invoking
|
||||
* this method.
|
||||
*
|
||||
* <p> If the containing type is a parameterized type,
|
||||
* the number of type arguments must equal the
|
||||
* number of the declaration's formal type parameters.
|
||||
* If it is not parameterized or if it is <tt>null</tt>, this method is
|
||||
* equivalent to <tt>getDeclaredType(decl, typeArgs)</tt>.
|
||||
*
|
||||
* @param containing the containing type, or <tt>null</tt> if none
|
||||
* @param decl the type declaration
|
||||
* @param typeArgs the actual type arguments
|
||||
* @return the type corresponding to the type declaration and
|
||||
* actual type arguments,
|
||||
* contained within the given type
|
||||
* @throws IllegalArgumentException if too many or too few
|
||||
* type arguments are given, or if an inappropriate type
|
||||
* argument, declaration, or containing type is provided
|
||||
*/
|
||||
DeclaredType getDeclaredType(DeclaredType containing,
|
||||
TypeDeclaration decl,
|
||||
TypeMirror... typeArgs);
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Utilities to assist in the processing of {@linkplain
|
||||
* com.sun.mirror.declaration declarations} and {@linkplain
|
||||
* com.sun.mirror.type types}.
|
||||
*
|
||||
* <p>The {@code apt} tool and its associated API have been superseded
|
||||
* by the standardized annotation processing API. The replacement for
|
||||
* the functionality in this package is {@link javax.lang.model.util}.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
package com.sun.mirror.util;
|
@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import com.sun.mirror.apt.AnnotationProcessorFactory;
|
||||
|
||||
/**
|
||||
* The main program for the command-line tool apt.
|
||||
*
|
||||
* <p>Nothing described in this source file is part of any supported
|
||||
* API. If you write code that depends on this, you do so at your own
|
||||
* risk. This code and its internal interfaces are subject to change
|
||||
* or deletion without notice.
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
static {
|
||||
ClassLoader loader = Main.class.getClassLoader();
|
||||
if (loader != null)
|
||||
loader.setPackageAssertionStatus("com.sun.tools.apt", true);
|
||||
}
|
||||
|
||||
/** Command line interface. If args is <tt>null</tt>, a
|
||||
* <tt>NullPointerException</tt> is thrown.
|
||||
* @param args The command line parameters.
|
||||
*/
|
||||
public static void main(String... args) {
|
||||
System.exit(process(args));
|
||||
}
|
||||
|
||||
/** Programatic interface. If args is <tt>null</tt>, a
|
||||
* <tt>NullPointerException</tt> is thrown.
|
||||
* Output is directed to <tt>System.err</tt>.
|
||||
* @param args The command line parameters.
|
||||
*/
|
||||
public static int process(String... args) {
|
||||
return processing(null, null, args);
|
||||
}
|
||||
|
||||
/** Programmatic interface. If any argument
|
||||
* is <tt>null</tt>, a <tt>NullPointerException</tt> is thrown.
|
||||
* @param args The command line parameters.
|
||||
* @param out Where the tool's output is directed.
|
||||
*/
|
||||
public static int process(PrintWriter out, String... args) {
|
||||
if (out == null)
|
||||
throw new NullPointerException("Parameter out cannot be null.");
|
||||
return processing(null, out, args);
|
||||
}
|
||||
|
||||
/** Programmatic interface. If <tt>factory</tt> or <tt>args</tt>
|
||||
* is <tt>null</tt>, a <tt>NullPointerException</tt> is thrown.
|
||||
* The "<tt>-factory</tt>" and "<tt>-factorypath</tt>"
|
||||
* command line parameters are ignored by this entry point.
|
||||
* Output is directed to <tt>System.err</tt>.
|
||||
*
|
||||
* @param factory The annotation processor factory to use
|
||||
* @param args The command line parameters.
|
||||
*/
|
||||
public static int process(AnnotationProcessorFactory factory, String... args) {
|
||||
return process(factory, new PrintWriter(System.err, true), args);
|
||||
}
|
||||
|
||||
/** Programmatic interface. If any argument
|
||||
* is <tt>null</tt>, a <tt>NullPointerException</tt> is thrown.
|
||||
* The "<tt>-factory</tt>" and "<tt>-factorypath</tt>"
|
||||
* command line parameters are ignored by this entry point.
|
||||
*
|
||||
* @param factory The annotation processor factory to use
|
||||
* @param args The command line parameters.
|
||||
* @param out Where the tool's output is directed.
|
||||
*/
|
||||
public static int process(AnnotationProcessorFactory factory, PrintWriter out,
|
||||
String... args) {
|
||||
if (out == null)
|
||||
throw new NullPointerException("Parameter out cannot be null.");
|
||||
if (factory == null)
|
||||
throw new NullPointerException("Parameter factory cannot be null");
|
||||
return processing(factory, out, args);
|
||||
}
|
||||
|
||||
private static int processing(AnnotationProcessorFactory factory,
|
||||
PrintWriter out,
|
||||
String... args) {
|
||||
if (out == null)
|
||||
out = new PrintWriter(System.err, true);
|
||||
com.sun.tools.apt.main.Main compiler =
|
||||
new com.sun.tools.apt.main.Main("apt", out);
|
||||
return compiler.compile(args, factory);
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2009, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.comp;
|
||||
|
||||
public class AnnotationProcessingError extends Error {
|
||||
private static final long serialVersionUID = 3279196183341719287L;
|
||||
AnnotationProcessingError(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -1,509 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2011, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.comp;
|
||||
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.comp.*;
|
||||
import com.sun.tools.javac.tree.*;
|
||||
import com.sun.tools.javac.util.*;
|
||||
import com.sun.tools.javac.tree.TreeScanner;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.apt.util.Bark;
|
||||
import com.sun.tools.javac.util.Position;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.sun.tools.apt.*;
|
||||
import com.sun.tools.apt.comp.*;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
|
||||
import com.sun.mirror.declaration.TypeDeclaration;
|
||||
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
|
||||
import com.sun.mirror.apt.*;
|
||||
// import com.sun.mirror.apt.AnnotationProcessorFactory;
|
||||
import com.sun.mirror.apt.AnnotationProcessors;
|
||||
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.apt.mirror.apt.FilerImpl;
|
||||
import com.sun.tools.apt.mirror.apt.AnnotationProcessorEnvironmentImpl;
|
||||
|
||||
|
||||
import static com.sun.tools.apt.mirror.declaration.DeclarationMaker.isJavaIdentifier;
|
||||
|
||||
/**
|
||||
* Apt compiler phase.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own
|
||||
* risk. This code and its internal interfaces are subject to change
|
||||
* or deletion without notice.</b>
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Apt extends ListBuffer<Env<AttrContext>> {
|
||||
java.util.Set<String> genSourceFileNames = new java.util.LinkedHashSet<String>();
|
||||
public java.util.Set<String> getSourceFileNames() {
|
||||
return genSourceFileNames;
|
||||
}
|
||||
|
||||
/** List of names of generated class files.
|
||||
*/
|
||||
java.util.Set<String> genClassFileNames = new java.util.LinkedHashSet<String>();
|
||||
public java.util.Set<String> getClassFileNames() {
|
||||
return genClassFileNames;
|
||||
}
|
||||
|
||||
/* AptEnvironment */
|
||||
AptEnv aptenv;
|
||||
|
||||
private Context context;
|
||||
|
||||
/** The context key for the todo list. */
|
||||
|
||||
protected static final Context.Key<Apt> aptKey =
|
||||
new Context.Key<Apt>();
|
||||
|
||||
/** Get the Apt instance for this context. */
|
||||
public static Apt instance(Context context) {
|
||||
Apt instance = context.get(aptKey);
|
||||
if (instance == null)
|
||||
instance = new Apt(context);
|
||||
return instance;
|
||||
}
|
||||
|
||||
/** Create a new apt list. */
|
||||
protected Apt(Context context) {
|
||||
this.context = context;
|
||||
|
||||
context.put(aptKey, this);
|
||||
aptenv = AptEnv.instance(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to scan javac trees to build data structures needed for
|
||||
* bootstrapping the apt environment. In particular:
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li> Generate list of canonical names of annotation types that
|
||||
* appear in source files given on the command line
|
||||
*
|
||||
* <li> Collect list of javac symbols representing source files
|
||||
* given on the command line
|
||||
*
|
||||
* </ul>
|
||||
*/
|
||||
static class AptTreeScanner extends TreeScanner {
|
||||
|
||||
// Set of fully qualified names of annotation types present in
|
||||
// examined source
|
||||
private Set<String> annotationSet;
|
||||
|
||||
// Symbols to build bootstrapping declaration list
|
||||
private Collection<ClassSymbol> specifiedDeclCollection;
|
||||
private Collection<ClassSymbol> declCollection;
|
||||
|
||||
public Set<String> getAnnotationSet() {
|
||||
return annotationSet;
|
||||
}
|
||||
|
||||
public AptTreeScanner() {
|
||||
annotationSet = new LinkedHashSet<String>();
|
||||
specifiedDeclCollection = new LinkedHashSet<ClassSymbol>();
|
||||
declCollection = new LinkedHashSet<ClassSymbol>();
|
||||
}
|
||||
|
||||
public void visitTopLevel(JCTree.JCCompilationUnit tree) {
|
||||
super.visitTopLevel(tree);
|
||||
// Print out contents -- what are we dealing with?
|
||||
|
||||
for(JCTree d: tree.defs) {
|
||||
if (d instanceof JCTree.JCClassDecl)
|
||||
specifiedDeclCollection.add(((JCTree.JCClassDecl) d).sym);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void visitBlock(JCTree.JCBlock tree) {
|
||||
; // Do nothing.
|
||||
}
|
||||
|
||||
|
||||
// should add nested classes to packages, etc.
|
||||
public void visitClassDef(JCTree.JCClassDecl tree) {
|
||||
if (tree.sym == null) {
|
||||
// could be an anon class w/in an initializer
|
||||
return;
|
||||
}
|
||||
|
||||
super.visitClassDef(tree);
|
||||
|
||||
declCollection.add(tree.sym);
|
||||
}
|
||||
|
||||
public void visitMethodDef(JCTree.JCMethodDecl tree) {
|
||||
super.visitMethodDef(tree);
|
||||
}
|
||||
|
||||
public void visitVarDef(JCTree.JCVariableDecl tree) {
|
||||
super.visitVarDef(tree);
|
||||
}
|
||||
|
||||
public void visitAnnotation(JCTree.JCAnnotation tree) {
|
||||
super.visitAnnotation(tree);
|
||||
annotationSet.add(tree.type.tsym.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> computeAnnotationSet(Collection<ClassSymbol> classSymbols) {
|
||||
Set<String> annotationSet = new HashSet<String>();
|
||||
|
||||
for(ClassSymbol classSymbol: classSymbols) {
|
||||
computeAnnotationSet(classSymbol, annotationSet);
|
||||
}
|
||||
return annotationSet;
|
||||
}
|
||||
|
||||
void computeAnnotationSet(Symbol symbol, Set<String> annotationSet) {
|
||||
if (symbol != null ) {
|
||||
if (symbol.getAnnotationMirrors() != null)
|
||||
for(Attribute.Compound compound: symbol.getAnnotationMirrors())
|
||||
annotationSet.add(compound.type.tsym.toString()); // should fullName be used instead of toString?
|
||||
|
||||
if (symbol instanceof Symbol.MethodSymbol) // add parameter annotations
|
||||
for(Symbol param: ((MethodSymbol) symbol).params())
|
||||
computeAnnotationSet(param, annotationSet);
|
||||
|
||||
if (symbol.members() != null) {
|
||||
for(Scope.Entry e = symbol.members().elems; e != null; e = e.sibling)
|
||||
computeAnnotationSet(e.sym, annotationSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void main(com.sun.tools.javac.util.List<JCTree.JCCompilationUnit> treeList,
|
||||
ListBuffer<ClassSymbol> classes,
|
||||
Map<String, String> origOptions,
|
||||
ClassLoader aptCL,
|
||||
AnnotationProcessorFactory providedFactory,
|
||||
java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories) {
|
||||
Bark bark = Bark.instance(context);
|
||||
java.io.PrintWriter out = bark.getWriter(Log.WriterKind.WARNING);
|
||||
Options options = Options.instance(context);
|
||||
|
||||
Collection<TypeDeclaration> spectypedecls = new LinkedHashSet<TypeDeclaration>();
|
||||
Collection<TypeDeclaration> typedecls = new LinkedHashSet<TypeDeclaration>();
|
||||
Set<String> unmatchedAnnotations = new LinkedHashSet<String>();
|
||||
Set<AnnotationTypeDeclaration> emptyATDS = Collections.emptySet();
|
||||
Set<Class<? extends AnnotationProcessorFactory> > currentRoundFactories =
|
||||
new LinkedHashSet<Class<? extends AnnotationProcessorFactory> >();
|
||||
|
||||
// Determine what annotations are present on the input source
|
||||
// files, create collections of specified type declarations,
|
||||
// and type declarations.
|
||||
AptTreeScanner ats = new AptTreeScanner();
|
||||
for(JCTree t: treeList) {
|
||||
t.accept(ats);
|
||||
}
|
||||
|
||||
// Turn collection of ClassSymbols into Collection of apt decls
|
||||
for (ClassSymbol cs : ats.specifiedDeclCollection) {
|
||||
TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(cs);
|
||||
spectypedecls.add(decl);
|
||||
}
|
||||
|
||||
for (ClassSymbol cs : ats.declCollection) {
|
||||
TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(cs);
|
||||
typedecls.add(decl);
|
||||
}
|
||||
|
||||
unmatchedAnnotations.addAll(ats.getAnnotationSet());
|
||||
|
||||
// Process input class files
|
||||
for(ClassSymbol cs : classes) {
|
||||
TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(cs);
|
||||
// System.out.println("Adding a class to spectypedecls");
|
||||
spectypedecls.add(decl);
|
||||
typedecls.add(decl);
|
||||
computeAnnotationSet(cs, unmatchedAnnotations);
|
||||
}
|
||||
|
||||
if (options.get("-XListAnnotationTypes") != null) {
|
||||
out.println("Set of annotations found:" +
|
||||
(new TreeSet<String>(unmatchedAnnotations)).toString());
|
||||
}
|
||||
|
||||
AnnotationProcessorEnvironmentImpl trivAPE =
|
||||
new AnnotationProcessorEnvironmentImpl(spectypedecls, typedecls, origOptions, context);
|
||||
|
||||
if (options.get("-XListDeclarations") != null) {
|
||||
out.println("Set of Specified Declarations:" +
|
||||
spectypedecls);
|
||||
|
||||
out.println("Set of Included Declarations: " +
|
||||
typedecls);
|
||||
}
|
||||
|
||||
if (options.get("-print") != null) {
|
||||
if (spectypedecls.size() == 0 )
|
||||
throw new UsageMessageNeededException();
|
||||
|
||||
// Run the printing processor
|
||||
AnnotationProcessor proc = (new BootstrapAPF()).getProcessorFor(new HashSet<AnnotationTypeDeclaration>(),
|
||||
trivAPE);
|
||||
proc.process();
|
||||
} else {
|
||||
// Discovery process
|
||||
|
||||
// List of annotation processory factory instances
|
||||
java.util.Iterator<AnnotationProcessorFactory> providers = null;
|
||||
{
|
||||
/*
|
||||
* If a factory is provided by the user, the
|
||||
* "-factory" and "-factorypath" options are not used.
|
||||
*
|
||||
* Otherwise, if the "-factory" option is used, search
|
||||
* the appropriate path for the named class.
|
||||
* Otherwise, use sun.misc.Service to implement the
|
||||
* default discovery policy.
|
||||
*/
|
||||
|
||||
java.util.List<AnnotationProcessorFactory> list =
|
||||
new LinkedList<AnnotationProcessorFactory>();
|
||||
String factoryName = options.get("-factory");
|
||||
|
||||
if (providedFactory != null) {
|
||||
list.add(providedFactory);
|
||||
providers = list.iterator();
|
||||
} else if (factoryName != null) {
|
||||
try {
|
||||
AnnotationProcessorFactory factory =
|
||||
(AnnotationProcessorFactory) (aptCL.loadClass(factoryName).newInstance());
|
||||
list.add(factory);
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
bark.aptWarning("FactoryNotFound", factoryName);
|
||||
} catch (ClassCastException cce) {
|
||||
bark.aptWarning("FactoryWrongType", factoryName);
|
||||
} catch (Exception e ) {
|
||||
bark.aptWarning("FactoryCantInstantiate", factoryName);
|
||||
} catch(Throwable t) {
|
||||
throw new AnnotationProcessingError(t);
|
||||
}
|
||||
|
||||
providers = list.iterator();
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<AnnotationProcessorFactory> iter =
|
||||
sun.misc.Service.providers(AnnotationProcessorFactory.class, aptCL);
|
||||
providers = iter;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
java.util.Map<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>> factoryToAnnotation =
|
||||
new LinkedHashMap<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>>();
|
||||
|
||||
if (!providers.hasNext() && productiveFactories.size() == 0) {
|
||||
if (unmatchedAnnotations.size() > 0)
|
||||
bark.aptWarning("NoAnnotationProcessors");
|
||||
if (spectypedecls.size() == 0)
|
||||
throw new UsageMessageNeededException();
|
||||
return; // no processors; nothing else to do
|
||||
} else {
|
||||
// If there are no annotations, still give
|
||||
// processors that match everything a chance to
|
||||
// run.
|
||||
|
||||
if(unmatchedAnnotations.size() == 0)
|
||||
unmatchedAnnotations.add("");
|
||||
|
||||
Set<String> emptyStringSet = new HashSet<String>();
|
||||
emptyStringSet.add("");
|
||||
emptyStringSet = Collections.unmodifiableSet(emptyStringSet);
|
||||
|
||||
while (providers.hasNext() ) {
|
||||
Object provider = providers.next();
|
||||
try {
|
||||
Set<String> matchedStrings = new HashSet<String>();
|
||||
|
||||
AnnotationProcessorFactory apf = (AnnotationProcessorFactory) provider;
|
||||
Collection<String> supportedTypes = apf.supportedAnnotationTypes();
|
||||
|
||||
Collection<Pattern> supportedTypePatterns = new LinkedList<Pattern>();
|
||||
for(String s: supportedTypes)
|
||||
supportedTypePatterns.add(importStringToPattern(s));
|
||||
|
||||
for(String s: unmatchedAnnotations) {
|
||||
for(Pattern p: supportedTypePatterns) {
|
||||
if (p.matcher(s).matches()) {
|
||||
matchedStrings.add(s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unmatchedAnnotations.removeAll(matchedStrings);
|
||||
|
||||
if (options.get("-XPrintFactoryInfo") != null) {
|
||||
out.println("Factory " + apf.getClass().getName() +
|
||||
" matches " +
|
||||
((matchedStrings.size() == 0)?
|
||||
"nothing.": matchedStrings));
|
||||
}
|
||||
|
||||
if (matchedStrings.size() > 0) {
|
||||
// convert annotation names to annotation
|
||||
// type decls
|
||||
Set<AnnotationTypeDeclaration> atds = new HashSet<AnnotationTypeDeclaration>();
|
||||
|
||||
// If a "*" processor is called on the
|
||||
// empty string, pass in an empty set of
|
||||
// annotation type declarations.
|
||||
if (!matchedStrings.equals(emptyStringSet)) {
|
||||
for(String s: matchedStrings) {
|
||||
TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(s);
|
||||
AnnotationTypeDeclaration annotdecl;
|
||||
if (decl == null) {
|
||||
bark.aptError("DeclarationCreation", s);
|
||||
} else {
|
||||
try {
|
||||
annotdecl = (AnnotationTypeDeclaration)decl;
|
||||
atds.add(annotdecl);
|
||||
|
||||
} catch (ClassCastException cce) {
|
||||
bark.aptError("BadDeclaration", s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentRoundFactories.add(apf.getClass());
|
||||
productiveFactories.add(apf.getClass());
|
||||
factoryToAnnotation.put(apf, atds);
|
||||
} else if (productiveFactories.contains(apf.getClass())) {
|
||||
// If a factory provided a processor in a
|
||||
// previous round but doesn't match any
|
||||
// annotations this round, call it with an
|
||||
// empty set of declarations.
|
||||
currentRoundFactories.add(apf.getClass());
|
||||
factoryToAnnotation.put(apf, emptyATDS );
|
||||
}
|
||||
|
||||
if (unmatchedAnnotations.size() == 0)
|
||||
break;
|
||||
|
||||
} catch (ClassCastException cce) {
|
||||
bark.aptWarning("BadFactory", cce);
|
||||
}
|
||||
}
|
||||
|
||||
unmatchedAnnotations.remove("");
|
||||
}
|
||||
|
||||
// If the set difference of productiveFactories and
|
||||
// currentRoundFactories is non-empty, call the remaining
|
||||
// productive factories with an empty set of declarations.
|
||||
{
|
||||
java.util.Set<Class<? extends AnnotationProcessorFactory> > neglectedFactories =
|
||||
new LinkedHashSet<Class<? extends AnnotationProcessorFactory>>(productiveFactories);
|
||||
neglectedFactories.removeAll(currentRoundFactories);
|
||||
for(Class<? extends AnnotationProcessorFactory> working : neglectedFactories) {
|
||||
try {
|
||||
AnnotationProcessorFactory factory = working.newInstance();
|
||||
factoryToAnnotation.put(factory, emptyATDS);
|
||||
} catch (Exception e ) {
|
||||
bark.aptWarning("FactoryCantInstantiate", working.getName());
|
||||
} catch(Throwable t) {
|
||||
throw new AnnotationProcessingError(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (unmatchedAnnotations.size() > 0)
|
||||
bark.aptWarning("AnnotationsWithoutProcessors", unmatchedAnnotations);
|
||||
|
||||
Set<AnnotationProcessor> processors = new LinkedHashSet<AnnotationProcessor>();
|
||||
|
||||
// If there were no source files AND no factory matching "*",
|
||||
// make sure the usage message is printed
|
||||
if (spectypedecls.size() == 0 &&
|
||||
factoryToAnnotation.keySet().size() == 0 )
|
||||
throw new UsageMessageNeededException();
|
||||
|
||||
try {
|
||||
for(Map.Entry<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>> entry :
|
||||
factoryToAnnotation.entrySet()) {
|
||||
AnnotationProcessorFactory apFactory = entry.getKey();
|
||||
AnnotationProcessor processor = apFactory.getProcessorFor(entry.getValue(),
|
||||
trivAPE);
|
||||
if (processor != null)
|
||||
processors.add(processor);
|
||||
else
|
||||
bark.aptWarning("NullProcessor", apFactory.getClass().getName());
|
||||
}
|
||||
} catch(Throwable t) {
|
||||
throw new AnnotationProcessingError(t);
|
||||
}
|
||||
|
||||
LinkedList<AnnotationProcessor> temp = new LinkedList<AnnotationProcessor>();
|
||||
temp.addAll(processors);
|
||||
|
||||
AnnotationProcessor proc = AnnotationProcessors.getCompositeAnnotationProcessor(temp);
|
||||
|
||||
try {
|
||||
proc.process();
|
||||
} catch (Throwable t) {
|
||||
throw new AnnotationProcessingError(t);
|
||||
}
|
||||
|
||||
// Invoke listener callback mechanism
|
||||
trivAPE.roundComplete();
|
||||
|
||||
FilerImpl filerimpl = (FilerImpl)trivAPE.getFiler();
|
||||
genSourceFileNames = filerimpl.getSourceFileNames();
|
||||
genClassFileNames = filerimpl.getClassFileNames();
|
||||
filerimpl.flush(); // Make sure new files are written out
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert import-style string to regex matching that string. If
|
||||
* the string is a valid import-style string, return a regex that
|
||||
* won't match anything.
|
||||
*/
|
||||
Pattern importStringToPattern(String s) {
|
||||
if (com.sun.tools.javac.processing.JavacProcessingEnvironment.isValidImportString(s)) {
|
||||
return com.sun.tools.javac.processing.JavacProcessingEnvironment.validImportStringToPattern(s);
|
||||
} else {
|
||||
Bark bark = Bark.instance(context);
|
||||
bark.aptWarning("MalformedSupportedString", s);
|
||||
return com.sun.tools.javac.processing.JavacProcessingEnvironment.noMatches;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.comp;
|
||||
|
||||
import java.util.*;
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BootstrapAPF implements AnnotationProcessorFactory {
|
||||
|
||||
static final Collection<String> supportedOptions =
|
||||
Collections.unmodifiableSet(new HashSet<String>());
|
||||
|
||||
static Collection<String> supportedAnnotations;
|
||||
static {
|
||||
Collection<String> c = new HashSet<String>();
|
||||
c.add("*");
|
||||
supportedAnnotations = Collections.unmodifiableCollection(c);
|
||||
}
|
||||
|
||||
public BootstrapAPF(){}
|
||||
|
||||
public Collection<String> supportedOptions() {
|
||||
return BootstrapAPF.supportedOptions;
|
||||
}
|
||||
|
||||
public Collection<String> supportedAnnotationTypes() {
|
||||
return supportedAnnotations;
|
||||
}
|
||||
|
||||
public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
|
||||
AnnotationProcessorEnvironment env) {
|
||||
return new PrintAP(env);
|
||||
}
|
||||
}
|
@ -1,467 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2006, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.comp;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import static com.sun.mirror.declaration.Modifier.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.apt.*;
|
||||
|
||||
import java.util.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
/**
|
||||
* Class used to implement "-print" option.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PrintAP implements AnnotationProcessor {
|
||||
|
||||
|
||||
static class PrintingVisitors {
|
||||
int indentation = 0; // Indentation level;
|
||||
AnnotationProcessorEnvironment env;
|
||||
Messager out;
|
||||
Declaration java_lang_Object;
|
||||
Declaration java_lang_annotation_Annotation;
|
||||
|
||||
static Set<Modifier> EMPTY_ELIDES = Collections.emptySet();
|
||||
static Set<Modifier> INTERFACE_ELIDES = EnumSet.of(ABSTRACT);
|
||||
static Set<Modifier> ENUM_ELIDES = EnumSet.of(FINAL, ABSTRACT);
|
||||
static Set<Modifier> INTERFACE_MEMBER_ELIDES = EnumSet.of(ABSTRACT, PUBLIC, STATIC, FINAL);
|
||||
|
||||
PrintingVisitors(AnnotationProcessorEnvironment env) {
|
||||
this.env = env;
|
||||
this.out = env.getMessager();
|
||||
this.java_lang_Object = env.getTypeDeclaration("java.lang.Object");
|
||||
this.java_lang_annotation_Annotation = env.getTypeDeclaration("java.lang.annotation.Annotation");
|
||||
}
|
||||
|
||||
|
||||
static String [] spaces = {
|
||||
"",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
};
|
||||
|
||||
|
||||
String indent(){
|
||||
int indentation = this.indentation;
|
||||
if (indentation < 0)
|
||||
return "";
|
||||
else if (indentation <= 10)
|
||||
return spaces[indentation];
|
||||
else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (indentation > 10) {
|
||||
sb.append(spaces[indentation]);
|
||||
indentation -= 10;
|
||||
}
|
||||
sb.append(spaces[indentation]);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PrePrinting extends SimpleDeclarationVisitor {
|
||||
Map<EnumDeclaration, Integer> enumCardinality = new HashMap<EnumDeclaration, Integer>();
|
||||
Map<EnumDeclaration, Integer> enumConstVisited = new HashMap<EnumDeclaration, Integer>();
|
||||
|
||||
PrePrinting(){}
|
||||
|
||||
public void visitClassDeclaration(ClassDeclaration d) {
|
||||
System.out.println();
|
||||
printDocComment(d);
|
||||
printModifiers(d, EMPTY_ELIDES);
|
||||
System.out.print("class " + d.getSimpleName());
|
||||
printFormalTypeParameters(d);
|
||||
|
||||
// Elide "extends Object"
|
||||
ClassType Super = d.getSuperclass();
|
||||
if (Super != null && !java_lang_Object.equals(Super.getDeclaration()) )
|
||||
System.out.print(" extends " + Super.toString());
|
||||
|
||||
printInterfaces(d);
|
||||
|
||||
System.out.println(" {");
|
||||
|
||||
PrintingVisitors.this.indentation++;
|
||||
}
|
||||
|
||||
public void visitEnumDeclaration(EnumDeclaration d) {
|
||||
enumCardinality.put(d, d.getEnumConstants().size());
|
||||
enumConstVisited.put(d, 1);
|
||||
|
||||
System.out.println();
|
||||
printDocComment(d);
|
||||
printModifiers(d, ENUM_ELIDES);
|
||||
|
||||
System.out.print("enum " + d.getSimpleName());
|
||||
printFormalTypeParameters(d);
|
||||
printInterfaces(d);
|
||||
|
||||
System.out.println(" {");
|
||||
|
||||
PrintingVisitors.this.indentation++;
|
||||
}
|
||||
|
||||
|
||||
public void visitInterfaceDeclaration(InterfaceDeclaration d) {
|
||||
System.out.println();
|
||||
printDocComment(d);
|
||||
printModifiers(d, INTERFACE_ELIDES);
|
||||
System.out.print("interface " + d.getSimpleName());
|
||||
|
||||
printFormalTypeParameters(d);
|
||||
printInterfaces(d);
|
||||
|
||||
System.out.println(" {");
|
||||
|
||||
PrintingVisitors.this.indentation++;
|
||||
}
|
||||
|
||||
public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {
|
||||
System.out.println();
|
||||
printDocComment(d);
|
||||
printModifiers(d, INTERFACE_ELIDES);
|
||||
System.out.print("@interface " + d.getSimpleName());
|
||||
printFormalTypeParameters(d);
|
||||
|
||||
printInterfaces(d);
|
||||
|
||||
System.out.println(" {");
|
||||
|
||||
PrintingVisitors.this.indentation++;
|
||||
}
|
||||
|
||||
public void visitFieldDeclaration(FieldDeclaration d) {
|
||||
System.out.println();
|
||||
printDocComment(d);
|
||||
printModifiers(d,
|
||||
(d.getDeclaringType() instanceof InterfaceDeclaration)?
|
||||
INTERFACE_MEMBER_ELIDES : EMPTY_ELIDES);
|
||||
System.out.print(d.getType().toString() + " " +
|
||||
d.getSimpleName() );
|
||||
String constantExpr = d.getConstantExpression();
|
||||
if (constantExpr != null) {
|
||||
System.out.print(" = " + constantExpr);
|
||||
}
|
||||
System.out.println(";" );
|
||||
}
|
||||
|
||||
public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {
|
||||
EnumDeclaration ed = d.getDeclaringType();
|
||||
int enumCard = enumCardinality.get(ed);
|
||||
int enumVisit = enumConstVisited.get(ed);
|
||||
|
||||
System.out.println();
|
||||
printDocComment(d);
|
||||
System.out.print(PrintingVisitors.this.indent());
|
||||
System.out.print(d.getSimpleName() );
|
||||
System.out.println((enumVisit < enumCard )? ",":";" );
|
||||
|
||||
enumConstVisited.put(ed, enumVisit+1);
|
||||
}
|
||||
|
||||
public void visitMethodDeclaration(MethodDeclaration d) {
|
||||
System.out.println();
|
||||
printDocComment(d);
|
||||
printModifiers(d,
|
||||
(d.getDeclaringType() instanceof InterfaceDeclaration)?
|
||||
INTERFACE_MEMBER_ELIDES : EMPTY_ELIDES);
|
||||
printFormalTypeParameters(d);
|
||||
System.out.print(d.getReturnType().toString() + " ");
|
||||
System.out.print(d.getSimpleName() + "(");
|
||||
printParameters(d);
|
||||
System.out.print(")");
|
||||
printThrows(d);
|
||||
System.out.println(";");
|
||||
}
|
||||
|
||||
public void visitConstructorDeclaration(ConstructorDeclaration d) {
|
||||
System.out.println();
|
||||
printDocComment(d);
|
||||
printModifiers(d, EMPTY_ELIDES);
|
||||
printFormalTypeParameters(d);
|
||||
System.out.print(d.getSimpleName() + "(");
|
||||
printParameters(d);
|
||||
System.out.print(")");
|
||||
printThrows(d);
|
||||
System.out.println(";");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class PostPrinting extends SimpleDeclarationVisitor {
|
||||
PostPrinting(){}
|
||||
|
||||
public void visitTypeDeclaration(TypeDeclaration d) {
|
||||
PrintingVisitors.this.indentation--;
|
||||
|
||||
System.out.print(PrintingVisitors.this.indent());
|
||||
System.out.println("}");
|
||||
}
|
||||
}
|
||||
|
||||
private void printAnnotations(Collection<AnnotationMirror> annots) {
|
||||
|
||||
for(AnnotationMirror annot: annots) {
|
||||
System.out.print(this.indent());
|
||||
System.out.print(annot.toString());
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
private void printAnnotationsInline(Collection<AnnotationMirror> annots) {
|
||||
|
||||
for(AnnotationMirror annot: annots) {
|
||||
System.out.print(annot);
|
||||
System.out.print(" ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void printParameters(ExecutableDeclaration ex) {
|
||||
|
||||
Collection<ParameterDeclaration> parameters = ex.getParameters();
|
||||
int size = parameters.size();
|
||||
|
||||
switch (size) {
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for(ParameterDeclaration parameter: parameters) {
|
||||
printModifiers(parameter, EMPTY_ELIDES);
|
||||
|
||||
if (ex.isVarArgs() ) {
|
||||
System.out.print(((ArrayType)parameter.getType()).getComponentType() );
|
||||
System.out.print("...");
|
||||
} else
|
||||
System.out.print(parameter.getType());
|
||||
System.out.print(" " + parameter.getSimpleName());
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
int i = 1;
|
||||
for(ParameterDeclaration parameter: parameters) {
|
||||
if (i == 2)
|
||||
PrintingVisitors.this.indentation++;
|
||||
|
||||
if (i > 1)
|
||||
System.out.print(PrintingVisitors.this.indent());
|
||||
|
||||
printModifiers(parameter, EMPTY_ELIDES);
|
||||
|
||||
if (i == size && ex.isVarArgs() ) {
|
||||
System.out.print(((ArrayType)parameter.getType()).getComponentType() );
|
||||
System.out.print("...");
|
||||
} else
|
||||
System.out.print(parameter.getType());
|
||||
System.out.print(" " + parameter.getSimpleName());
|
||||
|
||||
if (i < size)
|
||||
System.out.println(",");
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (parameters.size() >= 2)
|
||||
PrintingVisitors.this.indentation--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void printDocComment(Declaration d) {
|
||||
String docComment = d.getDocComment();
|
||||
|
||||
if (docComment != null) {
|
||||
// Break comment into lines
|
||||
java.util.StringTokenizer st = new StringTokenizer(docComment,
|
||||
"\n\r");
|
||||
System.out.print(PrintingVisitors.this.indent());
|
||||
System.out.println("/**");
|
||||
|
||||
while(st.hasMoreTokens()) {
|
||||
System.out.print(PrintingVisitors.this.indent());
|
||||
System.out.print(" *");
|
||||
System.out.println(st.nextToken());
|
||||
}
|
||||
|
||||
System.out.print(PrintingVisitors.this.indent());
|
||||
System.out.println(" */");
|
||||
}
|
||||
}
|
||||
|
||||
private void printModifiers(Declaration d, Collection<Modifier> elides) {
|
||||
printAnnotations(d.getAnnotationMirrors());
|
||||
|
||||
System.out.print(PrintingVisitors.this.indent());
|
||||
|
||||
for(Modifier m: adjustModifiers(d.getModifiers(), elides) ){
|
||||
System.out.print(m.toString() + " ");
|
||||
}
|
||||
}
|
||||
|
||||
private void printModifiers(ParameterDeclaration d, Collection<Modifier> elides) {
|
||||
printAnnotationsInline(d.getAnnotationMirrors());
|
||||
|
||||
for(Modifier m: adjustModifiers(d.getModifiers(), elides) ) {
|
||||
System.out.print(m.toString() + " ");
|
||||
}
|
||||
}
|
||||
|
||||
private Collection<Modifier> adjustModifiers(Collection<Modifier> mods,
|
||||
Collection<Modifier> elides) {
|
||||
if (elides.isEmpty())
|
||||
return mods;
|
||||
else {
|
||||
Collection<Modifier> newMods = new LinkedHashSet<Modifier>();
|
||||
newMods.addAll(mods);
|
||||
newMods.removeAll(elides);
|
||||
return newMods;
|
||||
}
|
||||
}
|
||||
|
||||
private void printFormalTypeParameters(ExecutableDeclaration e) {
|
||||
printFormalTypeParameterSet(e.getFormalTypeParameters(), true);
|
||||
}
|
||||
|
||||
private void printFormalTypeParameters(TypeDeclaration d) {
|
||||
printFormalTypeParameterSet(d.getFormalTypeParameters(), false);
|
||||
}
|
||||
|
||||
private void printFormalTypeParameterSet(Collection<TypeParameterDeclaration> typeParams, boolean pad) {
|
||||
if (typeParams.size() != 0) {
|
||||
System.out.print("<");
|
||||
|
||||
boolean first = true;
|
||||
for(TypeParameterDeclaration tpd: typeParams) {
|
||||
if (!first)
|
||||
System.out.print(", ");
|
||||
System.out.print(tpd.toString());
|
||||
}
|
||||
|
||||
System.out.print(">");
|
||||
if (pad)
|
||||
System.out.print(" ");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void printInterfaceSet(Collection<InterfaceType> interfaces,
|
||||
boolean classNotInterface) {
|
||||
if (interfaces.size() != 0) {
|
||||
System.out.print((classNotInterface?" implements" : " extends"));
|
||||
|
||||
boolean first = true;
|
||||
for(InterfaceType interType: interfaces) {
|
||||
if (!first)
|
||||
System.out.print(",");
|
||||
System.out.print(" ");
|
||||
System.out.print(interType.toString());
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void printInterfaces(TypeDeclaration d) {
|
||||
printInterfaceSet(d.getSuperinterfaces(), d instanceof ClassDeclaration);
|
||||
}
|
||||
|
||||
private void printInterfaces(AnnotationTypeDeclaration d) {
|
||||
Collection<InterfaceType> interfaces = new HashSet<InterfaceType>(d.getSuperinterfaces());
|
||||
|
||||
for(InterfaceType interType: interfaces) {
|
||||
if (java_lang_annotation_Annotation.equals(interType.getDeclaration()) )
|
||||
interfaces.remove(interType);
|
||||
}
|
||||
|
||||
printInterfaceSet(interfaces, d instanceof ClassDeclaration);
|
||||
}
|
||||
|
||||
private void printThrows(ExecutableDeclaration d) {
|
||||
Collection<ReferenceType> thrownTypes = d.getThrownTypes();
|
||||
final int size = thrownTypes.size();
|
||||
if (size != 0) {
|
||||
System.out.print(" throws");
|
||||
|
||||
int i = 1;
|
||||
for(ReferenceType thrownType: thrownTypes) {
|
||||
if (i == 1) {
|
||||
System.out.print(" ");
|
||||
}
|
||||
|
||||
if (i == 2)
|
||||
PrintingVisitors.this.indentation++;
|
||||
|
||||
if (i >= 2)
|
||||
System.out.print(PrintingVisitors.this.indent());
|
||||
|
||||
System.out.print(thrownType.toString());
|
||||
|
||||
|
||||
if (i != size) {
|
||||
System.out.println(", ");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (size >= 2)
|
||||
PrintingVisitors.this.indentation--;
|
||||
}
|
||||
}
|
||||
|
||||
DeclarationVisitor getPrintingVisitor() {
|
||||
return DeclarationVisitors.getSourceOrderDeclarationScanner(new PrePrinting(),
|
||||
new PostPrinting());
|
||||
}
|
||||
}
|
||||
|
||||
AnnotationProcessorEnvironment env;
|
||||
PrintAP(AnnotationProcessorEnvironment env) {
|
||||
this.env = env;
|
||||
}
|
||||
|
||||
|
||||
public void process() {
|
||||
Collection<TypeDeclaration> typedecls = env.getSpecifiedTypeDeclarations();
|
||||
|
||||
for (TypeDeclaration td: typedecls)
|
||||
td.accept((new PrintingVisitors(env)).getPrintingVisitor());
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2009, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.comp;
|
||||
|
||||
|
||||
public class UsageMessageNeededException extends RuntimeException {
|
||||
private static final long serialVersionUID = -3265159608992825840L;
|
||||
}
|
@ -1,291 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2011, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.main;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
import com.sun.tools.javac.file.JavacFileManager;
|
||||
import com.sun.tools.javac.util.*;
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.jvm.*;
|
||||
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
import com.sun.tools.javac.tree.JCTree.*;
|
||||
|
||||
import com.sun.tools.apt.comp.*;
|
||||
import com.sun.tools.apt.util.Bark;
|
||||
import com.sun.mirror.apt.AnnotationProcessorFactory;
|
||||
|
||||
/**
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own
|
||||
* risk. This code and its internal interfaces are subject to change
|
||||
* or deletion without notice.</b>
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AptJavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
|
||||
/** The context key for the compiler. */
|
||||
protected static final Context.Key<AptJavaCompiler> compilerKey =
|
||||
new Context.Key<AptJavaCompiler>();
|
||||
|
||||
/** Get the JavaCompiler instance for this context. */
|
||||
public static AptJavaCompiler instance(Context context) {
|
||||
AptJavaCompiler instance = context.get(compilerKey);
|
||||
if (instance == null)
|
||||
instance = new AptJavaCompiler(context);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
java.util.Set<String> genSourceFileNames;
|
||||
java.util.Set<String> genClassFileNames;
|
||||
|
||||
public java.util.Set<String> getSourceFileNames() {
|
||||
return genSourceFileNames;
|
||||
}
|
||||
|
||||
/** List of names of generated class files.
|
||||
*/
|
||||
public java.util.Set<String> getClassFileNames() {
|
||||
return genClassFileNames;
|
||||
}
|
||||
|
||||
java.util.Set<java.io.File> aggregateGenFiles = java.util.Collections.emptySet();
|
||||
|
||||
public java.util.Set<java.io.File> getAggregateGenFiles() {
|
||||
return aggregateGenFiles;
|
||||
}
|
||||
|
||||
/** The bark to be used for error reporting.
|
||||
*/
|
||||
Bark bark;
|
||||
|
||||
/** The log to be used for error reporting.
|
||||
*/
|
||||
Log log;
|
||||
|
||||
/** The annotation framework
|
||||
*/
|
||||
Apt apt;
|
||||
|
||||
private static Context preRegister(Context context) {
|
||||
Bark.preRegister(context);
|
||||
|
||||
if (context.get(JavaFileManager.class) == null)
|
||||
JavacFileManager.preRegister(context);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/** Construct a new compiler from a shared context.
|
||||
*/
|
||||
public AptJavaCompiler(Context context) {
|
||||
super(preRegister(context));
|
||||
|
||||
context.put(compilerKey, this);
|
||||
apt = Apt.instance(context);
|
||||
|
||||
ClassReader classReader = ClassReader.instance(context);
|
||||
classReader.preferSource = true;
|
||||
|
||||
// TEMPORARY NOTE: bark==log, but while refactoring, we maintain their
|
||||
// original identities, to remember the original intent.
|
||||
log = Log.instance(context);
|
||||
bark = Bark.instance(context);
|
||||
|
||||
Options options = Options.instance(context);
|
||||
classOutput = options.get("-retrofit") == null;
|
||||
nocompile = options.get("-nocompile") != null;
|
||||
print = options.get("-print") != null;
|
||||
classesAsDecls= options.get("-XclassesAsDecls") != null;
|
||||
|
||||
genSourceFileNames = new java.util.LinkedHashSet<String>();
|
||||
genClassFileNames = new java.util.LinkedHashSet<String>();
|
||||
|
||||
// this forces a copy of the line map to be kept in the tree,
|
||||
// for use by com.sun.mirror.util.SourcePosition.
|
||||
lineDebugInfo = true;
|
||||
}
|
||||
|
||||
/* Switches:
|
||||
*/
|
||||
|
||||
/** Emit class files. This switch is always set, except for the first
|
||||
* phase of retrofitting, where signatures are parsed.
|
||||
*/
|
||||
public boolean classOutput;
|
||||
|
||||
/** The internal printing annotation processor should be used.
|
||||
*/
|
||||
public boolean print;
|
||||
|
||||
/** Compilation should not be done after annotation processing.
|
||||
*/
|
||||
public boolean nocompile;
|
||||
|
||||
/** Are class files being treated as declarations
|
||||
*/
|
||||
public boolean classesAsDecls;
|
||||
|
||||
/** Try to open input stream with given name.
|
||||
* Report an error if this fails.
|
||||
* @param filename The file name of the input stream to be opened.
|
||||
*/
|
||||
// PROVIDED FOR EXTREME BACKWARDS COMPATIBILITY
|
||||
// There are some very obscure errors that can arise while translating
|
||||
// the contents of a file from bytes to characters. In Tiger, these
|
||||
// diagnostics were ignored. This method provides compatibility with
|
||||
// that behavior. It would be better to honor those diagnostics, in which
|
||||
// case, this method can be deleted.
|
||||
@Override
|
||||
public CharSequence readSource(JavaFileObject filename) {
|
||||
try {
|
||||
inputFiles.add(filename);
|
||||
boolean prev = bark.setDiagnosticsIgnored(true);
|
||||
try {
|
||||
return filename.getCharContent(false);
|
||||
}
|
||||
finally {
|
||||
bark.setDiagnosticsIgnored(prev);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
bark.error(Position.NOPOS, "cant.read.file", filename);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Parse contents of input stream.
|
||||
* @param filename The name of the file from which input stream comes.
|
||||
* @param input The input stream to be parsed.
|
||||
*/
|
||||
// PROVIDED FOR BACKWARDS COMPATIBILITY
|
||||
// In Tiger, diagnostics from the scanner and parser were ignored.
|
||||
// This method provides compatibility with that behavior.
|
||||
// It would be better to honor those diagnostics, in which
|
||||
// case, this method can be deleted.
|
||||
@Override
|
||||
protected JCCompilationUnit parse(JavaFileObject filename, CharSequence content) {
|
||||
boolean prev = bark.setDiagnosticsIgnored(true);
|
||||
try {
|
||||
return super.parse(filename, content);
|
||||
}
|
||||
finally {
|
||||
bark.setDiagnosticsIgnored(prev);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean keepComments() {
|
||||
return true; // make doc comments available to mirror API impl.
|
||||
}
|
||||
|
||||
/** Track when the JavaCompiler has been used to compile something. */
|
||||
private boolean hasBeenUsed = false;
|
||||
|
||||
/** Main method: compile a list of files, return all compiled classes
|
||||
* @param filenames The names of all files to be compiled.
|
||||
*/
|
||||
public List<ClassSymbol> compile(List<String> filenames,
|
||||
Map<String, String> origOptions,
|
||||
ClassLoader aptCL,
|
||||
AnnotationProcessorFactory providedFactory,
|
||||
java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories,
|
||||
java.util.Set<java.io.File> aggregateGenFiles)
|
||||
throws Throwable {
|
||||
// as a JavaCompiler can only be used once, throw an exception if
|
||||
// it has been used before.
|
||||
assert !hasBeenUsed : "attempt to reuse JavaCompiler";
|
||||
hasBeenUsed = true;
|
||||
|
||||
this.aggregateGenFiles = aggregateGenFiles;
|
||||
|
||||
long msec = System.currentTimeMillis();
|
||||
|
||||
ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
|
||||
try {
|
||||
JavacFileManager fm = (JavacFileManager)fileManager;
|
||||
//parse all files
|
||||
ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>();
|
||||
for (List<String> l = filenames; l.nonEmpty(); l = l.tail) {
|
||||
if (classesAsDecls) {
|
||||
if (! l.head.endsWith(".java") ) { // process as class file
|
||||
ClassSymbol cs = reader.enterClass(names.fromString(l.head));
|
||||
try {
|
||||
cs.complete();
|
||||
} catch(Symbol.CompletionFailure cf) {
|
||||
bark.aptError("CantFindClass", l);
|
||||
continue;
|
||||
}
|
||||
|
||||
classes.append(cs); // add to list of classes
|
||||
continue;
|
||||
}
|
||||
}
|
||||
JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next();
|
||||
trees.append(parse(fo));
|
||||
}
|
||||
|
||||
//enter symbols for all files
|
||||
List<JCCompilationUnit> roots = trees.toList();
|
||||
|
||||
if (errorCount() == 0) {
|
||||
boolean prev = bark.setDiagnosticsIgnored(true);
|
||||
try {
|
||||
enter.main(roots);
|
||||
}
|
||||
finally {
|
||||
bark.setDiagnosticsIgnored(prev);
|
||||
}
|
||||
}
|
||||
|
||||
if (errorCount() == 0) {
|
||||
apt.main(roots,
|
||||
classes,
|
||||
origOptions, aptCL,
|
||||
providedFactory,
|
||||
productiveFactories);
|
||||
genSourceFileNames.addAll(apt.getSourceFileNames());
|
||||
genClassFileNames.addAll(apt.getClassFileNames());
|
||||
}
|
||||
|
||||
} catch (Abort ex) {
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
log.printVerbose("total", Long.toString(System.currentTimeMillis() - msec));
|
||||
|
||||
chk.reportDeferredDiagnostics();
|
||||
|
||||
printCount("error", errorCount());
|
||||
printCount("warn", warningCount());
|
||||
|
||||
return classes.toList();
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.main;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.FileReader;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.StreamTokenizer;
|
||||
import com.sun.tools.javac.util.ListBuffer;
|
||||
|
||||
/**
|
||||
* Various utility methods for processing Java tool command line arguments.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class CommandLine {
|
||||
/**
|
||||
* Process Win32-style command files for the specified command line
|
||||
* arguments and return the resulting arguments. A command file argument
|
||||
* is of the form '@file' where 'file' is the name of the file whose
|
||||
* contents are to be parsed for additional arguments. The contents of
|
||||
* the command file are parsed using StreamTokenizer and the original
|
||||
* '@file' argument replaced with the resulting tokens. Recursive command
|
||||
* files are not supported. The '@' character itself can be quoted with
|
||||
* the sequence '@@'.
|
||||
*/
|
||||
public static String[] parse(String[] args)
|
||||
throws IOException
|
||||
{
|
||||
ListBuffer<String> newArgs = new ListBuffer<String>();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String arg = args[i];
|
||||
if (arg.length() > 1 && arg.charAt(0) == '@') {
|
||||
arg = arg.substring(1);
|
||||
if (arg.charAt(0) == '@') {
|
||||
newArgs.append(arg);
|
||||
} else {
|
||||
loadCmdFile(arg, newArgs);
|
||||
}
|
||||
} else {
|
||||
newArgs.append(arg);
|
||||
}
|
||||
}
|
||||
return newArgs.toList().toArray(new String[newArgs.length()]);
|
||||
}
|
||||
|
||||
private static void loadCmdFile(String name, ListBuffer<String> args)
|
||||
throws IOException
|
||||
{
|
||||
Reader r = new BufferedReader(new FileReader(name));
|
||||
StreamTokenizer st = new StreamTokenizer(r);
|
||||
st.resetSyntax();
|
||||
st.wordChars(' ', 255);
|
||||
st.whitespaceChars(0, ' ');
|
||||
st.commentChar('#');
|
||||
st.quoteChar('"');
|
||||
st.quoteChar('\'');
|
||||
while (st.nextToken() != StreamTokenizer.TT_EOF) {
|
||||
args.append(st.sval);
|
||||
}
|
||||
r.close();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,107 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2008, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror;
|
||||
|
||||
|
||||
import com.sun.tools.apt.mirror.declaration.DeclarationMaker;
|
||||
import com.sun.tools.apt.mirror.type.TypeMaker;
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.code.Symbol.CompletionFailure;
|
||||
import com.sun.tools.javac.comp.Attr;
|
||||
import com.sun.tools.javac.comp.Enter;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.Names;
|
||||
|
||||
|
||||
/**
|
||||
* The environment for a run of apt.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AptEnv {
|
||||
|
||||
public Names names; // javac's name table
|
||||
public Symtab symtab; // javac's predefined symbols
|
||||
public Types jctypes; // javac's type utilities
|
||||
public Enter enter; // javac's enter phase
|
||||
public Attr attr; // javac's attr phase (to evaluate
|
||||
// constant initializers)
|
||||
public TypeMaker typeMaker; // apt's internal type utilities
|
||||
public DeclarationMaker declMaker; // apt's internal declaration utilities
|
||||
|
||||
|
||||
private static final Context.Key<AptEnv> aptEnvKey =
|
||||
new Context.Key<AptEnv>();
|
||||
|
||||
public static AptEnv instance(Context context) {
|
||||
AptEnv instance = context.get(aptEnvKey);
|
||||
if (instance == null) {
|
||||
instance = new AptEnv(context);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private AptEnv(Context context) {
|
||||
context.put(aptEnvKey, this);
|
||||
|
||||
names = Names.instance(context);
|
||||
symtab = Symtab.instance(context);
|
||||
jctypes = Types.instance(context);
|
||||
enter = Enter.instance(context);
|
||||
attr = Attr.instance(context);
|
||||
typeMaker = TypeMaker.instance(context);
|
||||
declMaker = DeclarationMaker.instance(context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Does a symbol have a given flag? Forces symbol completion.
|
||||
*/
|
||||
public static boolean hasFlag(Symbol sym, long flag) {
|
||||
return (getFlags(sym) & flag) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a symbol's flags. Forces completion.
|
||||
*/
|
||||
public static long getFlags(Symbol sym) {
|
||||
complete(sym);
|
||||
return sym.flags();
|
||||
}
|
||||
|
||||
/**
|
||||
* Completes a symbol, ignoring completion failures.
|
||||
*/
|
||||
private static void complete(Symbol sym) {
|
||||
while (true) {
|
||||
try {
|
||||
sym.complete();
|
||||
return;
|
||||
} catch (CompletionFailure e) {
|
||||
// Should never see two in a row, but loop just to be sure.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,185 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.apt;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.util.*;
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.tools.apt.mirror.apt.*;
|
||||
import com.sun.tools.apt.mirror.declaration.DeclarationMaker;
|
||||
import com.sun.tools.apt.mirror.util.*;
|
||||
import com.sun.tools.apt.util.Bark;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
|
||||
import com.sun.tools.apt.mirror.apt.FilerImpl;
|
||||
import com.sun.tools.apt.mirror.apt.MessagerImpl;
|
||||
import com.sun.tools.apt.mirror.apt.RoundStateImpl;
|
||||
import com.sun.tools.apt.mirror.apt.RoundCompleteEventImpl;
|
||||
|
||||
import com.sun.tools.javac.util.Context;
|
||||
|
||||
import java.util.*;
|
||||
import static com.sun.mirror.util.DeclarationVisitors.*;
|
||||
|
||||
/*
|
||||
* Annotation Processor Environment implementation.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AnnotationProcessorEnvironmentImpl implements AnnotationProcessorEnvironment {
|
||||
|
||||
Collection<TypeDeclaration> spectypedecls;
|
||||
Collection<TypeDeclaration> typedecls;
|
||||
Map<String, String> origOptions;
|
||||
DeclarationMaker declMaker;
|
||||
Declarations declUtils;
|
||||
Types typeUtils;
|
||||
Messager messager;
|
||||
FilerImpl filer;
|
||||
Bark bark;
|
||||
Set<RoundCompleteListener> roundCompleteListeners;
|
||||
|
||||
public AnnotationProcessorEnvironmentImpl(Collection<TypeDeclaration> spectypedecls,
|
||||
Collection<TypeDeclaration> typedecls,
|
||||
Map<String, String> origOptions,
|
||||
Context context) {
|
||||
// Safer to copy collections before applying unmodifiable
|
||||
// wrapper.
|
||||
this.spectypedecls = Collections.unmodifiableCollection(spectypedecls);
|
||||
this.typedecls = Collections.unmodifiableCollection(typedecls);
|
||||
this.origOptions = Collections.unmodifiableMap(origOptions);
|
||||
|
||||
declMaker = DeclarationMaker.instance(context);
|
||||
declUtils = DeclarationsImpl.instance(context);
|
||||
typeUtils = TypesImpl.instance(context);
|
||||
messager = MessagerImpl.instance(context);
|
||||
filer = FilerImpl.instance(context);
|
||||
bark = Bark.instance(context);
|
||||
roundCompleteListeners = new LinkedHashSet<RoundCompleteListener>();
|
||||
}
|
||||
|
||||
public Map<String,String> getOptions() {
|
||||
return origOptions;
|
||||
}
|
||||
|
||||
public Messager getMessager() {
|
||||
return messager;
|
||||
}
|
||||
|
||||
public Filer getFiler() {
|
||||
return filer;
|
||||
}
|
||||
|
||||
public Collection<TypeDeclaration> getSpecifiedTypeDeclarations() {
|
||||
return spectypedecls;
|
||||
}
|
||||
|
||||
public PackageDeclaration getPackage(String name) {
|
||||
return declMaker.getPackageDeclaration(name);
|
||||
}
|
||||
|
||||
public TypeDeclaration getTypeDeclaration(String name) {
|
||||
return declMaker.getTypeDeclaration(name);
|
||||
}
|
||||
|
||||
public Collection<TypeDeclaration> getTypeDeclarations() {
|
||||
return typedecls;
|
||||
}
|
||||
|
||||
public Collection<Declaration> getDeclarationsAnnotatedWith(
|
||||
AnnotationTypeDeclaration a) {
|
||||
/*
|
||||
* create collection of Declarations annotated with a given
|
||||
* annotation.
|
||||
*/
|
||||
|
||||
CollectingAP proc = new CollectingAP(this, a);
|
||||
proc.process();
|
||||
return proc.decls;
|
||||
}
|
||||
|
||||
private static class CollectingAP implements AnnotationProcessor {
|
||||
AnnotationProcessorEnvironment env;
|
||||
Collection<Declaration> decls;
|
||||
AnnotationTypeDeclaration atd;
|
||||
CollectingAP(AnnotationProcessorEnvironment env,
|
||||
AnnotationTypeDeclaration atd) {
|
||||
this.env = env;
|
||||
this.atd = atd;
|
||||
decls = new HashSet<Declaration>();
|
||||
}
|
||||
|
||||
private class CollectingVisitor extends SimpleDeclarationVisitor {
|
||||
public void visitDeclaration(Declaration d) {
|
||||
for(AnnotationMirror am: d.getAnnotationMirrors()) {
|
||||
if (am.getAnnotationType().getDeclaration().equals(CollectingAP.this.atd))
|
||||
CollectingAP.this.decls.add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void process() {
|
||||
for(TypeDeclaration d: env.getSpecifiedTypeDeclarations())
|
||||
d.accept(getSourceOrderDeclarationScanner(new CollectingVisitor(),
|
||||
NO_OP));
|
||||
}
|
||||
}
|
||||
|
||||
public Declarations getDeclarationUtils() {
|
||||
return declUtils;
|
||||
}
|
||||
|
||||
public Types getTypeUtils() {
|
||||
return typeUtils;
|
||||
}
|
||||
|
||||
public void addListener(AnnotationProcessorListener listener) {
|
||||
if (listener == null)
|
||||
throw new NullPointerException();
|
||||
else {
|
||||
if (listener instanceof RoundCompleteListener)
|
||||
roundCompleteListeners.add((RoundCompleteListener)listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeListener(AnnotationProcessorListener listener) {
|
||||
if (listener == null)
|
||||
throw new NullPointerException();
|
||||
else
|
||||
roundCompleteListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void roundComplete() {
|
||||
RoundState roundState = new RoundStateImpl(bark.nerrors > 0,
|
||||
filer.getSourceFileNames().size() > 0,
|
||||
filer.getClassFileNames().size() > 0,
|
||||
origOptions);
|
||||
RoundCompleteEvent roundCompleteEvent = new RoundCompleteEventImpl(this, roundState);
|
||||
|
||||
filer.roundOver();
|
||||
for(RoundCompleteListener rcl: roundCompleteListeners)
|
||||
rcl.roundComplete(roundCompleteEvent);
|
||||
}
|
||||
}
|
@ -1,354 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.apt;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sun.mirror.apt.Filer;
|
||||
import com.sun.tools.apt.mirror.declaration.DeclarationMaker;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.Options;
|
||||
import com.sun.tools.javac.util.Position;
|
||||
import com.sun.tools.apt.util.Bark;
|
||||
|
||||
import static com.sun.mirror.apt.Filer.Location.*;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of Filer.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class FilerImpl implements Filer {
|
||||
/*
|
||||
* The Filer class must maintain a number of constraints. First,
|
||||
* multiple attempts to open the same path within the same
|
||||
* invocation of apt results in an IOException being thrown. For
|
||||
* example, trying to open the same source file twice:
|
||||
*
|
||||
* createSourceFile("foo.Bar")
|
||||
* ...
|
||||
* createSourceFile("foo.Bar")
|
||||
*
|
||||
* is disallowed as is opening a text file that happens to have
|
||||
* the same name as a source file:
|
||||
*
|
||||
* createSourceFile("foo.Bar")
|
||||
* ...
|
||||
* createTextFile(SOURCE_TREE, "foo", new File("Bar"), null)
|
||||
*
|
||||
* Additionally, creating a source file that corresponds to an
|
||||
* already created class file (or vice versa) generates at least a
|
||||
* warning. This is an error if -XclassesAsDecls is being used
|
||||
* since you can't create the same type twice. However, if the
|
||||
* Filer is used to create a text file named *.java that happens
|
||||
* to correspond to an existing class file, a warning is *not*
|
||||
* generated. Similarly, a warning is not generated for a binary
|
||||
* file named *.class and an existing source file.
|
||||
*
|
||||
* The reason for this difference is that source files and class
|
||||
* files are registered with apt and can get passed on as
|
||||
* declarations to the next round of processing. Files that are
|
||||
* just named *.java and *.class are not processed in that manner;
|
||||
* although having extra source files and class files on the
|
||||
* source path and class path can alter the behavior of the tool
|
||||
* and any final compile.
|
||||
*/
|
||||
|
||||
private enum FileKind {
|
||||
SOURCE {
|
||||
void register(File file, String name, FilerImpl that) throws IOException {
|
||||
// Check for corresponding class file
|
||||
if (that.filesCreated.contains(new File(that.locations.get(CLASS_TREE),
|
||||
that.nameToPath(name, ".class")))) {
|
||||
|
||||
that.bark.aptWarning("CorrespondingClassFile", name);
|
||||
if (that.opts.get("-XclassesAsDecls") != null)
|
||||
throw new IOException();
|
||||
}
|
||||
that.sourceFileNames.add(file.getPath());
|
||||
}
|
||||
},
|
||||
|
||||
CLASS {
|
||||
void register(File file, String name, FilerImpl that) throws IOException {
|
||||
if (that.filesCreated.contains(new File(that.locations.get(SOURCE_TREE),
|
||||
that.nameToPath(name, ".java")))) {
|
||||
that.bark.aptWarning("CorrespondingSourceFile", name);
|
||||
if (that.opts.get("-XclassesAsDecls") != null)
|
||||
throw new IOException();
|
||||
}
|
||||
// Track the binary name instead of the filesystem location
|
||||
that.classFileNames.add(name);
|
||||
}
|
||||
},
|
||||
|
||||
OTHER {
|
||||
// Nothing special to do
|
||||
void register(File file, String name, FilerImpl that) throws IOException {}
|
||||
};
|
||||
|
||||
abstract void register(File file, String name, FilerImpl that) throws IOException;
|
||||
}
|
||||
|
||||
private final Options opts;
|
||||
private final DeclarationMaker declMaker;
|
||||
private final com.sun.tools.apt.main.AptJavaCompiler comp;
|
||||
|
||||
// Platform's default encoding
|
||||
private final static String DEFAULT_ENCODING =
|
||||
new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding();
|
||||
|
||||
private String encoding; // name of charset used for source files
|
||||
|
||||
private final EnumMap<Location, File> locations; // where new files go
|
||||
|
||||
|
||||
private static final Context.Key<FilerImpl> filerKey =
|
||||
new Context.Key<FilerImpl>();
|
||||
|
||||
// Set of files opened.
|
||||
private Collection<Flushable> wc;
|
||||
|
||||
private Bark bark;
|
||||
|
||||
// All created files.
|
||||
private final Set<File> filesCreated;
|
||||
|
||||
// Names of newly created source files
|
||||
private HashSet<String> sourceFileNames = new HashSet<String>();
|
||||
|
||||
// Names of newly created class files
|
||||
private HashSet<String> classFileNames = new HashSet<String>();
|
||||
|
||||
private boolean roundOver;
|
||||
|
||||
public static FilerImpl instance(Context context) {
|
||||
FilerImpl instance = context.get(filerKey);
|
||||
if (instance == null) {
|
||||
instance = new FilerImpl(context);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
// flush all output streams;
|
||||
public void flush() {
|
||||
for(Flushable opendedFile: wc) {
|
||||
try {
|
||||
opendedFile.flush();
|
||||
if (opendedFile instanceof FileOutputStream) {
|
||||
try {
|
||||
((FileOutputStream) opendedFile).getFD().sync() ;
|
||||
} catch (java.io.SyncFailedException sfe) {}
|
||||
}
|
||||
} catch (IOException e) { }
|
||||
}
|
||||
}
|
||||
|
||||
private FilerImpl(Context context) {
|
||||
context.put(filerKey, this);
|
||||
opts = Options.instance(context);
|
||||
declMaker = DeclarationMaker.instance(context);
|
||||
bark = Bark.instance(context);
|
||||
comp = com.sun.tools.apt.main.AptJavaCompiler.instance(context);
|
||||
roundOver = false;
|
||||
this.filesCreated = comp.getAggregateGenFiles();
|
||||
|
||||
// Encoding
|
||||
encoding = opts.get("-encoding");
|
||||
if (encoding == null) {
|
||||
encoding = DEFAULT_ENCODING;
|
||||
}
|
||||
|
||||
wc = new HashSet<Flushable>();
|
||||
|
||||
// Locations
|
||||
locations = new EnumMap<Location, File>(Location.class);
|
||||
String s = opts.get("-s"); // location for new source files
|
||||
String d = opts.get("-d"); // location for new class files
|
||||
locations.put(SOURCE_TREE, new File(s != null ? s : "."));
|
||||
locations.put(CLASS_TREE, new File(d != null ? d : "."));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public PrintWriter createSourceFile(String name) throws IOException {
|
||||
String pathname = nameToPath(name, ".java");
|
||||
File file = new File(locations.get(SOURCE_TREE),
|
||||
pathname);
|
||||
PrintWriter pw = getPrintWriter(file, encoding, name, FileKind.SOURCE);
|
||||
return pw;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public OutputStream createClassFile(String name) throws IOException {
|
||||
String pathname = nameToPath(name, ".class");
|
||||
File file = new File(locations.get(CLASS_TREE),
|
||||
pathname);
|
||||
OutputStream os = getOutputStream(file, name, FileKind.CLASS);
|
||||
return os;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public PrintWriter createTextFile(Location loc,
|
||||
String pkg,
|
||||
File relPath,
|
||||
String charsetName) throws IOException {
|
||||
File file = (pkg.length() == 0)
|
||||
? relPath
|
||||
: new File(nameToPath(pkg), relPath.getPath());
|
||||
if (charsetName == null) {
|
||||
charsetName = encoding;
|
||||
}
|
||||
return getPrintWriter(loc, file.getPath(), charsetName, null, FileKind.OTHER);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public OutputStream createBinaryFile(Location loc,
|
||||
String pkg,
|
||||
File relPath) throws IOException {
|
||||
File file = (pkg.length() == 0)
|
||||
? relPath
|
||||
: new File(nameToPath(pkg), relPath.getPath());
|
||||
return getOutputStream(loc, file.getPath(), null, FileKind.OTHER);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts the canonical name of a top-level type or package to a
|
||||
* pathname. Suffix is ".java" or ".class" or "".
|
||||
*/
|
||||
private String nameToPath(String name, String suffix) throws IOException {
|
||||
if (!DeclarationMaker.isJavaIdentifier(name.replace('.', '_'))) {
|
||||
bark.aptWarning("IllegalFileName", name);
|
||||
throw new IOException();
|
||||
}
|
||||
return name.replace('.', File.separatorChar) + suffix;
|
||||
}
|
||||
|
||||
private String nameToPath(String name) throws IOException {
|
||||
return nameToPath(name, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a writer for a text file given its location, its
|
||||
* pathname relative to that location, and its encoding.
|
||||
*/
|
||||
private PrintWriter getPrintWriter(Location loc, String pathname,
|
||||
String encoding, String name, FileKind kind) throws IOException {
|
||||
File file = new File(locations.get(loc), pathname);
|
||||
return getPrintWriter(file, encoding, name, kind);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a writer for a text file given its encoding.
|
||||
*/
|
||||
private PrintWriter getPrintWriter(File file,
|
||||
String encoding, String name, FileKind kind) throws IOException {
|
||||
prepareFile(file, name, kind);
|
||||
PrintWriter pw =
|
||||
new PrintWriter(
|
||||
new BufferedWriter(
|
||||
new OutputStreamWriter(new FileOutputStream(file),
|
||||
encoding)));
|
||||
wc.add(pw);
|
||||
return pw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an output stream for a binary file given its location
|
||||
* and its pathname relative to that location.
|
||||
*/
|
||||
private OutputStream getOutputStream(Location loc, String pathname, String name, FileKind kind)
|
||||
throws IOException {
|
||||
File file = new File(locations.get(loc), pathname);
|
||||
return getOutputStream(file, name, kind);
|
||||
}
|
||||
|
||||
private OutputStream getOutputStream(File file, String name, FileKind kind) throws IOException {
|
||||
prepareFile(file, name, kind);
|
||||
OutputStream os = new FileOutputStream(file);
|
||||
wc.add(os);
|
||||
return os;
|
||||
|
||||
}
|
||||
|
||||
public Set<String> getSourceFileNames() {
|
||||
return sourceFileNames;
|
||||
}
|
||||
|
||||
public Set<String> getClassFileNames() {
|
||||
return classFileNames;
|
||||
}
|
||||
|
||||
public void roundOver() {
|
||||
roundOver = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the file has not already been created during this
|
||||
* invocation. If not, creates intermediate directories, and
|
||||
* deletes the file if it already exists.
|
||||
*/
|
||||
private void prepareFile(File file, String name, FileKind kind) throws IOException {
|
||||
if (roundOver) {
|
||||
bark.aptWarning("NoNewFilesAfterRound", file.toString());
|
||||
throw new IOException();
|
||||
}
|
||||
|
||||
if (filesCreated.contains(file)) {
|
||||
bark.aptWarning("FileReopening", file.toString());
|
||||
throw new IOException();
|
||||
} else {
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
} else {
|
||||
File parent = file.getParentFile();
|
||||
if (parent != null && !parent.exists()) {
|
||||
if(!parent.mkdirs()) {
|
||||
bark.aptWarning("BadParentDirectory", file.toString());
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kind.register(file, name, this);
|
||||
filesCreated.add(file);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.apt;
|
||||
|
||||
import javax.tools.JavaFileObject;
|
||||
import com.sun.mirror.apt.Messager;
|
||||
import com.sun.tools.apt.mirror.util.SourcePositionImpl;
|
||||
import com.sun.mirror.util.SourcePosition;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.Name;
|
||||
import com.sun.tools.javac.util.Position;
|
||||
import com.sun.tools.apt.util.Bark;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of Messager.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MessagerImpl implements Messager {
|
||||
private final Bark bark;
|
||||
|
||||
private static final Context.Key<MessagerImpl> messagerKey =
|
||||
new Context.Key<MessagerImpl>();
|
||||
|
||||
public static MessagerImpl instance(Context context) {
|
||||
MessagerImpl instance = context.get(messagerKey);
|
||||
if (instance == null) {
|
||||
instance = new MessagerImpl(context);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private MessagerImpl(Context context) {
|
||||
context.put(messagerKey, this);
|
||||
bark = Bark.instance(context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void printError(String msg) {
|
||||
bark.aptError("Messager", msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void printError(SourcePosition pos, String msg) {
|
||||
if (pos instanceof SourcePositionImpl) {
|
||||
SourcePositionImpl posImpl = (SourcePositionImpl) pos;
|
||||
JavaFileObject prev = bark.useSource(posImpl.getSource());
|
||||
bark.aptError(posImpl.getJavacPosition(), "Messager", msg);
|
||||
bark.useSource(prev);
|
||||
} else
|
||||
printError(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void printWarning(String msg) {
|
||||
bark.aptWarning("Messager", msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void printWarning(SourcePosition pos, String msg) {
|
||||
if (pos instanceof SourcePositionImpl) {
|
||||
SourcePositionImpl posImpl = (SourcePositionImpl) pos;
|
||||
JavaFileObject prev = bark.useSource(posImpl.getSource());
|
||||
bark.aptWarning(posImpl.getJavacPosition(), "Messager", msg);
|
||||
bark.useSource(prev);
|
||||
} else
|
||||
printWarning(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void printNotice(String msg) {
|
||||
bark.aptNote("Messager", msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void printNotice(SourcePosition pos, String msg) {
|
||||
if (pos instanceof SourcePositionImpl) {
|
||||
SourcePositionImpl posImpl = (SourcePositionImpl) pos;
|
||||
JavaFileObject prev = bark.useSource(posImpl.getSource());
|
||||
bark.aptNote(posImpl.getJavacPosition(), "Messager", msg);
|
||||
bark.useSource(prev);
|
||||
} else
|
||||
printNotice(msg);
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2009, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.apt;
|
||||
|
||||
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
|
||||
import com.sun.mirror.apt.RoundCompleteEvent;
|
||||
import com.sun.mirror.apt.RoundState;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class RoundCompleteEventImpl extends RoundCompleteEvent {
|
||||
private static final long serialVersionUID = 7067621446720784300L;
|
||||
|
||||
public RoundCompleteEventImpl(AnnotationProcessorEnvironment source,
|
||||
RoundState rs) {
|
||||
super(source, rs);
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.apt;
|
||||
|
||||
import com.sun.mirror.apt.RoundState;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class RoundStateImpl implements RoundState {
|
||||
private final boolean finalRound;
|
||||
private final boolean errorRaised;
|
||||
private final boolean sourceFilesCreated;
|
||||
private final boolean classFilesCreated;
|
||||
|
||||
public RoundStateImpl(boolean errorRaised,
|
||||
boolean sourceFilesCreated,
|
||||
boolean classFilesCreated,
|
||||
Map<String,String> options) {
|
||||
/*
|
||||
* In the default mode of operation, this round is the final
|
||||
* round if an error was raised OR there were no new source
|
||||
* files generated. If classes are being treated as
|
||||
* declarations, this is the final round if an error was
|
||||
* raised OR neither new source files nor new class files were
|
||||
* generated.
|
||||
*/
|
||||
this.finalRound =
|
||||
errorRaised ||
|
||||
(!sourceFilesCreated &&
|
||||
!(classFilesCreated && options.keySet().contains("-XclassesAsDecls")) );
|
||||
this.errorRaised = errorRaised;
|
||||
this.sourceFilesCreated = sourceFilesCreated;
|
||||
this.classFilesCreated = classFilesCreated;
|
||||
}
|
||||
|
||||
public boolean finalRound() {
|
||||
return finalRound;
|
||||
}
|
||||
|
||||
public boolean errorRaised() {
|
||||
return errorRaised;
|
||||
}
|
||||
|
||||
public boolean sourceFilesCreated() {
|
||||
return sourceFilesCreated;
|
||||
}
|
||||
|
||||
public boolean classFilesCreated() {
|
||||
return classFilesCreated;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return
|
||||
"[final round: " + finalRound +
|
||||
", error raised: " + errorRaised +
|
||||
", source files created: " + sourceFilesCreated +
|
||||
", class files created: " + classFilesCreated + "]";
|
||||
}
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.AnnotationType;
|
||||
import com.sun.mirror.util.SourcePosition;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.Attribute;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
import com.sun.tools.javac.util.Name;
|
||||
import com.sun.tools.javac.util.Pair;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of AnnotationMirror
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AnnotationMirrorImpl implements AnnotationMirror {
|
||||
|
||||
protected final AptEnv env;
|
||||
protected final Attribute.Compound anno;
|
||||
protected final Declaration decl;
|
||||
|
||||
|
||||
AnnotationMirrorImpl(AptEnv env, Attribute.Compound anno, Declaration decl) {
|
||||
this.env = env;
|
||||
this.anno = anno;
|
||||
this.decl = decl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a string representation of this annotation.
|
||||
* String is of one of the forms:
|
||||
* @com.example.foo(name1=val1, name2=val2)
|
||||
* @com.example.foo(val)
|
||||
* @com.example.foo
|
||||
* Omit parens for marker annotations, and omit "value=" when allowed.
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("@");
|
||||
Constants.Formatter fmtr = Constants.getFormatter(sb);
|
||||
|
||||
fmtr.append(anno.type.tsym);
|
||||
|
||||
int len = anno.values.length();
|
||||
if (len > 0) { // omit parens for marker annotations
|
||||
sb.append('(');
|
||||
boolean first = true;
|
||||
for (Pair<MethodSymbol, Attribute> val : anno.values) {
|
||||
if (!first) {
|
||||
sb.append(", ");
|
||||
}
|
||||
first = false;
|
||||
|
||||
Name name = val.fst.name;
|
||||
if (len > 1 || name != env.names.value) {
|
||||
fmtr.append(name);
|
||||
sb.append('=');
|
||||
}
|
||||
sb.append(new AnnotationValueImpl(env, val.snd, this));
|
||||
}
|
||||
sb.append(')');
|
||||
}
|
||||
return fmtr.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public AnnotationType getAnnotationType() {
|
||||
return (AnnotationType) env.typeMaker.getType(anno.type);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Map<AnnotationTypeElementDeclaration, AnnotationValue>
|
||||
getElementValues() {
|
||||
Map<AnnotationTypeElementDeclaration, AnnotationValue> res =
|
||||
new LinkedHashMap<AnnotationTypeElementDeclaration,
|
||||
AnnotationValue>(); // whew!
|
||||
for (Pair<MethodSymbol, Attribute> val : anno.values) {
|
||||
res.put(getElement(val.fst),
|
||||
new AnnotationValueImpl(env, val.snd, this));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public SourcePosition getPosition() {
|
||||
// Return position of the declaration on which this annotation
|
||||
// appears.
|
||||
return (decl == null) ? null : decl.getPosition();
|
||||
|
||||
}
|
||||
|
||||
public Declaration getDeclaration() {
|
||||
return this.decl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the annotation type element for a symbol.
|
||||
*/
|
||||
private AnnotationTypeElementDeclaration getElement(MethodSymbol m) {
|
||||
return (AnnotationTypeElementDeclaration)
|
||||
env.declMaker.getExecutableDeclaration(m);
|
||||
}
|
||||
}
|
@ -1,355 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import sun.reflect.annotation.*;
|
||||
|
||||
import com.sun.mirror.type.TypeMirror;
|
||||
import com.sun.mirror.type.MirroredTypeException;
|
||||
import com.sun.mirror.type.MirroredTypesException;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
import com.sun.tools.javac.util.Name;
|
||||
import com.sun.tools.javac.util.Pair;
|
||||
|
||||
|
||||
/**
|
||||
* A generator of dynamic proxy implementations of
|
||||
* java.lang.annotation.Annotation.
|
||||
*
|
||||
* <p> The "dynamic proxy return form" of an attribute element value is
|
||||
* the form used by sun.reflect.annotation.AnnotationInvocationHandler.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class AnnotationProxyMaker {
|
||||
|
||||
private final AptEnv env;
|
||||
private final Attribute.Compound attrs;
|
||||
private final Class<? extends Annotation> annoType;
|
||||
|
||||
|
||||
private AnnotationProxyMaker(AptEnv env,
|
||||
Attribute.Compound attrs,
|
||||
Class<? extends Annotation> annoType) {
|
||||
this.env = env;
|
||||
this.attrs = attrs;
|
||||
this.annoType = annoType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a dynamic proxy for an annotation mirror.
|
||||
*/
|
||||
public static <A extends Annotation> A generateAnnotation(
|
||||
AptEnv env, Attribute.Compound attrs, Class<A> annoType) {
|
||||
AnnotationProxyMaker apm = new AnnotationProxyMaker(env, attrs, annoType);
|
||||
return annoType.cast(apm.generateAnnotation());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a dynamic proxy for an annotation mirror.
|
||||
*/
|
||||
private Annotation generateAnnotation() {
|
||||
return AnnotationParser.annotationForMap(annoType,
|
||||
getAllReflectedValues());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map from element names to their values in "dynamic
|
||||
* proxy return form". Includes all elements, whether explicit or
|
||||
* defaulted.
|
||||
*/
|
||||
private Map<String, Object> getAllReflectedValues() {
|
||||
Map<String, Object> res = new LinkedHashMap<String, Object>();
|
||||
|
||||
for (Map.Entry<MethodSymbol, Attribute> entry :
|
||||
getAllValues().entrySet()) {
|
||||
MethodSymbol meth = entry.getKey();
|
||||
Object value = generateValue(meth, entry.getValue());
|
||||
if (value != null) {
|
||||
res.put(meth.name.toString(), value);
|
||||
} else {
|
||||
// Ignore this element. May lead to
|
||||
// IncompleteAnnotationException somewhere down the line.
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map from element symbols to their values.
|
||||
* Includes all elements, whether explicit or defaulted.
|
||||
*/
|
||||
private Map<MethodSymbol, Attribute> getAllValues() {
|
||||
Map<MethodSymbol, Attribute> res =
|
||||
new LinkedHashMap<MethodSymbol, Attribute>();
|
||||
|
||||
// First find the default values.
|
||||
ClassSymbol sym = (ClassSymbol) attrs.type.tsym;
|
||||
for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
|
||||
if (e.sym.kind == Kinds.MTH) {
|
||||
MethodSymbol m = (MethodSymbol) e.sym;
|
||||
Attribute def = m.defaultValue;
|
||||
if (def != null) {
|
||||
res.put(m, def);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Next find the explicit values, possibly overriding defaults.
|
||||
for (Pair<MethodSymbol, Attribute> p : attrs.values) {
|
||||
res.put(p.fst, p.snd);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an element value to its "dynamic proxy return form".
|
||||
* Returns an exception proxy on some errors, but may return null if
|
||||
* a useful exception cannot or should not be generated at this point.
|
||||
*/
|
||||
private Object generateValue(MethodSymbol meth, Attribute attr) {
|
||||
ValueVisitor vv = new ValueVisitor(meth);
|
||||
return vv.getValue(attr);
|
||||
}
|
||||
|
||||
|
||||
private class ValueVisitor implements Attribute.Visitor {
|
||||
|
||||
private MethodSymbol meth; // annotation element being visited
|
||||
private Class<?> runtimeType; // runtime type of annotation element
|
||||
private Object value; // value in "dynamic proxy return form"
|
||||
|
||||
ValueVisitor(MethodSymbol meth) {
|
||||
this.meth = meth;
|
||||
}
|
||||
|
||||
Object getValue(Attribute attr) {
|
||||
Method method; // runtime method of annotation element
|
||||
try {
|
||||
method = annoType.getMethod(meth.name.toString());
|
||||
} catch (NoSuchMethodException e) {
|
||||
return null;
|
||||
}
|
||||
runtimeType = method.getReturnType();
|
||||
attr.accept(this);
|
||||
if (!(value instanceof ExceptionProxy) &&
|
||||
!AnnotationType.invocationHandlerReturnType(runtimeType)
|
||||
.isInstance(value)) {
|
||||
typeMismatch(method, attr);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public void visitConstant(Attribute.Constant c) {
|
||||
value = Constants.decodeConstant(c.value, c.type);
|
||||
}
|
||||
|
||||
public void visitClass(Attribute.Class c) {
|
||||
value = new MirroredTypeExceptionProxy(
|
||||
env.typeMaker.getType(c.type));
|
||||
}
|
||||
|
||||
public void visitArray(Attribute.Array a) {
|
||||
Type elemtype = env.jctypes.elemtype(a.type);
|
||||
|
||||
if (elemtype.tsym == env.symtab.classType.tsym) { // Class[]
|
||||
// Construct a proxy for a MirroredTypesException
|
||||
ArrayList<TypeMirror> elems = new ArrayList<TypeMirror>();
|
||||
for (int i = 0; i < a.values.length; i++) {
|
||||
Type elem = ((Attribute.Class) a.values[i]).type;
|
||||
elems.add(env.typeMaker.getType(elem));
|
||||
}
|
||||
value = new MirroredTypesExceptionProxy(elems);
|
||||
|
||||
} else {
|
||||
int len = a.values.length;
|
||||
Class<?> runtimeTypeSaved = runtimeType;
|
||||
runtimeType = runtimeType.getComponentType();
|
||||
try {
|
||||
Object res = Array.newInstance(runtimeType, len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
a.values[i].accept(this);
|
||||
if (value == null || value instanceof ExceptionProxy) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Array.set(res, i, value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
value = null; // indicates a type mismatch
|
||||
return;
|
||||
}
|
||||
}
|
||||
value = res;
|
||||
} finally {
|
||||
runtimeType = runtimeTypeSaved;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public void visitEnum(Attribute.Enum e) {
|
||||
if (runtimeType.isEnum()) {
|
||||
String constName = e.value.toString();
|
||||
try {
|
||||
value = Enum.valueOf((Class)runtimeType, constName);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
value = new EnumConstantNotPresentExceptionProxy(
|
||||
(Class<Enum<?>>)runtimeType, constName);
|
||||
}
|
||||
} else {
|
||||
value = null; // indicates a type mismatch
|
||||
}
|
||||
}
|
||||
|
||||
public void visitCompound(Attribute.Compound c) {
|
||||
try {
|
||||
Class<? extends Annotation> nested =
|
||||
runtimeType.asSubclass(Annotation.class);
|
||||
value = generateAnnotation(env, c, nested);
|
||||
} catch (ClassCastException ex) {
|
||||
value = null; // indicates a type mismatch
|
||||
}
|
||||
}
|
||||
|
||||
public void visitError(Attribute.Error e) {
|
||||
value = null; // indicates a type mismatch
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets "value" to an ExceptionProxy indicating a type mismatch.
|
||||
*/
|
||||
private void typeMismatch(Method method, final Attribute attr) {
|
||||
class AnnotationTypeMismatchExceptionProxy extends ExceptionProxy {
|
||||
private static final long serialVersionUID = 8473323277815075163L;
|
||||
transient final Method method;
|
||||
AnnotationTypeMismatchExceptionProxy(Method method) {
|
||||
this.method = method;
|
||||
}
|
||||
public String toString() {
|
||||
return "<error>"; // eg: @Anno(value=<error>)
|
||||
}
|
||||
protected RuntimeException generateException() {
|
||||
return new AnnotationTypeMismatchException(method,
|
||||
attr.type.toString());
|
||||
}
|
||||
}
|
||||
value = new AnnotationTypeMismatchExceptionProxy(method);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ExceptionProxy for MirroredTypeException.
|
||||
* The toString, hashCode, and equals methods foward to the underlying
|
||||
* type.
|
||||
*/
|
||||
private static final class MirroredTypeExceptionProxy extends ExceptionProxy {
|
||||
private static final long serialVersionUID = 6662035281599933545L;
|
||||
|
||||
private MirroredTypeException ex;
|
||||
|
||||
MirroredTypeExceptionProxy(TypeMirror t) {
|
||||
// It would be safer if we could construct the exception in
|
||||
// generateException(), but there would be no way to do
|
||||
// that properly following deserialization.
|
||||
ex = new MirroredTypeException(t);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return ex.getQualifiedName();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
TypeMirror t = ex.getTypeMirror();
|
||||
return (t != null)
|
||||
? t.hashCode()
|
||||
: ex.getQualifiedName().hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
TypeMirror t = ex.getTypeMirror();
|
||||
return t != null &&
|
||||
obj instanceof MirroredTypeExceptionProxy &&
|
||||
t.equals(
|
||||
((MirroredTypeExceptionProxy) obj).ex.getTypeMirror());
|
||||
}
|
||||
|
||||
protected RuntimeException generateException() {
|
||||
return (RuntimeException) ex.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ExceptionProxy for MirroredTypesException.
|
||||
* The toString, hashCode, and equals methods foward to the underlying
|
||||
* types.
|
||||
*/
|
||||
private static final class MirroredTypesExceptionProxy extends ExceptionProxy {
|
||||
private static final long serialVersionUID = -6670822532616693951L;
|
||||
|
||||
private MirroredTypesException ex;
|
||||
|
||||
MirroredTypesExceptionProxy(Collection<TypeMirror> ts) {
|
||||
// It would be safer if we could construct the exception in
|
||||
// generateException(), but there would be no way to do
|
||||
// that properly following deserialization.
|
||||
ex = new MirroredTypesException(ts);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return ex.getQualifiedNames().toString();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
Collection<TypeMirror> ts = ex.getTypeMirrors();
|
||||
return (ts != null)
|
||||
? ts.hashCode()
|
||||
: ex.getQualifiedNames().hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
Collection<TypeMirror> ts = ex.getTypeMirrors();
|
||||
return ts != null &&
|
||||
obj instanceof MirroredTypesExceptionProxy &&
|
||||
ts.equals(
|
||||
((MirroredTypesExceptionProxy) obj).ex.getTypeMirrors());
|
||||
}
|
||||
|
||||
protected RuntimeException generateException() {
|
||||
return (RuntimeException) ex.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.util.DeclarationVisitor;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of AnnotationTypeDeclaration
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AnnotationTypeDeclarationImpl extends InterfaceDeclarationImpl
|
||||
implements AnnotationTypeDeclaration
|
||||
{
|
||||
AnnotationTypeDeclarationImpl(AptEnv env, ClassSymbol sym) {
|
||||
super(env, sym);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<AnnotationTypeElementDeclaration> getMethods() {
|
||||
return identityFilter.filter(super.getMethods(),
|
||||
AnnotationTypeElementDeclaration.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void accept(DeclarationVisitor v) {
|
||||
v.visitAnnotationTypeDeclaration(this);
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.util.DeclarationVisitor;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.Symbol.MethodSymbol;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of AnnotationTypeElementDeclaration
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AnnotationTypeElementDeclarationImpl extends MethodDeclarationImpl
|
||||
implements AnnotationTypeElementDeclaration {
|
||||
|
||||
AnnotationTypeElementDeclarationImpl(AptEnv env, MethodSymbol sym) {
|
||||
super(env, sym);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public AnnotationTypeDeclaration getDeclaringType() {
|
||||
return (AnnotationTypeDeclaration) super.getDeclaringType();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public AnnotationValue getDefaultValue() {
|
||||
return (sym.defaultValue == null)
|
||||
? null
|
||||
: new AnnotationValueImpl(env, sym.defaultValue, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void accept(DeclarationVisitor v) {
|
||||
v.visitAnnotationTypeElementDeclaration(this);
|
||||
}
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.util.SourcePosition;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.Attribute;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
import com.sun.tools.javac.code.TypeTags;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of AnnotationValue
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AnnotationValueImpl implements AnnotationValue {
|
||||
|
||||
protected final AptEnv env;
|
||||
protected final Attribute attr;
|
||||
protected final AnnotationMirrorImpl annotation;
|
||||
|
||||
AnnotationValueImpl(AptEnv env, Attribute attr, AnnotationMirrorImpl annotation) {
|
||||
this.env = env;
|
||||
this.attr = attr;
|
||||
this.annotation = annotation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Constants.Formatter fmtr = Constants.getFormatter(sb);
|
||||
|
||||
fmtr.append(getValue());
|
||||
return fmtr.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Object getValue() {
|
||||
ValueVisitor vv = new ValueVisitor();
|
||||
attr.accept(vv);
|
||||
return vv.value;
|
||||
}
|
||||
|
||||
|
||||
public SourcePosition getPosition() {
|
||||
// Imprecise implementation; just return position of enclosing
|
||||
// annotation.
|
||||
return (annotation == null) ? null : annotation.getPosition();
|
||||
}
|
||||
|
||||
private class ValueVisitor implements Attribute.Visitor {
|
||||
|
||||
public Object value;
|
||||
|
||||
public void visitConstant(Attribute.Constant c) {
|
||||
value = Constants.decodeConstant(c.value, c.type);
|
||||
}
|
||||
|
||||
public void visitClass(Attribute.Class c) {
|
||||
value = env.typeMaker.getType(
|
||||
env.jctypes.erasure(c.type));
|
||||
}
|
||||
|
||||
public void visitEnum(Attribute.Enum e) {
|
||||
value = env.declMaker.getFieldDeclaration(e.value);
|
||||
}
|
||||
|
||||
public void visitCompound(Attribute.Compound c) {
|
||||
value = new AnnotationMirrorImpl(env, c,
|
||||
(annotation == null) ?
|
||||
null :
|
||||
annotation.getDeclaration());
|
||||
}
|
||||
|
||||
public void visitArray(Attribute.Array a) {
|
||||
ArrayList<AnnotationValue> vals =
|
||||
new ArrayList<AnnotationValue>(a.values.length);
|
||||
for (Attribute elem : a.values) {
|
||||
vals.add(new AnnotationValueImpl(env, elem, annotation));
|
||||
}
|
||||
value = vals;
|
||||
}
|
||||
|
||||
public void visitError(Attribute.Error e) {
|
||||
value = "<error>"; // javac will already have logged an error msg
|
||||
}
|
||||
}
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.ClassType;
|
||||
import com.sun.mirror.util.DeclarationVisitor;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of ClassDeclaration
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ClassDeclarationImpl extends TypeDeclarationImpl
|
||||
implements ClassDeclaration {
|
||||
|
||||
ClassDeclarationImpl(AptEnv env, ClassSymbol sym) {
|
||||
super(env, sym);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Overridden here to handle @Inherited.
|
||||
*/
|
||||
public <A extends Annotation> A getAnnotation(Class<A> annoType) {
|
||||
|
||||
boolean inherited = annoType.isAnnotationPresent(Inherited.class);
|
||||
for (Type t = sym.type;
|
||||
t.tsym != env.symtab.objectType.tsym && !t.isErroneous();
|
||||
t = env.jctypes.supertype(t)) {
|
||||
|
||||
A result = getAnnotation(annoType, t.tsym);
|
||||
if (result != null || !inherited) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public ClassType getSuperclass() {
|
||||
// java.lang.Object has no superclass
|
||||
if (sym == env.symtab.objectType.tsym) {
|
||||
return null;
|
||||
}
|
||||
Type t = env.jctypes.supertype(sym.type);
|
||||
return (ClassType) env.typeMaker.getType(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<ConstructorDeclaration> getConstructors() {
|
||||
ArrayList<ConstructorDeclaration> res =
|
||||
new ArrayList<ConstructorDeclaration>();
|
||||
for (Symbol s : getMembers(true)) {
|
||||
if (s.isConstructor()) {
|
||||
MethodSymbol m = (MethodSymbol) s;
|
||||
res.add((ConstructorDeclaration)
|
||||
env.declMaker.getExecutableDeclaration(m));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<MethodDeclaration> getMethods() {
|
||||
return identityFilter.filter(super.getMethods(),
|
||||
MethodDeclaration.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void accept(DeclarationVisitor v) {
|
||||
v.visitClassDeclaration(this);
|
||||
}
|
||||
}
|
@ -1,294 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.TypeMirror;
|
||||
import com.sun.tools.apt.mirror.type.TypeMirrorImpl;
|
||||
import com.sun.tools.javac.code.Type;
|
||||
|
||||
import static com.sun.tools.javac.code.TypeTags.*;
|
||||
|
||||
|
||||
/**
|
||||
* Utility class for operating on constant expressions.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class Constants {
|
||||
|
||||
/**
|
||||
* Converts a constant in javac's internal representation (in which
|
||||
* boolean, char, byte, short, and int are each represented by an Integer)
|
||||
* into standard representation. Other values (including null) are
|
||||
* returned unchanged.
|
||||
*/
|
||||
static Object decodeConstant(Object value, Type type) {
|
||||
if (value instanceof Integer) {
|
||||
int i = ((Integer) value).intValue();
|
||||
switch (type.tag) {
|
||||
case BOOLEAN: return Boolean.valueOf(i != 0);
|
||||
case CHAR: return Character.valueOf((char) i);
|
||||
case BYTE: return Byte.valueOf((byte) i);
|
||||
case SHORT: return Short.valueOf((short) i);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatter for generating the text of constant
|
||||
* expressions. Equivalent to
|
||||
* <tt>getFormatter(new StringBuilder())</tt>.
|
||||
*/
|
||||
static Formatter getFormatter() {
|
||||
return new Formatter(new StringBuilder());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatter for generating the text of constant
|
||||
* expressions. Also generates the text of constant
|
||||
* "pseudo-expressions" for annotations and array-valued
|
||||
* annotation elements.
|
||||
*
|
||||
* @param buf where the expression is written
|
||||
*/
|
||||
static Formatter getFormatter(StringBuilder buf) {
|
||||
return new Formatter(buf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Utility class used to generate the text of constant
|
||||
* expressions. Also generates the text of constant
|
||||
* "pseudo-expressions" for annotations and array-valued
|
||||
* annotation elements.
|
||||
*/
|
||||
static class Formatter {
|
||||
|
||||
private StringBuilder buf; // where the output goes
|
||||
|
||||
private Formatter(StringBuilder buf) {
|
||||
this.buf = buf;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a constant whose type is not statically known
|
||||
* by dispatching to the appropriate overloaded append method.
|
||||
*/
|
||||
void append(Object val) {
|
||||
if (val instanceof String) {
|
||||
append((String) val);
|
||||
} else if (val instanceof Character) {
|
||||
append((Character) val);
|
||||
} else if (val instanceof Boolean) {
|
||||
append((Boolean) val);
|
||||
} else if (val instanceof Byte) {
|
||||
append((Byte) val);
|
||||
} else if (val instanceof Short) {
|
||||
append((Short) val);
|
||||
} else if (val instanceof Integer) {
|
||||
append((Integer) val);
|
||||
} else if (val instanceof Long) {
|
||||
append((Long) val);
|
||||
} else if (val instanceof Float) {
|
||||
append((Float) val);
|
||||
} else if (val instanceof Double) {
|
||||
append((Double) val);
|
||||
} else if (val instanceof TypeMirror) {
|
||||
append((TypeMirrorImpl) val);
|
||||
} else if (val instanceof EnumConstantDeclaration) {
|
||||
append((EnumConstantDeclarationImpl) val);
|
||||
} else if (val instanceof AnnotationMirror) {
|
||||
append((AnnotationMirrorImpl) val);
|
||||
} else if (val instanceof Collection<?>) {
|
||||
append((Collection<?>) val);
|
||||
} else {
|
||||
appendUnquoted(val.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a string, escaped (as needed) and quoted.
|
||||
*/
|
||||
void append(String val) {
|
||||
buf.append('"');
|
||||
appendUnquoted(val);
|
||||
buf.append('"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a Character, escaped (as needed) and quoted.
|
||||
*/
|
||||
void append(Character val) {
|
||||
buf.append('\'');
|
||||
appendUnquoted(val.charValue());
|
||||
buf.append('\'');
|
||||
}
|
||||
|
||||
void append(Boolean val) {
|
||||
buf.append(val);
|
||||
}
|
||||
|
||||
void append(Byte val) {
|
||||
buf.append(String.format("0x%02x", val));
|
||||
}
|
||||
|
||||
void append(Short val) {
|
||||
buf.append(val);
|
||||
}
|
||||
|
||||
void append(Integer val) {
|
||||
buf.append(val);
|
||||
}
|
||||
|
||||
void append(Long val) {
|
||||
buf.append(val).append('L');
|
||||
}
|
||||
|
||||
void append(Float val) {
|
||||
if (val.isNaN()) {
|
||||
buf.append("0.0f/0.0f");
|
||||
} else if (val.isInfinite()) {
|
||||
if (val.floatValue() < 0) {
|
||||
buf.append('-');
|
||||
}
|
||||
buf.append("1.0f/0.0f");
|
||||
} else {
|
||||
buf.append(val).append('f');
|
||||
}
|
||||
}
|
||||
|
||||
void append(Double val) {
|
||||
if (val.isNaN()) {
|
||||
buf.append("0.0/0.0");
|
||||
} else if (val.isInfinite()) {
|
||||
if (val.doubleValue() < 0) {
|
||||
buf.append('-');
|
||||
}
|
||||
buf.append("1.0/0.0");
|
||||
} else {
|
||||
buf.append(val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the class literal corresponding to a type. Should
|
||||
* only be invoked for types that have an associated literal.
|
||||
* e.g: "java.lang.String.class"
|
||||
* "boolean.class"
|
||||
* "int[].class"
|
||||
*/
|
||||
void append(TypeMirrorImpl t) {
|
||||
appendUnquoted(t.type.toString());
|
||||
buf.append(".class");
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the fully qualified name of an enum constant.
|
||||
* e.g: "java.math.RoundingMode.UP"
|
||||
*/
|
||||
void append(EnumConstantDeclarationImpl e) {
|
||||
appendUnquoted(e.sym.enclClass() + "." + e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the text of an annotation pseudo-expression.
|
||||
* e.g: "@pkg.Format(linesep='\n')"
|
||||
*/
|
||||
void append(AnnotationMirrorImpl anno) {
|
||||
appendUnquoted(anno.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the elements of a collection, enclosed within braces
|
||||
* and separated by ", ". Useful for array-valued annotation
|
||||
* elements.
|
||||
*/
|
||||
void append(Collection<?> vals) {
|
||||
buf.append('{');
|
||||
boolean first = true;
|
||||
for (Object val : vals) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
buf.append(", ");
|
||||
}
|
||||
append(((AnnotationValue) val).getValue());
|
||||
}
|
||||
buf.append('}');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For each char of a string, append using appendUnquoted(char).
|
||||
*/
|
||||
private void appendUnquoted(String s) {
|
||||
for (char c : s.toCharArray()) {
|
||||
appendUnquoted(c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a char (unquoted), using escapes for those that are not
|
||||
* printable ASCII. We don't know what is actually printable in
|
||||
* the locale in which this result will be used, so ASCII is our
|
||||
* best guess as to the least common denominator.
|
||||
*/
|
||||
private void appendUnquoted(char c) {
|
||||
switch (c) {
|
||||
case '\b': buf.append("\\b"); break;
|
||||
case '\t': buf.append("\\t"); break;
|
||||
case '\n': buf.append("\\n"); break;
|
||||
case '\f': buf.append("\\f"); break;
|
||||
case '\r': buf.append("\\r"); break;
|
||||
case '\"': buf.append("\\\""); break;
|
||||
case '\'': buf.append("\\\'"); break;
|
||||
case '\\': buf.append("\\\\"); break;
|
||||
default:
|
||||
if (isPrintableAscii(c)) {
|
||||
buf.append(c);
|
||||
} else {
|
||||
buf.append(String.format("\\u%04x", (int) c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is c a printable ASCII character?
|
||||
*/
|
||||
private static boolean isPrintableAscii(char c) {
|
||||
return c >= ' ' && c <= '~';
|
||||
}
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.util.DeclarationVisitor;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.Flags;
|
||||
import com.sun.tools.javac.code.Symbol.MethodSymbol;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of ConstructorDeclaration
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ConstructorDeclarationImpl extends ExecutableDeclarationImpl
|
||||
implements ConstructorDeclaration {
|
||||
|
||||
ConstructorDeclarationImpl(AptEnv env, MethodSymbol sym) {
|
||||
super(env, sym);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Returns the simple name of the declaring class.
|
||||
*/
|
||||
public String getSimpleName() {
|
||||
return sym.enclClass().name.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void accept(DeclarationVisitor v) {
|
||||
v.visitConstructorDeclaration(this);
|
||||
}
|
||||
}
|
@ -1,254 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.util.*;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.apt.mirror.util.SourcePositionImpl;
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
import com.sun.tools.javac.comp.AttrContext;
|
||||
import com.sun.tools.javac.comp.Env;
|
||||
import com.sun.tools.javac.tree.*;
|
||||
import com.sun.tools.javac.util.Name;
|
||||
import com.sun.tools.javac.util.Position;
|
||||
|
||||
import static com.sun.mirror.declaration.Modifier.*;
|
||||
import static com.sun.tools.javac.code.Kinds.*;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of Declaration
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class DeclarationImpl implements Declaration {
|
||||
|
||||
protected final AptEnv env;
|
||||
public final Symbol sym;
|
||||
|
||||
protected static final DeclarationFilter identityFilter =
|
||||
new DeclarationFilter();
|
||||
|
||||
|
||||
/**
|
||||
* "sym" should be completed before this constructor is called.
|
||||
*/
|
||||
protected DeclarationImpl(AptEnv env, Symbol sym) {
|
||||
this.env = env;
|
||||
this.sym = sym;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p> ParameterDeclarationImpl overrides this implementation.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof DeclarationImpl) {
|
||||
DeclarationImpl that = (DeclarationImpl) obj;
|
||||
return sym == that.sym && env == that.env;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p> ParameterDeclarationImpl overrides this implementation.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return sym.hashCode() + env.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getDocComment() {
|
||||
// Our doc comment is contained in a map in our toplevel,
|
||||
// indexed by our tree. Find our enter environment, which gives
|
||||
// us our toplevel. It also gives us a tree that contains our
|
||||
// tree: walk it to find our tree. This is painful.
|
||||
Env<AttrContext> enterEnv = getEnterEnv();
|
||||
if (enterEnv == null)
|
||||
return null;
|
||||
JCTree tree = TreeInfo.declarationFor(sym, enterEnv.tree);
|
||||
return enterEnv.toplevel.docComments.get(tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<AnnotationMirror> getAnnotationMirrors() {
|
||||
Collection<AnnotationMirror> res =
|
||||
new ArrayList<AnnotationMirror>();
|
||||
for (Attribute.Compound a : sym.getAnnotationMirrors()) {
|
||||
res.add(env.declMaker.getAnnotationMirror(a, this));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Overridden by ClassDeclarationImpl to handle @Inherited.
|
||||
*/
|
||||
public <A extends Annotation> A getAnnotation(Class<A> annoType) {
|
||||
return getAnnotation(annoType, sym);
|
||||
}
|
||||
|
||||
protected <A extends Annotation> A getAnnotation(Class<A> annoType,
|
||||
Symbol annotated) {
|
||||
if (!annoType.isAnnotation()) {
|
||||
throw new IllegalArgumentException(
|
||||
"Not an annotation type: " + annoType);
|
||||
}
|
||||
String name = annoType.getName();
|
||||
for (Attribute.Compound attr : annotated.getAnnotationMirrors()) {
|
||||
if (name.equals(attr.type.tsym.flatName().toString())) {
|
||||
return AnnotationProxyMaker.generateAnnotation(env, attr,
|
||||
annoType);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Cache for modifiers.
|
||||
private EnumSet<Modifier> modifiers = null;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<Modifier> getModifiers() {
|
||||
if (modifiers == null) {
|
||||
modifiers = EnumSet.noneOf(Modifier.class);
|
||||
long flags = AptEnv.getFlags(sym);
|
||||
|
||||
if (0 != (flags & Flags.PUBLIC)) modifiers.add(PUBLIC);
|
||||
if (0 != (flags & Flags.PROTECTED)) modifiers.add(PROTECTED);
|
||||
if (0 != (flags & Flags.PRIVATE)) modifiers.add(PRIVATE);
|
||||
if (0 != (flags & Flags.ABSTRACT)) modifiers.add(ABSTRACT);
|
||||
if (0 != (flags & Flags.STATIC)) modifiers.add(STATIC);
|
||||
if (0 != (flags & Flags.FINAL)) modifiers.add(FINAL);
|
||||
if (0 != (flags & Flags.TRANSIENT)) modifiers.add(TRANSIENT);
|
||||
if (0 != (flags & Flags.VOLATILE)) modifiers.add(VOLATILE);
|
||||
if (0 != (flags & Flags.SYNCHRONIZED)) modifiers.add(SYNCHRONIZED);
|
||||
if (0 != (flags & Flags.NATIVE)) modifiers.add(NATIVE);
|
||||
if (0 != (flags & Flags.STRICTFP)) modifiers.add(STRICTFP);
|
||||
}
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Overridden in some subclasses.
|
||||
*/
|
||||
public String getSimpleName() {
|
||||
return sym.name.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public SourcePosition getPosition() {
|
||||
// Find the toplevel. From there use a tree-walking utility
|
||||
// that finds the tree for our symbol, and with it the position.
|
||||
Env<AttrContext> enterEnv = getEnterEnv();
|
||||
if (enterEnv == null)
|
||||
return null;
|
||||
JCTree.JCCompilationUnit toplevel = enterEnv.toplevel;
|
||||
JavaFileObject sourcefile = toplevel.sourcefile;
|
||||
if (sourcefile == null)
|
||||
return null;
|
||||
int pos = TreeInfo.positionFor(sym, toplevel);
|
||||
|
||||
return new SourcePositionImpl(sourcefile, pos, toplevel.lineMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a visitor to this declaration.
|
||||
*
|
||||
* @param v the visitor operating on this declaration
|
||||
*/
|
||||
public void accept(DeclarationVisitor v) {
|
||||
v.visitDeclaration(this);
|
||||
}
|
||||
|
||||
|
||||
private Collection<Symbol> members = null; // cache for getMembers()
|
||||
|
||||
/**
|
||||
* Returns the symbols of type or package members (and constructors)
|
||||
* that are not synthetic or otherwise unwanted.
|
||||
* Caches the result if "cache" is true.
|
||||
*/
|
||||
protected Collection<Symbol> getMembers(boolean cache) {
|
||||
if (members != null) {
|
||||
return members;
|
||||
}
|
||||
LinkedList<Symbol> res = new LinkedList<Symbol>();
|
||||
for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
|
||||
if (e.sym != null && !unwanted(e.sym)) {
|
||||
res.addFirst(e.sym);
|
||||
}
|
||||
}
|
||||
return cache ? (members = res) : res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether this is a symbol that should never be seen by clients,
|
||||
* such as a synthetic class.
|
||||
* Note that a class synthesized by the compiler may not be flagged as
|
||||
* synthetic: see bugid 4959932.
|
||||
*/
|
||||
private static boolean unwanted(Symbol s) {
|
||||
return AptEnv.hasFlag(s, Flags.SYNTHETIC) ||
|
||||
(s.kind == TYP &&
|
||||
!DeclarationMaker.isJavaIdentifier(s.name.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this declaration's enter environment, or null if it
|
||||
* has none.
|
||||
*/
|
||||
private Env<AttrContext> getEnterEnv() {
|
||||
// Get enclosing class of sym, or sym itself if it is a class
|
||||
// or package.
|
||||
TypeSymbol ts = (sym.kind != PCK)
|
||||
? sym.enclClass()
|
||||
: (PackageSymbol) sym;
|
||||
return (ts != null)
|
||||
? env.enter.getEnv(ts)
|
||||
: null;
|
||||
}
|
||||
}
|
@ -1,270 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2006, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.Name;
|
||||
import com.sun.tools.javac.main.JavaCompiler;
|
||||
|
||||
/**
|
||||
* Utilities for constructing and caching declarations.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DeclarationMaker {
|
||||
|
||||
private AptEnv env;
|
||||
private Context context;
|
||||
private JavaCompiler javacompiler;
|
||||
private static final Context.Key<DeclarationMaker> declarationMakerKey =
|
||||
new Context.Key<DeclarationMaker>();
|
||||
|
||||
public static DeclarationMaker instance(Context context) {
|
||||
DeclarationMaker instance = context.get(declarationMakerKey);
|
||||
if (instance == null) {
|
||||
instance = new DeclarationMaker(context);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private DeclarationMaker(Context context) {
|
||||
context.put(declarationMakerKey, this);
|
||||
env = AptEnv.instance(context);
|
||||
this.context = context;
|
||||
this.javacompiler = JavaCompiler.instance(context);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Cache of package declarations
|
||||
private Map<PackageSymbol, PackageDeclaration> packageDecls =
|
||||
new HashMap<PackageSymbol, PackageDeclaration>();
|
||||
|
||||
/**
|
||||
* Returns the package declaration for a package symbol.
|
||||
*/
|
||||
public PackageDeclaration getPackageDeclaration(PackageSymbol p) {
|
||||
PackageDeclaration res = packageDecls.get(p);
|
||||
if (res == null) {
|
||||
res = new PackageDeclarationImpl(env, p);
|
||||
packageDecls.put(p, res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the package declaration for the package with the given name.
|
||||
* Name is fully-qualified, or "" for the unnamed package.
|
||||
* Returns null if package declaration not found.
|
||||
*/
|
||||
public PackageDeclaration getPackageDeclaration(String name) {
|
||||
PackageSymbol p = null;
|
||||
if (name.equals("") )
|
||||
p = env.symtab.unnamedPackage;
|
||||
else {
|
||||
if (!isJavaName(name))
|
||||
return null;
|
||||
Symbol s = nameToSymbol(name, false);
|
||||
if (s instanceof PackageSymbol) {
|
||||
p = (PackageSymbol) s;
|
||||
if (!p.exists())
|
||||
return null;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
return getPackageDeclaration(p);
|
||||
}
|
||||
|
||||
// Cache of type declarations
|
||||
private Map<ClassSymbol, TypeDeclaration> typeDecls =
|
||||
new HashMap<ClassSymbol, TypeDeclaration>();
|
||||
|
||||
/**
|
||||
* Returns the type declaration for a class symbol.
|
||||
* Forces completion, and returns null on error.
|
||||
*/
|
||||
public TypeDeclaration getTypeDeclaration(ClassSymbol c) {
|
||||
long flags = AptEnv.getFlags(c); // forces symbol completion
|
||||
if (c.kind == Kinds.ERR) {
|
||||
return null;
|
||||
}
|
||||
TypeDeclaration res = typeDecls.get(c);
|
||||
if (res == null) {
|
||||
if ((flags & Flags.ANNOTATION) != 0) {
|
||||
res = new AnnotationTypeDeclarationImpl(env, c);
|
||||
} else if ((flags & Flags.INTERFACE) != 0) {
|
||||
res = new InterfaceDeclarationImpl(env, c);
|
||||
} else if ((flags & Flags.ENUM) != 0) {
|
||||
res = new EnumDeclarationImpl(env, c);
|
||||
} else {
|
||||
res = new ClassDeclarationImpl(env, c);
|
||||
}
|
||||
typeDecls.put(c, res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type declaration for the type with the given canonical name.
|
||||
* Returns null if type declaration not found.
|
||||
*/
|
||||
public TypeDeclaration getTypeDeclaration(String name) {
|
||||
if (!isJavaName(name))
|
||||
return null;
|
||||
Symbol s = nameToSymbol(name, true);
|
||||
if (s instanceof ClassSymbol) {
|
||||
ClassSymbol c = (ClassSymbol) s;
|
||||
return getTypeDeclaration(c);
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a symbol given the type's or packages's canonical name,
|
||||
* or null if the name isn't found.
|
||||
*/
|
||||
private Symbol nameToSymbol(String name, boolean classCache) {
|
||||
Symbol s = null;
|
||||
Name nameName = env.names.fromString(name);
|
||||
if (classCache)
|
||||
s = env.symtab.classes.get(nameName);
|
||||
else
|
||||
s = env.symtab.packages.get(nameName);
|
||||
|
||||
if (s != null && s.exists())
|
||||
return s;
|
||||
|
||||
s = javacompiler.resolveIdent(name);
|
||||
if (s.kind == Kinds.ERR )
|
||||
return null;
|
||||
|
||||
if (s.kind == Kinds.PCK)
|
||||
s.complete();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// Cache of method and constructor declarations
|
||||
private Map<MethodSymbol, ExecutableDeclaration> executableDecls =
|
||||
new HashMap<MethodSymbol, ExecutableDeclaration>();
|
||||
|
||||
/**
|
||||
* Returns the method or constructor declaration for a method symbol.
|
||||
*/
|
||||
ExecutableDeclaration getExecutableDeclaration(MethodSymbol m) {
|
||||
ExecutableDeclaration res = executableDecls.get(m);
|
||||
if (res == null) {
|
||||
if (m.isConstructor()) {
|
||||
res = new ConstructorDeclarationImpl(env, m);
|
||||
} else if (isAnnotationTypeElement(m)) {
|
||||
res = new AnnotationTypeElementDeclarationImpl(env, m);
|
||||
} else {
|
||||
res = new MethodDeclarationImpl(env, m);
|
||||
}
|
||||
executableDecls.put(m, res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// Cache of field declarations
|
||||
private Map<VarSymbol, FieldDeclaration> fieldDecls =
|
||||
new HashMap<VarSymbol, FieldDeclaration>();
|
||||
|
||||
/**
|
||||
* Returns the field declaration for a var symbol.
|
||||
*/
|
||||
FieldDeclaration getFieldDeclaration(VarSymbol v) {
|
||||
FieldDeclaration res = fieldDecls.get(v);
|
||||
if (res == null) {
|
||||
if (hasFlag(v, Flags.ENUM)) {
|
||||
res = new EnumConstantDeclarationImpl(env, v);
|
||||
} else {
|
||||
res = new FieldDeclarationImpl(env, v);
|
||||
}
|
||||
fieldDecls.put(v, res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a parameter declaration.
|
||||
*/
|
||||
ParameterDeclaration getParameterDeclaration(VarSymbol v) {
|
||||
return new ParameterDeclarationImpl(env, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a type parameter declaration.
|
||||
*/
|
||||
public TypeParameterDeclaration getTypeParameterDeclaration(TypeSymbol t) {
|
||||
return new TypeParameterDeclarationImpl(env, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an annotation.
|
||||
*/
|
||||
AnnotationMirror getAnnotationMirror(Attribute.Compound a, Declaration decl) {
|
||||
return new AnnotationMirrorImpl(env, a, decl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is a string a valid Java identifier?
|
||||
*/
|
||||
public static boolean isJavaIdentifier(String id) {
|
||||
return javax.lang.model.SourceVersion.isIdentifier(id);
|
||||
}
|
||||
|
||||
public static boolean isJavaName(String name) {
|
||||
for(String id: name.split("\\.")) {
|
||||
if (! isJavaIdentifier(id))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a method an annotation type element?
|
||||
* It is if it's declared in an annotation type.
|
||||
*/
|
||||
private static boolean isAnnotationTypeElement(MethodSymbol m) {
|
||||
return hasFlag(m.enclClass(), Flags.ANNOTATION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a symbol have a given flag?
|
||||
*/
|
||||
private static boolean hasFlag(Symbol s, long flag) {
|
||||
return AptEnv.hasFlag(s, flag);
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.util.DeclarationVisitor;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.Symbol.VarSymbol;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of EnumConstantDeclaration
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class EnumConstantDeclarationImpl extends FieldDeclarationImpl
|
||||
implements EnumConstantDeclaration {
|
||||
|
||||
EnumConstantDeclarationImpl(AptEnv env, VarSymbol sym) {
|
||||
super(env, sym);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public EnumDeclaration getDeclaringType() {
|
||||
return (EnumDeclaration) super.getDeclaringType();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void accept(DeclarationVisitor v) {
|
||||
v.visitEnumConstantDeclaration(this);
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.util.*;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of EnumDeclaration
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class EnumDeclarationImpl extends ClassDeclarationImpl
|
||||
implements EnumDeclaration {
|
||||
|
||||
EnumDeclarationImpl(AptEnv env, ClassSymbol sym) {
|
||||
super(env, sym);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<EnumConstantDeclaration> getEnumConstants() {
|
||||
return identityFilter.filter(getFields(),
|
||||
EnumConstantDeclaration.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void accept(DeclarationVisitor v) {
|
||||
v.visitEnumDeclaration(this);
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.ReferenceType;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of ExecutableDeclaration
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class ExecutableDeclarationImpl extends MemberDeclarationImpl
|
||||
implements ExecutableDeclaration {
|
||||
public MethodSymbol sym;
|
||||
|
||||
protected ExecutableDeclarationImpl(AptEnv env, MethodSymbol sym) {
|
||||
super(env, sym);
|
||||
this.sym = sym;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns type parameters (if any), method name, and signature
|
||||
* (value parameter types).
|
||||
*/
|
||||
public String toString() {
|
||||
return sym.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isVarArgs() {
|
||||
return AptEnv.hasFlag(sym, Flags.VARARGS);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<ParameterDeclaration> getParameters() {
|
||||
Collection<ParameterDeclaration> res =
|
||||
new ArrayList<ParameterDeclaration>();
|
||||
for (VarSymbol param : sym.params())
|
||||
res.add(env.declMaker.getParameterDeclaration(param));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<ReferenceType> getThrownTypes() {
|
||||
ArrayList<ReferenceType> res = new ArrayList<ReferenceType>();
|
||||
for (Type t : sym.type.getThrownTypes()) {
|
||||
res.add((ReferenceType) env.typeMaker.getType(t));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.TypeMirror;
|
||||
import com.sun.mirror.util.DeclarationVisitor;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
import com.sun.tools.javac.code.TypeTags;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of FieldDeclaration
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class FieldDeclarationImpl extends MemberDeclarationImpl
|
||||
implements FieldDeclaration {
|
||||
|
||||
protected VarSymbol sym;
|
||||
|
||||
FieldDeclarationImpl(AptEnv env, VarSymbol sym) {
|
||||
super(env, sym);
|
||||
this.sym = sym;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the field's name.
|
||||
*/
|
||||
public String toString() {
|
||||
return getSimpleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public TypeMirror getType() {
|
||||
return env.typeMaker.getType(sym.type);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Object getConstantValue() {
|
||||
Object val = sym.getConstValue();
|
||||
// val may be null, indicating that this is not a constant.
|
||||
|
||||
return Constants.decodeConstant(val, sym.type);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getConstantExpression() {
|
||||
Object val = getConstantValue();
|
||||
if (val == null) {
|
||||
return null;
|
||||
}
|
||||
Constants.Formatter fmtr = Constants.getFormatter();
|
||||
fmtr.append(val);
|
||||
return fmtr.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void accept(DeclarationVisitor v) {
|
||||
v.visitFieldDeclaration(this);
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.util.DeclarationVisitor;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of InterfaceDeclaration
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class InterfaceDeclarationImpl extends TypeDeclarationImpl
|
||||
implements InterfaceDeclaration {
|
||||
|
||||
InterfaceDeclarationImpl(AptEnv env, ClassSymbol sym) {
|
||||
super(env, sym);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void accept(DeclarationVisitor v) {
|
||||
v.visitInterfaceDeclaration(this);
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.util.DeclarationVisitor;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.Symbol;
|
||||
import com.sun.tools.javac.code.Symbol.ClassSymbol;
|
||||
import com.sun.tools.javac.code.Type;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of MemberDeclaration
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class MemberDeclarationImpl extends DeclarationImpl
|
||||
implements MemberDeclaration {
|
||||
|
||||
protected MemberDeclarationImpl(AptEnv env, Symbol sym) {
|
||||
super(env, sym);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public TypeDeclaration getDeclaringType() {
|
||||
ClassSymbol c = getDeclaringClassSymbol();
|
||||
return (c == null)
|
||||
? null
|
||||
: env.declMaker.getTypeDeclaration(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* For methods, constructors, and types.
|
||||
*/
|
||||
public Collection<TypeParameterDeclaration> getFormalTypeParameters() {
|
||||
ArrayList<TypeParameterDeclaration> res =
|
||||
new ArrayList<TypeParameterDeclaration>();
|
||||
for (Type t : sym.type.getTypeArguments()) {
|
||||
res.add(env.declMaker.getTypeParameterDeclaration(t.tsym));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void accept(DeclarationVisitor v) {
|
||||
v.visitMemberDeclaration(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the ClassSymbol of the declaring type,
|
||||
* or null if this is a top-level type.
|
||||
*/
|
||||
private ClassSymbol getDeclaringClassSymbol() {
|
||||
return sym.owner.enclClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the formal type parameters of a type, member or constructor
|
||||
* as an angle-bracketed string. Each parameter consists of the simple
|
||||
* type variable name and any bounds (with no implicit "extends Object"
|
||||
* clause added). Type names are qualified.
|
||||
* Returns "" if there are no type parameters.
|
||||
*/
|
||||
protected static String typeParamsToString(AptEnv env, Symbol sym) {
|
||||
if (sym.type.getTypeArguments().isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (Type t : sym.type.getTypeArguments()) {
|
||||
Type.TypeVar tv = (Type.TypeVar) t;
|
||||
s.append(s.length() == 0 ? "<" : ", ")
|
||||
.append(TypeParameterDeclarationImpl.toString(env, tv));
|
||||
}
|
||||
s.append(">");
|
||||
return s.toString();
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.util.DeclarationVisitor;
|
||||
import com.sun.mirror.type.TypeMirror;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.Symbol.MethodSymbol;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of MethodDeclaration
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MethodDeclarationImpl extends ExecutableDeclarationImpl
|
||||
implements MethodDeclaration {
|
||||
|
||||
MethodDeclarationImpl(AptEnv env, MethodSymbol sym) {
|
||||
super(env, sym);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public TypeMirror getReturnType() {
|
||||
return env.typeMaker.getType(sym.type.getReturnType());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void accept(DeclarationVisitor v) {
|
||||
v.visitMethodDeclaration(this);
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2006, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.util.*;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of PackageDeclaration.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PackageDeclarationImpl extends DeclarationImpl
|
||||
implements PackageDeclaration {
|
||||
|
||||
private PackageSymbol sym;
|
||||
|
||||
|
||||
public PackageDeclarationImpl(AptEnv env, PackageSymbol sym) {
|
||||
super(env, sym);
|
||||
this.sym = sym;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the qualified name.
|
||||
*/
|
||||
public String toString() {
|
||||
return getQualifiedName();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getQualifiedName() {
|
||||
return sym.getQualifiedName().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<ClassDeclaration> getClasses() {
|
||||
return identityFilter.filter(getAllTypes(),
|
||||
ClassDeclaration.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<EnumDeclaration> getEnums() {
|
||||
return identityFilter.filter(getAllTypes(),
|
||||
EnumDeclaration.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<InterfaceDeclaration> getInterfaces() {
|
||||
return identityFilter.filter(getAllTypes(),
|
||||
InterfaceDeclaration.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<AnnotationTypeDeclaration> getAnnotationTypes() {
|
||||
return identityFilter.filter(getAllTypes(),
|
||||
AnnotationTypeDeclaration.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void accept(DeclarationVisitor v) {
|
||||
v.visitPackageDeclaration(this);
|
||||
}
|
||||
|
||||
|
||||
// Cache of all top-level type declarations in this package.
|
||||
private Collection<TypeDeclaration> allTypes = null;
|
||||
|
||||
/**
|
||||
* Caches and returns all top-level type declarations in this package.
|
||||
* Omits synthetic types.
|
||||
*/
|
||||
private Collection<TypeDeclaration> getAllTypes() {
|
||||
if (allTypes != null) {
|
||||
return allTypes;
|
||||
}
|
||||
allTypes = new ArrayList<TypeDeclaration>();
|
||||
for (Symbol s : getMembers(false)) {
|
||||
allTypes.add(env.declMaker.getTypeDeclaration((ClassSymbol) s));
|
||||
}
|
||||
return allTypes;
|
||||
}
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.TypeMirror;
|
||||
import com.sun.mirror.util.DeclarationVisitor;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.code.Symbol.VarSymbol;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of ParameterDeclaration
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ParameterDeclarationImpl extends DeclarationImpl
|
||||
implements ParameterDeclaration
|
||||
{
|
||||
protected VarSymbol sym;
|
||||
|
||||
|
||||
ParameterDeclarationImpl(AptEnv env, VarSymbol sym) {
|
||||
super(env, sym);
|
||||
this.sym = sym;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the simple name of the parameter.
|
||||
*/
|
||||
public String toString() {
|
||||
return getType() + " " + sym.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
// Neither ParameterDeclarationImpl objects nor their symbols
|
||||
// are cached by the current implementation, so check symbol
|
||||
// owners and names.
|
||||
|
||||
if (obj instanceof ParameterDeclarationImpl) {
|
||||
ParameterDeclarationImpl that = (ParameterDeclarationImpl) obj;
|
||||
return sym.owner == that.sym.owner &&
|
||||
sym.name == that.sym.name &&
|
||||
env == that.env;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public int hashCode() {
|
||||
return sym.owner.hashCode() + sym.name.hashCode() + env.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public TypeMirror getType() {
|
||||
return env.typeMaker.getType(sym.type);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void accept(DeclarationVisitor v) {
|
||||
v.visitParameterDeclaration(this);
|
||||
}
|
||||
}
|
@ -1,157 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.apt.mirror.declaration;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.DeclarationVisitor;
|
||||
import com.sun.tools.apt.mirror.AptEnv;
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.code.Symbol.*;
|
||||
import com.sun.tools.javac.util.Name;
|
||||
|
||||
/**
|
||||
* Implementation of TypeDeclaration
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class TypeDeclarationImpl extends MemberDeclarationImpl
|
||||
implements TypeDeclaration {
|
||||
|
||||
public ClassSymbol sym;
|
||||
|
||||
|
||||
/**
|
||||
* "sym" should be completed before this constructor is called.
|
||||
*/
|
||||
protected TypeDeclarationImpl(AptEnv env, ClassSymbol sym) {
|
||||
super(env, sym);
|
||||
this.sym = sym;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the type's name, with any type parameters (including those
|
||||
* of outer classes). Type names are qualified.
|
||||
*/
|
||||
public String toString() {
|
||||
return toString(env, sym);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public PackageDeclaration getPackage() {
|
||||
return env.declMaker.getPackageDeclaration(sym.packge());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getQualifiedName() {
|
||||
return sym.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<InterfaceType> getSuperinterfaces() {
|
||||
return env.typeMaker.getTypes(env.jctypes.interfaces(sym.type),
|
||||
InterfaceType.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<FieldDeclaration> getFields() {
|
||||
ArrayList<FieldDeclaration> res = new ArrayList<FieldDeclaration>();
|
||||
for (Symbol s : getMembers(true)) {
|
||||
if (s.kind == Kinds.VAR) {
|
||||
res.add(env.declMaker.getFieldDeclaration((VarSymbol) s));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<? extends MethodDeclaration> getMethods() {
|
||||
ArrayList<MethodDeclaration> res = new ArrayList<MethodDeclaration>();
|
||||
for (Symbol s : getMembers(true)) {
|
||||
if (s.kind == Kinds.MTH && !s.isConstructor() &&
|
||||
!env.names.clinit.equals(s.name) ) { // screen out static initializers
|
||||
MethodSymbol m = (MethodSymbol) s;
|
||||
res.add((MethodDeclaration)
|
||||
env.declMaker.getExecutableDeclaration(m));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection<TypeDeclaration> getNestedTypes() {
|
||||
ArrayList<TypeDeclaration> res = new ArrayList<TypeDeclaration>();
|
||||
for (Symbol s : getMembers(true)) {
|
||||
if (s.kind == Kinds.TYP) {
|
||||
res.add(env.declMaker.getTypeDeclaration((ClassSymbol) s));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void accept(DeclarationVisitor v) {
|
||||
v.visitTypeDeclaration(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a type's name, with any type parameters (including those
|
||||
* of outer classes). Type names are qualified.
|
||||
*/
|
||||
static String toString(AptEnv env, ClassSymbol c) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (c.isInner()) {
|
||||
// c is an inner class, so include type params of outer.
|
||||
ClassSymbol enclosing = c.owner.enclClass();
|
||||
sb.append(toString(env, enclosing))
|
||||
.append('.')
|
||||
.append(c.name);
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
sb.append(typeParamsToString(env, c));
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user