Initial Commit, version 0.1
This commit is contained in:
commit
5512bf181a
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
*/target/
|
54
apt-mirror-api/pom.xml
Executable file
54
apt-mirror-api/pom.xml
Executable file
@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
~ Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
~
|
||||||
|
~ This program is free software: you can redistribute it and/or modify
|
||||||
|
~ it under the terms of the GNU General Public License as published y
|
||||||
|
~ the Free Software Foundation, either version 3 of the License, or
|
||||||
|
~ (at your option) any later version.
|
||||||
|
~
|
||||||
|
~ This program 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 for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU General Public License
|
||||||
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<groupId>com.moparisthebest.aptIn16</groupId>
|
||||||
|
<artifactId>aptIn16</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>apt-mirror-api</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<name>apt-mirror-api</name>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>default-tools.jar</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>java.vendor</name>
|
||||||
|
<value>Sun Microsystems Inc.</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun</groupId>
|
||||||
|
<artifactId>tools</artifactId>
|
||||||
|
<version>1.6</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${java.home}/../lib/tools.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
</project>
|
71
apt-mirror-api/src/main/java/com/sun/mirror/apt/AnnotationProcessor.java
Executable file
71
apt-mirror-api/src/main/java/com/sun/mirror/apt/AnnotationProcessor.java
Executable file
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* @(#)AnnotationProcessor.java 1.2 04/02/10
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.2 04/02/10
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface AnnotationProcessor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process all program elements supported by this annotation processor.
|
||||||
|
*/
|
||||||
|
void process();
|
||||||
|
}
|
@ -0,0 +1,183 @@
|
|||||||
|
/*
|
||||||
|
* @(#)AnnotationProcessorEnvironment.java 1.7 04/07/19
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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/>
|
||||||
|
* <p> {@link DeclarationFilter}
|
||||||
|
* provides a simple way to select just the items of interest
|
||||||
|
* when a method returns a collection of declarations.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.7 04/07/19
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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);
|
||||||
|
}
|
110
apt-mirror-api/src/main/java/com/sun/mirror/apt/AnnotationProcessorFactory.java
Executable file
110
apt-mirror-api/src/main/java/com/sun/mirror/apt/AnnotationProcessorFactory.java
Executable file
@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* @(#)AnnotationProcessorFactory.java 1.9 04/07/13
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <p> Each implementation of an <tt>AnnotationProcessorFactory</tt>
|
||||||
|
* must provide a public no-argument constructor to be used by tools to
|
||||||
|
* instantiate the factory.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.9 04/07/13
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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);
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* @(#)AnnotationProcessorListener.java 1.1 04/06/25
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.apt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Superinterface for all annotation processor event listeners.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/06/25
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
public interface AnnotationProcessorListener extends java.util.EventListener {
|
||||||
|
}
|
132
apt-mirror-api/src/main/java/com/sun/mirror/apt/AnnotationProcessors.java
Executable file
132
apt-mirror-api/src/main/java/com/sun/mirror/apt/AnnotationProcessors.java
Executable file
@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* @(#)AnnotationProcessors.java 1.2 04/06/21
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.apt;
|
||||||
|
|
||||||
|
import com.sun.mirror.apt.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilities to create specialized annotation processors.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
161
apt-mirror-api/src/main/java/com/sun/mirror/apt/Filer.java
Executable file
161
apt-mirror-api/src/main/java/com/sun/mirror/apt/Filer.java
Executable file
@ -0,0 +1,161 @@
|
|||||||
|
/*
|
||||||
|
* @(#)Filer.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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/>
|
||||||
|
* <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.
|
||||||
|
*/
|
||||||
|
enum Location {
|
||||||
|
/**
|
||||||
|
* The location of new source files.
|
||||||
|
*/
|
||||||
|
SOURCE_TREE,
|
||||||
|
/**
|
||||||
|
* The location of new class files.
|
||||||
|
*/
|
||||||
|
CLASS_TREE
|
||||||
|
}
|
||||||
|
}
|
101
apt-mirror-api/src/main/java/com/sun/mirror/apt/Messager.java
Executable file
101
apt-mirror-api/src/main/java/com/sun/mirror/apt/Messager.java
Executable file
@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* @(#)Messager.java 1.2 04/07/27
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.2 04/07/27
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
75
apt-mirror-api/src/main/java/com/sun/mirror/apt/RoundCompleteEvent.java
Executable file
75
apt-mirror-api/src/main/java/com/sun/mirror/apt/RoundCompleteEvent.java
Executable file
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* @(#)RoundCompleteEvent.java 1.2 04/07/19
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.apt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event for the completion of a round of annotation processing.
|
||||||
|
* <p/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.2 04/07/19
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
49
apt-mirror-api/src/main/java/com/sun/mirror/apt/RoundCompleteListener.java
Executable file
49
apt-mirror-api/src/main/java/com/sun/mirror/apt/RoundCompleteListener.java
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* @(#)RoundCompleteListener.java 1.1 04/06/25
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.apt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener for the completion of a round of annotation processing.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/06/25
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
66
apt-mirror-api/src/main/java/com/sun/mirror/apt/RoundState.java
Executable file
66
apt-mirror-api/src/main/java/com/sun/mirror/apt/RoundState.java
Executable file
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* @(#)RoundState.java 1.1 04/06/25
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.apt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the status of a completed round of annotation processing.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/06/25
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
}
|
46
apt-mirror-api/src/main/java/com/sun/mirror/apt/package.html
Executable file
46
apt-mirror-api/src/main/java/com/sun/mirror/apt/package.html
Executable file
@ -0,0 +1,46 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!--
|
||||||
|
@(#)package.html 1.3 04/07/26
|
||||||
|
Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
its contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
-->
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body bgcolor="white">
|
||||||
|
|
||||||
|
Classes used to communicate information between
|
||||||
|
{@linkplain com.sun.mirror.apt.AnnotationProcessor annotation processors}
|
||||||
|
and an annotation processing tool.
|
||||||
|
|
||||||
|
<p>Note that the <code>apt</code> tool and its associated APIs may be
|
||||||
|
changed or superseded in future j2se releases.
|
||||||
|
|
||||||
|
@since 1.5
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* @(#)AnnotationMirror.java 1.5 04/07/16
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.5 04/07/16
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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();
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* @(#)AnnotationTypeDeclaration.java 1.2 04/04/20
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.declaration;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the declaration of an annotation type.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.2 04/04/20
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* @(#)AnnotationTypeElementDeclaration.java 1.3 04/04/20
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.declaration;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an element of an annotation type.
|
||||||
|
*
|
||||||
|
* @author Joe Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.3 04/04/20
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
83
apt-mirror-api/src/main/java/com/sun/mirror/declaration/AnnotationValue.java
Executable file
83
apt-mirror-api/src/main/java/com/sun/mirror/declaration/AnnotationValue.java
Executable file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* @(#)AnnotationValue.java 1.6 04/07/19
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.declaration;
|
||||||
|
|
||||||
|
import com.sun.mirror.util.SourcePosition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a value of an annotation type element.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.6 04/07/19
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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();
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* @(#)ClassDeclaration.java 1.3 04/02/20
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.3 04/02/20
|
||||||
|
* @see ClassType
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* @(#)ConstructorDeclaration.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.declaration;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a constructor of a class or interface.
|
||||||
|
*
|
||||||
|
* @author Joe Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface ConstructorDeclaration extends ExecutableDeclaration {
|
||||||
|
}
|
168
apt-mirror-api/src/main/java/com/sun/mirror/declaration/Declaration.java
Executable file
168
apt-mirror-api/src/main/java/com/sun/mirror/declaration/Declaration.java
Executable file
@ -0,0 +1,168 @@
|
|||||||
|
/*
|
||||||
|
* @(#)Declaration.java 1.6 04/07/16
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.6 04/07/16
|
||||||
|
* @see Declarations
|
||||||
|
* @see TypeMirror
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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}.
|
||||||
|
* <p/>
|
||||||
|
* <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/>
|
||||||
|
* <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);
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* @(#)EnumConstantDeclaration.java 1.2 04/03/09
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.declaration;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an enum constant declaration.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.2 04/03/09
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface EnumConstantDeclaration extends FieldDeclaration {
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
EnumDeclaration getDeclaringType();
|
||||||
|
}
|
56
apt-mirror-api/src/main/java/com/sun/mirror/declaration/EnumDeclaration.java
Executable file
56
apt-mirror-api/src/main/java/com/sun/mirror/declaration/EnumDeclaration.java
Executable file
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* @(#)EnumDeclaration.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.declaration;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the declaration of an enum type.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* @(#)ExecutableDeclaration.java 1.2 04/03/08
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.2 04/03/08
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* @(#)FieldDeclaration.java 1.2 04/04/20
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.declaration;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sun.mirror.type.TypeMirror;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a field of a type declaration.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.2 04/04/20
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* @(#)InterfaceDeclaration.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @see InterfaceType
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface InterfaceDeclaration extends TypeDeclaration {
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* @(#)MemberDeclaration.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* @(#)MethodDeclaration.java 1.2 04/04/20
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.2 04/04/20
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
101
apt-mirror-api/src/main/java/com/sun/mirror/declaration/Modifier.java
Executable file
101
apt-mirror-api/src/main/java/com/sun/mirror/declaration/Modifier.java
Executable file
@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* @(#)Modifier.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.declaration;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a modifier on the declaration of a program element such
|
||||||
|
* as a class, method, or field.
|
||||||
|
* <p/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/25
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* @(#)PackageDeclaration.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* @(#)ParameterDeclaration.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.declaration;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sun.mirror.type.TypeMirror;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a formal parameter of a method or constructor.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface ParameterDeclaration extends Declaration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the type of this parameter.
|
||||||
|
*
|
||||||
|
* @return the type of this parameter
|
||||||
|
*/
|
||||||
|
TypeMirror getType();
|
||||||
|
}
|
142
apt-mirror-api/src/main/java/com/sun/mirror/declaration/TypeDeclaration.java
Executable file
142
apt-mirror-api/src/main/java/com/sun/mirror/declaration/TypeDeclaration.java
Executable file
@ -0,0 +1,142 @@
|
|||||||
|
/*
|
||||||
|
* @(#)TypeDeclaration.java 1.4 04/04/30
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.4 04/04/30
|
||||||
|
* @see DeclaredType
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* @(#)TypeParameterDeclaration.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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}.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
48
apt-mirror-api/src/main/java/com/sun/mirror/declaration/package.html
Executable file
48
apt-mirror-api/src/main/java/com/sun/mirror/declaration/package.html
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!--
|
||||||
|
@(#)package.html 1.3 04/07/26
|
||||||
|
Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
its contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
-->
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body bgcolor="white">
|
||||||
|
|
||||||
|
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>Note that the <code>apt</code> tool and its associated APIs may be
|
||||||
|
changed or superseded in future j2se releases.
|
||||||
|
|
||||||
|
@since 1.5
|
||||||
|
</body>
|
||||||
|
</html>
|
117
apt-mirror-api/src/main/java/com/sun/mirror/overview.html
Executable file
117
apt-mirror-api/src/main/java/com/sun/mirror/overview.html
Executable file
@ -0,0 +1,117 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!--
|
||||||
|
@(#)overview.html 1.1 04/07/19
|
||||||
|
|
||||||
|
Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
its contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
-->
|
||||||
|
</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>
|
53
apt-mirror-api/src/main/java/com/sun/mirror/type/AnnotationType.java
Executable file
53
apt-mirror-api/src/main/java/com/sun/mirror/type/AnnotationType.java
Executable file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* @(#)AnnotationType.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.type;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an annotation type.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface AnnotationType extends InterfaceType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
AnnotationTypeDeclaration getDeclaration();
|
||||||
|
}
|
54
apt-mirror-api/src/main/java/com/sun/mirror/type/ArrayType.java
Executable file
54
apt-mirror-api/src/main/java/com/sun/mirror/type/ArrayType.java
Executable file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* @(#)ArrayType.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface ArrayType extends ReferenceType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the component type of this array type.
|
||||||
|
*
|
||||||
|
* @return the component type of this array type
|
||||||
|
*/
|
||||||
|
TypeMirror getComponentType();
|
||||||
|
}
|
75
apt-mirror-api/src/main/java/com/sun/mirror/type/ClassType.java
Executable file
75
apt-mirror-api/src/main/java/com/sun/mirror/type/ClassType.java
Executable file
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* @(#)ClassType.java 1.2 04/04/30
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.2 04/04/30
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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();
|
||||||
|
}
|
112
apt-mirror-api/src/main/java/com/sun/mirror/type/DeclaredType.java
Executable file
112
apt-mirror-api/src/main/java/com/sun/mirror/type/DeclaredType.java
Executable file
@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* @(#)DeclaredType.java 1.6 04/06/07
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.6 04/06/07
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface DeclaredType extends ReferenceType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the declaration of this type.
|
||||||
|
* <p/>
|
||||||
|
* <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/>
|
||||||
|
* <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/>
|
||||||
|
* <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();
|
||||||
|
}
|
53
apt-mirror-api/src/main/java/com/sun/mirror/type/EnumType.java
Executable file
53
apt-mirror-api/src/main/java/com/sun/mirror/type/EnumType.java
Executable file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* @(#)EnumType.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.type;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.EnumDeclaration;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an enum type.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface EnumType extends ClassType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
EnumDeclaration getDeclaration();
|
||||||
|
}
|
60
apt-mirror-api/src/main/java/com/sun/mirror/type/InterfaceType.java
Executable file
60
apt-mirror-api/src/main/java/com/sun/mirror/type/InterfaceType.java
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* @(#)InterfaceType.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface InterfaceType extends DeclaredType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
InterfaceDeclaration getDeclaration();
|
||||||
|
}
|
87
apt-mirror-api/src/main/java/com/sun/mirror/type/MirroredTypeException.java
Executable file
87
apt-mirror-api/src/main/java/com/sun/mirror/type/MirroredTypeException.java
Executable file
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* @(#)MirroredTypeException.java 1.1 04/04/20
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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}.
|
||||||
|
*
|
||||||
|
* @see MirroredTypesException
|
||||||
|
* @see Declaration#getAnnotation(Class)
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
97
apt-mirror-api/src/main/java/com/sun/mirror/type/MirroredTypesException.java
Executable file
97
apt-mirror-api/src/main/java/com/sun/mirror/type/MirroredTypesException.java
Executable file
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* @(#)MirroredTypesException.java 1.1 04/04/20
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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}.
|
||||||
|
*
|
||||||
|
* @see MirroredTypeException
|
||||||
|
* @see Declaration#getAnnotation(Class)
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
public MirroredTypesException(Collection<TypeMirror> types) {
|
||||||
|
super("Attempt to access Class objects for TypeMirrors " + types);
|
||||||
|
this.types = types;
|
||||||
|
names = new ArrayList();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
84
apt-mirror-api/src/main/java/com/sun/mirror/type/PrimitiveType.java
Executable file
84
apt-mirror-api/src/main/java/com/sun/mirror/type/PrimitiveType.java
Executable file
@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* @(#)PrimitiveType.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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>.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
46
apt-mirror-api/src/main/java/com/sun/mirror/type/ReferenceType.java
Executable file
46
apt-mirror-api/src/main/java/com/sun/mirror/type/ReferenceType.java
Executable file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* @(#)ReferenceType.java 1.2 04/06/07
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.type;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a reference type.
|
||||||
|
* These include class and interface types, array types, and type variables.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.2 04/06/07
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface ReferenceType extends TypeMirror {
|
||||||
|
}
|
85
apt-mirror-api/src/main/java/com/sun/mirror/type/TypeMirror.java
Executable file
85
apt-mirror-api/src/main/java/com/sun/mirror/type/TypeMirror.java
Executable file
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* @(#)TypeMirror.java 1.3 04/07/16
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.3 04/07/16
|
||||||
|
* @see Declaration
|
||||||
|
* @see Types
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
58
apt-mirror-api/src/main/java/com/sun/mirror/type/TypeVariable.java
Executable file
58
apt-mirror-api/src/main/java/com/sun/mirror/type/TypeVariable.java
Executable file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* @(#)TypeVariable.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @author Joe Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
49
apt-mirror-api/src/main/java/com/sun/mirror/type/VoidType.java
Executable file
49
apt-mirror-api/src/main/java/com/sun/mirror/type/VoidType.java
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* @(#)VoidType.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @see MethodDeclaration#getReturnType()
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface VoidType extends TypeMirror {
|
||||||
|
}
|
75
apt-mirror-api/src/main/java/com/sun/mirror/type/WildcardType.java
Executable file
75
apt-mirror-api/src/main/java/com/sun/mirror/type/WildcardType.java
Executable file
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* @(#)WildcardType.java 1.5 04/06/07
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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).
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.5 04/06/07
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
46
apt-mirror-api/src/main/java/com/sun/mirror/type/package.html
Executable file
46
apt-mirror-api/src/main/java/com/sun/mirror/type/package.html
Executable file
@ -0,0 +1,46 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!--
|
||||||
|
@(#)package.html 1.3 04/07/26
|
||||||
|
Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
its contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
-->
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body bgcolor="white">
|
||||||
|
|
||||||
|
Interfaces used to model types.
|
||||||
|
A type is represented by the appropriate subinterface of
|
||||||
|
{@link com.sun.mirror.type.TypeMirror}.
|
||||||
|
|
||||||
|
<p>Note that the <code>apt</code> tool and its associated APIs may be
|
||||||
|
changed or superseded in future j2se releases.
|
||||||
|
|
||||||
|
@since 1.5
|
||||||
|
</body>
|
||||||
|
</html>
|
317
apt-mirror-api/src/main/java/com/sun/mirror/util/DeclarationFilter.java
Executable file
317
apt-mirror-api/src/main/java/com/sun/mirror/util/DeclarationFilter.java
Executable file
@ -0,0 +1,317 @@
|
|||||||
|
/*
|
||||||
|
* @(#)DeclarationFilter.java 1.2 04/07/19
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <p> A subclass can create an arbitrary filter simply by implementing
|
||||||
|
* the {@link #matches(Declaration)} method.
|
||||||
|
* <p/>
|
||||||
|
* <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>
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.2 04/07/19
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
268
apt-mirror-api/src/main/java/com/sun/mirror/util/DeclarationScanner.java
Executable file
268
apt-mirror-api/src/main/java/com/sun/mirror/util/DeclarationScanner.java
Executable file
@ -0,0 +1,268 @@
|
|||||||
|
/*
|
||||||
|
* @(#)DeclarationScanner.java 1.5 04/04/20
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.5 04/04/20
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
166
apt-mirror-api/src/main/java/com/sun/mirror/util/DeclarationVisitor.java
Executable file
166
apt-mirror-api/src/main/java/com/sun/mirror/util/DeclarationVisitor.java
Executable file
@ -0,0 +1,166 @@
|
|||||||
|
/*
|
||||||
|
* @(#)DeclarationVisitor.java 1.3 04/04/20
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.3 04/04/20
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
103
apt-mirror-api/src/main/java/com/sun/mirror/util/DeclarationVisitors.java
Executable file
103
apt-mirror-api/src/main/java/com/sun/mirror/util/DeclarationVisitors.java
Executable file
@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* @(#)DeclarationVisitors.java 1.4 04/07/13
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilities to create specialized <tt>DeclarationVisitor</tt> instances.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.4 04/07/13
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
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/>
|
||||||
|
* <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/>
|
||||||
|
* <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);
|
||||||
|
}
|
||||||
|
}
|
70
apt-mirror-api/src/main/java/com/sun/mirror/util/Declarations.java
Executable file
70
apt-mirror-api/src/main/java/com/sun/mirror/util/Declarations.java
Executable file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* @(#)Declarations.java 1.1 04/01/26
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.util;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility methods for operating on declarations.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.1 04/01/26
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
234
apt-mirror-api/src/main/java/com/sun/mirror/util/SimpleDeclarationVisitor.java
Executable file
234
apt-mirror-api/src/main/java/com/sun/mirror/util/SimpleDeclarationVisitor.java
Executable file
@ -0,0 +1,234 @@
|
|||||||
|
/*
|
||||||
|
* @(#)SimpleDeclarationVisitor.java 1.3 04/04/30
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.util;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple visitor for declarations.
|
||||||
|
* <p/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.3 04/04/30
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
189
apt-mirror-api/src/main/java/com/sun/mirror/util/SimpleTypeVisitor.java
Executable file
189
apt-mirror-api/src/main/java/com/sun/mirror/util/SimpleTypeVisitor.java
Executable file
@ -0,0 +1,189 @@
|
|||||||
|
/*
|
||||||
|
* @(#)SimpleTypeVisitor.java 1.4 04/06/07
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.util;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sun.mirror.type.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple visitor for types.
|
||||||
|
* <p/>
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.4 04/06/07
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
277
apt-mirror-api/src/main/java/com/sun/mirror/util/SourceOrderDeclScanner.java
Executable file
277
apt-mirror-api/src/main/java/com/sun/mirror/util/SourceOrderDeclScanner.java
Executable file
@ -0,0 +1,277 @@
|
|||||||
|
/*
|
||||||
|
* @(#)SourceOrderDeclScanner.java 1.5 04/09/16
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.
|
||||||
|
* <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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.5 04/09/16
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int compareEqualPosition(Declaration d1, Declaration d2) {
|
||||||
|
assert d1.getPosition() == d2.getPosition();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
73
apt-mirror-api/src/main/java/com/sun/mirror/util/SourcePosition.java
Executable file
73
apt-mirror-api/src/main/java/com/sun/mirror/util/SourcePosition.java
Executable file
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* @(#)SourcePosition.java 1.2 04/07/16
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.mirror.util;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a position in a source file.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.2 04/07/16
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
138
apt-mirror-api/src/main/java/com/sun/mirror/util/TypeVisitor.java
Executable file
138
apt-mirror-api/src/main/java/com/sun/mirror/util/TypeVisitor.java
Executable file
@ -0,0 +1,138 @@
|
|||||||
|
/*
|
||||||
|
* @(#)TypeVisitor.java 1.4 04/06/07
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.4 04/06/07
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
190
apt-mirror-api/src/main/java/com/sun/mirror/util/Types.java
Executable file
190
apt-mirror-api/src/main/java/com/sun/mirror/util/Types.java
Executable file
@ -0,0 +1,190 @@
|
|||||||
|
/*
|
||||||
|
* @(#)Types.java 1.3 04/06/07
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @author Joseph D. Darcy
|
||||||
|
* @author Scott Seligman
|
||||||
|
* @version 1.3 04/06/07
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
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/>
|
||||||
|
* <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/>
|
||||||
|
* <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/>
|
||||||
|
* <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);
|
||||||
|
}
|
46
apt-mirror-api/src/main/java/com/sun/mirror/util/package.html
Executable file
46
apt-mirror-api/src/main/java/com/sun/mirror/util/package.html
Executable file
@ -0,0 +1,46 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!--
|
||||||
|
@(#)package.html 1.3 04/07/26
|
||||||
|
Copyright (c) 2004, Sun Microsystems, Inc.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the Sun Microsystems, Inc. nor the names of
|
||||||
|
its contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
-->
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body bgcolor="white">
|
||||||
|
|
||||||
|
Utilities to assist in the processing of {@linkplain
|
||||||
|
com.sun.mirror.declaration declarations} and {@linkplain
|
||||||
|
com.sun.mirror.type types}.
|
||||||
|
|
||||||
|
<p>Note that the <code>apt</code> tool and its associated APIs may be
|
||||||
|
changed or superseded in future j2se releases.
|
||||||
|
|
||||||
|
@since 1.5
|
||||||
|
</body>
|
||||||
|
</html>
|
70
apt-processor/pom.xml
Executable file
70
apt-processor/pom.xml
Executable file
@ -0,0 +1,70 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
~ Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
~
|
||||||
|
~ This program is free software: you can redistribute it and/or modify
|
||||||
|
~ it under the terms of the GNU General Public License as published y
|
||||||
|
~ the Free Software Foundation, either version 3 of the License, or
|
||||||
|
~ (at your option) any later version.
|
||||||
|
~
|
||||||
|
~ This program 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 for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU General Public License
|
||||||
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<groupId>com.moparisthebest.aptIn16</groupId>
|
||||||
|
<artifactId>aptIn16</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>apt-processor</artifactId>
|
||||||
|
<name>apt-processor</name>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.6</source>
|
||||||
|
<target>1.6</target>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>default-compile</id>
|
||||||
|
<configuration>
|
||||||
|
<compilerArgument>-proc:none</compilerArgument>
|
||||||
|
<includes>
|
||||||
|
<include>**</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>compile-everything-else</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<!-- http://cdivilly.wordpress.com/2010/03/16/maven-and-jsr-269-annotation-processors/ -->
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
149
apt-processor/src/main/java/com/moparisthebest/mirror/AptProcessor.java
Executable file
149
apt-processor/src/main/java/com/moparisthebest/mirror/AptProcessor.java
Executable file
@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror;
|
||||||
|
|
||||||
|
import com.sun.mirror.apt.AnnotationProcessorFactory;
|
||||||
|
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
|
||||||
|
import com.moparisthebest.mirror.apt.ConvertAnnotationProcessorEnvironment;
|
||||||
|
import com.moparisthebest.mirror.apt.ConvertAnnotationProcessorFactory;
|
||||||
|
import com.moparisthebest.mirror.declaration.ConvertDeclaration;
|
||||||
|
|
||||||
|
import javax.annotation.processing.Completion;
|
||||||
|
import javax.annotation.processing.ProcessingEnvironment;
|
||||||
|
import javax.annotation.processing.Processor;
|
||||||
|
import javax.annotation.processing.RoundEnvironment;
|
||||||
|
import javax.lang.model.SourceVersion;
|
||||||
|
import javax.lang.model.element.AnnotationMirror;
|
||||||
|
import javax.lang.model.element.Element;
|
||||||
|
import javax.lang.model.element.ExecutableElement;
|
||||||
|
import javax.lang.model.element.TypeElement;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class AptProcessor implements Processor {
|
||||||
|
|
||||||
|
final List<AnnotationProcessorFactory> factories;
|
||||||
|
final Set<String> supportedOptions;
|
||||||
|
final Set<String> supportedAnnotationTypes;
|
||||||
|
|
||||||
|
protected ConvertAnnotationProcessorEnvironment env;
|
||||||
|
|
||||||
|
public AptProcessor() throws IOException {
|
||||||
|
System.out.println("AptProcessor starting!");
|
||||||
|
Enumeration<URL> resources = getClass().getClassLoader().getResources("META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory");
|
||||||
|
Set<String> apfSet = new HashSet<String>();
|
||||||
|
String line;
|
||||||
|
while (resources.hasMoreElements()) {
|
||||||
|
try {
|
||||||
|
Scanner scan = new Scanner(resources.nextElement().openStream());
|
||||||
|
while (scan.hasNextLine()) {
|
||||||
|
line = scan.nextLine().trim();
|
||||||
|
// if line is empty or it's a comment (whitespace leading a hashtag), then skip
|
||||||
|
if (line.isEmpty() || line.matches("^\\s*#.*"))
|
||||||
|
continue;
|
||||||
|
apfSet.add(line);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<AnnotationProcessorFactory> factoryList = new ArrayList<AnnotationProcessorFactory>(apfSet.size());
|
||||||
|
Collection<String> options = new ArrayList<String>();
|
||||||
|
Set<String> annotationTypes = new HashSet<String>();
|
||||||
|
for (String apfName : apfSet) {
|
||||||
|
try {
|
||||||
|
AnnotationProcessorFactory apf = (AnnotationProcessorFactory) Class.forName(apfName).newInstance();
|
||||||
|
System.out.println("AptProcessor running " + apfName);
|
||||||
|
factoryList.add(apf);
|
||||||
|
annotationTypes.addAll(apf.supportedAnnotationTypes());
|
||||||
|
options.addAll(apf.supportedOptions());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.factories = Collections.unmodifiableList(factoryList);
|
||||||
|
this.supportedOptions = Collections.unmodifiableSet(ConvertAnnotationProcessorFactory.cleanOptions(options));
|
||||||
|
this.supportedAnnotationTypes = Collections.unmodifiableSet(annotationTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||||
|
//env.getFiler().setModified(false); // don't care about modified here I guess, just always return true
|
||||||
|
env.setRoundEnv(roundEnv);
|
||||||
|
final Set<AnnotationTypeDeclaration> annotationTypes =
|
||||||
|
Collections.unmodifiableSet(
|
||||||
|
ConvertDeclaration.getConvertable().convertToSet(annotations, AnnotationTypeDeclaration.class));
|
||||||
|
for (AnnotationProcessorFactory factory : factories) {
|
||||||
|
// sending in all instead of just the ones they handle *sometimes* causes exceptions, so I guess we will
|
||||||
|
// sort them out...
|
||||||
|
factory.getProcessorFor(annotationTypes, env).process();
|
||||||
|
/*
|
||||||
|
Set<AnnotationTypeDeclaration> atds = new HashSet<AnnotationTypeDeclaration>();
|
||||||
|
Collection<String> supportedTypes = factory.supportedAnnotationTypes();
|
||||||
|
for(AnnotationTypeDeclaration atd : annotationTypes)
|
||||||
|
if(supportedTypes.contains(atd.))
|
||||||
|
atd.
|
||||||
|
if(!atds.isEmpty())
|
||||||
|
factory.getProcessorFor(annotationTypes, env).process();
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
//return env.getFiler().isModified();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getSupportedOptions() {
|
||||||
|
return supportedOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getSupportedAnnotationTypes() {
|
||||||
|
return supportedAnnotationTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(ProcessingEnvironment processingEnv) {
|
||||||
|
env = new ConvertAnnotationProcessorEnvironment(processingEnv);
|
||||||
|
/*
|
||||||
|
if (!(processingEnv instanceof com.sun.tools.javac.processing.JavacProcessingEnvironment)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
System.out.println(processingEnv.getClass().getName());
|
||||||
|
com.sun.tools.javac.processing.JavacProcessingEnvironment pe = (com.sun.tools.javac.processing.JavacProcessingEnvironment) processingEnv;
|
||||||
|
Field discoveredProcs = pe.getClass().getDeclaredField("discoveredProcs");
|
||||||
|
com.sun.tools.javac.processing.JavacProcessingEnvironment.DiscoveredProcessors discoveredProcs.
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
System.exit(0);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SourceVersion getSupportedSourceVersion() {
|
||||||
|
return SourceVersion.latestSupported();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
# This file contains the processor's we want to run
|
||||||
|
# in this jar, there is only one, which runs all of
|
||||||
|
# the old-style Java 5 apt processors it can find
|
||||||
|
# automatically just like apt did, but in javac.
|
||||||
|
|
||||||
|
com.moparisthebest.mirror.AptProcessor
|
38
core/pom.xml
Executable file
38
core/pom.xml
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
~ Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
~
|
||||||
|
~ This program is free software: you can redistribute it and/or modify
|
||||||
|
~ it under the terms of the GNU General Public License as published y
|
||||||
|
~ the Free Software Foundation, either version 3 of the License, or
|
||||||
|
~ (at your option) any later version.
|
||||||
|
~
|
||||||
|
~ This program 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 for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU General Public License
|
||||||
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<groupId>com.moparisthebest.aptIn16</groupId>
|
||||||
|
<artifactId>aptIn16</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<name>core</name>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>apt-mirror-api</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -0,0 +1,328 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.apt;
|
||||||
|
|
||||||
|
import com.moparisthebest.mirror.convert.Convertable;
|
||||||
|
import com.moparisthebest.mirror.util.ConvertTypes;
|
||||||
|
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
|
||||||
|
import com.sun.mirror.apt.AnnotationProcessorListener;
|
||||||
|
import com.sun.mirror.apt.Messager;
|
||||||
|
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
|
||||||
|
import com.sun.mirror.declaration.Declaration;
|
||||||
|
import com.sun.mirror.declaration.PackageDeclaration;
|
||||||
|
import com.sun.mirror.declaration.TypeDeclaration;
|
||||||
|
import com.sun.mirror.util.Declarations;
|
||||||
|
import com.sun.mirror.util.Types;
|
||||||
|
import com.moparisthebest.mirror.declaration.ConvertDeclaration;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
import com.moparisthebest.mirror.type.ConvertTypeMirror;
|
||||||
|
import com.moparisthebest.mirror.util.ConvertDeclarations;
|
||||||
|
import com.moparisthebest.mirror.util.ConvertSourcePosition;
|
||||||
|
|
||||||
|
import javax.annotation.processing.ProcessingEnvironment;
|
||||||
|
import javax.annotation.processing.RoundEnvironment;
|
||||||
|
import javax.lang.model.element.TypeElement;
|
||||||
|
import javax.lang.model.util.Elements;
|
||||||
|
import javax.tools.FileObject;
|
||||||
|
import javax.tools.StandardLocation;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class ConvertAnnotationProcessorEnvironment implements AnnotationProcessorEnvironment {
|
||||||
|
|
||||||
|
private static final Object lock = new Object();
|
||||||
|
private boolean deriveSourcePath;
|
||||||
|
private final Map<String, String> options;
|
||||||
|
|
||||||
|
private final ProcessingEnvironment internal;
|
||||||
|
private final ConvertFiler filer;
|
||||||
|
private final ConvertMessager messager;
|
||||||
|
|
||||||
|
private RoundEnvironment roundEnv = null;
|
||||||
|
|
||||||
|
public static Elements elements = null;
|
||||||
|
|
||||||
|
private static final boolean debugOptions = ConvertAnnotationProcessorFactory.debug;
|
||||||
|
|
||||||
|
public ConvertAnnotationProcessorEnvironment(ProcessingEnvironment internal) {
|
||||||
|
//System.out.printf("internal: '%s' hash: '%s'\n", internal.toString(), internal.hashCode());
|
||||||
|
this.internal = internal;
|
||||||
|
filer = new ConvertFiler(internal.getFiler());
|
||||||
|
messager = new ConvertMessager(internal.getMessager());
|
||||||
|
ConvertSourcePosition.setProcessingEnvironment(internal, this);
|
||||||
|
// now set some static variables around, this could be nicer...
|
||||||
|
elements = internal.getElementUtils();
|
||||||
|
ConvertDeclaration.elements = elements;
|
||||||
|
ConvertTypeMirror.types = internal.getTypeUtils();
|
||||||
|
|
||||||
|
// now calculate options once, since they are sort-of expensive
|
||||||
|
// real apt passes them back like so:
|
||||||
|
//{-d=./aptgen, save-parameter-names=null, -s=./aptgen, -Aweb.content.root=./aptgen=null, -classpath=.;../netui16compiler/target/classes;../netui/target/classes;../controls/target/classes;../target/netui16compiler.jar, -nocompile=null, -factory=org.apache.beehive.netui.compiler.apt.PageFlowAnnotationProcessorFactory, -sourcepath=./aptgen}
|
||||||
|
// whereas internal.getOptions passes them like this:
|
||||||
|
// {web.content.root=./aptgen}
|
||||||
|
final Map<String, String> ret = new HashMap<String, String>();
|
||||||
|
final Map<String, String> internalOptions = internal.getOptions();
|
||||||
|
if (debugOptions) {
|
||||||
|
final File workingDir = new File(".");
|
||||||
|
System.out.println("working dir: " + workingDir.getAbsolutePath());
|
||||||
|
System.err.println("@@@@options: " + internalOptions);
|
||||||
|
}
|
||||||
|
// first put -A in front of all options
|
||||||
|
for (Map.Entry<String, String> internalOption : internalOptions.entrySet())
|
||||||
|
ret.put("-A" + internalOption.getKey(), internalOption.getValue());
|
||||||
|
// now set classpath
|
||||||
|
// some annotation processors (I'm looking at you beehive...) request '-classpath' and ignore '-cp',
|
||||||
|
// so put it under both :rolleyes:
|
||||||
|
ret.put("-cp", System.getProperty("java.class.path"));
|
||||||
|
ret.put("-classpath", System.getProperty("java.class.path"));
|
||||||
|
if (System.getProperty("sun.boot.class.path") != null)
|
||||||
|
ret.put("-bootclasspath", System.getProperty("sun.boot.class.path"));
|
||||||
|
if (debugOptions) {
|
||||||
|
System.out.println("System properties: " + System.getProperties());
|
||||||
|
System.out.println("java.class.path: " + System.getProperty("java.class.path"));
|
||||||
|
System.out.println("java.source.path: " + System.getProperty("java.source.path"));
|
||||||
|
System.out.println("sun.boot.class.path: " + System.getProperty("sun.boot.class.path"));
|
||||||
|
System.err.println("@@@@partialoptions: " + ret);
|
||||||
|
}
|
||||||
|
// now the hard part, get the rest of the options sent to javac...
|
||||||
|
|
||||||
|
// this will probably only work on sun compilers, but I'm out of options
|
||||||
|
String command = System.getProperty("sun.java.command");
|
||||||
|
// can't split by space because it isn't escaped or quoted...
|
||||||
|
//command: com.sun.tools.javac.Main -processor org.apache.beehive.netui.compiler.java6.PageFlowAnnotationProcessor -proc:only -Aweb.content.root=./apt gen -d ./apt gen -s ./apt gen -sourcepath ./apt gen -cp .;../netui16compiler/target/classes;../netui/target/classes;../controls/target/classes;C:\Users\burtrutj\.m2\repository\org\apache\beehive\beehive-netui-compiler\1.0.2\beehive-netui-compiler-1.0.2.jar;C:\Users\burtrutj\.m2\repository\org\apache\beehive\beehive-controls\1.0.2\beehive-controls-1.0.2.jar;../target/netui16compiler.jar backingControls/BackingControlsController.java backingControls/TestControl.java backingControls/page1.java
|
||||||
|
if (debugOptions)
|
||||||
|
System.err.println("command: " + command);
|
||||||
|
if (command != null)
|
||||||
|
try {
|
||||||
|
String[] options = command.split(" -"); // this should only break if a single argument has the literal string ' -' in it, hopefully it won't happen often
|
||||||
|
if (debugOptions)
|
||||||
|
System.out.println("options length: " + options.length);
|
||||||
|
// skip index one because it's the name of the program, ie com.sun.tools.javac.Main
|
||||||
|
for (int i = 1; i < options.length - 1; ++i) {
|
||||||
|
if (debugOptions)
|
||||||
|
System.err.println("option: " + options[i]);
|
||||||
|
if (options[i].startsWith("A") || options[i].startsWith("cp") || options[i].startsWith("classpath"))
|
||||||
|
continue; // it's an option we already have from above
|
||||||
|
if (debugOptions)
|
||||||
|
System.err.println("processing option: " + options[i]);
|
||||||
|
String[] item = options[i].split(" ", 2);
|
||||||
|
if (item.length == 0)
|
||||||
|
continue; // shouldn't ever be here
|
||||||
|
if (item[0].equals("bootclasspath") && item[1].trim().startsWith("@") && ret.containsKey("-bootclasspath"))
|
||||||
|
continue;
|
||||||
|
ret.put("-" + item[0], item.length < 2 ? null : item[1].trim());
|
||||||
|
}
|
||||||
|
// we saved the last option for last, because it has all the <source files> appended to it, what to do...
|
||||||
|
// all items in <source files> have to exist on the filesystem before we get here, so starting from the front
|
||||||
|
// grab the longest string that is a complete file, discard, and continue doing that until the file doesn't end
|
||||||
|
// with .java or we are out of files.
|
||||||
|
if (debugOptions)
|
||||||
|
System.err.println("last option: " + options[options.length - 1]);
|
||||||
|
String[] item = options[options.length - 1].split(" ", 2);
|
||||||
|
if (item.length < 2)
|
||||||
|
ret.put(item[0], null);
|
||||||
|
else {
|
||||||
|
// I thought there had to be an item at 1, or no files would have been passed to javac
|
||||||
|
// turns out things like maven have their own launchers...
|
||||||
|
final String valueAndFiles = item[1];
|
||||||
|
int stopIncluding = valueAndFiles.length();
|
||||||
|
// match the biggest file possible in the string, starting from the beginning
|
||||||
|
outer:
|
||||||
|
for (int i = 0; i < stopIncluding; ++i) {
|
||||||
|
do {
|
||||||
|
String fileName = valueAndFiles.substring(i, stopIncluding);
|
||||||
|
//System.err.println("fileName: "+fileName);
|
||||||
|
if (new File(fileName).isFile()) {
|
||||||
|
//System.err.println("success! it's a file!");
|
||||||
|
if (!fileName.trim().toLowerCase().endsWith(".java")) {
|
||||||
|
//System.err.println("breaking because filename doesn't end with .java: "+fileName.toLowerCase());
|
||||||
|
break outer;
|
||||||
|
}
|
||||||
|
stopIncluding = i;
|
||||||
|
i = 0;
|
||||||
|
continue outer;
|
||||||
|
}
|
||||||
|
} while (++i < stopIncluding);
|
||||||
|
}
|
||||||
|
String value = valueAndFiles.substring(0, stopIncluding).trim();
|
||||||
|
if (debugOptions)
|
||||||
|
System.err.printf("last option: '%s':'%s'\n", item[0], value.isEmpty() ? null : value);
|
||||||
|
ret.put(item[0], value.isEmpty() ? null : value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// now make sure -sourcepath is in there, some annotation processors (again, I'm looking at you, flipping beehive)
|
||||||
|
// require it be specified, if it isn't, try to hack it out...
|
||||||
|
//if(false)
|
||||||
|
if (ret.get("-sourcepath") == null || ret.get("-sourcepath").isEmpty())
|
||||||
|
try {
|
||||||
|
File path = null;
|
||||||
|
try {
|
||||||
|
FileObject sourcePath = internal.getFiler().getResource(StandardLocation.SOURCE_PATH, "", "trash");
|
||||||
|
//FileObject sourcePath = internal.getFiler().getResource(StandardLocation.SOURCE_PATH, "", "com/moparisthebest/controls/studysearch/studySearchCtrl.java");
|
||||||
|
|
||||||
|
//FileObject sourcePath = internal.getFiler().createResource(StandardLocation.SOURCE_PATH, "", "trash");
|
||||||
|
path = new File(sourcePath.toUri());
|
||||||
|
path = path.getParentFile().getCanonicalFile();
|
||||||
|
} catch (Exception e) {
|
||||||
|
//todo: this fails on jdk7, but works fine on jdk6, figure out a better way, for now, deriveSourcePath is called
|
||||||
|
if (debugOptions)
|
||||||
|
e.printStackTrace();
|
||||||
|
//Iterable<? extends File> spi = ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null).getLocation(StandardLocation.SOURCE_PATH);
|
||||||
|
//Iterator<? extends File> sp = spi.iterator();
|
||||||
|
//while(sp.hasNext())
|
||||||
|
// System.out.println(sp.next());
|
||||||
|
}
|
||||||
|
if (debugOptions)
|
||||||
|
System.err.println("guessed sourcepath: " + path);
|
||||||
|
if (path != null)
|
||||||
|
ret.put("-sourcepath", path.getAbsolutePath());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
System.out.println("Exception parsing command line options:");
|
||||||
|
e.printStackTrace();
|
||||||
|
System.out.println("successfully parsed options are: " + ret);
|
||||||
|
}
|
||||||
|
// try to derive it if it still doesn't exist and it's possible with ConvertSourcePosition
|
||||||
|
deriveSourcePath = ConvertSourcePosition.supported() && (ret.get("-sourcepath") == null || ret.get("-sourcepath").isEmpty());
|
||||||
|
//System.err.println("@@@@fixedoptions: " + ret);
|
||||||
|
//System.exit(0);
|
||||||
|
this.options = deriveSourcePath ? ret : Collections.unmodifiableMap(ret);
|
||||||
|
if (debugOptions)
|
||||||
|
System.out.println("options: " + this.options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deriveSourcePath(File file, String packageName) {
|
||||||
|
if (!deriveSourcePath)
|
||||||
|
return;
|
||||||
|
try {
|
||||||
|
File sourcePath = file;
|
||||||
|
int subDirs = packageName.split("\\.").length;
|
||||||
|
while (subDirs-- >= 0)
|
||||||
|
sourcePath = sourcePath.getParentFile();
|
||||||
|
//System.out.println("sourcePath: "+sourcePath);
|
||||||
|
// todo: we should really concatenate different sourcepath's with the platform's
|
||||||
|
// todo: path seperator, but for jdk6 we just specify one source path,
|
||||||
|
// todo: so we might as well do the same here for now
|
||||||
|
deriveSourcePath = false;
|
||||||
|
this.options.put("-sourcepath", sourcePath.getAbsolutePath());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoundEnv(RoundEnvironment roundEnv) {
|
||||||
|
this.roundEnv = roundEnv;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getOptions() {
|
||||||
|
Debug.implemented("Map<String, String>");
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Messager getMessager() {
|
||||||
|
return messager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConvertFiler getFiler() {
|
||||||
|
return filer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Declarations getDeclarationUtils() {
|
||||||
|
return new ConvertDeclarations(internal.getElementUtils());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Types getTypeUtils() {
|
||||||
|
return new ConvertTypes(internal.getTypeUtils());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<TypeDeclaration> getSpecifiedTypeDeclarations() {
|
||||||
|
Debug.implemented("Collection<TypeDeclaration>");
|
||||||
|
return Collections.emptyList(); //todo: probably not right?
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<TypeDeclaration> getTypeDeclarations() {
|
||||||
|
Debug.implemented("Collection<TypeDeclaration>");
|
||||||
|
return Collections.emptyList(); //todo: probably not right?
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PackageDeclaration getPackage(String name) {
|
||||||
|
Debug.implemented("PackageDeclaration");
|
||||||
|
return ConvertDeclaration.convert(internal.getElementUtils().getPackageElement(name), PackageDeclaration.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypeDeclaration getTypeDeclaration(String name) {
|
||||||
|
Debug.implemented("TypeDeclaration");
|
||||||
|
return ConvertDeclaration.convert(internal.getElementUtils().getTypeElement(name), TypeDeclaration.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Declaration> getDeclarationsAnnotatedWith(AnnotationTypeDeclaration a) {
|
||||||
|
Debug.implemented("Collection<Declaration>");
|
||||||
|
//System.err.println("AnnotationTypeDeclaration: "+a);
|
||||||
|
//System.err.println("TypeElement: "+Convertable.unwrapClass(a, TypeElement.class));
|
||||||
|
List<Declaration> ret = ConvertDeclaration.getConvertable().convert(roundEnv.getElementsAnnotatedWith(Convertable.unwrapClass(a, TypeElement.class)));
|
||||||
|
//System.err.println("retnoconvert: "+roundEnv.getElementsAnnotatedWith(Convertable.unwrapClass(a, TypeElement.class)));
|
||||||
|
//System.err.println("ret: "+ret);
|
||||||
|
//System.err.println("retclass: "+ret.toArray()[0].getClass());
|
||||||
|
return ret;
|
||||||
|
//return Convertable.sort(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addListener(AnnotationProcessorListener listener) {
|
||||||
|
// not supported
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeListener(AnnotationProcessorListener listener) {
|
||||||
|
// not supported
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o instanceof ProcessingEnvironment) return internal.equals(o);
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
ConvertAnnotationProcessorEnvironment that = (ConvertAnnotationProcessorEnvironment) o;
|
||||||
|
|
||||||
|
return internal.equals(that.internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return internal.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return internal.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,214 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.apt;
|
||||||
|
|
||||||
|
import com.moparisthebest.mirror.convert.Convertable;
|
||||||
|
import com.moparisthebest.mirror.declaration.ConvertDeclaration;
|
||||||
|
import com.sun.mirror.apt.AnnotationProcessorFactory;
|
||||||
|
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.annotation.processing.*;
|
||||||
|
import javax.lang.model.SourceVersion;
|
||||||
|
import javax.lang.model.element.AnnotationMirror;
|
||||||
|
import javax.lang.model.element.Element;
|
||||||
|
import javax.lang.model.element.ExecutableElement;
|
||||||
|
import javax.lang.model.element.TypeElement;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class ConvertAnnotationProcessorFactory implements Processor {
|
||||||
|
|
||||||
|
public static final boolean debug = false;
|
||||||
|
|
||||||
|
static {
|
||||||
|
String command = System.getProperty("sun.java.command");
|
||||||
|
// hack to stop IDEA from permanently freezing when processing annotations
|
||||||
|
// todo: please tell me why, for the life of me I can't figure it out...
|
||||||
|
if (command != null && command.startsWith("com.intellij.rt.compiler")) {
|
||||||
|
// command looks like: com.intellij.rt.compiler.JavacRunner java version 1.6.0_30 com.sun.tools.javac.Main [options]
|
||||||
|
System.setOut(System.err);
|
||||||
|
System.err.println("INFO: activated IDEA hack of re-directing System.out to System.err");
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintStream oldOut = System.out;
|
||||||
|
|
||||||
|
if ((debug || System.getProperty("aptin16.debug") != null))
|
||||||
|
try {
|
||||||
|
FileOutputStream fos = null;
|
||||||
|
try {
|
||||||
|
fos = new FileOutputStream("/aptin16.log");
|
||||||
|
} catch (Exception e) {
|
||||||
|
fos = new FileOutputStream(System.getProperty("user.home") + "/aptin16.log");
|
||||||
|
}
|
||||||
|
PrintStream out = new PrintStream(fos, true);
|
||||||
|
System.setOut(out);
|
||||||
|
System.setErr(out);
|
||||||
|
System.out.println(new Date() + ": log successfully set!");
|
||||||
|
System.out.printf("oldOut: '%s' class: '%s'\n", oldOut.toString(), oldOut.getClass().toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private final AnnotationProcessorFactory internal;
|
||||||
|
|
||||||
|
// at least for now, all of the ProcessingEnvironment's multiple instances get sent
|
||||||
|
// are the EXACT same object, so we might as well make this static and save some time
|
||||||
|
protected static ConvertAnnotationProcessorEnvironment env = null;
|
||||||
|
|
||||||
|
public ConvertAnnotationProcessorFactory(String annotationProcessorFactoryName) {
|
||||||
|
AnnotationProcessorFactory internal = null;
|
||||||
|
try {
|
||||||
|
internal = (AnnotationProcessorFactory) Class.forName(annotationProcessorFactoryName).newInstance();
|
||||||
|
System.out.println("ConvertAnnotationProcessorFactory running " + internal.getClass().getName());
|
||||||
|
} catch (Throwable e) {
|
||||||
|
System.out.printf("Not running AnnotationProcessorFactory '%s' because of error!\n", annotationProcessorFactoryName);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
this.internal = internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConvertAnnotationProcessorFactory(AnnotationProcessorFactory internal) {
|
||||||
|
if (internal == null)
|
||||||
|
throw new NullPointerException("AnnotationProcessorFactory cannot be null!");
|
||||||
|
System.out.println("ConvertAnnotationProcessorFactory running " + internal.getClass().getName());
|
||||||
|
this.internal = internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Set<String> cleanOptions(Collection<String> input) {
|
||||||
|
Set<String> ret = new LinkedHashSet<String>(input.size());
|
||||||
|
for (String option : input)
|
||||||
|
ret.add(option.replaceFirst("^-A", "")); // have to strip -A from beginning of options...
|
||||||
|
if (Debug.debug)
|
||||||
|
System.out.println("supportedOptions: " + ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getSupportedOptions() {
|
||||||
|
return cleanOptions(internal.supportedOptions());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getSupportedAnnotationTypes() {
|
||||||
|
if (Debug.debug)
|
||||||
|
System.out.printf("factory: '%s' supportedAnnotationTypes: '%s'\n", internal.getClass().getName(), internal.supportedAnnotationTypes());
|
||||||
|
return Convertable.toSet(internal.supportedAnnotationTypes());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static synchronized void staticInit(ProcessingEnvironment processingEnv) {
|
||||||
|
if (env != null)
|
||||||
|
return;
|
||||||
|
env = new ConvertAnnotationProcessorEnvironment(processingEnv);
|
||||||
|
/*
|
||||||
|
// the following helps us debug, since I know no way of debugging in javac itself
|
||||||
|
System.setOut(
|
||||||
|
new PrintStream(System.out) {
|
||||||
|
|
||||||
|
|
||||||
|
public static final byte debugLevel = 90;
|
||||||
|
|
||||||
|
public void printInfo() {
|
||||||
|
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||||
|
int x = 2; // start at 3
|
||||||
|
printStackTrace(stackTrace[x], "", "");
|
||||||
|
int level = x + debugLevel;
|
||||||
|
StringBuilder tabs = new StringBuilder();
|
||||||
|
while (++x < level && x < stackTrace.length)
|
||||||
|
printStackTrace(stackTrace[x], "Called", tabs.append('\t').toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void printStackTrace(StackTraceElement ste, String msg, String returnType) {
|
||||||
|
super.printf("%s%s.%s(%s:%d) %s\n",
|
||||||
|
returnType,
|
||||||
|
//ste.getClassName().replaceFirst(".*\\.", "")
|
||||||
|
ste.getClassName()
|
||||||
|
, ste.getMethodName(),
|
||||||
|
ste.getFileName(), ste.getLineNumber(),
|
||||||
|
msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void println(String x) {
|
||||||
|
printInfo();
|
||||||
|
super.println(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
System.setErr(System.out);
|
||||||
|
//System.err.println("woohoo! quitting!");
|
||||||
|
//System.exit(0);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(ProcessingEnvironment processingEnv) {
|
||||||
|
//env = new ConvertAnnotationProcessorEnvironment(processingEnv); // if we change it back to an instance variable
|
||||||
|
staticInit(processingEnv);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param annotations
|
||||||
|
* @param roundEnv
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public synchronized boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||||
|
env.getFiler().setModified(false);
|
||||||
|
env.setRoundEnv(roundEnv);
|
||||||
|
internal.getProcessorFor(ConvertDeclaration.getConvertable().convertToSet(annotations, AnnotationTypeDeclaration.class), env).process();
|
||||||
|
return env.getFiler().isModified(); //todo: don't know what to return here
|
||||||
|
//return true;
|
||||||
|
//return false; // apt didn't return anything or have a notion of 'claiming' annotations, but false breaks beehive...
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SourceVersion getSupportedSourceVersion() {
|
||||||
|
return SourceVersion.latestSupported();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o instanceof AnnotationProcessorFactory) return internal.equals(o);
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
ConvertAnnotationProcessorFactory that = (ConvertAnnotationProcessorFactory) o;
|
||||||
|
|
||||||
|
return internal.equals(that.internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return internal.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return internal.toString();
|
||||||
|
}
|
||||||
|
}
|
120
core/src/main/java/com/moparisthebest/mirror/apt/ConvertFiler.java
Executable file
120
core/src/main/java/com/moparisthebest/mirror/apt/ConvertFiler.java
Executable file
@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.apt;
|
||||||
|
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.tools.StandardLocation;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class ConvertFiler implements com.sun.mirror.apt.Filer {
|
||||||
|
|
||||||
|
private final javax.annotation.processing.Filer internal;
|
||||||
|
private boolean modified = false;
|
||||||
|
|
||||||
|
public ConvertFiler(javax.annotation.processing.Filer internal) {
|
||||||
|
this.internal = internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isModified() {
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModified(boolean modified) {
|
||||||
|
this.modified = modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PrintWriter createSourceFile(String name) throws IOException {
|
||||||
|
Debug.implemented(PrintWriter.class);
|
||||||
|
modified = true;
|
||||||
|
return new PrintWriter(internal.createSourceFile(name).openWriter());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OutputStream createClassFile(String name) throws IOException {
|
||||||
|
Debug.implemented(OutputStream.class);
|
||||||
|
modified = true;
|
||||||
|
return internal.createClassFile(name).openOutputStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StandardLocation convert(Location location) {
|
||||||
|
switch (location) {
|
||||||
|
case CLASS_TREE:
|
||||||
|
return StandardLocation.CLASS_OUTPUT;
|
||||||
|
case SOURCE_TREE:
|
||||||
|
return StandardLocation.SOURCE_OUTPUT;
|
||||||
|
default:
|
||||||
|
return null; // should NEVER get here (those are the only two options for Location)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PrintWriter createTextFile(Location loc, String pkg, File relPath, String charsetName) throws IOException {
|
||||||
|
Debug.implemented(PrintWriter.class);
|
||||||
|
try {
|
||||||
|
OutputStream os = createBinaryFile(loc, pkg, relPath);
|
||||||
|
// since charsetName can be null, we need to use a different constructor
|
||||||
|
return new PrintWriter(charsetName == null ? new OutputStreamWriter(os) : new OutputStreamWriter(os, charsetName));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OutputStream createBinaryFile(Location loc, String pkg, File relPath) throws IOException {
|
||||||
|
Debug.implemented(OutputStream.class);
|
||||||
|
String relativeName = relPath.getPath();
|
||||||
|
//relativeName = relPath.getName();
|
||||||
|
relativeName = relativeName.replaceAll("\\\\", "/"); // on windows the relPath sometimes contains \ instead of /, which messes everything up
|
||||||
|
//System.out.printf("loc: '%s' pkg: '%s' relPath: '%s' relativeName: '%s'\n", loc, pkg, relPath.toString(), relativeName);
|
||||||
|
modified = true;
|
||||||
|
try {
|
||||||
|
return internal.createResource(convert(loc), pkg, relativeName).openOutputStream();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
Debug.implemented();
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o instanceof javax.annotation.processing.Filer) return internal.equals(o);
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
ConvertFiler that = (ConvertFiler) o;
|
||||||
|
|
||||||
|
return internal.equals(that.internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
Debug.implemented(int.class);
|
||||||
|
return internal.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
Debug.implemented(String.class);
|
||||||
|
return internal.toString();
|
||||||
|
}
|
||||||
|
}
|
91
core/src/main/java/com/moparisthebest/mirror/apt/ConvertMessager.java
Executable file
91
core/src/main/java/com/moparisthebest/mirror/apt/ConvertMessager.java
Executable file
@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.apt;
|
||||||
|
|
||||||
|
import com.sun.mirror.util.SourcePosition;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.annotation.processing.Messager;
|
||||||
|
import javax.tools.Diagnostic;
|
||||||
|
|
||||||
|
public class ConvertMessager implements com.sun.mirror.apt.Messager {
|
||||||
|
|
||||||
|
private final javax.annotation.processing.Messager internal;
|
||||||
|
|
||||||
|
public ConvertMessager(Messager internal) {
|
||||||
|
this.internal = internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printError(String msg) {
|
||||||
|
Debug.implemented(void.class);
|
||||||
|
internal.printMessage(Diagnostic.Kind.ERROR, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printWarning(String msg) {
|
||||||
|
Debug.implemented(void.class);
|
||||||
|
internal.printMessage(Diagnostic.Kind.WARNING, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printNotice(String msg) {
|
||||||
|
Debug.implemented(void.class);
|
||||||
|
internal.printMessage(Diagnostic.Kind.NOTE, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printError(SourcePosition pos, String msg) {
|
||||||
|
Debug.implemented(void.class);
|
||||||
|
printError(msg); // ignore pos
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printWarning(SourcePosition pos, String msg) {
|
||||||
|
Debug.implemented(void.class);
|
||||||
|
printWarning(msg); // ignore pos
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printNotice(SourcePosition pos, String msg) {
|
||||||
|
Debug.implemented(void.class);
|
||||||
|
printNotice(msg); // ignore pos
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o instanceof javax.annotation.processing.Messager) return internal.equals(o);
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
ConvertMessager that = (ConvertMessager) o;
|
||||||
|
|
||||||
|
return internal.equals(that.internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return internal.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return internal.toString();
|
||||||
|
}
|
||||||
|
}
|
148
core/src/main/java/com/moparisthebest/mirror/convert/Convertable.java
Executable file
148
core/src/main/java/com/moparisthebest/mirror/convert/Convertable.java
Executable file
@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.convert;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public abstract class Convertable<F, T> implements ConvertableIface<F, T> {
|
||||||
|
|
||||||
|
public abstract T convertToType(F from);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
public <E extends T> E convertToType(F from, Class<E> type) {
|
||||||
|
return (E) convertToType(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <E extends T> List<E> convert(Collection<? extends F> from, Class<E> type) {
|
||||||
|
List<E> ret = new ArrayList<E>(from.size());
|
||||||
|
for (F fromF : from)
|
||||||
|
ret.add(convertToType(fromF, type));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <E extends T> Set<E> convertToSet(Collection<? extends F> from, Class<E> type) {
|
||||||
|
Set<E> ret = new LinkedHashSet<E>(from.size());
|
||||||
|
for (F fromF : from)
|
||||||
|
ret.add(convertToType(fromF, type));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> convert(Collection<? extends F> from) {
|
||||||
|
List<T> ret = new ArrayList<T>(from.size());
|
||||||
|
for (F fromF : from)
|
||||||
|
ret.add(convertToType(fromF));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<T> convertToSet(Collection<? extends F> from) {
|
||||||
|
Set<T> ret = new LinkedHashSet<T>(from.size());
|
||||||
|
for (F fromF : from)
|
||||||
|
ret.add(convertToType(fromF));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
public static <R> R[] unwrapClass(Object[] convertable, R[] dest) {
|
||||||
|
if (convertable == null || dest == null)
|
||||||
|
return null;
|
||||||
|
if (convertable.length != dest.length)
|
||||||
|
throw new RuntimeException("convertable and dest need to be arrays of same length!");
|
||||||
|
try {
|
||||||
|
Class<R> componentType = (Class<R>) dest.getClass().getComponentType();
|
||||||
|
for (int x = 0; x < dest.length; ++x)
|
||||||
|
dest[x] = unwrapClass(convertable[x], componentType);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.err.println("fatal error!");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
public static <R> R unwrapClass(Object convertable, Class<R> iface) {
|
||||||
|
if (convertable == null)
|
||||||
|
return null;
|
||||||
|
try {
|
||||||
|
return iface.cast(((ConvertableIface<? extends R, ?>) convertable).unwrap());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.err.println("fatal error!");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <E extends Enum<E>> List<E> convertEnums(Collection<? extends Enum> from, Class<E> newe) {
|
||||||
|
List<E> ret = new ArrayList<E>(from.size());
|
||||||
|
for (Enum old : from)
|
||||||
|
ret.add(convertEnum(old, newe));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <E extends Enum<E>> E convertEnum(Enum old, Class<E> newe) {
|
||||||
|
return Enum.valueOf(newe, old.toString().toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Set<T> toSet(Collection<T> c) {
|
||||||
|
try {
|
||||||
|
if (c instanceof Set)
|
||||||
|
return (Set<T>) c;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
Set<T> ret = new LinkedHashSet<T>();
|
||||||
|
ret.addAll(c);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
public static <E> List<E> sort(List<E> ret) {
|
||||||
|
//System.out.println("un-sorted: "+ret);
|
||||||
|
Collections.sort(ret, toStringComparator);
|
||||||
|
//System.out.println("sorted: "+ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
public static <E> Set<E> sort(Set<E> set) {
|
||||||
|
/*return set;*/
|
||||||
|
|
||||||
|
TreeSet<E> ret = new TreeSet<E>(toStringComparator);
|
||||||
|
ret.addAll(set);
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
public static <E> E[] sort(E[] ret) {
|
||||||
|
Arrays.sort(ret, toStringComparator);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Comparator toStringComparator = new ToStringComparator();
|
||||||
|
|
||||||
|
private static class ToStringComparator implements Comparator<Object> {
|
||||||
|
public int compare(Object f1, Object f2) {
|
||||||
|
return f1.toString().compareTo(f2.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
25
core/src/main/java/com/moparisthebest/mirror/convert/ConvertableIface.java
Executable file
25
core/src/main/java/com/moparisthebest/mirror/convert/ConvertableIface.java
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.convert;
|
||||||
|
|
||||||
|
public interface ConvertableIface<F, T> {
|
||||||
|
public <E extends T> E convertToType(F from, Class<E> type);
|
||||||
|
|
||||||
|
public F unwrap();
|
||||||
|
}
|
49
core/src/main/java/com/moparisthebest/mirror/convert/ElementFilter.java
Executable file
49
core/src/main/java/com/moparisthebest/mirror/convert/ElementFilter.java
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.convert;
|
||||||
|
|
||||||
|
import javax.lang.model.element.Element;
|
||||||
|
import javax.lang.model.element.ElementKind;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class ElementFilter {
|
||||||
|
// Assumes targetKinds and E are sensible.
|
||||||
|
private static <E extends Element, F extends E, C extends Collection<F>> C collectionFilter(C collection, Iterable<? extends E> elements, Class<F> clazz, ElementKind... kinds) {
|
||||||
|
for (E e : elements) {
|
||||||
|
ElementKind findKind = e.getKind();
|
||||||
|
for (ElementKind kind : kinds)
|
||||||
|
if (kind == findKind) {
|
||||||
|
collection.add(clazz.cast(e));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assumes targetKinds and E are sensible.
|
||||||
|
public static <E extends Element, F extends E> List<F> listFilter(Iterable<? extends E> elements, Class<F> clazz, ElementKind... kinds) {
|
||||||
|
return collectionFilter(new ArrayList<F>(), elements, clazz, kinds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assumes targetKinds and E are sensible.
|
||||||
|
public static <E extends Element, F extends E> Set<F> setFilter(Iterable<? extends E> elements, Class<F> clazz, ElementKind... kinds) {
|
||||||
|
// Return set preserving iteration order of input set.
|
||||||
|
return collectionFilter(new LinkedHashSet<F>(), elements, clazz);
|
||||||
|
}
|
||||||
|
}
|
45
core/src/main/java/com/moparisthebest/mirror/convert/InstanceFilter.java
Executable file
45
core/src/main/java/com/moparisthebest/mirror/convert/InstanceFilter.java
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.convert;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class InstanceFilter {
|
||||||
|
|
||||||
|
// Assumes targetKinds and E are sensible.
|
||||||
|
private static <E, F extends E, C extends Collection<F>> C collectionFilter(C collection, Iterable<? extends E> elements, Class<F> clazz) {
|
||||||
|
for (E e : elements) {
|
||||||
|
//if (clazz.isAssignableFrom(e.getClass()))
|
||||||
|
if (clazz.isInstance(e))
|
||||||
|
collection.add(clazz.cast(e));
|
||||||
|
}
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assumes targetKinds and E are sensible.
|
||||||
|
public static <E, F extends E> List<F> listFilter(Iterable<? extends E> elements, Class<F> clazz) {
|
||||||
|
return collectionFilter(new ArrayList<F>(), elements, clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assumes targetKinds and E are sensible.
|
||||||
|
public static <E, F extends E> Set<F> setFilter(Iterable<? extends E> elements, Class<F> clazz) {
|
||||||
|
// Return set preserving iteration order of input set.
|
||||||
|
return collectionFilter(new LinkedHashSet<F>(), elements, clazz);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.moparisthebest.mirror.convert.Convertable;
|
||||||
|
import com.moparisthebest.mirror.util.ConvertSourcePosition;
|
||||||
|
import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
|
||||||
|
import com.sun.mirror.declaration.AnnotationValue;
|
||||||
|
import com.sun.mirror.type.AnnotationType;
|
||||||
|
import com.sun.mirror.util.SourcePosition;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
import com.moparisthebest.mirror.type.ConvertTypeMirror;
|
||||||
|
|
||||||
|
import javax.lang.model.element.AnnotationMirror;
|
||||||
|
import javax.lang.model.element.ExecutableElement;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ConvertAnnotationMirror extends Convertable<AnnotationMirror, com.sun.mirror.declaration.AnnotationMirror> implements com.sun.mirror.declaration.AnnotationMirror {
|
||||||
|
|
||||||
|
private final javax.lang.model.element.AnnotationMirror internal;
|
||||||
|
|
||||||
|
protected ConvertAnnotationMirror(AnnotationMirror internal) {
|
||||||
|
this.internal = internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ConvertAnnotationMirror() {
|
||||||
|
this.internal = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Convertable<javax.lang.model.element.AnnotationMirror, com.sun.mirror.declaration.AnnotationMirror> getConvertable() {
|
||||||
|
return new ConvertAnnotationMirror();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <F extends javax.lang.model.element.AnnotationMirror> com.sun.mirror.declaration.AnnotationMirror convert(F from) {
|
||||||
|
return convert(from, ConvertAnnotationMirror.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
public static <T extends com.sun.mirror.declaration.AnnotationMirror, F extends javax.lang.model.element.AnnotationMirror> T convert(F from, Class<T> thisClass) {
|
||||||
|
return (T) new ConvertAnnotationMirror(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public com.sun.mirror.declaration.AnnotationMirror convertToType(AnnotationMirror from) {
|
||||||
|
return new ConvertAnnotationMirror(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AnnotationMirror unwrap() {
|
||||||
|
return internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AnnotationType getAnnotationType() {
|
||||||
|
return ConvertTypeMirror.convert(internal.getAnnotationType(), AnnotationType.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<AnnotationTypeElementDeclaration, AnnotationValue> getElementValues() {
|
||||||
|
Debug.implemented("Map<AnnotationTypeElementDeclaration, AnnotationValue>");
|
||||||
|
Map<? extends ExecutableElement, ? extends javax.lang.model.element.AnnotationValue> internalValues = internal.getElementValues();
|
||||||
|
Map<AnnotationTypeElementDeclaration, AnnotationValue> ret = new HashMap<AnnotationTypeElementDeclaration, AnnotationValue>(internalValues.size());
|
||||||
|
for (Map.Entry<? extends ExecutableElement, ? extends javax.lang.model.element.AnnotationValue> internalEntry : internalValues.entrySet())
|
||||||
|
ret.put(new ConvertAnnotationTypeElementDeclaration(internalEntry.getKey()), new ConvertAnnotationValue(internalEntry.getValue()));
|
||||||
|
if (Debug.debug)
|
||||||
|
System.err.println("elementValues: " + ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SourcePosition getPosition() {
|
||||||
|
Debug.implemented("SourcePosition");
|
||||||
|
return ConvertSourcePosition.convert(internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o instanceof javax.lang.model.element.AnnotationMirror) return internal.equals(o);
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
ConvertAnnotationMirror that = (ConvertAnnotationMirror) o;
|
||||||
|
|
||||||
|
return internal.equals(that.internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return internal.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return internal.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.lang.model.element.TypeElement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ConvertAnnotationTypeDeclaration extends ConvertInterfaceDeclaration
|
||||||
|
implements com.sun.mirror.declaration.AnnotationTypeDeclaration
|
||||||
|
// , ConvertableIface<javax.lang.model.element.TypeElement, com.sun.mirror.declaration.AnnotationTypeDeclaration>
|
||||||
|
{
|
||||||
|
|
||||||
|
protected ConvertAnnotationTypeDeclaration(TypeElement internalTypeElement) {
|
||||||
|
super(internalTypeElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
public Collection<AnnotationTypeElementDeclaration> getMethods() {
|
||||||
|
Debug.implemented("Collection<AnnotationTypeElementDeclaration>");
|
||||||
|
Collection<? extends ConvertMethodDeclaration> superMethods = (Collection<? extends ConvertMethodDeclaration>) super.getMethods();
|
||||||
|
List<AnnotationTypeElementDeclaration> ret = new ArrayList<AnnotationTypeElementDeclaration>(superMethods.size());
|
||||||
|
for (ConvertMethodDeclaration item : superMethods)
|
||||||
|
if (item instanceof AnnotationTypeElementDeclaration)
|
||||||
|
ret.add((AnnotationTypeElementDeclaration) item);
|
||||||
|
else
|
||||||
|
ret.add(new ConvertAnnotationTypeElementDeclaration(item.internalExecutableElement));
|
||||||
|
//org.apache.beehive.netui.pageflow.annotations.Jpf.SimpleAction
|
||||||
|
if (Debug.debug) {
|
||||||
|
System.err.println("TypeElement: " + internalTypeElement);
|
||||||
|
System.err.println("ret: " + ret);
|
||||||
|
System.err.println("unfiltered: " + superMethods);
|
||||||
|
//System.err.println("filtered: "+InstanceFilter.listFilter(superMethods, AnnotationTypeElementDeclaration.class));
|
||||||
|
}
|
||||||
|
return sort(ret);// or not to sort?
|
||||||
|
//return InstanceFilter.listFilter(superMethods, AnnotationTypeElementDeclaration.class);
|
||||||
|
//return (Collection<AnnotationTypeElementDeclaration>)superMethods;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
|
||||||
|
import com.sun.mirror.declaration.AnnotationValue;
|
||||||
|
|
||||||
|
import javax.lang.model.element.ExecutableElement;
|
||||||
|
|
||||||
|
public class ConvertAnnotationTypeElementDeclaration extends ConvertMethodDeclaration implements com.sun.mirror.declaration.AnnotationTypeElementDeclaration {
|
||||||
|
|
||||||
|
protected ConvertAnnotationTypeElementDeclaration(ExecutableElement internalExecutableElement) {
|
||||||
|
super(internalExecutableElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AnnotationValue getDefaultValue() {
|
||||||
|
Debug.implemented("AnnotationValue");
|
||||||
|
return new ConvertAnnotationValue(internalExecutableElement.getDefaultValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AnnotationTypeDeclaration getDeclaringType() {
|
||||||
|
Debug.implemented("AnnotationTypeDeclaration");
|
||||||
|
ConvertTypeDeclaration ret = (ConvertTypeDeclaration) super.getDeclaringType();
|
||||||
|
if (ret instanceof AnnotationTypeDeclaration)
|
||||||
|
return (AnnotationTypeDeclaration) ret;
|
||||||
|
return new ConvertAnnotationTypeDeclaration(ret.internalTypeElement);// todo: no idea why I have to do this, returns ClassTypeDeclaration
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.moparisthebest.mirror.convert.Convertable;
|
||||||
|
import com.moparisthebest.mirror.util.ConvertSourcePosition;
|
||||||
|
import com.sun.mirror.util.SourcePosition;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
import com.moparisthebest.mirror.type.ConvertTypeMirror;
|
||||||
|
|
||||||
|
import javax.lang.model.element.AnnotationValue;
|
||||||
|
import javax.lang.model.element.ElementKind;
|
||||||
|
import javax.lang.model.element.VariableElement;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ConvertAnnotationValue extends Convertable<AnnotationValue, com.sun.mirror.declaration.AnnotationValue> implements com.sun.mirror.declaration.AnnotationValue {
|
||||||
|
private final javax.lang.model.element.AnnotationValue internal;
|
||||||
|
|
||||||
|
protected ConvertAnnotationValue(AnnotationValue internal) {
|
||||||
|
this.internal = internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ConvertAnnotationValue() {
|
||||||
|
this.internal = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Convertable<javax.lang.model.element.AnnotationValue, com.sun.mirror.declaration.AnnotationValue> getConvertable() {
|
||||||
|
return new ConvertAnnotationValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <F extends javax.lang.model.element.AnnotationValue> com.sun.mirror.declaration.AnnotationValue convert(F from) {
|
||||||
|
return convert(from, ConvertAnnotationValue.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
public static <T extends com.sun.mirror.declaration.AnnotationValue, F extends javax.lang.model.element.AnnotationValue> T convert(F from, Class<T> thisClass) {
|
||||||
|
return (T) new ConvertAnnotationValue(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public com.sun.mirror.declaration.AnnotationValue convertToType(AnnotationValue from) {
|
||||||
|
return convert(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AnnotationValue unwrap() {
|
||||||
|
return internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
* <p/>
|
||||||
|
* internal.getValue returns:
|
||||||
|
* * <ul><li> a wrapper class (such as {@link Integer}) for a primitive type
|
||||||
|
* <li> {@code String}
|
||||||
|
* <li> {@code TypeMirror}
|
||||||
|
* <li> {@code VariableElement} (representing an enum constant)
|
||||||
|
* <li> {@code AnnotationMirror}
|
||||||
|
* <li> {@code List<? extends AnnotationValue>}
|
||||||
|
* (representing the elements, in declared order, if the value is an array)
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @return the value
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
public Object getValue() {
|
||||||
|
Debug.implemented("Object");
|
||||||
|
Object ret = internal.getValue();
|
||||||
|
if (ret instanceof VariableElement && ((VariableElement) ret).getKind() == ElementKind.ENUM_CONSTANT)
|
||||||
|
ret = ConvertDeclaration.convert((VariableElement) ret);
|
||||||
|
else if (ret instanceof javax.lang.model.element.AnnotationMirror)
|
||||||
|
ret = ConvertAnnotationMirror.convert((javax.lang.model.element.AnnotationMirror) ret);
|
||||||
|
else if (ret instanceof javax.lang.model.type.TypeMirror)
|
||||||
|
ret = ConvertTypeMirror.convert((javax.lang.model.type.TypeMirror) ret);
|
||||||
|
else if (ret instanceof List)
|
||||||
|
ret = convert((List<? extends AnnotationValue>) ret);
|
||||||
|
// else, we are hoping it's a String or wrapper for a primitive type, just return it
|
||||||
|
if (Debug.debug)
|
||||||
|
System.err.println("!!!!!!!!!!!!ret: " + ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SourcePosition getPosition() {
|
||||||
|
Debug.implemented("SourcePosition");
|
||||||
|
return ConvertSourcePosition.convert(internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o instanceof javax.lang.model.element.AnnotationValue) return internal.equals(o);
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
ConvertAnnotationValue that = (ConvertAnnotationValue) o;
|
||||||
|
|
||||||
|
return internal.equals(that.internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return internal.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return internal.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.ConstructorDeclaration;
|
||||||
|
import com.sun.mirror.declaration.MethodDeclaration;
|
||||||
|
import com.sun.mirror.type.ClassType;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
import com.moparisthebest.mirror.type.ConvertTypeMirror;
|
||||||
|
|
||||||
|
import javax.lang.model.element.TypeElement;
|
||||||
|
import javax.lang.model.util.ElementFilter;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class ConvertClassDeclaration extends ConvertTypeDeclaration implements com.sun.mirror.declaration.ClassDeclaration {
|
||||||
|
|
||||||
|
protected ConvertClassDeclaration(TypeElement internalTypeElement) {
|
||||||
|
super(internalTypeElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClassType getSuperclass() {
|
||||||
|
Debug.implemented("ClassType");
|
||||||
|
if (Debug.debug) {
|
||||||
|
System.err.println("!!!!!!this" + this);
|
||||||
|
System.err.println("!!!!!!!!!!" + ConvertTypeMirror.convert(internalTypeElement.getSuperclass(), ClassType.class));
|
||||||
|
}
|
||||||
|
//if(true) return null;
|
||||||
|
return ConvertTypeMirror.convert(internalTypeElement.getSuperclass(), ClassType.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<ConstructorDeclaration> getConstructors() {
|
||||||
|
Debug.implemented("Collection<ConstructorDeclaration>");
|
||||||
|
return convert(ElementFilter.constructorsIn(internalTypeElement.getEnclosedElements()), ConstructorDeclaration.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
public Collection<MethodDeclaration> getMethods() {
|
||||||
|
Debug.implemented("Collection<MethodDeclaration>");
|
||||||
|
return (Collection<MethodDeclaration>) super.getMethods();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import javax.lang.model.element.ExecutableElement;
|
||||||
|
|
||||||
|
public class ConvertConstructorDeclaration extends ConvertExecutableDeclaration implements com.sun.mirror.declaration.ConstructorDeclaration {
|
||||||
|
|
||||||
|
protected ConvertConstructorDeclaration(ExecutableElement internalExecutableElement) {
|
||||||
|
super(internalExecutableElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
186
core/src/main/java/com/moparisthebest/mirror/declaration/ConvertDeclaration.java
Executable file
186
core/src/main/java/com/moparisthebest/mirror/declaration/ConvertDeclaration.java
Executable file
@ -0,0 +1,186 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.moparisthebest.mirror.convert.Convertable;
|
||||||
|
import com.moparisthebest.mirror.util.ConvertSourcePosition;
|
||||||
|
import com.sun.mirror.declaration.AnnotationMirror;
|
||||||
|
import com.sun.mirror.declaration.Declaration;
|
||||||
|
import com.sun.mirror.util.DeclarationVisitor;
|
||||||
|
import com.sun.mirror.util.SourcePosition;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.lang.model.element.*;
|
||||||
|
import javax.lang.model.util.Elements;
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class ConvertDeclaration extends Convertable<Element, Declaration> implements com.sun.mirror.declaration.Declaration {
|
||||||
|
|
||||||
|
public static Elements elements = null;
|
||||||
|
protected final javax.lang.model.element.Element internalElement;
|
||||||
|
|
||||||
|
protected ConvertDeclaration(Element internalElement) {
|
||||||
|
this.internalElement = internalElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ConvertDeclaration() {
|
||||||
|
this.internalElement = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Convertable<javax.lang.model.element.Element, com.sun.mirror.declaration.Declaration> getConvertable() {
|
||||||
|
return new ConvertDeclaration();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <F extends Element> com.sun.mirror.declaration.Declaration convert(F from) {
|
||||||
|
return convert(from, ConvertDeclaration.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
public static <T extends com.sun.mirror.declaration.Declaration, F extends Element> T convert(F from, Class<T> thisClass) {
|
||||||
|
//Debug.implemented("kind: "+from.getKind()+" class: "+from.getClass());
|
||||||
|
/*
|
||||||
|
why not instanceof ? in short, it doesn't work all the time
|
||||||
|
straight from the javadocs:
|
||||||
|
|
||||||
|
To implement operations based on the class of an Element object,
|
||||||
|
either use a visitor or use the result of the getKind() method.
|
||||||
|
Using instanceof is not necessarily a reliable idiom for determining
|
||||||
|
the effective class of an object in this modeling hierarchy since an
|
||||||
|
implementation may choose to have a single object implement multiple
|
||||||
|
Element subinterfaces.
|
||||||
|
*/
|
||||||
|
if (from == null)
|
||||||
|
return null;
|
||||||
|
switch (from.getKind()) {
|
||||||
|
// TypeElement
|
||||||
|
case ENUM:
|
||||||
|
return (T) new ConvertEnumDeclaration((TypeElement) from);
|
||||||
|
case CLASS:
|
||||||
|
return (T) new ConvertClassDeclaration((TypeElement) from);
|
||||||
|
case INTERFACE:
|
||||||
|
return (T) new ConvertInterfaceDeclaration((TypeElement) from);
|
||||||
|
|
||||||
|
// ExecutableElement
|
||||||
|
case CONSTRUCTOR:
|
||||||
|
return (T) new ConvertConstructorDeclaration((ExecutableElement) from);
|
||||||
|
case METHOD:
|
||||||
|
return (T) new ConvertMethodDeclaration((ExecutableElement) from);
|
||||||
|
|
||||||
|
// TypeElement OR ExecutableElement
|
||||||
|
case ANNOTATION_TYPE:
|
||||||
|
//System.err.println("KIND: "+from.getKind());
|
||||||
|
if (from instanceof TypeElement)
|
||||||
|
return (T) new ConvertAnnotationTypeDeclaration((TypeElement) from);
|
||||||
|
else if (from instanceof ExecutableElement)
|
||||||
|
return (T) new ConvertAnnotationTypeElementDeclaration((ExecutableElement) from);
|
||||||
|
|
||||||
|
//PackageElement
|
||||||
|
case PACKAGE:
|
||||||
|
return (T) new ConvertPackageDeclaration((PackageElement) from);
|
||||||
|
|
||||||
|
// TypeParameterElement
|
||||||
|
case TYPE_PARAMETER:
|
||||||
|
return (T) new ConvertTypeParameterDeclaration((TypeParameterElement) from);
|
||||||
|
|
||||||
|
// VariableElement
|
||||||
|
case ENUM_CONSTANT:
|
||||||
|
return (T) new ConvertEnumConstantDeclaration((VariableElement) from);
|
||||||
|
case PARAMETER:
|
||||||
|
return (T) new ConvertParameterDeclaration((VariableElement) from);
|
||||||
|
case FIELD:
|
||||||
|
return (T) new ConvertFieldDeclaration((VariableElement) from);
|
||||||
|
default:
|
||||||
|
System.err.println("FATAL ERROR, REACHED DEFAULT!");
|
||||||
|
System.exit(1);
|
||||||
|
//throw new RuntimeException("FATAL ERROR, REACHED DEFAULT!");
|
||||||
|
}
|
||||||
|
// shouldn't ever get here
|
||||||
|
return (T) new ConvertDeclaration(from);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Declaration convertToType(Element from) {
|
||||||
|
return convert(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Element unwrap() {
|
||||||
|
return internalElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(DeclarationVisitor v) {
|
||||||
|
Debug.notimplemented("void"); //todo: implement ConvertDeclaration.accept
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<AnnotationMirror> getAnnotationMirrors() {
|
||||||
|
return ConvertAnnotationMirror.getConvertable().convert(internalElement.getAnnotationMirrors());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<com.sun.mirror.declaration.Modifier> getModifiers() {
|
||||||
|
return Convertable.convertEnums(internalElement.getModifiers(), com.sun.mirror.declaration.Modifier.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
|
||||||
|
return internalElement.getAnnotation(annotationType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSimpleName() {
|
||||||
|
return internalElement.getSimpleName().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDocComment() {
|
||||||
|
return null; // not supported
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SourcePosition getPosition() {
|
||||||
|
Debug.implemented("SourcePosition");
|
||||||
|
return ConvertSourcePosition.convert(internalElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o instanceof javax.lang.model.element.Element) return internalElement.equals(o);
|
||||||
|
if (o == null || !(o instanceof ConvertDeclaration)) return false;
|
||||||
|
|
||||||
|
ConvertDeclaration that = (ConvertDeclaration) o;
|
||||||
|
|
||||||
|
return internalElement.equals(that.internalElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return internalElement.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return internalElement.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.EnumDeclaration;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.lang.model.element.VariableElement;
|
||||||
|
|
||||||
|
public class ConvertEnumConstantDeclaration extends ConvertFieldDeclaration implements com.sun.mirror.declaration.EnumConstantDeclaration {
|
||||||
|
|
||||||
|
protected ConvertEnumConstantDeclaration(VariableElement internalVariableElement) {
|
||||||
|
super(internalVariableElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumDeclaration getDeclaringType() {
|
||||||
|
Debug.notimplemented("EnumDeclaration"); //todo: implement ConvertEnumConstantDeclaration.getDeclaringType
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.EnumConstantDeclaration;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.lang.model.element.TypeElement;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class ConvertEnumDeclaration extends ConvertClassDeclaration implements com.sun.mirror.declaration.EnumDeclaration {
|
||||||
|
|
||||||
|
protected ConvertEnumDeclaration(TypeElement internalTypeElement) {
|
||||||
|
super(internalTypeElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<EnumConstantDeclaration> getEnumConstants() {
|
||||||
|
Debug.notimplemented("Collection<EnumConstantDeclaration>"); //todo: implement ConvertEnumDeclaration.getEnumConstants
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
import com.moparisthebest.mirror.type.ConvertTypeMirror;
|
||||||
|
import com.sun.mirror.declaration.ParameterDeclaration;
|
||||||
|
import com.sun.mirror.declaration.TypeParameterDeclaration;
|
||||||
|
import com.sun.mirror.type.ReferenceType;
|
||||||
|
|
||||||
|
import javax.lang.model.element.ExecutableElement;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class ConvertExecutableDeclaration extends ConvertMemberDeclaration implements com.sun.mirror.declaration.ExecutableDeclaration {
|
||||||
|
|
||||||
|
protected final ExecutableElement internalExecutableElement;
|
||||||
|
|
||||||
|
protected ConvertExecutableDeclaration(ExecutableElement internalExecutableElement) {
|
||||||
|
super(internalExecutableElement);
|
||||||
|
this.internalExecutableElement = internalExecutableElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVarArgs() {
|
||||||
|
return internalExecutableElement.isVarArgs();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<TypeParameterDeclaration> getFormalTypeParameters() {
|
||||||
|
Debug.implemented("Collection<TypeParameterDeclaration>");
|
||||||
|
return convert(internalExecutableElement.getTypeParameters(), TypeParameterDeclaration.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<ParameterDeclaration> getParameters() {
|
||||||
|
Debug.implemented("Collection<ParameterDeclaration>");
|
||||||
|
return convert(internalExecutableElement.getParameters(), ParameterDeclaration.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<ReferenceType> getThrownTypes() {
|
||||||
|
Debug.implemented("Collection<ReferenceType>");
|
||||||
|
return ConvertTypeMirror.getConvertable().convert(internalExecutableElement.getThrownTypes(), ReferenceType.class);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
import com.moparisthebest.mirror.type.ConvertTypeMirror;
|
||||||
|
import com.sun.mirror.type.TypeMirror;
|
||||||
|
|
||||||
|
import javax.lang.model.element.ExecutableElement;
|
||||||
|
import javax.lang.model.element.VariableElement;
|
||||||
|
|
||||||
|
public class ConvertFieldDeclaration extends ConvertMemberDeclaration implements com.sun.mirror.declaration.FieldDeclaration {
|
||||||
|
|
||||||
|
protected final VariableElement internalVariableElement;
|
||||||
|
|
||||||
|
protected ConvertFieldDeclaration(VariableElement internalVariableElement) {
|
||||||
|
super(internalVariableElement);
|
||||||
|
this.internalVariableElement = internalVariableElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypeMirror getType() {
|
||||||
|
return ConvertTypeMirror.convert(internalVariableElement.asType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getConstantValue() {
|
||||||
|
return internalVariableElement.getConstantValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getConstantExpression() {
|
||||||
|
Debug.notimplemented("String"); //todo: implement ConvertFieldDeclaration.getConstantExpression
|
||||||
|
if (getConstantValue() == null)
|
||||||
|
return null;
|
||||||
|
// otherwise it is a compile-time constant and we should be able to derive this
|
||||||
|
// hint: http://stackoverflow.com/questions/6373145/accessing-source-code-from-java-annotation-processor
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o instanceof ExecutableElement) return internalVariableElement.equals(o);
|
||||||
|
if (o == null || !(o instanceof ConvertFieldDeclaration)) return false;
|
||||||
|
|
||||||
|
ConvertFieldDeclaration that = (ConvertFieldDeclaration) o;
|
||||||
|
|
||||||
|
return internalVariableElement.equals(that.internalVariableElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return internalVariableElement.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return internalVariableElement.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import javax.lang.model.element.TypeElement;
|
||||||
|
|
||||||
|
public class ConvertInterfaceDeclaration extends ConvertTypeDeclaration implements com.sun.mirror.declaration.InterfaceDeclaration {
|
||||||
|
|
||||||
|
public ConvertInterfaceDeclaration(TypeElement internalTypeElement) {
|
||||||
|
super(internalTypeElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.TypeDeclaration;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.lang.model.element.Element;
|
||||||
|
import javax.lang.model.element.ElementKind;
|
||||||
|
|
||||||
|
public class ConvertMemberDeclaration extends ConvertDeclaration implements com.sun.mirror.declaration.MemberDeclaration {
|
||||||
|
|
||||||
|
public ConvertMemberDeclaration(Element internal) {
|
||||||
|
super(internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypeDeclaration getDeclaringType() {
|
||||||
|
Debug.implemented("TypeDeclaration");
|
||||||
|
Element enclosingElement = internalElement.getEnclosingElement();
|
||||||
|
if (enclosingElement == null || enclosingElement.getKind() == ElementKind.PACKAGE)
|
||||||
|
return null;
|
||||||
|
if (Debug.debug) {
|
||||||
|
System.err.printf("this: '%s' declaring type: '%s'\n", this.getClass(), convert(enclosingElement, TypeDeclaration.class).getClass());
|
||||||
|
System.err.printf("this: '%s' declaring type: '%s'\n", this, convert(enclosingElement, TypeDeclaration.class)); // todo: make sure this returns correctly
|
||||||
|
}
|
||||||
|
//return null;
|
||||||
|
return convert(enclosingElement, TypeDeclaration.class);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.sun.mirror.type.TypeMirror;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
import com.moparisthebest.mirror.type.ConvertTypeMirror;
|
||||||
|
|
||||||
|
import javax.lang.model.element.ExecutableElement;
|
||||||
|
|
||||||
|
public class ConvertMethodDeclaration extends ConvertExecutableDeclaration implements
|
||||||
|
com.sun.mirror.declaration.MethodDeclaration {
|
||||||
|
|
||||||
|
protected ConvertMethodDeclaration(ExecutableElement internalExecutableElement) {
|
||||||
|
super(internalExecutableElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypeMirror getReturnType() {
|
||||||
|
Debug.implemented("TypeMirror");
|
||||||
|
return ConvertTypeMirror.convert(internalExecutableElement.getReturnType());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.*;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.lang.model.element.Element;
|
||||||
|
import javax.lang.model.element.ElementKind;
|
||||||
|
import javax.lang.model.element.PackageElement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ConvertPackageDeclaration extends ConvertDeclaration implements com.sun.mirror.declaration.PackageDeclaration {
|
||||||
|
|
||||||
|
protected final PackageElement internalPackageElement;
|
||||||
|
|
||||||
|
protected ConvertPackageDeclaration(PackageElement internalPackageElement) {
|
||||||
|
super(internalPackageElement);
|
||||||
|
this.internalPackageElement = internalPackageElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQualifiedName() {
|
||||||
|
return internalPackageElement.getQualifiedName().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends TypeDeclaration> Collection<T> getTypeDeclarations(Class<T> type, ElementKind kind) {
|
||||||
|
// ElementFilter.typesIn(internalPackageElement.getEnclosedElements())
|
||||||
|
// only filters on types in general, we need finer granularity
|
||||||
|
List<T> ret = new ArrayList<T>();
|
||||||
|
for (Element e : internalPackageElement.getEnclosedElements())
|
||||||
|
if (e.getKind() == kind)
|
||||||
|
ret.add(convert(e, type));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<ClassDeclaration> getClasses() {
|
||||||
|
Debug.implemented("Collection<ClassDeclaration>");
|
||||||
|
return getTypeDeclarations(ClassDeclaration.class, ElementKind.CLASS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<EnumDeclaration> getEnums() {
|
||||||
|
Debug.implemented("Collection<EnumDeclaration>");
|
||||||
|
return getTypeDeclarations(EnumDeclaration.class, ElementKind.ENUM);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<InterfaceDeclaration> getInterfaces() {
|
||||||
|
Debug.implemented("Collection<InterfaceDeclaration>");
|
||||||
|
return getTypeDeclarations(InterfaceDeclaration.class, ElementKind.INTERFACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<AnnotationTypeDeclaration> getAnnotationTypes() {
|
||||||
|
Debug.implemented("Collection<AnnotationTypeDeclaration>");
|
||||||
|
return getTypeDeclarations(AnnotationTypeDeclaration.class, ElementKind.ANNOTATION_TYPE);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.*;
|
||||||
|
import com.sun.mirror.type.TypeMirror;
|
||||||
|
import com.moparisthebest.mirror.type.ConvertTypeMirror;
|
||||||
|
|
||||||
|
import javax.lang.model.element.VariableElement;
|
||||||
|
|
||||||
|
public class ConvertParameterDeclaration extends ConvertDeclaration implements ParameterDeclaration {
|
||||||
|
|
||||||
|
protected final VariableElement internalVariableElement;
|
||||||
|
|
||||||
|
protected ConvertParameterDeclaration(VariableElement internalVariableElement) {
|
||||||
|
super(internalVariableElement);
|
||||||
|
this.internalVariableElement = internalVariableElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypeMirror getType() {
|
||||||
|
return ConvertTypeMirror.convert(internalVariableElement.asType());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.*;
|
||||||
|
import com.sun.mirror.type.InterfaceType;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
import com.moparisthebest.mirror.type.ConvertTypeMirror;
|
||||||
|
|
||||||
|
import javax.lang.model.element.Element;
|
||||||
|
import javax.lang.model.element.ElementKind;
|
||||||
|
import javax.lang.model.element.TypeElement;
|
||||||
|
import javax.lang.model.util.ElementFilter;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class ConvertTypeDeclaration extends ConvertMemberDeclaration implements com.sun.mirror.declaration.TypeDeclaration {
|
||||||
|
|
||||||
|
protected final TypeElement internalTypeElement;
|
||||||
|
|
||||||
|
protected ConvertTypeDeclaration(TypeElement internalTypeElement) {
|
||||||
|
super(internalTypeElement);
|
||||||
|
this.internalTypeElement = internalTypeElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQualifiedName() {
|
||||||
|
return internalTypeElement.getQualifiedName().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PackageDeclaration getPackage() {
|
||||||
|
Debug.implemented("PackageDeclaration");
|
||||||
|
return new ConvertPackageDeclaration(elements.getPackageOf(internalTypeElement));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<TypeParameterDeclaration> getFormalTypeParameters() {
|
||||||
|
Debug.implemented("Collection<TypeParameterDeclaration>");
|
||||||
|
return convert(internalTypeElement.getTypeParameters(), TypeParameterDeclaration.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<InterfaceType> getSuperinterfaces() {
|
||||||
|
Debug.implemented("Collection<InterfaceType>");
|
||||||
|
return ConvertTypeMirror.getConvertable().convert(internalTypeElement.getInterfaces(), InterfaceType.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<FieldDeclaration> getFields() {
|
||||||
|
Debug.implemented("Collection<FieldDeclaration>");
|
||||||
|
return sort(convert(ElementFilter.fieldsIn(internalTypeElement.getEnclosedElements()), FieldDeclaration.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<? extends MethodDeclaration> getMethods() {
|
||||||
|
Debug.implemented("Collection<? extends MethodDeclaration>");
|
||||||
|
//return convert(ElementFilter.methodsIn(internalTypeElement.getEnclosedElements()), MethodDeclaration.class);
|
||||||
|
//return convert(com.moparisthebest.mirror.convert.ElementFilter.listFilter(internalTypeElement.getEnclosedElements(), Element.class, ElementKind.METHOD, ElementKind.ANNOTATION_TYPE), MethodDeclaration.class);
|
||||||
|
return sort(convert(com.moparisthebest.mirror.convert.ElementFilter.listFilter(internalTypeElement.getEnclosedElements(), Element.class, ElementKind.METHOD), MethodDeclaration.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<TypeDeclaration> getNestedTypes() {
|
||||||
|
Debug.implemented("Collection<TypeDeclaration>");
|
||||||
|
return convert(ElementFilter.typesIn(internalTypeElement.getEnclosedElements()), TypeDeclaration.class);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.declaration;
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.*;
|
||||||
|
import com.sun.mirror.type.ReferenceType;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.lang.model.element.TypeParameterElement;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class ConvertTypeParameterDeclaration extends ConvertDeclaration implements TypeParameterDeclaration {
|
||||||
|
|
||||||
|
protected final TypeParameterElement internalTypeParameterElement;
|
||||||
|
|
||||||
|
protected ConvertTypeParameterDeclaration(TypeParameterElement internalTypeParameterElement) {
|
||||||
|
super(internalTypeParameterElement);
|
||||||
|
this.internalTypeParameterElement = internalTypeParameterElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Declaration getOwner() {
|
||||||
|
return new ConvertDeclaration(internalTypeParameterElement.getGenericElement());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<ReferenceType> getBounds() {
|
||||||
|
Debug.notimplemented("Collection<ReferenceType>"); //todo: implement ConvertTypeParameterDeclaration.getBounds
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
93
core/src/main/java/com/moparisthebest/mirror/log/Debug.java
Executable file
93
core/src/main/java/com/moparisthebest/mirror/log/Debug.java
Executable file
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.log;
|
||||||
|
|
||||||
|
import com.moparisthebest.mirror.util.ConvertTypes;
|
||||||
|
|
||||||
|
public class Debug {
|
||||||
|
|
||||||
|
public static final byte debugLevel = 0;//6; // set to 0 to disable debugging
|
||||||
|
public static final boolean debug = (debugLevel > 0);
|
||||||
|
|
||||||
|
public static boolean implemented = false;
|
||||||
|
public static boolean notimplemented = true;
|
||||||
|
|
||||||
|
public static final String IMPLEMENTED = "implemented!";
|
||||||
|
public static final String NOT_IMPLEMENTED = "NOT implemented!!!!!!!!!!!!!!!!!!!!";
|
||||||
|
|
||||||
|
// don't touch
|
||||||
|
private static final String thisClassName = Debug.class.getName();
|
||||||
|
|
||||||
|
private static void printInfo(String msg, String returnType) {
|
||||||
|
printInfo(msg, returnType, debugLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printInfo(String msg, String returnType, byte debugLevel) {
|
||||||
|
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||||
|
//todo increment until out of this class
|
||||||
|
int x = 2; // start at 3
|
||||||
|
while (thisClassName.equals(stackTrace[++x].getClassName())) ;
|
||||||
|
printStackTrace(stackTrace[x], msg, returnType);
|
||||||
|
int level = x + debugLevel;
|
||||||
|
StringBuilder tabs = new StringBuilder();
|
||||||
|
while (++x < level && x < stackTrace.length)
|
||||||
|
printStackTrace(stackTrace[x], "Called", tabs.append('\t').toString());
|
||||||
|
//printStackTrace(stackTrace[x+3], "Called", "\t\t");
|
||||||
|
//System.exit(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void printStackTrace(StackTraceElement ste, String msg, String returnType) {
|
||||||
|
System.err.printf("%s %s.%s(%s:%d) %s\n",
|
||||||
|
returnType,
|
||||||
|
ste.getClassName().replaceFirst(".*\\.", "")
|
||||||
|
, ste.getMethodName(),
|
||||||
|
ste.getFileName(), ste.getLineNumber(),
|
||||||
|
msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void implemented() {
|
||||||
|
implemented((String) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void notimplemented() {
|
||||||
|
notimplemented((String) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void implemented(Class returnType) {
|
||||||
|
implemented(returnType.getSimpleName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void notimplemented(Class returnType) {
|
||||||
|
notimplemented(returnType.getSimpleName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void implemented(String returnType) {
|
||||||
|
if (debug && implemented)
|
||||||
|
printInfo(IMPLEMENTED, returnType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void notimplemented(String returnType) {
|
||||||
|
if (debug && notimplemented)
|
||||||
|
printInfo(NOT_IMPLEMENTED, returnType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new ConvertTypes(null).getTypeVariable(null);
|
||||||
|
}
|
||||||
|
}
|
37
core/src/main/java/com/moparisthebest/mirror/type/ConvertAnnotationType.java
Executable file
37
core/src/main/java/com/moparisthebest/mirror/type/ConvertAnnotationType.java
Executable file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.type;
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.lang.model.type.DeclaredType;
|
||||||
|
|
||||||
|
public class ConvertAnnotationType extends ConvertInterfaceType implements com.sun.mirror.type.AnnotationType {
|
||||||
|
|
||||||
|
protected ConvertAnnotationType(DeclaredType internal) {
|
||||||
|
super(internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AnnotationTypeDeclaration getDeclaration() {
|
||||||
|
Debug.implemented("AnnotationTypeDeclaration");
|
||||||
|
return (AnnotationTypeDeclaration) super.getDeclaration();
|
||||||
|
}
|
||||||
|
}
|
36
core/src/main/java/com/moparisthebest/mirror/type/ConvertArrayType.java
Executable file
36
core/src/main/java/com/moparisthebest/mirror/type/ConvertArrayType.java
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.type;
|
||||||
|
|
||||||
|
import com.sun.mirror.type.TypeMirror;
|
||||||
|
|
||||||
|
public class ConvertArrayType extends ConvertReferenceType implements com.sun.mirror.type.ArrayType {
|
||||||
|
|
||||||
|
protected final javax.lang.model.type.ArrayType internalArrayType;
|
||||||
|
|
||||||
|
protected ConvertArrayType(javax.lang.model.type.ArrayType internalArrayType) {
|
||||||
|
super(internalArrayType);
|
||||||
|
this.internalArrayType = internalArrayType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypeMirror getComponentType() {
|
||||||
|
return new ConvertTypeMirror(internalArrayType.getComponentType());
|
||||||
|
}
|
||||||
|
}
|
52
core/src/main/java/com/moparisthebest/mirror/type/ConvertClassType.java
Executable file
52
core/src/main/java/com/moparisthebest/mirror/type/ConvertClassType.java
Executable file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.type;
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.ClassDeclaration;
|
||||||
|
import com.sun.mirror.type.ClassType;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.lang.model.type.DeclaredType;
|
||||||
|
import javax.lang.model.type.TypeKind;
|
||||||
|
import javax.lang.model.type.TypeMirror;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ConvertClassType extends ConvertDeclaredType implements com.sun.mirror.type.ClassType {
|
||||||
|
|
||||||
|
protected ConvertClassType(DeclaredType internal) {
|
||||||
|
super(internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClassDeclaration getDeclaration() {
|
||||||
|
Debug.implemented("ClassDeclaration");
|
||||||
|
return (ClassDeclaration) super.getDeclaration();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClassType getSuperclass() {
|
||||||
|
Debug.implemented("ClassType");
|
||||||
|
List<? extends TypeMirror> superTypes = types.directSupertypes(this.internalDeclaredType);
|
||||||
|
if (Debug.debug)
|
||||||
|
System.out.println("superTypes: " + superTypes);
|
||||||
|
if (superTypes.isEmpty() || superTypes.get(0).getKind() != TypeKind.DECLARED)
|
||||||
|
return null;
|
||||||
|
return new ConvertClassType((DeclaredType) superTypes.get(0));
|
||||||
|
}
|
||||||
|
}
|
62
core/src/main/java/com/moparisthebest/mirror/type/ConvertDeclaredType.java
Executable file
62
core/src/main/java/com/moparisthebest/mirror/type/ConvertDeclaredType.java
Executable file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.type;
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.TypeDeclaration;
|
||||||
|
import com.sun.mirror.type.InterfaceType;
|
||||||
|
import com.sun.mirror.type.TypeMirror;
|
||||||
|
import com.moparisthebest.mirror.declaration.ConvertDeclaration;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.lang.model.type.DeclaredType;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class ConvertDeclaredType extends ConvertReferenceType implements com.sun.mirror.type.DeclaredType {
|
||||||
|
|
||||||
|
protected final javax.lang.model.type.DeclaredType internalDeclaredType;
|
||||||
|
|
||||||
|
protected ConvertDeclaredType(DeclaredType internalDeclaredType) {
|
||||||
|
super(internalDeclaredType);
|
||||||
|
this.internalDeclaredType = internalDeclaredType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypeDeclaration getDeclaration() {
|
||||||
|
Debug.implemented("TypeDeclaration");
|
||||||
|
return ConvertDeclaration.convert(internalDeclaredType.asElement(), TypeDeclaration.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public com.sun.mirror.type.DeclaredType getContainingType() {
|
||||||
|
Debug.notimplemented("DeclaredType"); //todo: implement ConvertDeclaredType.getContainingType
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<TypeMirror> getActualTypeArguments() {
|
||||||
|
Debug.implemented("Collection<TypeMirror>");
|
||||||
|
return convert(internalDeclaredType.getTypeArguments(), TypeMirror.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<InterfaceType> getSuperinterfaces() {
|
||||||
|
Debug.notimplemented("Collection<InterfaceType>"); //todo: implement ConvertDeclaredType.getSuperinterfaces
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
38
core/src/main/java/com/moparisthebest/mirror/type/ConvertEnumType.java
Executable file
38
core/src/main/java/com/moparisthebest/mirror/type/ConvertEnumType.java
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.type;
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.EnumDeclaration;
|
||||||
|
import com.sun.mirror.type.EnumType;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.lang.model.type.DeclaredType;
|
||||||
|
|
||||||
|
public class ConvertEnumType extends ConvertClassType implements EnumType {
|
||||||
|
|
||||||
|
protected ConvertEnumType(DeclaredType internal) {
|
||||||
|
super(internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumDeclaration getDeclaration() {
|
||||||
|
Debug.implemented("EnumDeclaration");
|
||||||
|
return (EnumDeclaration) super.getDeclaration();
|
||||||
|
}
|
||||||
|
}
|
37
core/src/main/java/com/moparisthebest/mirror/type/ConvertInterfaceType.java
Executable file
37
core/src/main/java/com/moparisthebest/mirror/type/ConvertInterfaceType.java
Executable file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.type;
|
||||||
|
|
||||||
|
import com.sun.mirror.declaration.InterfaceDeclaration;
|
||||||
|
import com.moparisthebest.mirror.log.Debug;
|
||||||
|
|
||||||
|
import javax.lang.model.type.DeclaredType;
|
||||||
|
|
||||||
|
public class ConvertInterfaceType extends ConvertDeclaredType implements com.sun.mirror.type.InterfaceType {
|
||||||
|
|
||||||
|
protected ConvertInterfaceType(DeclaredType internal) {
|
||||||
|
super(internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InterfaceDeclaration getDeclaration() {
|
||||||
|
Debug.implemented("InterfaceDeclaration");
|
||||||
|
return (InterfaceDeclaration) super.getDeclaration();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.type;
|
||||||
|
|
||||||
|
import javax.lang.model.type.TypeMirror;
|
||||||
|
|
||||||
|
public class ConvertMirroredTypeException extends com.sun.mirror.type.MirroredTypeException {
|
||||||
|
|
||||||
|
protected ConvertMirroredTypeException(TypeMirror type) {
|
||||||
|
super(new ConvertTypeMirror(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* aptIn16 - Apt implementation with Java 6 annotation processors.
|
||||||
|
* Copyright (C) 2012 Travis Burtrum (moparisthebest)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published y
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.moparisthebest.mirror.type;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ConvertMirroredTypesException extends com.sun.mirror.type.MirroredTypesException {
|
||||||
|
|
||||||
|
protected ConvertMirroredTypesException(List<? extends javax.lang.model.type.TypeMirror> types) {
|
||||||
|
super(ConvertTypeMirror.getConvertable().convert(types));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user