This commit was manufactured by cvs2svn to create tag 'v_556'.
Sprout from master 2005-05-12 14:18:58 UTC Philipe Mulet <pmulet> '94928'
Cherrypick from master 2005-05-12 19:13:34 UTC Olivier Thomann <oliviert> 'HEAD - Fix html tag errors (line 112, 113 and 200)':
org.eclipse.jdt.core/buildnotes_jdt-core.html
Delete:
org.eclipse.jdt.apt.core/.classpath
org.eclipse.jdt.apt.core/.cvsignore
org.eclipse.jdt.apt.core/.project
org.eclipse.jdt.apt.core/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jdt.apt.core/build.properties
org.eclipse.jdt.apt.core/howtobuildme.txt
org.eclipse.jdt.apt.core/plugin.xml
org.eclipse.jdt.apt.core/schema/annotationProcessorFactory.exsd
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/AptPlugin.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EclipseAnnotationProcessorEnvironment.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EclipseAnnotationProcessorFactory.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EnvironmentFactory.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/APTDispatch.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AnnotationProcessorFactoryLoader.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/BuildListener.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/EclipseMirrorImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/NonEclipseImplementationException.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationElementDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationMirrorImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationValueImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/BinaryParameterDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ClassDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ConstructorDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/DeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EnumConstantDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EnumDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ExecutableDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/FieldDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/IEclipseAnnotationValue.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/InterfaceDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MemberDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MethodDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/PackageDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/PackageDeclarationImplNoBinding.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ParameterDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/SourceParameterDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/TypeDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/TypeParameterDeclarationImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/AnnotationInvocationHandler.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/EclipseRoundCompleteEvent.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/FilerImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/JavaSourceFilePrintWriter.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/MessagerImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ProcessorEnvImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/FileGenerationResult.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileManager.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/ResourceChangedListener.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/ArrayTypeImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/ErrorType.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/PrimitiveTypeImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/VoidTypeImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/WildcardTypeImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/DeclarationsUtil.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/Factory.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FileSystemUtil.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/PackageUtil.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/SourcePositionImpl.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/TypesUtil.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/AptUtil.java
org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/EclipseMessager.java
org.eclipse.jdt.apt.tests/.classpath
org.eclipse.jdt.apt.tests/.cvsignore
org.eclipse.jdt.apt.tests/.project
org.eclipse.jdt.apt.tests/.settings/org.eclipse.jdt.core.prefs
org.eclipse.jdt.apt.tests/build.properties
org.eclipse.jdt.apt.tests/plugin.xml
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptReconcileTests.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorTests.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestAll.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestUtil.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotation.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotationProcessor.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotationProcessorFactory.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotation.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotationProcessor.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotationProcessorFactory.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/CodeExample.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotation.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotationProcessor.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotationProcessorFactory.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotation.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotationProcessor.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotationProcessorFactory.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotation.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotationProcessor.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotationProcessorFactory.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/jdtcoretests/AllJdtCoreTests.java
org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/plugin/AptTestsPlugin.java
diff --git a/org.eclipse.jdt.apt.core/.classpath b/org.eclipse.jdt.apt.core/.classpath
deleted file mode 100644
index 819c742..0000000
--- a/org.eclipse.jdt.apt.core/.classpath
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src">
- <attributes>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <attributes>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JRE 1.5.0">
- <attributes>
- </attributes>
- </classpathentry>
- <classpathentry exported="true" kind="lib" path="tools.jar">
- <attributes>
- </attributes>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jdt.apt.core/.cvsignore b/org.eclipse.jdt.apt.core/.cvsignore
deleted file mode 100755
index 1fe7c80..0000000
--- a/org.eclipse.jdt.apt.core/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-bin
-tools.jar
\ No newline at end of file
diff --git a/org.eclipse.jdt.apt.core/.project b/org.eclipse.jdt.apt.core/.project
deleted file mode 100644
index e57b7ab..0000000
--- a/org.eclipse.jdt.apt.core/.project
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.apt.core</name>
- <comment></comment>
- <projects>
- <project>cvs.org.eclipse.jdt.core</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.jdt.apt.core/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jdt.apt.core/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 5b7096a..0000000
--- a/org.eclipse.jdt.apt.core/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,53 +0,0 @@
-#Fri Apr 08 14:53:22 PDT 2005
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/org.eclipse.jdt.apt.core/build.properties b/org.eclipse.jdt.apt.core/build.properties
deleted file mode 100644
index c95d071..0000000
--- a/org.eclipse.jdt.apt.core/build.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-jars.compile.order = aptcore.jar
-source.aptcore.jar = src/
-output.aptcore.jar = bin/
-bin.includes = plugin.xml,\
- aptcore.jar,\
- tools.jar
-src.includes = tools.jar,\
- plugin.xml
diff --git a/org.eclipse.jdt.apt.core/howtobuildme.txt b/org.eclipse.jdt.apt.core/howtobuildme.txt
deleted file mode 100644
index a723032..0000000
--- a/org.eclipse.jdt.apt.core/howtobuildme.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-Building org.eclipse.jdt.apt.core:
-
-1. Requires JDK 1.5.
-2. In Eclipse, add a JRE entry for 1.5, named exactly "JRE 1.5.0". This name is referred to in the .classpath file.
-3. Requires tools.jar, from the 1.5 JDK lib directory, to be copied into the project root.
diff --git a/org.eclipse.jdt.apt.core/plugin.xml b/org.eclipse.jdt.apt.core/plugin.xml
deleted file mode 100644
index 56d00fc..0000000
--- a/org.eclipse.jdt.apt.core/plugin.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.jdt.apt.core"
- name="Annotation Processing Support Plug-in"
- version="1.0.0"
- provider-name="">
-
- <runtime>
- <library name="aptcore.jar">
- <export name="*"/>
- </library>
- <library name="tools.jar">
- <export name="*"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.jdt.core"/>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.core.resources"/>
- <!-- don't need to import 'org.eclipse.ui.editors'.
- This is here so I could read the source code for debugging. -->
- <import plugin="org.eclipse.ui.editors"/>
- </requires>
-
-<!-- =================================================================================== -->
-<!-- Extension Point: Annotation Processor Factories -->
-<!-- =================================================================================== -->
-
-<extension-point
- id="annotationProcessorFactory"
- name="Annotation Processor Factories"
- schema="schema/annotationProcessorFactory.exsd"/>
-
-<!-- =================================================================================== -->
-<!-- Extension: Marker posted during reconcile -->
-<!-- =================================================================================== -->
-<extension
- id="reconcile_marker"
- point="org.eclipse.core.resources.markers"
- name="APT Reconcile-time Marker">
- <super type="org.eclipse.core.resources.problemmarker"/>
- <super type="org.eclipse.core.resources.textmarker"/>
- <persistent value="false"/>
-</extension>
-<!-- =================================================================================== -->
-<!-- Extension: Marker posted during build -->
-<!-- =================================================================================== -->
-<extension
- id="build_marker"
- name="APT Build-time Marker"
- point="org.eclipse.core.resources.markers">
- <super type="org.eclipse.core.resources.problemmarker"/>
- <super type="org.eclipse.core.resources.textmarker"/>
- <persistent value="true"/>
-</extension>
-
-<!-- =================================================================================== -->
-<!-- Extension: Compilation Participant -->
-<!-- =================================================================================== -->
-<extension
- id="apt"
- name="Annotation Processing"
- point="org.eclipse.jdt.core.compilationParticipant">
- <compilationParticipant
- class="org.eclipse.jdt.apt.core.internal.BuildListener"
- eventMask="0xff"/>
-</extension>
-
-</plugin>
diff --git a/org.eclipse.jdt.apt.core/schema/annotationProcessorFactory.exsd b/org.eclipse.jdt.apt.core/schema/annotationProcessorFactory.exsd
deleted file mode 100644
index 75deec9..0000000
--- a/org.eclipse.jdt.apt.core/schema/annotationProcessorFactory.exsd
+++ /dev/null
@@ -1,117 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.jdt.apt.core">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.jdt.apt.core" id="annotationProcessorFactory" name="Annotation Processor Factories"/>
- </appInfo>
- <documentation>
- [Enter description of this extension point.]
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="factory" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="factory">
- <complexType>
- <attribute name="class" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="implements" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="enableDefault" type="string" use="required">
- <annotation>
- <documentation>
- true if this processor should be enabled by default. This value
-may be overridden via the annotation processing configuration settings.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 3.1
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- Annotation processors must implement com.sun.mirror.apt.AnnotationProcessorFactory, or a subclass thereof.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
-</schema>
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/AptPlugin.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/AptPlugin.java
deleted file mode 100644
index 4a9350c..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/AptPlugin.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * wharley@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core;
-
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.BundleContext;
-
-public class AptPlugin extends Plugin {
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
- }
-
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EclipseAnnotationProcessorEnvironment.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EclipseAnnotationProcessorEnvironment.java
deleted file mode 100644
index 82592ff..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EclipseAnnotationProcessorEnvironment.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API
- *******************************************************************************/
-package org.eclipse.jdt.apt.core.env;
-
-import org.eclipse.jdt.apt.core.util.EclipseMessager;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-
-/**
- * Extended the APT {@link AnnotationProcessorEnvironment} to expose
- * extra API.
- */
-public interface EclipseAnnotationProcessorEnvironment extends
- AnnotationProcessorEnvironment
-{
- /**
- * @return the root of the fully flushed out DOM/AST of the file that is currently being processed.
- * This AST will not contain any binding information.
- */
- CompilationUnit getAST();
-
- /**
- * @return a messager for registering diagnostics.
- */
- EclipseMessager getMessager();
-
- /**
- * Add a type dependency on the type named <code>fullyQualifiedTypeName</code>
- * @param fullyQualifiedTypeName the fully qualified (dot-separated) name of a type.
- * @throws IllegalArgumentException if <code>fullyQualifiedTypeName</code> cannot be resolved to a type.
- */
- void addTypeDependency(final String fullyQualifiedTypeName);
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EclipseAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EclipseAnnotationProcessorFactory.java
deleted file mode 100644
index 2b8d476..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EclipseAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API
- *******************************************************************************/
-package org.eclipse.jdt.apt.core.env;
-
-import java.util.Set;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-/**
- * Extend the APT annotation processor factory API to provide extra features.
- * Implementation of this annotation processor is treated just like
- * the regular annotation processor during build and reconcile.
- * @author tyeung
- *
- */
-public interface EclipseAnnotationProcessorFactory extends
- AnnotationProcessorFactory
-{
- /**
- * Returns an annotation processor for a set of annotation types.
- * Implementation of this API is guaranteed to be invoked with an
- * extended annotation processor environment for both
- * {@link #getProcessorFor} version of the method.
- *
- * @param atds the set of annotation types
- * @param env the environment for processing.
- * @return an annotation processor or null if the processor cannot be created.
- */
- AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
- EclipseAnnotationProcessorEnvironment env);
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EnvironmentFactory.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EnvironmentFactory.java
deleted file mode 100644
index 650250c..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EnvironmentFactory.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.env;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-
-public class EnvironmentFactory {
-
- /**
- * @param compilationUnit the working copy for which the Environment object is to be created
- * @param javaProject the java project that the working copy is in.
- * @return the created environment.
- */
-
- public static AnnotationProcessorEnvironment getEnvironment(ICompilationUnit compilationUnit, IJavaProject javaProject )
- {
- return ProcessorEnvImpl.newProcessorEnvironmentForReconcile( compilationUnit, javaProject );
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/APTDispatch.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/APTDispatch.java
deleted file mode 100644
index 855216e..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/APTDispatch.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- * mkaufman@bea.com
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.apt.core.internal.declaration.TypeDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.env.EclipseRoundCompleteEvent;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl.AnnotationVisitor;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedFileManager;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.apt.core.util.AptUtil;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.apt.AnnotationProcessorListener;
-import com.sun.mirror.apt.RoundCompleteListener;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-/**
- * Dispatch APT.
- * @author tyeung
- *
- */
-public class APTDispatch {
-
- public static APTResult runAPTDuringBuild(
- final List<AnnotationProcessorFactory> factories, IFile file,
- IJavaProject javaProj) {
-
- //
- // bail-out early if there aren't factories, or if there aren't any annotation instances
- //
- if ( factories == null || factories.size() == 0 || ! AptUtil.hasAnnotationInstance( file ) )
- {
- if ( DEBUG ) trace( "runAPTDuringBuild: leaving early because there are no factories or annotation instances");
- Set<IFile> deletedFiles = cleanupAllGeneratedFilesForParent( file );
- if ( deletedFiles.size() == 0 )
- return EMPTY_APT_RESULT;
- else
- return new APTResult( (Set<IFile>)Collections.emptySet(), deletedFiles, (Set<String>)Collections.emptySet() );
- }
-
- ProcessorEnvImpl processorEnv = ProcessorEnvImpl
- .newProcessorEnvironmentForBuild( file, javaProj);
- APTResult result = runAPT(factories, processorEnv);
- return result;
- }
-
- /**
- * Run annnotation processing.
- * @param factories the list of annotation processor factories to be run.
- * @return the set of files that need to be compiled.
- */
- public static APTResult runAPTDuringReconcile(
- final List<AnnotationProcessorFactory> factories,
- ICompilationUnit compilationUnit, IJavaProject javaProj) {
-
- //
- // bail-out early if there aren't factories or if there arent any annotation instances
- //
- if ( factories == null || factories.size() == 0 || ! AptUtil.hasAnnotationInstance( compilationUnit ))
- {
- if ( DEBUG ) trace( "runAPTDuringReconcile: leaving early because there are no factories or annotation instances");
- cleanupAllGeneratedFilesForParent( (IFile)compilationUnit.getResource() );
- return EMPTY_APT_RESULT;
- }
-
- ProcessorEnvImpl processorEnv = ProcessorEnvImpl
- .newProcessorEnvironmentForReconcile(compilationUnit, javaProj);
- return runAPT(factories, processorEnv);
- }
-
- private static APTResult runAPT(
- final List<AnnotationProcessorFactory> factories,
- final ProcessorEnvImpl processorEnv)
- {
- try {
- if (factories.size() == 0)
- {
- if ( DEBUG ) trace( "runAPT: leaving early because there are no factories");
- return EMPTY_APT_RESULT;
- }
-
- if ( ! processorEnv.getFile().exists() )
- {
- if ( DEBUG ) trace( "runAPT: leaving early because file doesn't exist");
- return EMPTY_APT_RESULT;
- }
-
- // clear out all the markers from the previous round.
- final String markerType = processorEnv.getPhase() == ProcessorEnvImpl.Phase.RECONCILE ? ProcessorEnvImpl.RECONCILE_MARKER
- : ProcessorEnvImpl.BUILD_MARKER;
- try {
- processorEnv.getFile().deleteMarkers(markerType, true,
- IResource.DEPTH_INFINITE);
-
- } catch (CoreException e) {
- throw new IllegalStateException(e);
- }
- final Map<String, AnnotationTypeDeclaration> annotationDecls = getAnnotationTypeDeclarations(
- processorEnv.getAstCompilationUnit(), processorEnv);
-
- if (annotationDecls.isEmpty())
- {
- if ( DEBUG ) trace ( "runAPT: leaving early because annotationDecls is empty" );
- return EMPTY_APT_RESULT;
- }
-
- GeneratedFileManager gfm = GeneratedFileManager.getGeneratedFileManager( processorEnv.getJavaProject().getProject() );
- Set<IFile> lastGeneratedFiles = gfm.getGeneratedFilesForParent( processorEnv.getFile() );
-
- for (int i = 0, size = factories.size(); i < size; i++) {
- final AnnotationProcessorFactory factory = (AnnotationProcessorFactory) factories
- .get(i);
- final Set<AnnotationTypeDeclaration> factoryDecls = getAnnotations(
- factory, annotationDecls);
-
- if (factoryDecls != null && factoryDecls.size() > 0) {
- final AnnotationProcessor processor = factory
- .getProcessorFor(factoryDecls, processorEnv);
- if (processor != null)
- {
- if ( DEBUG ) trace( "runAPT: invoking processor " + processor.getClass().getName() );
- processor.process();
- }
- }
-
- if (annotationDecls.isEmpty())
- break;
- }
- // TODO: (theodora) log unclaimed annotations.
-
- // notify the processor listeners
- final Set<AnnotationProcessorListener> listeners = processorEnv
- .getProcessorListeners();
- for (AnnotationProcessorListener listener : listeners) {
- EclipseRoundCompleteEvent event = null;
- if (listener instanceof RoundCompleteListener) {
- if (event == null)
- event = new EclipseRoundCompleteEvent(processorEnv);
- final RoundCompleteListener rcListener = (RoundCompleteListener) listener;
- rcListener.roundComplete(event);
- }
- }
-
- final Set<IFile> allGeneratedFiles = new HashSet<IFile>();
- Set<IFile> modifiedFiles = new HashSet<IFile>();
- Map<IFile, Boolean> filesMap = processorEnv.getGeneratedFiles();
- for (Map.Entry<IFile, Boolean> entry : filesMap.entrySet()) {
- allGeneratedFiles.add(entry.getKey());
- if (entry.getValue()) {
- modifiedFiles.add(entry.getKey());
- }
- }
-
- // any files that were generated for this parent on the last
- // run, but are no longer generated should be removed
- Set<IFile> deletedFiles = cleanupNoLongerGeneratedFiles( processorEnv.getFile(), lastGeneratedFiles, allGeneratedFiles, gfm );
-
- APTResult result = new APTResult( modifiedFiles, deletedFiles, processorEnv.getTypeDependencies() );
- processorEnv.close();
- return result;
-
- // log unclaimed annotations.
- } catch (Throwable t) {
- t.printStackTrace();
- }
- return EMPTY_APT_RESULT;
- }
-
- private static Set<IFile> cleanupAllGeneratedFilesForParent( IFile parent )
- {
- GeneratedFileManager gfm = GeneratedFileManager.getGeneratedFileManager( parent.getProject() );
- Set<IFile> lastGeneratedFiles = gfm.getGeneratedFilesForParent( parent );
- return cleanupNoLongerGeneratedFiles( parent, lastGeneratedFiles, (Set<IFile>)Collections.emptySet(), gfm );
- }
-
- private static Set<IFile> cleanupNoLongerGeneratedFiles(
- IFile parent, Set<IFile> lastGeneratedFiles, Set<IFile> newGeneratedFiles,
- GeneratedFileManager gfm )
- {
- HashSet<IFile> deletedFiles = new HashSet<IFile>();
- for ( IFile f : lastGeneratedFiles )
- {
- if ( ! newGeneratedFiles.contains( f ) )
- {
- if ( DEBUG ) trace ( "runAPT: File " + f + " is no longer a generated file for " + parent );
- try
- {
- if ( gfm.deleteGeneratedFile( f, parent, null ) )
- deletedFiles.add( f );
- }
- catch ( CoreException ce )
- {
- // TODO - handle this exception nicely
- ce.printStackTrace();
- }
- }
- }
- return deletedFiles;
- }
-
- /**
- * invoking annotation processors respecting apt semantics.
- */
- private static void checkAnnotations(
- final List<AnnotationProcessorFactory> factories,
- final Map<String, AnnotationTypeDeclaration> declarations,
- final ProcessorEnvImpl env) {
- for (int i = 0, size = factories.size(); i < size; i++) {
- final AnnotationProcessorFactory factory = (AnnotationProcessorFactory) factories
- .get(i);
- final Set<AnnotationTypeDeclaration> factoryDecls = getAnnotations(
- factory, declarations);
- final AnnotationProcessor processor = factory.getProcessorFor(
- factoryDecls, env);
- processor.process();
- if (declarations.isEmpty())
- return;
- }
- // log unclaimed annotations.
- }
-
- private static Map<String, AnnotationTypeDeclaration> getAnnotationTypeDeclarations(
- CompilationUnit astCompilationUnit, ProcessorEnvImpl env) {
- final List<Annotation> instances = new ArrayList<Annotation>();
- final AnnotationVisitor visitor = new AnnotationVisitor(instances);
- astCompilationUnit.accept(new AnnotationVisitor(instances));
- final Map<String, AnnotationTypeDeclaration> decls = new HashMap<String, AnnotationTypeDeclaration>();
- for (int i = 0, size = instances.size(); i < size; i++) {
- final Annotation instance = instances.get(i);
- final ITypeBinding annoType = instance.resolveTypeBinding();
- if (annoType == null)
- continue;
- final TypeDeclarationImpl annoDecl = Factory.createReferenceType(
- annoType, env);
- if (annoDecl.kind() == EclipseMirrorImpl.MirrorKind.TYPE_ANNOTATION)
- decls.put(annoDecl.getQualifiedName(),
- (AnnotationTypeDeclaration) annoDecl);
- }
- return decls;
- }
-
- /**
- * @return the set of {@link AnnotationTypeDeclaration} that {@link #factory} supports or null
- * if the factory doesn't support any of the declarations.
- * If the factory supports "*", then the empty set will be returned
- *
- * This method will destructively modify {@link #declarations}. Entries will be removed from
- * {@link #declarations} as the declarations are being added into the returned set.
- */
- private static Set<AnnotationTypeDeclaration> getAnnotations(
- final AnnotationProcessorFactory factory,
- final Map<String, AnnotationTypeDeclaration> declarations)
-
- {
- final Collection<String> supportedTypes = factory
- .supportedAnnotationTypes();
-
- if (supportedTypes == null || supportedTypes.size() == 0)
- return Collections.emptySet();
-
- final Set<AnnotationTypeDeclaration> fDecls = new HashSet<AnnotationTypeDeclaration>();
-
- for (Iterator<String> it = supportedTypes.iterator(); it.hasNext();) {
- final String typeName = it.next();
- if (typeName.equals("*")) {
- declarations.clear();
- return Collections.emptySet();
- } else if (typeName.endsWith("*")) {
- final String prefix = typeName.substring(0,
- typeName.length() - 2);
- for (Iterator<Map.Entry<String, AnnotationTypeDeclaration>> entries = declarations
- .entrySet().iterator(); entries.hasNext();) {
- final Map.Entry<String, AnnotationTypeDeclaration> entry = entries
- .next();
- final String key = entry.getKey();
- if (key.startsWith(prefix)) {
- fDecls
- .add((AnnotationTypeDeclaration) entry
- .getValue());
- entries.remove();
- }
- }
- } else {
- final AnnotationTypeDeclaration decl = declarations
- .get(typeName);
- if (decl != null) {
- fDecls.add(decl);
- declarations.remove(typeName);
- }
- }
- }
- return fDecls.isEmpty() ? null : fDecls;
- }
-
- public static class APTResult
- {
- APTResult( Set<IFile> newFiles, Set<IFile> deletedFiles, Set<String> deps )
- {
- _newFiles = newFiles;
- _newDependencies = deps;
- _deletedFiles = deletedFiles;
- }
-
- private Set<IFile> _newFiles;
- private Set<IFile> _deletedFiles;
- private Set<String> _newDependencies;
-
- Set<IFile> getNewFiles() { return _newFiles; }
- Set<IFile> getDeletedFiles() { return _deletedFiles; }
- Set<String> getNewDependencies() { return _newDependencies; }
- }
-
- public static void trace( String s )
- {
- if (DEBUG)
- {
- System.out.println( "[" + Thread.currentThread().getName() + "][" + APTDispatch.class.getName() + "] " + s );
- System.out.flush();
- }
- }
-
- public static final APTResult EMPTY_APT_RESULT = new APTResult( (Set<IFile>)Collections.emptySet(), (Set<IFile>)Collections.emptySet(), (Set<String>)Collections.emptySet() );
-
- public static final boolean DEBUG = false;
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AnnotationProcessorFactoryLoader.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AnnotationProcessorFactoryLoader.java
deleted file mode 100644
index 1b355a7..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AnnotationProcessorFactoryLoader.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * wharley@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.Constructor;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-
-public class AnnotationProcessorFactoryLoader {
-
- private List<AnnotationProcessorFactory> _factories = new ArrayList<AnnotationProcessorFactory>();
-
- private static boolean _verboseLoad = false;
-
- /** List of jar file entries that specify autoloadable service providers */
- private static final String[] AUTOLOAD_SERVICES = {
- "META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory"
- };
-
- /**
- * Discover and instantiate annotation processor factories by searching for plugins
- * which contribute to org.eclipse.jdt.apt.core.annotationProcessorFactory.
- * This method is used when running within the Eclipse framework. When running
- * standalone at the command line, use {@link #LoadFactoriesFromJars}.
- * This method can be called repeatedly, but each time it will erase the previous
- * contents of the list and do a full rediscovery.
- */
- public void loadFactoriesFromPlugins() {
- _factories.clear();
- IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(
- "org.eclipse.jdt.apt.core", //$NON-NLS-1$ - name of plugin that exposes this extension
- "annotationProcessorFactory"); //$NON-NLS-1$ - extension id
- IExtension[] extensions = extension.getExtensions();
- // for all extensions of this point...
- for(int i = 0; i < extensions.length; i++){
- IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
- // for all config elements named "factory"
- for(int j = 0; j < configElements.length; j++){
- String elementName = configElements[j].getName();
- if (!("factory".equals(elementName))) { //$NON-NLS-1$ - name of configElement
- continue;
- }
- try {
- Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$ - attribute name
- if (execExt instanceof AnnotationProcessorFactory){
- _factories.add((AnnotationProcessorFactory)execExt);
- }
- } catch(CoreException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- /**
- * Discover and instantiate annotation processor factories by searching for jars
- * on the classpath or factorypath that specify an AnnotationProcessorFactory
- * interface in their META-INF/services directory. This method is used when
- * running standalone at the command line ("apt mode"). When running within the
- * Eclipse framework, use {@link #loadFactoriesFromPlugins()}
- * This method can be called repeatedly, but each time it will erase the previous
- * contents of the list and do a full rediscovery.
- */
- public void loadFactoriesFromJars() {
- _factories.clear();
- // TODO: get these values somehow
- final String factoryClassName = null;
- final File[] factoryPaths = new File[0];
- _loadFromJars(factoryClassName, factoryPaths);
- }
-
- /**
- * @return Returns an immutable copy of the list of annotation processor factories.
- */
- public List<AnnotationProcessorFactory> getFactories() {
- return Collections.unmodifiableList(_factories);
- }
-
- /**
- * Discover and load all annotation processor factories.
- * @param factoryClassName if specified, only this factory will be loaded.
- * @param factoryPaths if specified, this will be used instead of classpath.
- */
- private void _loadFromJars (final String factoryClassName, final File[] factoryPaths)
- {
- final long start = System.nanoTime();
- File[] jarPath;
-
- // Create an appropriate loader. If factoryPaths is set, use it; otherwise use classpath.
- ClassLoader factoryLoader = null;
- if (factoryPaths.length > 0) {
- factoryLoader = _getExtensionClassLoader(factoryPaths);
- jarPath = factoryPaths;
- }
- else {
- factoryLoader = getClass().getClassLoader();
- jarPath = new File[0]; //TODO: how can I list all jars on compile cmdline classPath?
- }
-
- // If factoryClassName is specified, load only that; otherwise search all jars.
- if( factoryClassName != null ){
- _loadFactory(factoryClassName, factoryLoader);
- return;
- }
- else {
- final Set<String> classNames = new HashSet<String>();
- for (File jar : jarPath) {
- classNames.addAll(_getServiceClassnamesFromJar(jar));
- }
- for (String className : classNames) {
- final long loadStart = System.nanoTime();
- _loadFactory(className, factoryLoader);
- if (_verboseLoad) {
- System.err.printf("\tLoading APT factory %s took %.2f seconds.",
- className, (System.nanoTime() - loadStart) / 1000000000.0);
- System.err.println();
- System.err.println();
- }
- }
- }
-
- if (_verboseLoad) {
- System.err.println();
- System.err.printf("Loading all APT factories took %.2f seconds.", (System.nanoTime() - start) / 1000000000.0);
- System.err.println();
- System.err.println();
- }
- }
-
- /**
- * Get a class loader for loading the language implementations.
- * This is only called in the command-line compile case; in
- * the plugin case, Eclipse does the loading.
- *
- * @param jars the list of jars in the autoload directory
- * @return a classloader that can be used to load services from these jars
- */
- private ClassLoader _getExtensionClassLoader(final File[] jars)
- {
- //TODO: check that this is actually creating the right classLoader, in the apt/Eclipse world.
- final ClassLoader myLoader = getClass().getClassLoader();
- if (_verboseLoad)
- System.err.println("I will create my own URL class loader to load these classes; my class loader type is \"" +
- myLoader.getClass().getName() + "\".");
- final List<URL> temp = new ArrayList<URL>(jars.length);
- for (File jar : jars) {
- try {
- final URL url = jar.toURL();
- if (_verboseLoad) System.err.println("Conversion to URL succeeded: " + url);
- temp.add(url);
- }
- catch (MalformedURLException e) {
- if (_verboseLoad) System.err.println("This URL was malformed; skipping.");
- }
- }
- final URL[] urls = temp.toArray(new URL[temp.size()]);
- final ClassLoader jarLoader = new URLClassLoader(urls, myLoader);
- return jarLoader;
- }
-
- /**
- * Given a jar file, get the names of any AnnotationProcessorFactory
- * implementations it offers. The information is based on the Sun
- * <a href="http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#Service%20Provider">
- * Jar Service Provider spec</a>: the jar file contains a META-INF/services
- * directory; that directory contains text files named according to the desired
- * interfaces; and each file contains the names of the classes implementing
- * the specified service. The files may also contain whitespace (which is to
- * be ignored). The '#' character indicates the beginning of a line comment,
- * also to be ignored. Implied but not stated in the spec is that this routine
- * also ignores anything after the first nonwhitespace token on a line.
- * @param jar the jar file.
- * @return a list, possibly empty, of fully qualified classnames to be instantiated.
- */
- private List<String> _getServiceClassnamesFromJar(File jar)
- {
- List<String> classNames = new ArrayList<String>();
- JarFile jarFile;
- try {
- jarFile = new JarFile(jar);
-
- for (String providerName : AUTOLOAD_SERVICES) {
- JarEntry provider = jarFile.getJarEntry(providerName);
- if (provider == null) {
- continue;
- }
- // Extract classnames from this text file.
- InputStream is = jarFile.getInputStream(provider);
- BufferedReader rd;
- rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
- for (String line = rd.readLine(); line != null; line = rd.readLine()) {
- // hack off any comments
- int iComment = line.indexOf('#');
- if (iComment >= 0) {
- line = line.substring(0, iComment);
- }
- // add the first non-whitespace token to the list
- final String[] tokens = line.split("\\s", 2);
- if (tokens[0].length() > 0) {
- if (_verboseLoad) {
- System.err.println("Found provider classname: " + tokens[0]);
- }
- classNames.add(tokens[0]);
- }
- }
- rd.close();
- }
- jarFile.close();
- }
- catch (IOException e) {
- if (_verboseLoad) {
- System.err.println("\tUnable to extract provider names from \"" + jar + "\"; skipping because of: " + e);
- }
- return classNames;
- }
- return classNames;
- }
-
- private void _loadFactory(final String className, final ClassLoader classLoader)
- {
- try {
- if (_verboseLoad) {
- System.err.println("\tAttempting to load APT factory class \"" + className + "\"...");
- }
- Class c = classLoader.loadClass(className);
- Constructor ctor = c.getDeclaredConstructor( new Class[0] );
- AnnotationProcessorFactory factory = ( AnnotationProcessorFactory ) ctor.newInstance( new Object[0] );
- if (factory != null) {
- if(!_factories.contains( factory) )
- _factories.add(factory);
- }
- if (_verboseLoad) {
- System.err.println("\t... succeeded.");
- }
- }
- catch (Throwable t) {
- if (_verboseLoad) {
- System.err.println("\t... failed: " + t);
- if (t.getCause() != null) t.getCause().printStackTrace(System.err);
- }
- // Uncomment this to debug exception throws that are real.
- //throw new IllegalStateException(t);
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/BuildListener.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/BuildListener.java
deleted file mode 100644
index b03eeed..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/BuildListener.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-// TODO: this class gets constructed and called from JDT Core. So it needs to
-// be 1.4-compliant, and to contain the "switch" to disable the rest of the code
-// if we are running on 1.4 and/or if tools.jar is unavailable. - WHarley 3/05
-
-package org.eclipse.jdt.apt.core.internal;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jdt.apt.core.internal.APTDispatch.APTResult;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedFileManager;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.compiler.CompilationParticipantEvent;
-import org.eclipse.jdt.core.compiler.CompilationParticipantResult;
-import org.eclipse.jdt.core.compiler.ICompilationParticipant;
-import org.eclipse.jdt.core.compiler.PostReconcileCompilationEvent;
-import org.eclipse.jdt.core.compiler.PostReconcileCompilationResult;
-import org.eclipse.jdt.core.compiler.PreBuildCompilationEvent;
-import org.eclipse.jdt.core.compiler.PreBuildCompilationResult;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-
-
-public class BuildListener implements ICompilationParticipant
-{
- /**
- * This class is constructed indirectly, by registering an extension to the
- * org.eclipse.jdt.core.compilationParticipants extension point.
- */
- public BuildListener()
- {
- _factoryLoader = new AnnotationProcessorFactoryLoader();
- _factoryLoader.loadFactoriesFromPlugins();
- _factories = _factoryLoader.getFactories();
- }
-
- private String getUnitName( ICompilationUnit sourceUnit )
- {
- char[] mainTypeName = sourceUnit.getMainTypeName();
- StringBuffer sb = new StringBuffer( mainTypeName.length + DOT_JAVA.length() );
- sb.append( mainTypeName );
- sb.append( DOT_JAVA );
- return sb.toString();
- }
-
- public CompilationParticipantResult notify( CompilationParticipantEvent cpe )
- {
- if ( cpe == null )
- return GENERIC_COMPILATION_RESULT;
-
- else if ( cpe.getKind() == ICompilationParticipant.PRE_BUILD_EVENT )
- return preBuildNotify( (PreBuildCompilationEvent) cpe );
-
- else if ( cpe.getKind() == ICompilationParticipant.POST_RECONCILE_EVENT )
- return postReconcileNotify( (PostReconcileCompilationEvent) cpe );
- else if ( cpe.getKind() == ICompilationParticipant.CLEAN_EVENT )
- return cleanNotify( cpe );
- else
- return GENERIC_COMPILATION_RESULT;
- }
-
- private CompilationParticipantResult preBuildNotify( PreBuildCompilationEvent pbce )
- {
- if ( pbce == null )
- return EMPTY_PRE_BUILD_COMPILATION_RESULT;
-
- IFile[] buildFiles = pbce.getFiles();
- IJavaProject javaProject = pbce.getJavaProject();
-
- if ( buildFiles == null || buildFiles.length == 0 )
- return EMPTY_PRE_BUILD_COMPILATION_RESULT;
-
- HashSet<IFile> newFiles = new HashSet<IFile>();
- HashSet<IFile> deletedFiles = new HashSet<IFile>();
- HashMap<IFile, Set<String>> newDependencies = new HashMap<IFile, Set<String>>();
- for ( int i = 0; i < buildFiles.length; i++ )
- {
- APTResult result = APTDispatch.runAPTDuringBuild(
- _factories,
- buildFiles[i],
- javaProject );
- newFiles.addAll( result.getNewFiles() );
- deletedFiles.addAll( result.getDeletedFiles() );
- newDependencies.put( buildFiles[i], result.getNewDependencies() );
- }
-
- // for apt, new files will always trump deleted files
- for ( IFile df : deletedFiles )
- if ( newFiles.contains( df ) )
- deletedFiles.remove( df );
-
- return new PreBuildCompilationResult( newFiles.toArray( new IFile[ newFiles.size() ] ), deletedFiles.toArray( new IFile[ deletedFiles.size() ] ), newDependencies );
- }
-
- private CompilationParticipantResult postReconcileNotify( PostReconcileCompilationEvent prce )
- {
- try
- {
- org.eclipse.jdt.core.ICompilationUnit cu = prce.getCompilationUnit();
- IJavaProject javaProject = prce.getJavaProject();
-
- // these are null sometimes. Not sure why...
- if ( cu == null || javaProject == null )
- return GENERIC_COMPILATION_RESULT;
-
- APTDispatch.runAPTDuringReconcile( _factories, cu, javaProject );
- }
- catch ( Throwable t )
- {
- t.printStackTrace();
- }
- return new PostReconcileCompilationResult();
- }
-
- private CompilationParticipantResult cleanNotify( CompilationParticipantEvent cpe )
- {
- IProject p = cpe.getJavaProject().getProject();
- GeneratedFileManager gfm = GeneratedFileManager.getGeneratedFileManager( p );
- gfm.projectClean( true );
- return GENERIC_COMPILATION_RESULT;
- }
-
- private List<AnnotationProcessorFactory> _factories;
- private AnnotationProcessorFactoryLoader _factoryLoader;
- private final static String DOT_JAVA = ".java";
-
- private final static PreBuildCompilationResult EMPTY_PRE_BUILD_COMPILATION_RESULT =
- new PreBuildCompilationResult( new IFile[0], new IFile[0], Collections.emptyMap() );
-
- private final static CompilationParticipantResult GENERIC_COMPILATION_RESULT =
- new CompilationParticipantResult();
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/EclipseMirrorImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/EclipseMirrorImpl.java
deleted file mode 100644
index 500e7d3..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/EclipseMirrorImpl.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-
-public interface EclipseMirrorImpl
-{
- public enum MirrorKind
- {
- CONSTRUCTOR{
- public boolean isType(){ return false; }
- },
- METHOD{
- public boolean isType(){ return false; }
- },
- ANNOTATION_ELEMENT{
- public boolean isType(){ return false; }
- },
- FIELD{
- public boolean isType(){ return false; }
- },
- ENUM_CONSTANT{
- public boolean isType(){ return false; }
- },
- ANNOTATION_VALUE{
- public boolean isType(){ return false; }
- },
- ANNOTATION_MIRROR{
- public boolean isType(){ return false; }
- },
- TYPE_ANNOTATION{
- public boolean isType(){ return true; }
- },
- TYPE_INTERFACE{
- public boolean isType(){ return true; }
- },
- TYPE_CLASS{
- public boolean isType(){ return true; }
- },
- TYPE_ENUM{
- public boolean isType(){ return true; }
- },
- TYPE_ARRAY{
- public boolean isType(){ return true; }
- },
- TYPE_WILDCARD{
- public boolean isType(){ return true; }
- },
- TYPE_VOID{
- public boolean isType(){ return true; }
- },
- TYPE_PRIMITIVE{
- public boolean isType(){ return true; }
- },
- TYPE_PARAMETER_VARIABLE{
- public boolean isType(){ return true; }
- },
- TYPE_ERROR{
- public boolean isType(){ return true; }
- },
- FORMAL_PARAMETER{
- public boolean isType(){ return false; }
- },
- PACKAGE{
- public boolean isType(){ return false; }
- };
-
- public abstract boolean isType();
- }
-
- public MirrorKind kind();
-
- /**
- * @return the processor environment associated with the object.
- * return null for primitive, void and error type.
- */
- public ProcessorEnvImpl getEnvironment();
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/NonEclipseImplementationException.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/NonEclipseImplementationException.java
deleted file mode 100644
index 5497e0b..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/NonEclipseImplementationException.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal;
-
-/**
- * Thrown when the eclipse compiler encountered a non-eclipse implementation of the mirror type system.
- */
-public class NonEclipseImplementationException extends RuntimeException
-{
- private static final long serialVersionUID = 1L;
-
- public NonEclipseImplementationException(String msg)
- { super(msg); }
-
- public NonEclipseImplementationException(){}
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationDeclarationImpl.java
deleted file mode 100644
index 0a21ca1..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationDeclarationImpl.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
-import com.sun.mirror.type.AnnotationType;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.mirror.util.TypeVisitor;
-import java.util.Collection;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-public class AnnotationDeclarationImpl extends InterfaceDeclarationImpl implements AnnotationTypeDeclaration, AnnotationType
-{
- public AnnotationDeclarationImpl(final ITypeBinding binding, final ProcessorEnvImpl env)
- {
- super(binding, env);
- assert binding.isAnnotation() : "binding does not represent a annotation ";
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitAnnotationTypeDeclaration(this);
- }
-
- public Collection<AnnotationTypeElementDeclaration> getMethods()
- {
- return (Collection<AnnotationTypeElementDeclaration>)_getMethods();
- }
-
- // start of implementation of AnnotationType API
- public void accept(TypeVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitAnnotationType(this);
- }
-
- public AnnotationTypeDeclaration getDeclaration()
- {
- return (AnnotationTypeDeclaration)super.getDeclaration();
- }
- // end of implementation of AnnotationType API
-
- public MirrorKind kind(){ return MirrorKind.TYPE_ANNOTATION; }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationElementDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationElementDeclarationImpl.java
deleted file mode 100644
index 260a79d..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationElementDeclarationImpl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
-import com.sun.mirror.declaration.AnnotationValue;
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.util.DeclarationVisitor;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-
-public class AnnotationElementDeclarationImpl extends MethodDeclarationImpl implements AnnotationTypeElementDeclaration
-{
- public AnnotationElementDeclarationImpl(final IMethodBinding binding,
- final ProcessorEnvImpl env)
- {
- super(binding, env);
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitAnnotationTypeElementDeclaration(this);
- }
-
- public AnnotationTypeDeclaration getDeclaringType()
- {
- return (AnnotationTypeDeclaration)super.getDeclaringType();
- }
-
- /**
- * @return the default value of this annotation element if one exists.
- * Return null if the annotation element is defined in binary (feature not available right now).
- * Return null if the annotation element is part of a seconary type that is defined outside
- * the file associated with the environment.
- */
- public AnnotationValue getDefaultValue()
- {
- final IMethodBinding binding = getDeclarationBinding();
- final Object defaultValue = binding.getDefaultValue();
- return Factory.createDefaultValue(defaultValue, this, _env);
- }
-
- ASTNode getAstNodeForDefault()
- {
- final AnnotationTypeMemberDeclaration decl = (AnnotationTypeMemberDeclaration)getAstNode();
- if( decl != null )
- return decl.getDefault();
-
- return null;
- }
-
- public Collection<ParameterDeclaration> getParameters(){ return Collections.emptyList(); }
-
- public MirrorKind kind(){ return MirrorKind.ANNOTATION_ELEMENT; }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationMirrorImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationMirrorImpl.java
deleted file mode 100644
index ebe58c0..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationMirrorImpl.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.apt.core.internal.EclipseMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.apt.core.internal.util.SourcePositionImpl;
-import org.eclipse.jdt.core.dom.*;
-
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
-import com.sun.mirror.declaration.AnnotationValue;
-import com.sun.mirror.type.AnnotationType;
-import com.sun.mirror.util.SourcePosition;
-
-/**
- * Annotation instance from source.
- */
-public class AnnotationMirrorImpl implements AnnotationMirror, EclipseMirrorImpl
-{
- /**The ast node that correspond to the annotation.*/
- private final IResolvedAnnotation _domAnnotation;
- private final ProcessorEnvImpl _env;
- /** the declaration that is annotated by this annotation or the annotation element declaration
- * if this is (part of) a default value*/
- private final DeclarationImpl _annotated;
-
- public AnnotationMirrorImpl(IResolvedAnnotation annotationAstNode, DeclarationImpl decl, ProcessorEnvImpl env)
- {
- _domAnnotation = annotationAstNode;
- _env = env;
- _annotated = decl;
- assert _domAnnotation != null : "annotation node missing.";
- assert _annotated != null : "missing the declaration that is annotated with this annotation.";
- }
-
- public AnnotationType getAnnotationType()
- {
- final ITypeBinding binding = _domAnnotation.getAnnotationType();
- return (AnnotationType)Factory.createReferenceType(binding, _env);
- }
-
- public Map<AnnotationTypeElementDeclaration, AnnotationValue> getElementValues()
- {
- final IResolvedMemberValuePair[] pairs = _domAnnotation.getDeclaredMemberValuePairs();
- if (pairs.length == 0) {
- return Collections.emptyMap();
- }
-
- final Map<AnnotationTypeElementDeclaration, AnnotationValue> result =
- new LinkedHashMap<AnnotationTypeElementDeclaration, AnnotationValue>(pairs.length * 4 / 3 + 1 );
- for( IResolvedMemberValuePair pair : pairs ){
- final String name = pair.getName();
- if( name == null ) continue;
- IMethodBinding elementMethod = pair.getMemberBinding();
- if( elementMethod != null ){
- final DeclarationImpl mirrorDecl = Factory.createDeclaration(elementMethod, _env);
- final AnnotationValue annoValue =
- Factory.createAnnotationMemberValue(pair.getValue(), name, this, _env);
- if( mirrorDecl.kind() == EclipseMirrorImpl.MirrorKind.ANNOTATION_ELEMENT &&
- annoValue != null )
- result.put( (AnnotationTypeElementDeclaration)mirrorDecl, annoValue);
- }
- }
- return result;
- }
-
- public SourcePosition getPosition()
- {
- if( isFromSource() ){
- final CompilationUnit unit = _annotated.getCompilationUnit();
- final org.eclipse.jdt.core.dom.Annotation annotation = getAstNode();
- if( annotation == null ) return null;
- org.eclipse.jdt.core.dom.ASTNode astNode = annotation.getTypeName();
- if( astNode == null )
- astNode = annotation;
-
- return new SourcePositionImpl(astNode.getStartPosition(),
- astNode.getLength(),
- unit.lineNumber(astNode.getStartPosition()),
- _annotated);
- }
- return null;
- }
-
- public String toString()
- {
- return _domAnnotation.toString();
- }
-
- /**
- * @return the type(s) of the member value named <code>membername</code>.
- * If the value is a class literal, then return the type binding corresponding to the type requested.
- * Otherwise, return the type of the expression.
- * If the value is an array initialization, then the type of each of the initialization expresion will
- * be returned. Return null if no match is found.
- */
- public ITypeBinding[] getMemberValueTypeBinding(String membername)
- {
- if( membername == null ) return null;
- final IResolvedMemberValuePair[] declaredPairs = _domAnnotation.getDeclaredMemberValuePairs();
- for( IResolvedMemberValuePair pair : declaredPairs ){
- if( membername.equals(pair.getName()) ){
- final Object value = pair.getValue();
- return getValueTypeBinding(value, pair.getMemberBinding().getReturnType());
- }
- }
-
- // didn't find it in the ast, check the default values.
- final IMethodBinding binding = getMethodBinding(membername);
- if(binding == null ) return null;
- final Object defaultValue = binding.getDefaultValue();
- if( defaultValue != null )
- return getValueTypeBinding(defaultValue, binding.getReturnType() );
- else
- return null;
- }
-
- private ITypeBinding[] getValueTypeBinding(Object value, final ITypeBinding resolvedType)
- {
- if( value == null ) return null;
- if( resolvedType.isPrimitive() || resolvedType.isAnnotation() || value instanceof String )
- return new ITypeBinding[]{ resolvedType };
- else if( resolvedType.isArray() ){
- final Object[] elements = (Object[])value;
- final ITypeBinding[] result = new ITypeBinding[elements.length];
- final ITypeBinding leafType = resolvedType.getElementType();
- for(int i=0, len = elements.length; i<len; i++ ){
- final ITypeBinding[] t = getValueTypeBinding(elements[i], leafType);
- result[i] = t == null ? null : t[0];
- }
- return result;
- }
- else if( value instanceof IVariableBinding )
- return new ITypeBinding[]{ ( (IVariableBinding)value ).getDeclaringClass() };
- else if( value instanceof ITypeBinding )
- return new ITypeBinding[]{ (ITypeBinding)value };
- else
- throw new IllegalStateException("value = " + value + " resolvedType = " + resolvedType );
-
- }
-
- private ITypeBinding[] getExpressionTypeBindings(Expression expr)
- {
- if(expr == null) return null;
- switch(expr.getNodeType())
- {
- case ASTNode.ARRAY_INITIALIZER:
- final ArrayInitializer arrayInit = (ArrayInitializer)expr;
- final List<Expression> exprs = arrayInit.expressions();
- if( exprs == null || exprs.size() == 0 )
- return new ITypeBinding[0];
- final ITypeBinding[] bindings = new ITypeBinding[exprs.size()];
- for( int i=0, size = exprs.size(); i<size; i++ ){
- final Expression initExpr = exprs.get(i);
- bindings[i] = getExpressionTypeBinding(initExpr);
- }
- return bindings;
- default:
- return new ITypeBinding[]{ getExpressionTypeBinding(expr) };
- }
- }
-
- private ITypeBinding getExpressionTypeBinding(Expression expr)
- {
- if( expr.getNodeType() == ASTNode.TYPE_LITERAL )
- return ((TypeLiteral)expr).getType().resolveBinding();
- else
- return expr.resolveTypeBinding();
- }
-
- /**
- * @param memberName the name of the member
- * @return the value of the given member
- */
- private Object getValue(final String memberName)
- {
- if( memberName == null ) return null;
- final IResolvedMemberValuePair[] declaredPairs = _domAnnotation.getDeclaredMemberValuePairs();
- for( IResolvedMemberValuePair pair : declaredPairs ){
- if( memberName.equals(pair.getName()) ){
- return pair.getValue();
- }
- }
-
- // didn't find it in the ast, check the default values.
- final IMethodBinding binding = getMethodBinding(memberName);
- if(binding == null ) return null;
- return binding.getDefaultValue();
- }
-
- /**
- * @return the method binding that matches the given name from the annotation type
- * referenced by this annotation.
- */
- public IMethodBinding getMethodBinding(final String memberName)
- {
- if( memberName == null ) return null;
- final ITypeBinding typeBinding = _domAnnotation.getAnnotationType();
- if( typeBinding == null ) return null;
- final IMethodBinding[] methods = typeBinding.getDeclaredMethods();
- for( IMethodBinding method : methods ){
- if( memberName.equals(method.getName()) )
- return method;
- }
- return null;
- }
-
- public Object getReflectionValue(String memberName, Method method)
- throws Throwable
- {
- if(memberName == null || memberName.length() == 0 ) return null;
- final Class targetType = method.getReturnType();
- final Object value = getValue(memberName);
- return getReflectionValue(value, targetType);
- }
-
- private Object getReflectionValue(final Object value, final Class targetType)
- throws Throwable
- {
- if( value == null ) return null;
- else if(value instanceof Boolean ||
- value instanceof Byte ||
- value instanceof Character ||
- value instanceof Double ||
- value instanceof Float ||
- value instanceof Integer ||
- value instanceof Long ||
- value instanceof Short ||
- value instanceof String )
- return value;
- else if( value instanceof IVariableBinding )
- {
- final IVariableBinding varBinding = (IVariableBinding)value;
- final ITypeBinding declaringClass = varBinding.getDeclaringClass();
- if( declaringClass != null ){
- final String className = new String( declaringClass.getBinaryName() );
- final Class clazz = value.getClass().getClassLoader().loadClass( className );
- final Field returnedField = clazz.getField( varBinding.getName() );
- if( returnedField.getType() != targetType )
- throw new ClassCastException( targetType.getName() );
- return returnedField.get(null);
- }
- }
- else if (value instanceof Object[])
- {
- final Object[] elements = (Object[])value;
- assert targetType.isArray();
- final Class componentType = targetType.getComponentType();
- final char componentTypeName = componentType.getName().charAt(0);
- final int length = elements.length;;
- final Object array = Array.newInstance(componentType, length);
- if( length == 0) return array;
-
- for( int i=0; i<length; i++ ){
- final Object returnObj = getReflectionValue( elements[i], componentType );
- // fill in the array.
- // If it is an array of some primitive type, we will need to unwrap it.
- if( componentType.isPrimitive() ){
- if( componentType == boolean.class ){
- final Boolean bool = (Boolean)returnObj;
- Array.setBoolean( array, i, bool.booleanValue());
- }
- else if( componentType == byte.class ){
- final Byte b = (Byte)returnObj;
- Array.setByte( array, i, b.byteValue() );
- }
- else if( componentType == char.class ){
- final Character c = (Character)returnObj;
- Array.setChar( array, i, c.charValue() );
- }
- else if( componentType == double.class ){
- final Double d = (Double)returnObj;
- Array.setDouble( array, i, d.doubleValue() );
- }
- else if( componentType == float.class ){
- final Float f = (Float)returnObj;
- Array.setFloat( array, i, f.floatValue() );
- }
- else if( componentType == int.class ){
- final Integer integer = (Integer)returnObj;
- Array.setInt( array, i, integer.intValue() );
- }
- else if( componentType == long.class ){
- final Long l = (Long)returnObj;
- Array.setLong( array, i, l.longValue() );
- }
- else if( componentType == short.class ){
- final Short s = (Short)returnObj;
- Array.setShort( array, i, s.shortValue() );
- }
- else {
- throw new IllegalStateException("unrecognized primitive type: " + componentType );
- }
- }
- else{
- Array.set( array, i, returnObj );
- }
- }
- }
- // caller should have caught this case.
- else if( value instanceof ITypeBinding )
- throw new IllegalStateException();
-
- else if( value instanceof IResolvedAnnotation )
- {
- return Factory.createAnnotationMirror((IResolvedAnnotation)value, _annotated, _env);
- }
-
- return null;
- }
-
- public MirrorKind kind(){ return MirrorKind.ANNOTATION_MIRROR; }
-
- boolean isFromSource()
- {
- return _annotated.isFromSource();
- }
-
- org.eclipse.jdt.core.dom.Annotation getAstNode()
- {
- if( isFromSource() ){
- final CompilationUnit unit = _annotated.getCompilationUnit();
- final ASTNode node = unit.findDeclaringNode(_domAnnotation);
- if( node instanceof org.eclipse.jdt.core.dom.Annotation )
- return (org.eclipse.jdt.core.dom.Annotation)node;
- }
- return null;
- }
-
- ASTNode getASTNodeForElement(String name)
- {
- if( name == null ) return null;
- final org.eclipse.jdt.core.dom.Annotation anno = getAstNode();
- if( anno != null ){
- if( anno.isSingleMemberAnnotation() ){
- if( "value".equals(name) )
- return ((SingleMemberAnnotation)anno).getValue();
- }
- else if( anno.isNormalAnnotation() ){
- final List<MemberValuePair> pairs = ((NormalAnnotation)anno).values();
- for( MemberValuePair pair : pairs )
- {
- final String pairName = pair.getName() == null ? null : pair.getName().toString();
- if( name.equals(pairName) )
- return pair.getValue();
- }
- }
- }
- // marker annotation or no match.
- return null;
- }
-
- CompilationUnit getCompilationUnit() { return _annotated.getCompilationUnit(); }
-
- public ProcessorEnvImpl getEnvironment(){ return _env; }
-
- public IResource getResouce()
- { return _annotated.getResource(); }
-
- public DeclarationImpl getAnnotatedDeclaration(){ return _annotated; }
-
- public boolean equals(Object obj){
- if( obj instanceof AnnotationMirrorImpl ){
- return ((AnnotationMirrorImpl)obj)._domAnnotation == _domAnnotation;
- }
- return false;
- }
-
- public int hashCode(){
- return _domAnnotation.hashCode();
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationValueImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationValueImpl.java
deleted file mode 100644
index d1c9821..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationValueImpl.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import java.util.List;
-
-import com.sun.mirror.util.SourcePosition;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.apt.core.internal.EclipseMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.SourcePositionImpl;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ArrayInitializer;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-
-public class AnnotationValueImpl implements IEclipseAnnotationValue, EclipseMirrorImpl
-{
- /**
- * Either the annotation that directly contains this annotation value
- * or an annotation method, which indicates that this is its default value.
- */
- private EclipseMirrorImpl _parent;
- private final ProcessorEnvImpl _env;
- /** the annotation value */
- private final Object _value;
- /**
- * The name of the element if this is a value from an annotation member value.
- * <code>null</code> otherwise
- */
- private final String _name;
- /**
- * If this is part of an array, then the index into the array.
- * <code>-1</code> when this doesn't apply
- */
- private final int _index;
-
- /**
- *
- * @param value the default value of an annotation element declaration
- * @param element the annotation element declaration.
- * @param index zero-based index into the array if the this value is an array element.
- * <code>-1</code> otherwise.
- * @param env
- */
- public AnnotationValueImpl( final Object value,
- final int index,
- final AnnotationElementDeclarationImpl element,
- final ProcessorEnvImpl env)
- {
-
- _value = value;
- _env = env;
- _parent = element;
- _name = null;
- _index = index;
- assert _env != null : "missing environment";
- assert _parent != null : "missing element";
- }
-
- /**
- *
- * @param value the annotation value
- * @param name the name of the element member
- * @param index zero-based index into the array if the this value is an array element.
- * <code>-1</code> otherwise.
- * @param annotation the annotation containing this value
- * @param env
- */
- public AnnotationValueImpl( final Object value,
- final String name,
- final int index,
- final AnnotationMirrorImpl annotation,
- final ProcessorEnvImpl env)
- {
- _value = value;
- _env = env;
- _parent = annotation;
- _name = name;
- _index = index;
- assert _env != null : "missing environment";
- assert _parent != null : "missing element";
- }
-
- public SourcePosition getPosition()
- {
- final MirrorKind kind = _parent.kind();
- ASTNode astNode = null;
- switch(kind)
- {
- case ANNOTATION_MIRROR:
- final AnnotationMirrorImpl anno = (AnnotationMirrorImpl)_parent;
- astNode = anno.getASTNodeForElement(_name);
- break;
- case ANNOTATION_ELEMENT:
- final AnnotationElementDeclarationImpl element = (AnnotationElementDeclarationImpl)_parent;
- astNode = element.getAstNodeForDefault();
- default:
- throw new IllegalStateException(); // should never reach this point.
- }
- // did not come from source.
- if( astNode == null )
- return null;
- if( _index >= 0 && astNode.getNodeType() == ASTNode.ARRAY_INITIALIZER ){
- final ArrayInitializer arrayInit = (ArrayInitializer)astNode;
- final List exprs = arrayInit.expressions();
- if (exprs != null && _index < exprs.size() )
- astNode = (ASTNode)exprs.get(_index);
- }
- if( astNode == null ) return null;
-
- final CompilationUnit unit = getCompilationUnit();
- if( unit == null ) return null;
- return new SourcePositionImpl(astNode.getStartPosition(),
- astNode.getLength(),
- unit.lineNumber(astNode.getStartPosition()),
- this);
- }
-
- CompilationUnit getCompilationUnit()
- {
- final MirrorKind kind = _parent.kind();
- switch(kind)
- {
- case ANNOTATION_MIRROR:
- return ((AnnotationMirrorImpl)_parent).getCompilationUnit();
- case ANNOTATION_ELEMENT:
- return ((MethodDeclarationImpl)_parent).getCompilationUnit();
- default:
- throw new IllegalStateException(); // should never reach this point.
- }
- }
-
- public boolean isFromSource()
- {
- final MirrorKind kind = _parent.kind();
- switch(kind)
- {
- case ANNOTATION_MIRROR:
- return ((AnnotationMirrorImpl)_parent).isFromSource();
- case ANNOTATION_ELEMENT:
- return ((MethodDeclarationImpl)_parent).isFromSource();
- default:
- throw new IllegalStateException(); // should never reach this point.
- }
- }
-
- public IResource getResource()
- {
- final MirrorKind kind = _parent.kind();
- switch(kind)
- {
- case ANNOTATION_MIRROR:
- return ((AnnotationMirrorImpl)_parent).getResouce();
- case ANNOTATION_ELEMENT:
- return ((MethodDeclarationImpl)_parent).getResource();
- default:
- throw new IllegalStateException(); // should never reach this point.
- }
- }
-
- public Object getValue(){ return _value; }
-
- public MirrorKind kind(){ return MirrorKind.ANNOTATION_VALUE; }
-
- public ProcessorEnvImpl getEnvironment(){
- return _env;
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/BinaryParameterDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/BinaryParameterDeclarationImpl.java
deleted file mode 100644
index 4d82967..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/BinaryParameterDeclarationImpl.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import com.sun.mirror.declaration.Modifier;
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.util.SourcePosition;
-import java.util.Collection;
-import java.util.Collections;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-/**
- * Represents a formal parameter that came from binary.
- */
-public class BinaryParameterDeclarationImpl extends ParameterDeclarationImpl implements ParameterDeclaration
-{
- /**
- * Parameter declaration from binary
- */
- public BinaryParameterDeclarationImpl(ExecutableDeclarationImpl executable,
- ITypeBinding typeBinding,
- int index,
- ProcessorEnvImpl env)
- {
- super(executable, typeBinding, index, env);
- }
-
- public Collection<Modifier> getModifiers()
- {
- // TODO
- // we don't store this information. so simply return nothing for now.
- return Collections.emptyList();
- }
-
- public SourcePosition getPosition()
- {
- return null;
- }
-
- public boolean equals(Object obj){
- if( obj instanceof BinaryParameterDeclarationImpl ){
- final BinaryParameterDeclarationImpl otherParam = (BinaryParameterDeclarationImpl)obj;
- return otherParam._paramIndex == _paramIndex &&
- otherParam._executable.getDeclarationBinding().isEqualTo(_executable.getDeclarationBinding()) ;
- }
- return false;
- }
-
- boolean isFromSource(){ return false; }
-
- ASTNode getAstNode(){ return null; }
-
- public IResource getResource(){ return null; }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ClassDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ClassDeclarationImpl.java
deleted file mode 100644
index cd11693..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ClassDeclarationImpl.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-import com.sun.mirror.declaration.ClassDeclaration;
-import com.sun.mirror.declaration.ConstructorDeclaration;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.type.ClassType;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.mirror.util.TypeVisitor;
-
-public class ClassDeclarationImpl extends TypeDeclarationImpl implements ClassDeclaration, ClassType
-{
- public ClassDeclarationImpl(final ITypeBinding binding, final ProcessorEnvImpl env)
- {
- super(binding, env);
- // Enum types return false for isClass().
- assert !binding.isInterface();
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitClassDeclaration(this);
- }
-
- public Collection<ConstructorDeclaration> getConstructors()
- {
- final IMethodBinding[] methods = getDeclarationBinding().getDeclaredMethods();
- final List<ConstructorDeclaration> results = new ArrayList<ConstructorDeclaration>(methods.length);
- for( IMethodBinding method : methods ){
- if( method.isSynthetic() ) continue;
- if( method.isConstructor() ){
- Declaration mirrorDecl = Factory.createDeclaration(method, _env);
- if( mirrorDecl != null)
- results.add((ConstructorDeclaration)mirrorDecl);
- }
- }
- return results;
-
- }
-
- public Collection<MethodDeclaration> getMethods()
- {
- return (Collection<MethodDeclaration>)_getMethods();
- }
-
- // Start of implementation of ClassType API
- public void accept(TypeVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitClassType(this);
- }
-
- public ClassType getSuperclass()
- {
- final ITypeBinding superClass = getDeclarationBinding().getSuperclass();
- if( superClass.isClass() )
- return (ClassType)Factory.createReferenceType(superClass, _env);
- else // catch error case where user extends some interface instead of a class.
- return Factory.createErrorClassType(superClass);
- }
-
- public ClassDeclaration getDeclaration()
- {
- return (ClassDeclaration)super.getDeclaration();
- }
- // End of implementation of ClassType API
-
- public MirrorKind kind(){ return MirrorKind.TYPE_CLASS; }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ConstructorDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ConstructorDeclarationImpl.java
deleted file mode 100644
index a762570..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ConstructorDeclarationImpl.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-
-import com.sun.mirror.declaration.ConstructorDeclaration;
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.util.DeclarationVisitor;
-
-public class ConstructorDeclarationImpl extends ExecutableDeclarationImpl implements ConstructorDeclaration
-{
- public ConstructorDeclarationImpl(final IMethodBinding binding, ProcessorEnvImpl env)
- {
- super(binding, env);
- assert binding.isConstructor() : "binding does not represent a constructor";
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitConstructorDeclaration(this);
- }
-
- public MirrorKind kind(){ return MirrorKind.CONSTRUCTOR; }
-
- public String toString()
- {
- final StringBuilder buffer = new StringBuilder();
- final IMethodBinding methodBinding = getDeclarationBinding();
- buffer.append(methodBinding.getName());
- buffer.append('(');
- int i=0;
- for( ParameterDeclaration param : getParameters() ){
- if( i++ != 0 )
- buffer.append(", ");
- buffer.append(param);
- }
- buffer.append(')');
-
- return buffer.toString();
- }
-}
-
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/DeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/DeclarationImpl.java
deleted file mode 100644
index 9771bd8..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/DeclarationImpl.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
- package org.eclipse.jdt.apt.core.internal.declaration;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.apt.core.internal.EclipseMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.env.AnnotationInvocationHandler;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IResolvedAnnotation;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.Modifier;
-import com.sun.mirror.util.DeclarationVisitor;
-
-public abstract class DeclarationImpl implements Declaration, EclipseMirrorImpl
-{
- /** the type binding corresponding to this declaration */
- final IBinding _binding;
- final ProcessorEnvImpl _env;
-
- DeclarationImpl(final IBinding binding, final ProcessorEnvImpl env)
- {
- assert binding != null : "binding cannot be null";
- assert env != null : "missing environment";
- _binding = binding;
- _env = env;
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- visitor.visitDeclaration(this);
- }
-
- public boolean equals(Object obj)
- {
- if(obj instanceof DeclarationImpl)
- return _binding.isEqualTo( ((DeclarationImpl)obj)._binding );
-
- return false;
- }
-
- public int hashCode(){ return _binding.hashCode(); }
-
- <A extends Annotation> A _getAnnotation(Class<A> annotationClass,
- IResolvedAnnotation[] annoInstances)
- {
- final String annoTypeName = annotationClass.getName();
- if( annoTypeName == null ) return null;
- final int len = annoInstances == null ? 0 : annoInstances.length;
- if( len == 0 ) return null;
- for( IResolvedAnnotation annoInstance : annoInstances){
- final ITypeBinding binding = annoInstance.getAnnotationType();
- if(binding.isAnnotation() ){
- final String curTypeName = binding.getQualifiedName();
- if( annoTypeName.equals(curTypeName) ){
- final AnnotationMirrorImpl annoMirror =
- (AnnotationMirrorImpl)Factory.createAnnotationMirror(annoInstance, this, _env);
- final AnnotationInvocationHandler handler = new AnnotationInvocationHandler(annoMirror);
- return (A)Proxy.newProxyInstance(annotationClass.getClassLoader(),
- new Class[]{ annotationClass }, handler );
- }
- }
- }
- return null;
- }
-
- <A extends Annotation> A _getAnnotation(Class<A> annotationClass,
- List<org.eclipse.jdt.core.dom.Annotation> annoInstances)
- {
- final String annoTypeName = annotationClass.getName();
- if( annoInstances == null || annoInstances.size() == 0 ) return null;
- for( org.eclipse.jdt.core.dom.Annotation annoInstance : annoInstances){
- final ITypeBinding binding = annoInstance.resolveTypeBinding();
- if(binding.isAnnotation() ){
- final String curTypeName = binding.getQualifiedName();
- if( annoTypeName.equals(curTypeName) ){
- final AnnotationMirrorImpl annoMirror =
- (AnnotationMirrorImpl)Factory.createAnnotationMirror(annoInstance.resolveAnnotation(), this, _env);
- final AnnotationInvocationHandler handler = new AnnotationInvocationHandler(annoMirror);
- return (A)Proxy.newProxyInstance(annotationClass.getClassLoader(),
- new Class[]{ annotationClass }, handler );
- }
- }
- }
- return null;
- }
-
- Collection<AnnotationMirror> _getAnnotationMirrors(IResolvedAnnotation[] annoInstances)
- {
- final int len = annoInstances == null ? 0 : annoInstances.length;
- if( len == 0 ) return Collections.emptyList();
- final List<AnnotationMirror> result = new ArrayList<AnnotationMirror>(len);
- for(IResolvedAnnotation annoInstance : annoInstances){
- final AnnotationMirrorImpl annoMirror =
- (AnnotationMirrorImpl)Factory.createAnnotationMirror(annoInstance, this, _env);
- result.add(annoMirror);
- }
- return result;
- }
-
- Collection<AnnotationMirror> _getAnnotationMirrors(List<org.eclipse.jdt.core.dom.Annotation> annoInstances)
- {
- if( annoInstances == null || annoInstances.size() == 0 ) return Collections.emptyList();
- final List<AnnotationMirror> result = new ArrayList<AnnotationMirror>(annoInstances.size());
- for( org.eclipse.jdt.core.dom.Annotation annoInstance : annoInstances){
- final AnnotationMirrorImpl annoMirror =
- (AnnotationMirrorImpl)Factory.createAnnotationMirror(annoInstance.resolveAnnotation(), this, _env);
- result.add(annoMirror);
- }
- return result;
- }
-
-
-
-
-
- /**
- * @return the binding that corresponds to the original declaration.
- * For parameterized type or raw type, return the generic type declaration binding.
- * For parameterized method, return the method declaration binding that has the
- * type parameters not the one with the parameters substituted with type arguments.
- * In other cases, simply return the same binding.
- */
- public abstract IBinding getDeclarationBinding();
-
- public Collection<Modifier> getModifiers()
- {
- final int modBits = getDeclarationBinding().getModifiers();
- final List<Modifier> mods = new ArrayList<Modifier>(4);
- if( org.eclipse.jdt.core.dom.Modifier.isAbstract(modBits) )
- mods.add(Modifier.ABSTRACT);
- if( org.eclipse.jdt.core.dom.Modifier.isFinal(modBits) )
- mods.add(Modifier.FINAL);
- if( org.eclipse.jdt.core.dom.Modifier.isNative(modBits) )
- mods.add(Modifier.NATIVE);
- if( org.eclipse.jdt.core.dom.Modifier.isPrivate(modBits) )
- mods.add(Modifier.PRIVATE);
- if( org.eclipse.jdt.core.dom.Modifier.isProtected(modBits) )
- mods.add(Modifier.PROTECTED);
- if( org.eclipse.jdt.core.dom.Modifier.isPublic(modBits) )
- mods.add(Modifier.PUBLIC);
- if( org.eclipse.jdt.core.dom.Modifier.isStatic(modBits) )
- mods.add(Modifier.STATIC);
- if( org.eclipse.jdt.core.dom.Modifier.isStrictfp(modBits) )
- mods.add(Modifier.STRICTFP);
- if( org.eclipse.jdt.core.dom.Modifier.isSynchronized(modBits) )
- mods.add(Modifier.SYNCHRONIZED);
- if( org.eclipse.jdt.core.dom.Modifier.isTransient(modBits) )
- mods.add(Modifier.TRANSIENT);
- if( org.eclipse.jdt.core.dom.Modifier.isVolatile(modBits) )
- mods.add(Modifier.VOLATILE);
- return mods;
- }
-
-
- /**
- * @return true iff this declaration came from a source file.
- * Return false otherwise.
- */
- abstract boolean isFromSource();
-
- /**
- * @return the ast node that corresponding to this declaration.
- * Return null if this declaration came from binary.
- * @see #isFromSource();
- */
- ASTNode getAstNode(){
- if( !isFromSource() ) return null;
- return _env.getASTNodeForBinding(getDeclarationBinding());
- }
-
- /**
- * @return the compilation unit that the ast node of this declaration came from
- * Return null if this declaration came from binary.
- * @see #isFromSource()
- */
- CompilationUnit getCompilationUnit(){
- if( !isFromSource() ) return null;
- return _env.getCompilationUnitForBinding(getDeclarationBinding());
- }
-
- /**
- * @return the resource of this declaration if the declaration is from source.
- */
- public IResource getResource(){
- if( isFromSource() ){
- final IBinding binding = getDeclarationBinding();
- return _env.getDeclaringFileForBinding(binding);
- }
- return null;
- }
-
- public ProcessorEnvImpl getEnvironment(){ return _env; }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EnumConstantDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EnumConstantDeclarationImpl.java
deleted file mode 100644
index a9ba957..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EnumConstantDeclarationImpl.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import com.sun.mirror.declaration.EnumConstantDeclaration;
-import com.sun.mirror.declaration.EnumDeclaration;
-import com.sun.mirror.util.DeclarationVisitor;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-
-public class EnumConstantDeclarationImpl extends FieldDeclarationImpl implements EnumConstantDeclaration
-{
- public EnumConstantDeclarationImpl(IVariableBinding binding, ProcessorEnvImpl env)
- {
- super(binding, env);
- assert binding.isEnumConstant() : "binding does not represent an enum constant";
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- }
-
- public EnumDeclaration getDeclaringType()
- {
- return (EnumDeclaration)super.getDeclaringType();
- }
-
- public MirrorKind kind(){ return MirrorKind.ENUM_CONSTANT; }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EnumDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EnumDeclarationImpl.java
deleted file mode 100644
index 958c53b..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EnumDeclarationImpl.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.EnumConstantDeclaration;
-import com.sun.mirror.declaration.EnumDeclaration;
-import com.sun.mirror.type.EnumType;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.mirror.util.TypeVisitor;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-
-public class EnumDeclarationImpl extends ClassDeclarationImpl implements EnumDeclaration, EnumType
-{
- public EnumDeclarationImpl(final ITypeBinding binding, final ProcessorEnvImpl env)
- {
- super(binding, env);
- assert binding.isEnum() : "binding is not an enum.";
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitEnumDeclaration(this);
- }
-
- public Collection<EnumConstantDeclaration> getEnumConstants()
- {
- final ITypeBinding enumBinding = getDeclarationBinding();
- final IVariableBinding[] fields = enumBinding.getDeclaredFields();
- final List<EnumConstantDeclaration> results = new ArrayList<EnumConstantDeclaration>(4);
- for( IVariableBinding field : fields ){
- if( field.isEnumConstant() ){
- final Declaration mirrorDecl = Factory.createDeclaration(field, _env);
- if( mirrorDecl != null )
- results.add((EnumConstantDeclaration)mirrorDecl);
- }
- }
- return results;
- }
-
- // start of implementation of EnumType API
-
- // end of implementation of EnumType API
- public void accept(TypeVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitEnumType(this);
- }
-
- public EnumDeclaration getDeclaration()
- {
- return (EnumDeclaration)super.getDeclaration();
- }
-
- public MirrorKind kind(){ return MirrorKind.TYPE_ENUM; }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ExecutableDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ExecutableDeclarationImpl.java
deleted file mode 100644
index 5153a33..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ExecutableDeclarationImpl.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-import com.sun.mirror.declaration.ExecutableDeclaration;
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.declaration.TypeParameterDeclaration;
-import com.sun.mirror.type.ReferenceType;
-import com.sun.mirror.util.DeclarationVisitor;
-
-public abstract class ExecutableDeclarationImpl extends MemberDeclarationImpl implements ExecutableDeclaration
-{
- public ExecutableDeclarationImpl(final IMethodBinding binding, final ProcessorEnvImpl env)
- {
- super(binding, env);
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitExecutableDeclaration(this);
- }
-
- public TypeDeclaration getDeclaringType()
- {
- final IMethodBinding methodBinding = getDeclarationBinding();
- return Factory.createReferenceType(methodBinding.getDeclaringClass(), _env);
- }
-
- public Collection<TypeParameterDeclaration> getFormalTypeParameters()
- {
- final IMethodBinding methodBinding = getDeclarationBinding();
- final ITypeBinding[] typeParams = methodBinding.getTypeParameters();
- if( typeParams == null || typeParams.length == 0 )
- return Collections.emptyList();
- final List<TypeParameterDeclaration> result = new ArrayList<TypeParameterDeclaration>();
- for( ITypeBinding typeVar : typeParams ){
- final TypeParameterDeclaration typeParamDecl = (TypeParameterDeclaration)Factory.createDeclaration(typeVar, _env);
- if( typeParamDecl != null )
- result.add(typeParamDecl);
- }
- return result;
- }
- public Collection<ParameterDeclaration> getParameters()
- {
- final IMethodBinding methodBinding = getDeclarationBinding();
- final ITypeBinding[] paramTypes = methodBinding.getParameterTypes();
- if( paramTypes == null || paramTypes.length == 0 )
- return Collections.emptyList();
-
- final ITypeBinding declaringClass = methodBinding.getDeclaringClass();
- final List<ParameterDeclaration> result = new ArrayList<ParameterDeclaration>(paramTypes.length);
-
- if( isFromSource() ){
-
- for( int i=0; i<paramTypes.length; i++ ){
- final ITypeBinding type = paramTypes[i];
- final ParameterDeclaration param = new SourceParameterDeclarationImpl(this, type, i, _env);
- result.add(param);
- }
- }
- else{
- for( int i=0; i<paramTypes.length; i++ ){
- final ITypeBinding type = paramTypes[i];
- final ParameterDeclaration param = new BinaryParameterDeclarationImpl(this, type, i, _env);
- result.add(param);
- }
- }
-
- return result;
- }
-
- public Collection<ReferenceType> getThrownTypes()
- {
- final IMethodBinding methodBinding = getDeclarationBinding();
- final ITypeBinding[] exceptions = methodBinding.getExceptionTypes();
- final List<ReferenceType> results = new ArrayList<ReferenceType>(4);
- for( ITypeBinding exception : exceptions ){
- final TypeDeclaration mirrorDecl = Factory.createReferenceType(exception, _env);
- if( mirrorDecl != null)
- results.add((ReferenceType)mirrorDecl);
- }
- return results;
- }
-
- public boolean isVarArgs()
- {
- return getDeclarationBinding().isVarargs();
- }
-
- public String getSimpleName()
- {
- return getDeclarationBinding().getName();
- }
-
- public IMethodBinding getDeclarationBinding()
- {
- return (IMethodBinding)_binding;
- }
-
- boolean isFromSource()
- {
- final ITypeBinding type = getDeclarationBinding().getDeclaringClass();
- return ( type != null && type.isFromSource() );
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/FieldDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/FieldDeclarationImpl.java
deleted file mode 100644
index 8d13091..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/FieldDeclarationImpl.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-
-import com.sun.mirror.declaration.FieldDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.util.DeclarationVisitor;
-
-public class FieldDeclarationImpl extends MemberDeclarationImpl implements FieldDeclaration
-{
- public FieldDeclarationImpl(final IVariableBinding binding, final ProcessorEnvImpl env)
- {
- super(binding, env);
- assert binding.isField() : "binding doesn't represent a field";
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitFieldDeclaration(this);
- }
-
- public String getConstantExpression()
- {
- final IVariableBinding field = getDeclarationBinding();
- final Object constant = field.getConstantValue();
- if( constant == null ) return null;
- return constant.toString();
- }
-
- public Object getConstantValue()
- {
- final IVariableBinding field = getDeclarationBinding();
- return field.getConstantValue();
- }
-
- public TypeDeclaration getDeclaringType()
- {
- final IVariableBinding field = getDeclarationBinding();
- final ITypeBinding outer = field.getDeclaringClass();
- return Factory.createReferenceType(outer, _env);
- }
-
- public String getSimpleName()
- {
- final IVariableBinding field = getDeclarationBinding();
- final String name = field.getName();
- return name == null ? "" : name;
- }
-
- public TypeMirror getType()
- {
- final IVariableBinding field = getDeclarationBinding();
- final TypeMirror typeMirror = Factory.createTypeMirror( field.getType(), _env );
- if( typeMirror == null )
- return Factory.createErrorClassType(field.getType());
- return typeMirror;
- }
-
- public IVariableBinding getDeclarationBinding()
- {
- return (IVariableBinding)_binding;
- }
-
- public String toString()
- {
- return getSimpleName();
- }
-
- public MirrorKind kind(){ return MirrorKind.FIELD; }
-
- boolean isFromSource()
- {
- final ITypeBinding type = getDeclarationBinding().getDeclaringClass();
- return ( type != null && type.isFromSource() );
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/IEclipseAnnotationValue.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/IEclipseAnnotationValue.java
deleted file mode 100644
index 348bdbe..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/IEclipseAnnotationValue.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import org.eclipse.jdt.apt.core.internal.EclipseMirrorImpl;
-
-import com.sun.mirror.declaration.AnnotationValue;
-
-/**
- * Represents an annotation member value.
- * The value may have come from source or from binary.
- */
-public interface IEclipseAnnotationValue extends AnnotationValue, EclipseMirrorImpl
-{
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/InterfaceDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/InterfaceDeclarationImpl.java
deleted file mode 100644
index 606eba2..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/InterfaceDeclarationImpl.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import com.sun.mirror.declaration.InterfaceDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.type.InterfaceType;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.mirror.util.TypeVisitor;
-import java.util.Collection;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-public class InterfaceDeclarationImpl extends TypeDeclarationImpl implements InterfaceDeclaration, InterfaceType
-{
- public InterfaceDeclarationImpl(final ITypeBinding binding, final ProcessorEnvImpl env)
- {
- super(binding, env);
- assert binding.isInterface() : "binding does not represents an interface.";
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitInterfaceDeclaration(this);
- }
-
- public Collection<? extends MethodDeclaration> getMethods()
- {
- return _getMethods();
- }
-
- // start of implementation of InterfaceType API
- public void accept(TypeVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitInterfaceType(this);
- }
-
- public InterfaceDeclaration getDeclaration()
- {
- return (InterfaceDeclaration)super.getDeclaration();
- }
- // end of implementation of InterfaceType API
-
- public MirrorKind kind(){ return MirrorKind.TYPE_INTERFACE; }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MemberDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MemberDeclarationImpl.java
deleted file mode 100644
index e69dc3a..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MemberDeclarationImpl.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.jdt.apt.core.internal.EclipseMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.SourcePositionImpl;
-import org.eclipse.jdt.core.dom.*;
-
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.MemberDeclaration;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.mirror.util.SourcePosition;
-
-public abstract class MemberDeclarationImpl extends DeclarationImpl implements MemberDeclaration, EclipseMirrorImpl
-{
- MemberDeclarationImpl(final IBinding binding, ProcessorEnvImpl env)
- {
- super(binding, env);
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitMemberDeclaration(this);
- }
-
- public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
- {
- final IResolvedAnnotation[] instances = getAnnotationInstances();
- return _getAnnotation(annotationClass, instances);
- }
-
- public Collection<AnnotationMirror> getAnnotationMirrors()
- {
- final IResolvedAnnotation[] instances = getAnnotationInstances();
- return _getAnnotationMirrors(instances);
- }
-
- private IResolvedAnnotation[] getAnnotationInstances()
- {
- final IBinding binding = getDeclarationBinding();
- final IResolvedAnnotation[] instances;
- switch( binding.getKind() )
- {
- case IBinding.TYPE:
- instances = ((ITypeBinding)binding).getAnnotations();
- break;
- case IBinding.METHOD:
- instances = ((IMethodBinding)binding).getAnnotations();
- break;
- case IBinding.VARIABLE:
- instances = ((IVariableBinding)binding).getAnnotations();
- break;
- case IBinding.PACKAGE:
- // TODO: support package annotation
- return null;
- default:
- throw new IllegalStateException();
- }
- return instances;
- }
-
- public String getDocComment()
- {
- if( isFromSource()){
- final Javadoc javaDoc = ((BodyDeclaration)getAstNode()).getJavadoc();
- if( javaDoc == null ) return "";
- return javaDoc.toString();
- }
- return null;
-
- }
-
- /**
- * @return the ast node that holds the range of this member declaration in source.
- * The default is to find the name of the node and if that fails, return the
- * node with the smallest range that contains the declaration.
- */
- private ASTNode getRangeNode()
- {
- final ASTNode node = getAstNode();
- if( node == null ) return null;
- SimpleName name = null;
- switch( node.getNodeType() )
- {
- case ASTNode.TYPE_DECLARATION:
- case ASTNode.ANNOTATION_TYPE_DECLARATION:
- case ASTNode.ENUM_DECLARATION:
- name = ((AbstractTypeDeclaration)node).getName();
- break;
- case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION:
- name = ((AnnotationTypeMemberDeclaration)node).getName();
- break;
- case ASTNode.METHOD_DECLARATION:
- name = ((MethodDeclaration)node).getName();
- break;
- case ASTNode.SINGLE_VARIABLE_DECLARATION:
- name = ((SingleVariableDeclaration)node).getName();
- break;
- case ASTNode.FIELD_DECLARATION:
- final String declName = getSimpleName();
- if( declName == null ) return node;
- for(Object obj : ((FieldDeclaration)node).fragments() ){
- VariableDeclarationFragment frag = (VariableDeclarationFragment)obj;
- if( declName.equals(frag.getName()) ){
- name = frag.getName();
- break;
- }
- }
- break;
- case ASTNode.ENUM_CONSTANT_DECLARATION:
- name = ((EnumConstantDeclaration)node).getName();
- break;
- default:
- return node;
- }
- if( name == null ) return node;
- return name;
- }
-
- /**
- * @return the source position of this declaration.
- * Return null if this declaration did not come from source or
- * if the declaration is (or is part of) a secondary type that is defined
- * outside of the file associated with the environment.
- */
- public SourcePosition getPosition()
- {
- if( isFromSource() ){
- final ASTNode node = getRangeNode();
- if( node == null ) return null;
- final CompilationUnit unit = getCompilationUnit();
- final int start = node.getStartPosition();
- return new SourcePositionImpl(start,
- node.getLength(),
- unit.lineNumber(start),
- this);
- }
- return null;
- }
-
- /**
- * @return the list of annotation ast node on the given body declaration.
- * This declaration must came from source.
- * Return the empty list if the declaration is part of a secondary type outside
- * of the file associated with the environment.
- */
- List<org.eclipse.jdt.core.dom.Annotation> getAnnotations()
- {
- assert isFromSource() : "Declaration did not come from source.";
- final BodyDeclaration decl = (BodyDeclaration)getAstNode();
- if( decl == null ) return Collections.emptyList();
- final List<IExtendedModifier> extMods = decl.modifiers();
- if( extMods == null || extMods.isEmpty() ) return Collections.emptyList();
- List<org.eclipse.jdt.core.dom.Annotation> annos = new ArrayList<org.eclipse.jdt.core.dom.Annotation>(4);
- for( IExtendedModifier extMod : extMods ){
- if( extMod.isAnnotation() )
- annos.add((org.eclipse.jdt.core.dom.Annotation)extMod);
- }
- return annos;
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MethodDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MethodDeclarationImpl.java
deleted file mode 100644
index 0ebd02c..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MethodDeclarationImpl.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.util.DeclarationVisitor;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-public class MethodDeclarationImpl extends ExecutableDeclarationImpl implements MethodDeclaration
-{
- public MethodDeclarationImpl(final IMethodBinding binding,
- final ProcessorEnvImpl env)
- {
- super(binding, env);
- assert !binding.isConstructor() : "binding does not represent a method.";
- }
-
- public TypeMirror getReturnType()
- {
- final IMethodBinding methodBinding = getDeclarationBinding();
- final ITypeBinding retType = methodBinding.getReturnType();
- final TypeMirror type = Factory.createTypeMirror(retType, _env);
- if(retType == null )
- return Factory.createErrorClassType(retType);
- return type;
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitMethodDeclaration(this);
- }
-
- public MirrorKind kind(){ return MirrorKind.METHOD; }
-
- public String toString()
- {
- final StringBuilder buffer = new StringBuilder();
- final IMethodBinding methodBinding = getDeclarationBinding();
- final ITypeBinding[] typeParams = methodBinding.getTypeParameters();
- if( typeParams != null && typeParams.length > 0 ){
- buffer.append('<');
- for(int i=0; i<typeParams.length; i++ ){
- if( i != 0 )
- buffer.append(", ");
- buffer.append(typeParams[i]);
- }
- buffer.append('>');
- }
-
- if( methodBinding.getReturnType() != null )
- buffer.append(methodBinding.getReturnType().getName());
- buffer.append(' ');
- buffer.append(methodBinding.getName());
- buffer.append('(');
- int i=0;
- for( ParameterDeclaration param : getParameters() ){
- if( i++ != 0 )
- buffer.append(", ");
- buffer.append(param);
- }
- buffer.append(')');
-
- return buffer.toString();
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/PackageDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/PackageDeclarationImpl.java
deleted file mode 100644
index a3b9088..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/PackageDeclarationImpl.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import java.lang.annotation.Annotation;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.PackageUtil;
-import org.eclipse.jdt.apt.core.internal.util.SourcePositionImpl;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IPackageBinding;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.mirror.util.SourcePosition;
-
-public class PackageDeclarationImpl extends DeclarationImpl implements PackageDeclaration
-{
- // If this package came from directly requesting it via the environment,
- // need to hide the source position, as this is an artifact of our implementation
- private final boolean _hideSourcePosition;
-
- /** The back-pointer to the type declaration that created this package declaration
- * @see TypeDeclarationImpl#getPackage()
- */
- private final TypeDeclarationImpl _typeDecl;
- public PackageDeclarationImpl(
- final IPackageBinding binding,
- final TypeDeclarationImpl typeDecl,
- final ProcessorEnvImpl env,
- final boolean hideSourcePosition)
- {
- super(binding, env);
- _typeDecl = typeDecl;
- _hideSourcePosition = hideSourcePosition;
- }
-
- public IPackageBinding getPackageBinding(){ return (IPackageBinding)_binding; }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitPackageDeclaration(this);
- }
-
- public <A extends Annotation> A getAnnotation(Class<A> anno)
- {
- return _getAnnotation(anno, getPackageBinding().getAnnotations());
- }
-
- public Collection<AnnotationMirror> getAnnotationMirrors()
- {
- return _getAnnotationMirrors(getPackageBinding().getAnnotations());
- }
-
- public Collection<AnnotationTypeDeclaration> getAnnotationTypes()
- {
- // jdt currently have no support for package declaration.
- return Collections.emptyList();
- }
-
- public Collection<ClassDeclaration> getClasses() {
- return PackageUtil.getClasses(this, _env);
- }
-
- public Collection<EnumDeclaration> getEnums() {
- return PackageUtil.getEnums(this, _env);
- }
-
- public Collection<InterfaceDeclaration> getInterfaces() {
- return PackageUtil.getInterfaces(this, _env);
- }
-
- public String getDocComment()
- {
- return null;
- }
-
- public Collection<Modifier> getModifiers()
- {
- // package doesn't have modifiers.
- return Collections.emptyList();
- }
-
- public SourcePosition getPosition()
- {
- if (_hideSourcePosition)
- return null;
- if(_typeDecl.isFromSource()){
- final CompilationUnit unit = _typeDecl.getCompilationUnit();
- final ASTNode node = unit.findDeclaringNode(getDeclarationBinding());
- if( node == null ) return null;
- final int start = node.getStartPosition();
- return new SourcePositionImpl(start,
- node.getLength(),
- unit.lineNumber(start),
- this);
- }
- return null;
-
- }
-
- public String getQualifiedName()
- {
- return getPackageBinding().getName();
- }
-
- public String getSimpleName()
- {
- IPackageBinding pkg = getPackageBinding();
- final String[] components = pkg.getNameComponents();
- if( components == null || components.length == 0 ) return "";
- return components[components.length - 1];
- }
-
- public MirrorKind kind(){ return MirrorKind.PACKAGE; }
-
- public String toString(){ return getQualifiedName(); }
-
- public IPackageBinding getDeclarationBinding(){ return (IPackageBinding)_binding; }
-
- boolean isFromSource(){ return _typeDecl.isFromSource(); }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/PackageDeclarationImplNoBinding.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/PackageDeclarationImplNoBinding.java
deleted file mode 100644
index 6ff7011..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/PackageDeclarationImplNoBinding.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import java.lang.annotation.Annotation;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.core.IPackageFragment;
-
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.ClassDeclaration;
-import com.sun.mirror.declaration.EnumDeclaration;
-import com.sun.mirror.declaration.InterfaceDeclaration;
-import com.sun.mirror.declaration.Modifier;
-import com.sun.mirror.declaration.PackageDeclaration;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.mirror.util.SourcePosition;
-
-/**
- * For packages that have no binding. E.g. Packages with no
- * classes, like "java.lang", or possibly "" (the default package).
- */
-public class PackageDeclarationImplNoBinding implements PackageDeclaration {
-
- private final IPackageFragment[] fragments;
- private final ProcessorEnvImpl env;
-
- public PackageDeclarationImplNoBinding(final IPackageFragment[] fragments, ProcessorEnvImpl env) {
- this.fragments = fragments;
- this.env = env;
- }
-
- public String getQualifiedName() {
- return fragments[0].getElementName();
- }
-
- public Collection<ClassDeclaration> getClasses() {
- return Collections.emptyList();
- }
-
- public Collection<EnumDeclaration> getEnums() {
- return Collections.emptyList();
- }
-
- public Collection<InterfaceDeclaration> getInterfaces() {
- return Collections.emptyList();
- }
-
- public Collection<AnnotationTypeDeclaration> getAnnotationTypes() {
- return Collections.emptyList();
- }
-
- public String getDocComment() {
- // Packages have no comments
- return null;
- }
-
- public Collection<AnnotationMirror> getAnnotationMirrors() {
- return Collections.emptyList();
- }
-
- public <A extends Object & Annotation> A getAnnotation(Class<A> arg0) {
- return null;
- }
-
- public Collection<Modifier> getModifiers() {
- // Packages do not have modifiers
- return Collections.emptyList();
- }
-
- public String getSimpleName() {
- String components = getQualifiedName();
- int dotIndex = components.indexOf(".");
- if (dotIndex < 0)
- return components;
- return components.substring(dotIndex + 1);
- }
-
- public SourcePosition getPosition() {
- // non-source, we do not have a source position
- return null;
- }
-
- public void accept(final DeclarationVisitor visitor) {
- visitor.visitDeclaration(this);
- visitor.visitPackageDeclaration(this);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ParameterDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ParameterDeclarationImpl.java
deleted file mode 100644
index e6897ae..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ParameterDeclarationImpl.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.util.DeclarationVisitor;
-import java.lang.annotation.Annotation;
-import java.util.Collection;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.IResolvedAnnotation;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.SimpleName;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-
-/**
- * Represents a formal parameter
- */
-public abstract class ParameterDeclarationImpl extends DeclarationImpl implements ParameterDeclaration
-{
- static final String ARG = "arg";
- /** this executable that this parameter came from */
- protected final ExecutableDeclarationImpl _executable;
- /** thie parameter is the <code>_paramIndex</code>th in <code>_executable</code> */
- protected final int _paramIndex;
-
- /**
- * Parameter declaration
- * @param the executable that declares this parameter
- * @param type the type of the parameter
- * @param index the index of this parameter in <code>executable</code>'s param list.
- */
- public ParameterDeclarationImpl(ExecutableDeclarationImpl executable,
- ITypeBinding type,
- int index,
- ProcessorEnvImpl env)
- {
- super(type, env);
- _executable = executable;
- _paramIndex = index;
- assert _executable != null : "missing executable";
- assert _paramIndex >= 0 : "invalid param index " + _paramIndex;
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitParameterDeclaration(this);
- }
-
- public String getDocComment()
- {
- return null;
- }
-
- public String getSimpleName()
- {
- final SingleVariableDeclaration decl = (SingleVariableDeclaration)getAstNode();
- if( decl == null ) return ARG + _paramIndex;
- final SimpleName name = decl.getName();
- return name == null ? ARG : name.toString();
- }
-
- public TypeMirror getType()
- {
- final TypeMirror mirrorType = Factory.createTypeMirror(getTypeBinding(), _env);
- if( mirrorType == null )
- return Factory.createErrorClassType(getTypeBinding());
- return mirrorType;
- }
-
- public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
- {
- final IMethodBinding methodBinding = _executable.getDeclarationBinding();
- final IResolvedAnnotation[] paramAnnos = methodBinding.getParameterAnnotations(_paramIndex);
- return _getAnnotation(annotationClass, paramAnnos);
- }
-
- public Collection<AnnotationMirror> getAnnotationMirrors()
- {
- final IMethodBinding methodBinding = _executable.getDeclarationBinding();
- final IResolvedAnnotation[] paramAnnos = methodBinding.getParameterAnnotations(_paramIndex);
- return _getAnnotationMirrors(paramAnnos);
- }
-
- private ITypeBinding getTypeBinding(){ return (ITypeBinding)_binding; }
-
- public MirrorKind kind(){ return MirrorKind.FORMAL_PARAMETER; }
-
- public int hashCode(){ return _executable.getDeclarationBinding().hashCode() + _paramIndex; }
-
- public String toString(){
- final StringBuilder builder = new StringBuilder();
- builder.append(getTypeBinding().getName());
- builder.append(' ');
- builder.append(getSimpleName());
- return builder.toString();
- }
-
- public IBinding getDeclarationBinding(){ throw new UnsupportedOperationException("should never be called"); }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/SourceParameterDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/SourceParameterDeclarationImpl.java
deleted file mode 100644
index db663ae..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/SourceParameterDeclarationImpl.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.SourcePositionImpl;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IExtendedModifier;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-
-import com.sun.mirror.declaration.Modifier;
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.util.SourcePosition;
-
-/**
- * Represents a formal parameter that came from source
- */
-public class SourceParameterDeclarationImpl extends ParameterDeclarationImpl implements ParameterDeclaration{
-
- // Ideally, we would store the IVariableBinding, but getting to it could be expensive
- // since it requires the ast node (SingleVariableDeclaration).
- // This could have a performance impact if the parameter did not come
- // from the compilation unit that is in the processor environment. In such a case,
- // we will have to go parse and resolve the file that contains the declaration.
- // Currently, the decision is to turn this into a on-demand process. (theodora)
-
- /**
- * Parameter declaration from source files
- * @param the executable that declares this parameter
- * @param type the type of the parameter
- * @param index the index of this parameter in <code>executable</code>'s param list.
- */
- public SourceParameterDeclarationImpl(ExecutableDeclarationImpl executable,
- ITypeBinding type,
- int index,
- ProcessorEnvImpl env)
- {
- super(executable, type, index, env);
- }
-
- public Collection<Modifier> getModifiers()
- {
- final SingleVariableDeclaration paramDecl = (SingleVariableDeclaration)getAstNode();
- if( paramDecl == null ) return Collections.emptyList();
- final List<IExtendedModifier> extMods = paramDecl.modifiers();
- if( extMods == null || extMods.isEmpty() ) return Collections.emptyList();
- for( IExtendedModifier extMod : extMods ){
- if( extMod.isModifier() ){
- final org.eclipse.jdt.core.dom.Modifier mod =
- (org.eclipse.jdt.core.dom.Modifier)extMod;
- if( org.eclipse.jdt.core.dom.Modifier.isFinal(mod.getFlags()) )
- return Collections.singletonList(Modifier.FINAL);
- }
- }
- return Collections.emptyList();
- }
-
- public SourcePosition getPosition()
- {
- final ASTNode node = getAstNode();
- if( node == null ) return null;
- final CompilationUnit unit = _executable.getCompilationUnit();
- return new SourcePositionImpl(node.getStartPosition(),
- node.getLength(),
- unit.lineNumber(node.getStartPosition()),
- this);
- }
-
- public boolean equals(Object obj){
- if( obj instanceof SourceParameterDeclarationImpl ){
- final SourceParameterDeclarationImpl otherParam = (SourceParameterDeclarationImpl)obj;
- return otherParam._paramIndex == _paramIndex &&
- otherParam._executable.getDeclarationBinding().isEqualTo(_executable.getDeclarationBinding()) ;
- }
- return false;
- }
-
- boolean isFromSource(){ return true; }
-
- SingleVariableDeclaration getAstNode()
- {
- final MethodDeclaration methodDecl = (MethodDeclaration)_executable.getAstNode();
- if( methodDecl == null ) return null;
- return (SingleVariableDeclaration)methodDecl.parameters().get(_paramIndex);
- }
-
- CompilationUnit getCompilationUnit()
- {
- return _executable.getCompilationUnit();
- }
-
- public IResource getResource(){
- return _executable.getResource();
- }
-}
-
-
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/TypeDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/TypeDeclarationImpl.java
deleted file mode 100644
index fcab521..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/TypeDeclarationImpl.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.DeclaredType;
-import com.sun.mirror.type.InterfaceType;
-import com.sun.mirror.type.ReferenceType;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.mirror.util.TypeVisitor;
-
-public abstract class TypeDeclarationImpl extends MemberDeclarationImpl implements TypeDeclaration, DeclaredType, ReferenceType
-{
- public TypeDeclarationImpl(final ITypeBinding binding,
- final ProcessorEnvImpl env)
- {
- super(binding, env);
- }
-
- public String getQualifiedName()
- {
- ITypeBinding type = getTypeBinding();
- return type.getQualifiedName();
- }
-
- public String getSimpleName()
- {
- ITypeBinding type = getTypeBinding();
- return type.getName();
- }
-
- public PackageDeclaration getPackage()
- {
- ITypeBinding binding = getDeclarationBinding();
- return new PackageDeclarationImpl(binding.getPackage(), this, _env, false);
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitTypeDeclaration(this);
- }
-
- public ITypeBinding getTypeBinding(){ return (ITypeBinding)_binding; }
-
- public Collection<FieldDeclaration> getFields()
- {
- final IVariableBinding[] fields = getDeclarationBinding().getDeclaredFields();
- final List<FieldDeclaration> results = new ArrayList<FieldDeclaration>(fields.length);
- for( IVariableBinding field : fields ){
- if( field.isSynthetic() ) continue;
- Declaration mirrorDecl = Factory.createDeclaration(field, _env);
- if( mirrorDecl != null)
- results.add( (FieldDeclaration)mirrorDecl);
- }
- return results;
- }
-
- public Collection<TypeDeclaration> getNestedTypes()
- {
- final ITypeBinding[] memberTypes = getDeclarationBinding().getDeclaredTypes();
- final List<TypeDeclaration> results = new ArrayList<TypeDeclaration>(memberTypes.length);
- for( ITypeBinding type : memberTypes ){
- Declaration mirrorDecl = Factory.createReferenceType(type, _env);
- if( mirrorDecl != null )
- results.add((TypeDeclaration)mirrorDecl);
- }
- return results;
- }
-
- public Collection<TypeParameterDeclaration> getFormalTypeParameters()
- {
- final ITypeBinding[] typeParams = getDeclarationBinding().getTypeParameters();
- final List<TypeParameterDeclaration> results = new ArrayList<TypeParameterDeclaration>(typeParams.length);
- for( ITypeBinding typeParam : typeParams ){
- Declaration mirrorDecl = Factory.createDeclaration(typeParam, _env);
- if( mirrorDecl != null )
- results.add( (TypeParameterDeclaration)mirrorDecl );
- }
- return results;
- }
-
- public TypeDeclaration getDeclaringType()
- {
- final ITypeBinding decl = getDeclarationBinding();
- if( decl.isMember() )
- return Factory.createReferenceType(decl.getDeclaringClass(), _env);
- return null;
- }
-
- // Start of implementation of DeclaredType API
- public Collection<TypeMirror> getActualTypeArguments()
- {
- final ITypeBinding type = getTypeBinding();
- final ITypeBinding[] typeArgs = type.getTypeArguments();
- if( typeArgs == null || typeArgs.length == 0 )
- return Collections.emptyList();
-
- final Collection<TypeMirror> result = new ArrayList<TypeMirror>(typeArgs.length);
- for( ITypeBinding arg : typeArgs ){
- final TypeMirror mirror = Factory.createTypeMirror(arg, _env);
- if(arg == null)
- result.add(Factory.createErrorClassType(arg));
- else
- result.add(mirror);
- }
-
- return result;
- }
-
- public DeclaredType getContainingType()
- {
- final ITypeBinding outer = getTypeBinding().getDeclaringClass();
- return (DeclaredType)Factory.createReferenceType(outer, _env);
- }
-
- public TypeDeclaration getDeclaration()
- {
- final ITypeBinding declBinding = getDeclarationBinding();
- if( declBinding == _binding ) return this;
- else return (TypeDeclaration)Factory.createReferenceType(declBinding, _env);
- }
-
- public Collection<InterfaceType> getSuperinterfaces()
- {
- final ITypeBinding[] superInterfaceBindings = getDeclarationBinding().getInterfaces();
- if( superInterfaceBindings == null || superInterfaceBindings.length == 0 )
- return Collections.emptyList();
- final List<InterfaceType> results = new ArrayList<InterfaceType>(superInterfaceBindings.length);
- for( ITypeBinding binding : superInterfaceBindings ){
- if( binding.isInterface() ){
- final TypeDeclarationImpl mirrorDecl = Factory.createReferenceType(binding, _env);
- if( mirrorDecl.kind() == MirrorKind.TYPE_INTERFACE ){
- results.add((InterfaceType)mirrorDecl);
- }
- }
- else results.add(Factory.createErrorInterfaceType(binding));
- }
- return results;
- }
-
- public void accept(TypeVisitor visitor)
- {
- visitor.visitTypeMirror(this);
- visitor.visitDeclaredType(this);
- visitor.visitReferenceType(this);
- }
-
- // End of implementation of DeclaredType API
-
- public ITypeBinding getDeclarationBinding()
- {
- final ITypeBinding type = getTypeBinding();
- return type.getTypeDeclaration();
- }
-
- protected List<? extends MethodDeclaration> _getMethods()
- {
- final IMethodBinding[] methods = getDeclarationBinding().getDeclaredMethods();
- final List<MethodDeclaration> results = new ArrayList<MethodDeclaration>(methods.length);
- for( IMethodBinding method : methods ){
- if( method.isConstructor() || method.isSynthetic() ) continue;
- Declaration mirrorDecl = Factory.createDeclaration(method, _env);
- if( mirrorDecl != null)
- results.add((MethodDeclaration)mirrorDecl);
- }
- return results;
- }
-
- public String toString()
- {
- final ITypeBinding binding = getTypeBinding();
- if( binding.isRawType() || !binding.isParameterizedType() )
- return getQualifiedName();
-
- final StringBuilder buffer = new StringBuilder();
- buffer.append(getQualifiedName());
- final ITypeBinding[] typeArgs = binding.getTypeArguments();
- if(typeArgs != null){
- buffer.append('<');
- for( int i=0; i<typeArgs.length; i++ ){
- if( i != 0 )
- buffer.append(',');
- buffer.append(typeArgs[i].getName());
- }
- buffer.append('>');
- }
-
- return buffer.toString();
- }
-
- boolean isFromSource(){ return getDeclarationBinding().isFromSource(); }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/TypeParameterDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/TypeParameterDeclarationImpl.java
deleted file mode 100644
index 5b7ccc0..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/TypeParameterDeclarationImpl.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.apt.core.internal.util.SourcePositionImpl;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.Modifier;
-import com.sun.mirror.declaration.TypeParameterDeclaration;
-import com.sun.mirror.type.ReferenceType;
-import com.sun.mirror.type.TypeVariable;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.mirror.util.SourcePosition;
-import com.sun.mirror.util.TypeVisitor;
-
-public class TypeParameterDeclarationImpl extends DeclarationImpl implements TypeParameterDeclaration, TypeVariable
-{
- public TypeParameterDeclarationImpl(final ITypeBinding binding,
- final ProcessorEnvImpl env)
- {
- super(binding, env);
- assert binding.isTypeVariable();
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitTypeParameterDeclaration(this);
- }
-
- public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
- {
- return null;
- }
-
- public Collection<AnnotationMirror> getAnnotationMirrors()
- {
- return Collections.emptyList();
- }
-
- public Collection<ReferenceType> getBounds()
- {
- final ITypeBinding[] bounds = getDeclarationBinding().getTypeBounds();
- if( bounds == null || bounds.length == 0 )
- return Collections.emptyList();
-
- final Collection<ReferenceType> result = new ArrayList<ReferenceType>(4);
- for( ITypeBinding bound : bounds ){
- final ReferenceType type = (ReferenceType)Factory.createReferenceType(bound, _env);
- if( type != null )
- result.add(type);
- }
-
- return result;
- }
-
- public String getDocComment()
- {
- return null;
- }
-
- public Collection<Modifier> getModifiers()
- {
- return Collections.emptyList();
- }
-
- public Declaration getOwner()
- {
- // TODO: (theodora) uncomment the following code when we get the next version of jdt.core
- /*
- final ITypeBinding binding = getDeclarationBinding();
- // declared on a class
- IBinding owner = binding.getDeclaringClass();
- if( owner == null )
- // declared on the method
- owner = binding.getDeclaringMethod();
- // actually don't know for some reason.
- if( owner == null ) return null;
- return Factory.createDeclaration(owner, _env);
-
- */
- throw new UnsupportedOperationException("Need version 1.44 of jdt.core.dom.ITypeBinding.java. tyeung@bea.com");
- }
-
- public SourcePosition getPosition()
- {
- if( isFromSource() )
- {
- final ASTNode node = getAstNode();
- if( node == null ) return null;
- final CompilationUnit unit = getCompilationUnit();
- final int offset = node.getStartPosition();
- return new SourcePositionImpl(offset, node.getLength(), unit.lineNumber(offset), this);
- }
- else
- return null;
- }
-
- public String getSimpleName()
- {
- final ITypeBinding typeVar = getDeclarationBinding();
- return typeVar.getName();
- }
-
- // Start of implementation of TypeVariable API
- public void accept(TypeVisitor visitor)
- {
- visitor.visitTypeMirror(this);
- visitor.visitReferenceType(this);
- visitor.visitTypeVariable(this);
- }
-
- public TypeParameterDeclaration getDeclaration()
- {
- return this;
- }
- // End of implementation of TypeVariable API
-
- public String toString()
- {
- return getSimpleName();
- }
-
- public MirrorKind kind(){ return MirrorKind.TYPE_PARAMETER_VARIABLE; }
-
- public ITypeBinding getDeclarationBinding(){ return (ITypeBinding) _binding; }
-
- boolean isFromSource(){ return getDeclarationBinding().isFromSource(); }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/AnnotationInvocationHandler.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/AnnotationInvocationHandler.java
deleted file mode 100644
index b81e6d9..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/AnnotationInvocationHandler.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.env;
-
-import com.sun.mirror.type.MirroredTypeException;
-import com.sun.mirror.type.MirroredTypesException;
-import com.sun.mirror.type.TypeMirror;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import org.eclipse.jdt.apt.core.internal.declaration.AnnotationMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-public class AnnotationInvocationHandler implements InvocationHandler
-{
- private final AnnotationMirrorImpl _instance;
-
- public AnnotationInvocationHandler(final AnnotationMirrorImpl annotation)
- {
- _instance = annotation;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- {
- final String methodName = method.getName();
- if( args == null || args.length == 0 )
- {
- if( methodName.equals("hashCode") )
- return new Integer( _instance.hashCode() );
- if( methodName.equals("toString") )
- return _instance.toString();
- }
- else if( args.length == 1 && methodName.equals("equals") )
- {
- return new Boolean( _instance.equals( args[0] ) );
- }
- if( args != null && args.length != 0 )
- throw new NoSuchMethodException("method " + method.getName() + formatArgs(args) + " does not exists");
- final String c_methodName = method.getName();
- final IMethodBinding methodBinding = _instance.getMethodBinding(c_methodName);
- if( methodBinding == null )
- throw new NoSuchMethodException("method " + method.getName() + "() does not exists");
-
- final ITypeBinding retType = methodBinding.getReturnType();
- // type of annotation member is java.lang.Class
- if( retType.isClass() && "java.lang.Class".equals(retType.getQualifiedName()) ){
- // need to figure out the class that's being accessed
- final ITypeBinding[] classTypes = _instance.getMemberValueTypeBinding(c_methodName);
- TypeMirror mirrorType = null;
- if( classTypes != null && classTypes.length > 0 ){
- mirrorType = Factory.createTypeMirror(classTypes[0], _instance.getEnvironment() );
- }
- if( mirrorType == null )
- mirrorType = Factory.createErrorClassType(classTypes[0]);
- throw new MirroredTypeException(mirrorType);
- }
- else if( retType.isArray() ){
- final ITypeBinding leafType = retType.getElementType();
- // type of annotation member is java.lang.Class[]
- if( leafType.isClass() && "java.lang.Class".equals(leafType.getQualifiedName()) ){
- final ITypeBinding[] classTypes = _instance.getMemberValueTypeBinding(c_methodName);
- final Collection<TypeMirror> mirrorTypes;
- if( classTypes == null || classTypes.length == 0 )
- mirrorTypes = Collections.emptyList();
- else{
- mirrorTypes = new ArrayList<TypeMirror>(classTypes.length);
- for( ITypeBinding type : classTypes ){
- TypeMirror mirror = Factory.createTypeMirror(type, _instance.getEnvironment() );
- if( mirror == null )
- mirrorTypes.add( Factory.createTypeMirror(type, _instance.getEnvironment() ) );
- else
- mirrorTypes.add(mirror);
- }
- }
-
- throw new MirroredTypesException(mirrorTypes);
- }
- }
- return _instance.getReflectionValue(c_methodName, method);
- }
-
- private String formatArgs(final Object[] args)
- {
- // estimate that each class name (plus the separators) is 10 characters long plus 2 for "()".
- final StringBuilder builder = new StringBuilder(args.length * 8 + 2 );
- builder.append('(');
- for( int i=0; i<args.length; i++ )
- {
- if( i > 0 ) builder.append(", ");
- builder.append(args[i].getClass().getName());
- }
-
- builder.append(')');
-
- return builder.toString();
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/EclipseRoundCompleteEvent.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/EclipseRoundCompleteEvent.java
deleted file mode 100644
index 451bff1..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/EclipseRoundCompleteEvent.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial implementation.
- *******************************************************************************/
-package org.eclipse.jdt.apt.core.internal.env;
-
-
-import com.sun.mirror.apt.RoundCompleteEvent;
-import com.sun.mirror.apt.RoundState;
-
-public class EclipseRoundCompleteEvent extends RoundCompleteEvent
-{
- static final long serialVersionUID = 0;
-
- public EclipseRoundCompleteEvent(final ProcessorEnvImpl env)
- {
- super( env, new State(env) );
- }
-
- private static class State implements RoundState
- {
- private final ProcessorEnvImpl _env;
- State(ProcessorEnvImpl env){ _env = env; }
- public boolean classFilesCreated() { return _env.hasGeneratedClassFiles(); }
- public boolean errorRaised() { return _env.hasRaisedErrors(); }
- public boolean sourceFilesCreated() { return _env.hasGeneratedSourceFiles(); }
- public boolean finalRound() {
- // apt terminates when there are no new generated source files
- return !_env.hasGeneratedSourceFiles();
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/FilerImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/FilerImpl.java
deleted file mode 100644
index 68de223..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/FilerImpl.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.env;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-import org.eclipse.jdt.apt.core.internal.util.FileSystemUtil;
-
-
-import com.sun.mirror.apt.Filer;
-
-
-public class FilerImpl implements Filer {
-
- private ProcessorEnvImpl _env;
- private boolean _generatedClassFiles = false;
-
- public FilerImpl( ProcessorEnvImpl env )
- {
- _env = env;
- }
-
- /**
- * 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.
- *
- * Character set used is the default character set for the platform
- *
- * @param name - canonical (fully qualified) name of the principal type being declared in this file
- */
- public PrintWriter createSourceFile(String typeName) throws IOException
- {
- return new JavaSourceFilePrintWriter( typeName, new StringWriter(), _env, null /* charset */ );
- }
-
-
- /**
- * 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
- */
- public OutputStream createClassFile(String name) throws IOException
- {
- _generatedClassFiles = true;
- throw new UnsupportedOperationException( "Not Yet Implemented" );
- }
-
- public boolean hasGeneratedClassFile(){ return _generatedClassFiles; }
-
- /**
- * 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 loc,
- * pkg, and relPath.
- *
- * A charset for encoding the file may be provided. If none is given,
- * the charset used to encode source files (see 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
- */
- public PrintWriter createTextFile(Filer.Location loc, String pkg, File relPath, String charsetName)
- throws IOException
- {
- // TODO: figure out what to do with the loc
- // Filer.Location.CLASS_TREE vs Filer.Location.SOURCE_TREE
- File f = new File(".");
-
- if( pkg != null )
- f = new File( f, pkg.replace('.', File.separatorChar) );
-
- f = new File( f, relPath.getPath() );
-
- // REVIEW: for no apparent reason it is sometimes necessary to create the
- // parent dir, else an IOException occurs creating f..
- File p = f.getParentFile();
- FileSystemUtil.mkdirs( p );
- return charsetName == null ? new PrintWriter( f ) : new PrintWriter( f, charsetName );
- }
-
- /**
- * 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 loc, pkg, and relPath.
- *
- * @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
- */
- public OutputStream createBinaryFile(Filer.Location loc, String pkg, File relPath)
- throws IOException
- {
- throw new UnsupportedOperationException( "Not yet implemented");
- }
-
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/JavaSourceFilePrintWriter.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/JavaSourceFilePrintWriter.java
deleted file mode 100644
index 7a5b30e..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/JavaSourceFilePrintWriter.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.env;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.apt.core.internal.generatedfile.FileGenerationResult;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedFileManager;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner;
-
-
-public class JavaSourceFilePrintWriter extends PrintWriter {
-
- public JavaSourceFilePrintWriter( String typeName, StringWriter sw, ProcessorEnvImpl env, String charsetName )
- {
- super( sw );
- _sw = sw;
- _typeName = typeName;
- _env = env;
- _charsetName = charsetName;
- }
-
- public void close()
- {
- try
- {
- String contents = _sw.toString();
- super.close();
- GeneratedFileManager gfm = GeneratedFileManager.getGeneratedFileManager(_env.getProject());
- ProcessorEnvImpl.Phase phase = _env.getPhase();
-
- if ( phase == ProcessorEnvImpl.Phase.RECONCILE )
- {
- ICompilationUnit parentCompilationUnit = _env.getCompilationUnit();
- FileGenerationResult result = gfm.generateFileDuringReconcile(
- parentCompilationUnit, _typeName, contents, DefaultWorkingCopyOwner.PRIMARY, null, null );
- _env.addGeneratedFile(result.getFile(), result.isModified());
- }
- else if ( phase == ProcessorEnvImpl.Phase.BUILD)
- {
- FileGenerationResult result = gfm.generateFileDuringBuild( _env.getFile(), _env.getJavaProject(), _typeName, contents, null /* progress monitor */, _charsetName );
- _env.addGeneratedFile( result.getFile(), result.isModified());
- }
- else
- {
- assert false : "Unexpected phase value: " + phase ;
- }
- }
- catch ( JavaModelException jme )
- {
- // TODO: handle this exception in a nicer way.
- jme.printStackTrace();
- throw new RuntimeException( jme );
- }
- catch ( CoreException ce )
- {
- // TODO: handle this exception
- ce.printStackTrace();
- throw new RuntimeException( ce );
- }
- catch( UnsupportedEncodingException use )
- {
- // TODO: handle this exception
- throw new RuntimeException( use );
- }
- }
-
-
- private StringWriter _sw;
- private String _typeName;
- private ProcessorEnvImpl _env;
- private String _charsetName;
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/MessagerImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/MessagerImpl.java
deleted file mode 100644
index eb0daf4..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/MessagerImpl.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.env;
-
-import com.sun.mirror.apt.Messager;
-import com.sun.mirror.util.SourcePosition;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.apt.core.internal.NonEclipseImplementationException;
-import org.eclipse.jdt.apt.core.internal.util.SourcePositionImpl;
-import org.eclipse.jdt.apt.core.util.EclipseMessager;
-import org.eclipse.jdt.core.dom.ASTNode;
-
-public class MessagerImpl implements Messager, EclipseMessager
-{
- private final ProcessorEnvImpl _env;
-
- MessagerImpl(ProcessorEnvImpl env){
- _env = env;
- }
-
- public void printError(SourcePosition pos, String msg)
- {
- if( pos instanceof SourcePositionImpl )
- print((SourcePositionImpl)pos, IMarker.SEVERITY_ERROR, msg);
- else if (pos == null )
- printError(msg);
- else
- throw new NonEclipseImplementationException("only applicable to eclipse mirror objects." +
- " Found " + pos.getClass().getName());
- }
-
- public void printError(ASTNode node, String msg)
- {
- if( node == null )
- throw new IllegalArgumentException("'node' cannot be null");
- final int start = node.getStartPosition();
- final int line = _env.getAstCompilationUnit().lineNumber(start);
- addMarker(_env.getFile(), start, node.getLength() + start, IMarker.SEVERITY_ERROR, msg, line );
- }
-
- public void printError(String msg)
- {
- print(IMarker.SEVERITY_ERROR, msg);
- }
-
- public void printNotice(SourcePosition pos, String msg)
- {
- if( pos instanceof SourcePositionImpl )
- print((SourcePositionImpl)pos, IMarker.SEVERITY_INFO, msg);
- else if (pos == null )
- printNotice(msg);
- else
- throw new NonEclipseImplementationException("only applicable to eclipse mirror objects." +
- " Found " + pos.getClass().getName());
- }
-
- public void printNotice(ASTNode node, String msg)
- {
- if( node == null )
- throw new IllegalArgumentException("'node' cannot be null");
- final int start = node.getStartPosition();
- final int line = _env.getAstCompilationUnit().lineNumber(start);
- addMarker(_env.getFile(), start, node.getLength() + start, IMarker.SEVERITY_INFO, msg, line );
- }
-
- public void printNotice(String msg)
- {
- print(IMarker.SEVERITY_INFO, msg);
- }
-
- public void printWarning(SourcePosition pos, String msg)
- {
- if( pos instanceof SourcePositionImpl )
- print((SourcePositionImpl)pos, IMarker.SEVERITY_WARNING, msg);
- else if (pos == null )
- printWarning(msg);
- else
- throw new NonEclipseImplementationException("only applicable to eclipse mirror objects." +
- " Found " + pos.getClass().getName());
- }
-
- public void printWarning(ASTNode node, String msg)
- {
- if( node == null )
- throw new IllegalArgumentException("'node' cannot be null");
- final int start = node.getStartPosition();
- final int line = _env.getAstCompilationUnit().lineNumber(start);
- addMarker(_env.getFile(), start, node.getLength() + start, IMarker.SEVERITY_WARNING, msg, line );
- }
-
- public void printWarning(String msg)
- {
- print(IMarker.SEVERITY_WARNING, msg);
- }
-
- private void print(SourcePositionImpl pos,
- int severity,
- String msg)
- {
-
- final int start = pos.getStartingOffset();
- final int end = pos.getEndingOffset();
- final IResource resource = pos.getResource();
- if( resource == null ){
- throw new IllegalStateException("missing resource");
- }
- else{
- addMarker(resource,
- pos.getStartingOffset(),
- pos.getEndingOffset(),
- severity,
- msg,
- pos.line());
- }
- }
-
- private void print(int severity, String msg)
- {
- addMarker(null, 0, 1, severity, msg, 1);
- }
-
- private void addMarker(final IResource resource, final int start, final int end,
- final int severity, final String msg, final int line)
- {
- if( msg == null )
- throw new IllegalArgumentException("missing message");
- Map<String, Object> map = new HashMap<String, Object>(8); // entries = 6, loadFactory = 0.75 thus, capacity = 8
- map.put( IMarker.CHAR_START, start );
- map.put( IMarker.CHAR_END, end );
- map.put( IMarker.SEVERITY, severity );
- map.put( IMarker.MESSAGE, msg );
- map.put( IMarker.LINE_NUMBER, line);
- map.put( IMarker.LOCATION, "line: " + line);
- map = Collections.unmodifiableMap(map);
- _env.addMarker(resource, map);
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ProcessorEnvImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ProcessorEnvImpl.java
deleted file mode 100644
index 3b23209..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ProcessorEnvImpl.java
+++ /dev/null
@@ -1,1127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.env;
-
-import java.io.BufferedInputStream;
-import java.io.CharArrayWriter;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.apt.core.env.EclipseAnnotationProcessorEnvironment;
-import org.eclipse.jdt.apt.core.internal.declaration.PackageDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.PackageDeclarationImplNoBinding;
-import org.eclipse.jdt.apt.core.internal.declaration.TypeDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.type.PrimitiveTypeImpl;
-import org.eclipse.jdt.apt.core.internal.type.VoidTypeImpl;
-import org.eclipse.jdt.apt.core.internal.util.DeclarationsUtil;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.apt.core.internal.util.PackageUtil;
-import org.eclipse.jdt.apt.core.internal.util.TypesUtil;
-import org.eclipse.jdt.apt.core.util.EclipseMessager;
-import org.eclipse.jdt.core.BindingKey;
-import org.eclipse.jdt.core.IClassFile;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ASTParser;
-import org.eclipse.jdt.core.dom.ASTRequestor;
-import org.eclipse.jdt.core.dom.ASTVisitor;
-import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration;
-import org.eclipse.jdt.core.dom.Block;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.DoStatement;
-import org.eclipse.jdt.core.dom.ForStatement;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.IExtendedModifier;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jdt.core.dom.IfStatement;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.TryStatement;
-import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.AnnotationProcessorListener;
-import com.sun.mirror.apt.Filer;
-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;
-
-public class ProcessorEnvImpl implements AnnotationProcessorEnvironment,
- EclipseAnnotationProcessorEnvironment
-{
- public static final String RECONCILE_MARKER = "org.eclipse.jdt.apt.core.reconcile_marker";
- public static final String BUILD_MARKER = "org.eclipse.jdt.apt.core.build_marker";
- public static final ICompilationUnit[] NO_UNIT = new ICompilationUnit[0];
-
- public enum Phase { RECONCILE, BUILD };
-
- private final CompilationUnit _astCompilationUnit;
- private final ICompilationUnit _compilationUnit;
- private final List<MarkerInfo> _markerInfos;
- private final Phase _phase;
- private final IFile _file;
- /**
- * The source code in <code>_file</code>.
- * This is the exact same source code that created the dom compil
- */
- private final char[] _source;
-
- private final IJavaProject _javaProject;
- // Stores the generated files and whether or not they were modified. In this case,
- // new files will be considered "modified".
- private final Map<IFile, Boolean> _generatedFiles = new HashMap<IFile, Boolean>();
- private Set<AnnotationProcessorListener> _listeners = null;
- private final FilerImpl _filer;
- private boolean _isClosed = false;
-
- /**
- * Set of strings that indicate new type dependencies introduced on the file
- * each string is a fully-qualified type name.
- */
- private Set<String> _typeDependencies = new HashSet<String>();
-
- // void type and the primitive types will be null if the '_file'
- // is outside of the workspace.
- private VoidTypeImpl _voidType;
- private PrimitiveTypeImpl[] _primitives;
-
- /**
- * Mapping model compilation unit to dom compilation unit.
- * The assumption here is that once the client examine some binding from some file, it will continue
- * to examine other bindings from came from that same file.
- */
- private final Map<ICompilationUnit, CompilationUnit> _modelCompUnit2astCompUnit;
- /**
- * Mapping (source) top-level type binding to the compilation unit that defines it.
- */
- private final Map<ITypeBinding, ICompilationUnit> _typeBinding2ModelCompUnit;
-
- public static ProcessorEnvImpl newProcessorEnvironmentForReconcile(ICompilationUnit compilationUnit, IJavaProject javaProj)
- {
- return new ProcessorEnvImpl( compilationUnit, javaProj, Phase.RECONCILE );
- }
-
- public static ProcessorEnvImpl newProcessorEnvironmentForBuild( IFile file, IJavaProject javaProj )
- {
- return new ProcessorEnvImpl( file, javaProj, Phase.BUILD );
- }
-
- private ProcessorEnvImpl( IFile file, IJavaProject javaProj, Phase phase )
- {
- assert phase == Phase.BUILD : "Unexpected phase value. Use Phase.BUILD instead of " + phase;
-
- _compilationUnit = null;
-
- char[] source = null;
-
- try
- {
- source = getFileContents( file );
- }
- catch( Exception e )
- {
- // TODO: propagate these exceptions out of APTDispatch
- e.printStackTrace();
- }
-
- _source = source;
- assert _source != null : "missing source";
-
- String unitName = file.getProjectRelativePath().toString();
- ASTNode node = createDietAST( unitName, javaProj, null, _source );
- _astCompilationUnit = (org.eclipse.jdt.core.dom.CompilationUnit) node;
- _phase = phase;
- _file = file;
- _javaProject = javaProj;
- _modelCompUnit2astCompUnit = new HashMap<ICompilationUnit, CompilationUnit>();
- _typeBinding2ModelCompUnit = new HashMap<ITypeBinding, ICompilationUnit>();
- _markerInfos = new ArrayList<MarkerInfo>(4);
- _filer = new FilerImpl(this);
- initPrimitives(_javaProject);
- }
-
- private ProcessorEnvImpl(ICompilationUnit compilationUnit, IJavaProject javaProj, Phase phase)
- {
- assert phase == Phase.RECONCILE : "Unexpected phase value. Use Phase.RECONCILE instead of " + phase;
-
- _source = null;
- String unitName = compilationUnit.getResource().getProjectRelativePath().toString();
- ASTNode node = createDietAST( unitName, javaProj, compilationUnit, null );
-
- _astCompilationUnit = (org.eclipse.jdt.core.dom.CompilationUnit) node;
-
- _compilationUnit = compilationUnit;
- _phase = phase;
- _file = (IFile)compilationUnit.getResource();
- _javaProject = javaProj;
- _modelCompUnit2astCompUnit = new HashMap<ICompilationUnit, CompilationUnit>();
- _typeBinding2ModelCompUnit = new HashMap<ITypeBinding, ICompilationUnit>();
- _markerInfos = new ArrayList<MarkerInfo>(4);
- _filer = new FilerImpl(this);
- initPrimitives(_javaProject);
- }
-
-
- /**
- * This should create an AST without imports or method-body statements
- */
- private static ASTNode createDietAST( String unitName, IJavaProject javaProject, ICompilationUnit compilationUnit, char[] source )
- {
- ASTParser p = ASTParser.newParser( AST.JLS3 );
- if ( compilationUnit != null )
- p.setSource( compilationUnit );
- else
- p.setSource( source );
- p.setResolveBindings( true );
- p.setProject( javaProject );
- p.setUnitName( unitName );
- p.setFocalPosition( 0 );
- p.setKind( ASTParser.K_COMPILATION_UNIT );
- ASTNode node = p.createAST( null );
- return node;
- }
-
-
- public Collection<Declaration> getDeclarationsAnnotatedWith(AnnotationTypeDeclaration a)
- {
- final ITypeBinding annotationType = TypesUtil.getTypeBinding(a);
- if( annotationType == null || !annotationType.isAnnotation()) return Collections.emptyList();
- final List<IBinding> annotatedDecls = getBindingsAnnotatedWith(annotationType);
- if( annotatedDecls.isEmpty() ) return Collections.emptyList();
- final Collection<Declaration> results = new ArrayList<Declaration>(annotatedDecls.size());
- for( IBinding annotatedDecl : annotatedDecls ){
- Declaration mirrorDecl = Factory.createDeclaration(annotatedDecl, this);
- if( mirrorDecl != null )
- results.add(mirrorDecl);
- }
- return results;
- }
-
- private List<IBinding> getBindingsAnnotatedWith(final ITypeBinding annotationType)
- {
- final Map<ASTNode, List<Annotation>> astNode2Anno = new HashMap<ASTNode, List<Annotation>>();
- _astCompilationUnit.accept( new AnnotatedNodeVisitor(astNode2Anno) );
- if( astNode2Anno.isEmpty() )
- return Collections.emptyList();
- final List<IBinding> annotatedBindings = new ArrayList<IBinding>();
- for(Map.Entry<ASTNode, List<Annotation>> entry : astNode2Anno.entrySet() ){
- final ASTNode node = entry.getKey();
- for( Annotation anno : entry.getValue() ){
- final IBinding resolvedTypeBinding = anno.resolveTypeBinding();
- if( annotationType.isEqualTo(resolvedTypeBinding) )
- getBinding(node, annotatedBindings);
- }
- }
- return annotatedBindings;
-
- }
-
- /**
- * @param node the ast node in question
- * @param bindings the list to be populated.
- * adding the binding(s) corresponding to the ast node to this list.
- */
- private void getBinding(ASTNode node, List<IBinding> bindings)
- {
- if( node == null ) return;
- IBinding binding = null;
- switch( node.getNodeType() )
- {
- case ASTNode.FIELD_DECLARATION:
- final List<VariableDeclarationFragment> fragments =
- ((org.eclipse.jdt.core.dom.FieldDeclaration)node).fragments();
- for( VariableDeclarationFragment frag : fragments ){
- final IBinding fieldBinding = frag.resolveBinding();
- if( fieldBinding != null )
- bindings.add(fieldBinding);
- }
- return;
-
- case ASTNode.ENUM_CONSTANT_DECLARATION:
- binding = ((org.eclipse.jdt.core.dom.EnumConstantDeclaration)node).resolveVariable();
- break;
- case ASTNode.METHOD_DECLARATION:
- binding = ((org.eclipse.jdt.core.dom.MethodDeclaration)node).resolveBinding();
- case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION:
- binding = ((AnnotationTypeMemberDeclaration)node).resolveBinding();
- break;
- case ASTNode.TYPE_DECLARATION:
- case ASTNode.ANNOTATION_TYPE_DECLARATION:
- case ASTNode.ENUM_DECLARATION:
- binding = ((AbstractTypeDeclaration)node).resolveBinding();
- break;
- case ASTNode.SINGLE_VARIABLE_DECLARATION:
- binding = ((SingleVariableDeclaration)node).resolveBinding();
- break;
- case ASTNode.PACKAGE_DECLARATION:
- binding = ((org.eclipse.jdt.core.dom.PackageDeclaration)node).resolveBinding();
- break;
- default:
- throw new UnsupportedOperationException("unknown node type: " + node.getNodeType());
- }
-
- if(binding != null)
- bindings.add(binding);
- return;
- }
-
- private Map<ASTNode, List<Annotation>> findASTNodesWithAnnotataion()
- {
- throw new UnsupportedOperationException("e-mail tyeung@bea.com if you need this now.");
- }
-
- private static final class AnnotatedNodeVisitor extends ASTVisitor
- {
- private final Map<ASTNode, List<Annotation>> _result;
- private AnnotatedNodeVisitor(Map<ASTNode, List<Annotation>> map)
- {
- _result = map;
- }
-
- /**
- * visit package declaration
- */
- public boolean visit(org.eclipse.jdt.core.dom.PackageDeclaration node)
- {
- final List<Annotation> annotations = node.annotations();
- if( !annotations.isEmpty() )
- _result.put(node, annotations);
-
- return false;
- }
-
- /**
- * visit class and interface declaration
- */
- public boolean visit(org.eclipse.jdt.core.dom.TypeDeclaration node)
- {
- visitBodyDeclaration(node);
- return true;
- }
-
- /**
- * visit annotation type declaration
- */
- public boolean visit(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration node)
- {
- visitBodyDeclaration(node);
- return true;
- }
-
- /**
- * visit enum type declaration
- */
- public boolean visit(org.eclipse.jdt.core.dom.EnumDeclaration node)
- {
- visitBodyDeclaration(node);
- return true;
- }
-
- /**
- * visit field declaration
- */
- public boolean visit(org.eclipse.jdt.core.dom.FieldDeclaration node)
- {
- visitBodyDeclaration(node);
- return true;
- }
-
- /**
- * visit enum constant declaration
- */
- public boolean visit(org.eclipse.jdt.core.dom.EnumConstantDeclaration node)
- {
- visitBodyDeclaration(node);
- return true;
- }
-
- /**
- * visit method declaration
- */
- public boolean visit(MethodDeclaration node)
- {
- visitBodyDeclaration(node);
- return true;
- }
-
- /**
- * visit annotation type member
- */
- public boolean visit(AnnotationTypeMemberDeclaration node)
- {
- visitBodyDeclaration(node);
- return true;
- }
-
- private void visitBodyDeclaration(final BodyDeclaration node)
- {
- final List<IExtendedModifier> extMods = node.modifiers();
- List<Annotation> annos = null;
- for( IExtendedModifier extMod : extMods ){
- if( extMod.isAnnotation() ){
- if( annos == null ){
- annos = new ArrayList<Annotation>(2);
- _result.put(node, annos);
- }
- annos.add((Annotation)extMod);
- }
- }
- }
-
- /**
- * visiting formal parameter declaration.
- */
- public boolean visit(SingleVariableDeclaration node)
- {
- final List<IExtendedModifier> extMods = node.modifiers();
- List<Annotation> annos = null;
- for( IExtendedModifier extMod : extMods ){
- if( extMod.isAnnotation() ){
- if( annos == null ){
- annos = new ArrayList<Annotation>(2);
- _result.put(node, annos);
- }
- annos.add((Annotation)extMod);
- }
- }
- return false;
- }
-
- /**
- * @return false so we skip everything beyond declaration level.
- */
- public boolean visit(Block node)
- { // so we don't look into anything beyond declaration level.
- return false;
- }
- public boolean visit(MarkerAnnotation node){ return false; }
- public boolean visit(NormalAnnotation node){ return false; }
- public boolean visit(SingleMemberAnnotation node){ return false; }
-
- }
-
- /**
- * Traverse the ast looking for annotations at the declaration level.
- */
- public static final class AnnotationVisitor extends ASTVisitor
- {
- final List<Annotation> _annotations;
- public AnnotationVisitor(final List<Annotation> annotations)
- { _annotations = annotations; }
-
- public boolean visit(MarkerAnnotation annotation)
- {
- _annotations.add(annotation);
- return false;
- }
-
- public boolean visit(SingleMemberAnnotation annotation)
- {
- _annotations.add(annotation);
- return false;
- }
-
- public boolean visit(NormalAnnotation annotation)
- {
- _annotations.add(annotation);
- return false;
- }
-
-
- // make sure we don't hit Arguments other than formal parameters.
- public boolean visit(Block blk){ return false; }
- public boolean visit(DoStatement doStatement){ return false; }
- public boolean visit(ForStatement forStatement){ return false; }
- public boolean visit(IfStatement ifStatement){ return false; }
- public boolean visit(TryStatement tryStatement){ return false; }
- }
-
-
- public Declarations getDeclarationUtils()
- {
- return new DeclarationsUtil();
- }
-
- public Filer getFiler()
- {
- checkValid();
- return _filer;
- }
-
- public EclipseMessager getMessager()
- {
- checkValid();
- return new MessagerImpl(this);
- }
-
- public Map<String, String> getOptions()
- {
- final HashMap<String, String> options = new HashMap<String, String>(2);
- options.put("phase", getPhase().toString());
- return options;
- }
-
- public PackageDeclaration getPackage(String name)
- {
- if (name == null)
- throw new IllegalArgumentException("name cannot be null");
-
- checkValid();
- IPackageFragment[] pkgFrags = PackageUtil.getPackageFragments(name, this);
-
- // No packages found, null expected
- if (pkgFrags.length == 0)
- return null;
-
- // If there are no source or class files, we'll need to return
- // a special implementation of the package decl that expects
- // no declarations inside it
- boolean containsNoJavaResources = true;
- for (IPackageFragment pkg : pkgFrags) {
- try {
- if (pkg.containsJavaResources()) {
- containsNoJavaResources = false;
- break;
- }
- }
- catch (JavaModelException e) {}
- }
- if (containsNoJavaResources)
- return new PackageDeclarationImplNoBinding(pkgFrags, this);
-
- // We should be able to create a class or
- // source file from one of the packages.
- ICompilationUnit compUnit = null;
- IClassFile classFile = null;
-
- OUTER:
- for (IPackageFragment pkg : pkgFrags) {
- try {
- ICompilationUnit[] compUnits = pkg.getCompilationUnits();
- if (compUnits.length > 0) {
- compUnit = compUnits[0];
- break;
- }
- IClassFile[] classFiles = pkg.getClassFiles();
- if (classFiles.length > 0) {
- // Need to grab the first one that's not an inner class,
- // as eclipse has trouble parsing inner class files
- for (IClassFile tempClassFile : classFiles) {
- if (tempClassFile.getElementName().indexOf("$") < 0) {
- classFile = tempClassFile;
- break OUTER;
- }
- }
- }
- }
- catch (JavaModelException e) {}
- }
-
- IType type = null;
- if (compUnit != null) {
- try {
- IType[] types = compUnit.getAllTypes();
- }
- catch (JavaModelException e) {}
- }
- else if (classFile != null) {
- try {
- type = classFile.getType();
- }
- catch (JavaModelException e) {}
- }
-
- // Given a type, we can construct a package declaration impl from it,
- // but we must hide the fact that it came from a real declaration,
- // as the client requested it without that context
- if (type != null) {
- TypeDeclarationImpl typeDecl = (TypeDeclarationImpl)getTypeDeclaration(type);
- ITypeBinding binding = typeDecl.getDeclarationBinding();
- return new PackageDeclarationImpl(binding.getPackage(), typeDecl, this, true);
- }
-
- // No classes or source files found
- return new PackageDeclarationImplNoBinding(pkgFrags, this);
- }
-
- public Collection<TypeDeclaration> getSpecifiedTypeDeclarations()
- {
- return getTypeDeclarations();
- }
-
- /**
- * @param key the key to a type binding, could be reference type, array or primitive.
- * @return the binding corresponding to the given key or null if none is found.
- */
- public ITypeBinding getTypeBinding(final String key)
- {
- class BindingRequestor extends ASTRequestor
- {
- private ITypeBinding _result = null;
- public void acceptBinding(String bindingKey, IBinding binding)
- {
- if( binding != null && binding.getKind() == IBinding.TYPE )
- _result = (ITypeBinding)binding;
- }
- }
-
- final BindingRequestor requestor = new BindingRequestor();
- final ASTParser parser = ASTParser.newParser(AST.JLS3);
- parser.setResolveBindings(true);
- parser.setProject(_javaProject);
- parser.createASTs(NO_UNIT, new String[]{key}, requestor, null);
- return requestor._result;
- }
-
- public TypeDeclaration getTypeDeclaration(String name)
- {
- checkValid();
- if( name == null ) return null;
- // first look into the current compilation unit
- final String typeKey = BindingKey.createTypeBindingKey(name);
- final ASTNode node = _astCompilationUnit.findDeclaringNode(typeKey);
- ITypeBinding typeBinding = null;
- if( node != null ){
- final int nodeType = node.getNodeType();
- if( nodeType == ASTNode.TYPE_DECLARATION ||
- nodeType == ASTNode.ANNOTATION_TYPE_DECLARATION ||
- nodeType == ASTNode.ENUM_DECLARATION )
- typeBinding = ((AbstractTypeDeclaration)node).resolveBinding();
- }
- if( typeBinding != null )
- return Factory.createReferenceType(typeBinding, this);
-
- // then go search for it else where.
- typeBinding = getTypeBinding(typeKey);
- if( typeBinding != null ){
- addTypeDependency( name );
- return Factory.createReferenceType(typeBinding, this);
- }
-
- return null;
- }
-
- public TypeDeclaration getTypeDeclaration(final IType type) {
- if (type == null) return null;
- String name = type.getFullyQualifiedName();
- return getTypeDeclaration(name);
- }
-
- /**
- * @return the list of all named type declarations in compilation unit associated with
- * this environment.
- * This implementation is different from the API specification that it does not return
- * all included types in the universe.
- */
- public Collection<TypeDeclaration> getTypeDeclarations()
- {
- final List<ITypeBinding> bindings = getTypeBindings();
- if( bindings.isEmpty() )
- return Collections.emptyList();
- final List<TypeDeclaration> mirrorDecls = new ArrayList<TypeDeclaration>(bindings.size());
-
- for( ITypeBinding binding : bindings ){
- final TypeDeclaration mirrorDecl = Factory.createReferenceType(binding, this);
- if( mirrorDecl != null )
- mirrorDecls.add(mirrorDecl);
- }
-
- return mirrorDecls;
- }
-
- private List<ITypeBinding> getTypeBindings()
- {
- final List<AbstractTypeDeclaration> declTypes = _astCompilationUnit.types();
- if( declTypes == null || declTypes.isEmpty() )
- return Collections.emptyList();
- final List<ITypeBinding> typeBindings = new ArrayList<ITypeBinding>(declTypes.size());
-
- for( AbstractTypeDeclaration decl : declTypes ){
- getTypeBindings(decl.resolveBinding(), typeBindings);
- }
- return typeBindings;
- }
-
- /**
- * Add <code>type</code> and all its declared nested type(s) to <code>types</code>
- * @param type the container type
- * @param typeBindings upon return, contains all the nested types within <code>type</code>
- * and the type itself.
- */
- private void getTypeBindings(final ITypeBinding type, final List<ITypeBinding> typeBindings)
- {
- if( type == null ) return;
- typeBindings.add(type);
- final ITypeBinding[] nestedTypes = type.getDeclaredTypes();
- for( ITypeBinding nestedType : type.getDeclaredTypes() ) {
- typeBindings.add(nestedType);
- getTypeBindings(nestedType, typeBindings);
- }
- }
-
- public Types getTypeUtils()
- {
- return new TypesUtil(this);
- }
-
- public void addListener(AnnotationProcessorListener listener)
- {
- checkValid();
- if(_listeners == null )
- _listeners = new HashSet<AnnotationProcessorListener>();
- _listeners.add(listener);
- }
-
- public void removeListener(AnnotationProcessorListener listener)
- {
- checkValid();
- if( _listeners == null ) return;
- _listeners.remove(listener);
- }
-
- public Set<AnnotationProcessorListener> getProcessorListeners()
- {
- if( _listeners == null )
- return Collections.emptySet();
- return Collections.unmodifiableSet(_listeners);
- }
-
- public void addGeneratedFile( IFile f, boolean contentsChanged ) {
- _generatedFiles.put( f, contentsChanged );
- }
-
- public CompilationUnit getAstCompilationUnit() { return _astCompilationUnit; }
- public ICompilationUnit getCompilationUnit() { return _compilationUnit; }
- public Phase getPhase() { return _phase; }
-
- public IFile getFile() { return _file; }
- public IProject getProject() { return _javaProject.getProject(); }
- public IJavaProject getJavaProject() { return _javaProject; }
- public Map<IFile, Boolean> getGeneratedFiles() { return _generatedFiles; }
-
- /**
- * @return true iff source files has been generated.
- * Always return false when this environment is closed.
- */
- public boolean hasGeneratedSourceFiles() { return !_generatedFiles.isEmpty(); }
-
- /**
- * @return true iff class files has been generated.
- * Always return false when this environment is closed.
- */
- public boolean hasGeneratedClassFiles() { return _filer.hasGeneratedClassFile(); }
-
- /**
- * @return true iff errors (markers with serverity == IMarker.SEVERITY_ERRROR) has been posted
- * Always return false when this environment is closed.
- */
- public boolean hasRaisedErrors()
- {
- checkValid();
- for(MarkerInfo info : _markerInfos )
- {
- final Object val = info._markerAttrs.get(IMarker.SEVERITY);
- if( val != null && ((Integer)val).intValue() == IMarker.SEVERITY_ERROR )
- return true;
- }
- return false;
- }
-
- /**
- * @param binding must be correspond to a type, method or field declaration.
- * @return the ast node the corresponds to the declaration of the given binding.
- * Return null if none is found.
- */
- public ASTNode getASTNodeForBinding(final IBinding binding)
- {
- final CompilationUnit astUnit = getCompilationUnitForBinding(binding);
- if( astUnit == null ) return null;
- return astUnit.findDeclaringNode(binding.getKey());
- }
-
- /**
- * @param binding must be correspond to a type, method or field declaration.
- * @return the compilation unit that contains the declaration of the given binding.
- */
- public CompilationUnit getCompilationUnitForBinding(final IBinding binding)
- {
- assert binding.getKind() == IBinding.TYPE ||
- binding.getKind() == IBinding.METHOD ||
- binding.getKind() == IBinding.VARIABLE ;
- ASTNode node = getAstCompilationUnit().findDeclaringNode(binding);
- if( node != null ) return getAstCompilationUnit();
- else{
- final IMember member = (IMember)binding.getJavaElement();
- final ICompilationUnit unit;
- if( member != null ){
- unit = member.getCompilationUnit();
- }
- else{
- final ITypeBinding typeBinding = getDeclaringClass(binding);
- if( _typeBinding2ModelCompUnit.get(typeBinding) != null )
- unit = _typeBinding2ModelCompUnit.get(typeBinding);
- else{
- final String qname = typeBinding.getQualifiedName();
- final String pathname = qname.replace('.', File.separatorChar);
- final IPath path = Path.fromOSString(pathname);
- try{
- unit = (ICompilationUnit)_javaProject.findElement(path);
- _typeBinding2ModelCompUnit.put(typeBinding, unit);
- }
- catch(JavaModelException e){
- throw new IllegalStateException(e);
- }
- }
- }
- if( unit == null ) return null;
-
- final CompilationUnit astUnit = _modelCompUnit2astCompUnit.get(unit);
- if( astUnit != null ) return astUnit;
- else{
- // Note: very expensive operation. we are re-compiling a file with binding information.
- final ASTParser parser = ASTParser.newParser(AST.JLS3);
- parser.setResolveBindings(true);
- parser.setSource(unit);
- parser.setFocalPosition(0);
- CompilationUnit resultUnit = (CompilationUnit)parser.createAST(null);
- _modelCompUnit2astCompUnit.put(unit, resultUnit);
- return resultUnit;
- }
- }
- }
-
- /**
- * @param binding must be correspond to a type, method or field declaration
- * @return the file that contains the declaration of given binding.
- */
- public IFile getDeclaringFileForBinding(final IBinding binding)
- {
- assert binding.getKind() == IBinding.TYPE ||
- binding.getKind() == IBinding.METHOD ||
- binding.getKind() == IBinding.VARIABLE ;
- // check to see whether it is in the current file.
- ASTNode node = getAstCompilationUnit().findDeclaringNode(binding);
- if( node != null ) return _file;
- else{
- final IMember member = (IMember)binding.getJavaElement();
- if( member != null ){
- final ICompilationUnit unit = member.getCompilationUnit();
- return (IFile)unit.getResource();
- }
- else{
- final ITypeBinding type = getDeclaringClass(binding);
- assert type.isTopLevel() : "type must be top-level type";
- final String qname = type.getQualifiedName();
- final String pathname = qname.replace('.', File.separatorChar);
- final IPath path = Path.fromOSString(pathname);
- try{
- // the element would be a compilation unit.
- final IJavaElement element = _javaProject.findElement(path);
- if( element == null ) return null;
- return (IFile)element.getResource();
- }
- catch(JavaModelException e){
- throw new IllegalStateException(e);
- }
- }
- }
- }
-
- /**
- * @param bindin a type, method or field binding.
- * @return the top-level type binding that declares <code>binding</code>
- * or itself if it is already one.
- */
- private ITypeBinding getDeclaringClass(final IBinding binding)
- {
- assert binding != null : "binding cannot be null";
- ITypeBinding aTypeBinding = null;
- switch( binding.getKind() )
- {
- case IBinding.TYPE:
- aTypeBinding = (ITypeBinding)binding;
- break;
- case IBinding.METHOD:
- aTypeBinding = ((IMethodBinding)binding).getDeclaringClass();
- break;
- case IBinding.VARIABLE:
- aTypeBinding = ((IVariableBinding)binding).getDeclaringClass();
- break;
- default:
- throw new IllegalStateException("unrecognized binding type " + binding.getKind());
- }
- if(aTypeBinding == null ) return null;
- while( !aTypeBinding.isTopLevel() ){
- aTypeBinding = aTypeBinding.getDeclaringClass();
- }
- return aTypeBinding;
- }
-
-
-
- /**
- *
- * reads a given file's contents and returns them as a char array.
- *
- * @param file
- * @return
- * @throws CoreException
- */
- public static char[] getFileContents( IFile file )
- throws CoreException, IOException
- {
- char[] rtrn = null;
- InputStream is = null;
- BufferedInputStream bis = null;
- InputStreamReader isr = null;
- CharArrayWriter w = null;
-
- try
- {
- is = file.getContents();
- bis = new BufferedInputStream( is );
- isr = new InputStreamReader( bis, file.getCharset() );
- w = new CharArrayWriter( 4096 );
- int c = -1;
- while ( ( c = isr.read() ) > -1 )
- w.write( c );
- rtrn = w.toCharArray();
- }
- finally
- {
- try { if ( isr != null ) isr.close(); } catch ( IOException ioe ) {};
- try { if ( bis != null ) bis.close(); } catch ( IOException ioe ) {};
- try { if ( is != null ) is.close(); } catch ( IOException ioe ) {};
- if ( w != null ) w.close();
- }
- return rtrn;
- }
-
- /* (non-Javadoc)
- * Once the environment is closed the following is not allowed
- * 1) posting messge
- * 2) generating file
- * 3) retrieving type or package by name
- * 4) add or remove listeners
- */
- public void close(){
- // post all of the messages
- postMarkers();
-
- _modelCompUnit2astCompUnit.clear();
- _markerInfos.clear();
- _generatedFiles.clear();
- if(_listeners != null)
- _listeners.clear();
- _isClosed = true;
- }
-
- private void checkValid()
- {
- if( _isClosed )
- throw new IllegalStateException("Environment has expired");
- }
-
- /**
- * Add a marker to the environment.
- * @param resource null to indicate the resource of the current compilation unit in this environment.
- * @param markerAttrs the attributes to the marker
- */
- void addMarker(final IResource resource, Map<String, Object> markerAttrs)
- {
- _markerInfos.add( new MarkerInfo(resource, markerAttrs));
- }
-
- void postMarkers()
- {
- // Posting all the markers to the workspace. Doing this in a batch process
- // to minimize the amount of notification.
- try{
- // the resource of the compilation unit in the environment.
- final IResource currentResource = _file;
- final IWorkspaceRunnable runnable = new IWorkspaceRunnable(){
- public void run(IProgressMonitor monitor)
- {
- final String markerType = _phase == Phase.RECONCILE ?
- RECONCILE_MARKER : BUILD_MARKER;
- for( MarkerInfo markerInfo : _markerInfos ){
- IResource resource = markerInfo._resource;
- if( resource == null )
- resource = currentResource;
- try{
- final IMarker marker = resource.createMarker(markerType);
- marker.setAttributes(markerInfo._markerAttrs);
- }
- catch(CoreException e){
- throw new IllegalStateException(e);
- }
- }
- };
- };
- currentResource.getWorkspace().run(runnable, null);
- }
- catch(CoreException e){
- throw new IllegalStateException(e);
- }
- finally{
- _markerInfos.clear();
- }
- }
-
- /**
- * @return - the extra type dependencies for the file under compilation
- */
- public Set<String> getTypeDependencies() { return _typeDependencies; }
-
- private static class MarkerInfo
- {
- private final IResource _resource;
- private final Map<String, Object> _markerAttrs;
-
- private MarkerInfo(final IResource resource, final Map<String, Object> markerAttrs )
- {
- _resource = resource;
- _markerAttrs = markerAttrs;
- }
- }
-
- // Implementation for EclipseAnnotationProcessorEnvironment
- public CompilationUnit getAST()
- {
- if( _compilationUnit != null )
- {
- final ASTParser parser = ASTParser.newParser(AST.JLS3);
- parser.setResolveBindings(false);
- parser.setSource(_compilationUnit);
- CompilationUnit resultUnit = (CompilationUnit)parser.createAST(null);
- return resultUnit;
- }
- else{
- // this is a fully-flushed out DOM/AST unlike the one that's current in the environment.
- // also this copy will not contain any binding information nor pointers to java element.
- ASTParser p = ASTParser.newParser( AST.JLS3 );
- p.setSource( _source );
- p.setResolveBindings( false );
- p.setProject( _javaProject );
- p.setUnitName( _file.getProjectRelativePath().toString() );
- p.setKind( ASTParser.K_COMPILATION_UNIT );
- ASTNode node = p.createAST( null );
- return (CompilationUnit)node;
- }
- }
-
- public void addTypeDependency(final String fullyQualifiedTypeName )
- {
- _typeDependencies.add( fullyQualifiedTypeName );
- }
-
- private void initPrimitives(final IJavaProject project)
- {
- if(_primitives != null ) return;
- _primitives = new PrimitiveTypeImpl[8];
- class PrimitiveBindingRequestor extends ASTRequestor
- {
- public void acceptBinding(String bindingKey, IBinding binding)
- {
- if( binding.getKind() == IBinding.TYPE ){
- if( "boolean".equals(binding.getName()) )
- _primitives[0] = new PrimitiveTypeImpl( (ITypeBinding)binding );
- else if( "byte".equals(binding.getName()) )
- _primitives[1] = new PrimitiveTypeImpl( (ITypeBinding)binding );
- else if( "char".equals(binding.getName()) )
- _primitives[2] = new PrimitiveTypeImpl( (ITypeBinding)binding );
- else if( "double".equals(binding.getName()) )
- _primitives[3] = new PrimitiveTypeImpl( (ITypeBinding)binding );
- else if( "float".equals(binding.getName()) )
- _primitives[4] = new PrimitiveTypeImpl( (ITypeBinding)binding );
- else if( "int".equals(binding.getName()) )
- _primitives[5] = new PrimitiveTypeImpl( (ITypeBinding)binding );
- else if( "long".equals(binding.getName()) )
- _primitives[6] = new PrimitiveTypeImpl( (ITypeBinding)binding );
- else if( "short".equals(binding.getName()) )
- _primitives[7] = new PrimitiveTypeImpl( (ITypeBinding)binding );
- else if( "void".equals(binding.getName()) )
- _voidType = new VoidTypeImpl( (ITypeBinding)binding );
- else
- System.err.println("got unexpected type " + binding.getName());
- }
- else
- System.err.println("got unexpected binding " + binding.getClass().getName() + binding );
- }
- }
-
- final String[] keys = { BindingKey.createTypeBindingKey("boolean"),
- BindingKey.createTypeBindingKey("byte"),
- BindingKey.createTypeBindingKey("char"),
- BindingKey.createTypeBindingKey("double"),
- BindingKey.createTypeBindingKey("float"),
- BindingKey.createTypeBindingKey("int"),
- BindingKey.createTypeBindingKey("long"),
- BindingKey.createTypeBindingKey("short"),
- BindingKey.createTypeBindingKey("void")};
-
- final PrimitiveBindingRequestor requestor = new PrimitiveBindingRequestor();
- final ASTParser parser = ASTParser.newParser(AST.JLS3);
- parser.setProject(project);
- parser.setResolveBindings(true);
- parser.createASTs(ProcessorEnvImpl.NO_UNIT, keys, requestor, null);
- }
-
- public PrimitiveTypeImpl getBooleanType(){ return _primitives[0]; }
- public PrimitiveTypeImpl getByteType(){ return _primitives[1]; }
- public PrimitiveTypeImpl getCharType(){ return _primitives[2]; }
- public PrimitiveTypeImpl getDoubleType(){ return _primitives[3]; }
- public PrimitiveTypeImpl getFloatType(){ return _primitives[4]; }
- public PrimitiveTypeImpl getIntType(){ return _primitives[5]; }
- public PrimitiveTypeImpl getLongType(){ return _primitives[6]; }
- public PrimitiveTypeImpl getShortType(){ return _primitives[7]; }
- public VoidTypeImpl getVoidType(){ return _voidType; }
-
- // End of implementation for EclipseAnnotationProcessorEnvironment
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/FileGenerationResult.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/FileGenerationResult.java
deleted file mode 100644
index cb87124..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/FileGenerationResult.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.eclipse.jdt.apt.core.internal.generatedfile;
-
-import org.eclipse.core.resources.IFile;
-
-/**
- * Simple container class for holding the result of file generation.<P>
- *
- * It contains the generated file, as well as a boolean indicating if it
- * has changed since it was last seen. This is used to force compilation
- * of the file later.
- */
-public class FileGenerationResult {
-
- private final IFile file;
- private final boolean modified;
-
- public FileGenerationResult(final IFile file, final boolean modified) {
- this.file = file;
- this.modified = modified;
- }
-
- public IFile getFile() {
- return file;
- }
-
- public boolean isModified() {
- return modified;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileManager.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileManager.java
deleted file mode 100644
index 3072da2..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileManager.java
+++ /dev/null
@@ -1,843 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *******************************************************************************/
-
-
-package org.eclipse.jdt.apt.core.internal.generatedfile;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourceAttributes;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IProblemRequestor;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.WorkingCopyOwner;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.internal.core.JavaProject;
-
-
-/**
- * Class for managing generated files
- */
-public class GeneratedFileManager {
-
- private final IProject _project;
-
- // Use a weak hash map to allow file managers to get GC'ed if a project
- // goes away
- private static final Map<IProject, GeneratedFileManager> MANAGERS_MAP =
- new WeakHashMap<IProject, GeneratedFileManager>();
-
- /**
- * Construction can only take place from within
- * the factory method, getGeneratedFileManager().
- */
- private GeneratedFileManager(final IProject project) {
- _project = project;
- }
-
- private static void init()
- {
- _initialized = true;
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- int mask = IResourceChangeEvent.PRE_BUILD | IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE;
- workspace.addResourceChangeListener( new ResourceChangedListener(), mask );
- }
-
- public static synchronized List<GeneratedFileManager> getGeneratedFileManagers() {
- return new ArrayList(MANAGERS_MAP.values());
- }
-
- public static synchronized GeneratedFileManager getGeneratedFileManager(final IProject project)
- {
- if ( ! _initialized )
- init();
- GeneratedFileManager gfm = MANAGERS_MAP.get(project);
- if (gfm != null)
- return gfm;
-
- gfm = new GeneratedFileManager(project);
- MANAGERS_MAP.put(project, gfm);
- return gfm;
- }
-
- /**
- * Return the file and a flag indicating if the content was modified.
- *
- * @param parentFile
- * @param typeName
- * @param contents
- * @param progressMonitor
- * @param charsetName
- * @return - the newly created IFile along with whether it was modified
- * @throws CoreException
- * @throws UnsupportedEncodingException
- */
- public synchronized FileGenerationResult generateFileDuringBuild(
- IFile parentFile,
- IJavaProject javaProject,
- String typeName,
- String contents,
- IProgressMonitor progressMonitor,
- String charsetName )
- throws CoreException, UnsupportedEncodingException
- {
- try
- {
- IProject project = javaProject.getProject();
- // create folder for generated source files
- IFolder folder = project.getFolder( GENERATED_SOURCE_FOLDER_NAME );
- if (!folder.exists())
- folder.create(true, false, null);
-
- //
- // make sure __generated_src dir is on the cp if not already
- //
- updateProjectClasspath( (JavaProject)javaProject, folder, progressMonitor );
-
- // split the type name into its parts
- String[] parts = typeName.split( "\\.");
-
- // create folders for the package parts
- int i = 0;
- for ( ;i < parts.length - 1; i++ )
- {
- folder = folder.getFolder( parts[i] );
- if ( !folder.exists() )
- folder.create( true, false, null );
- }
-
- String fileName = parts[i] + ".java";
- IFile file = folder.getFile( fileName );
-
- byte[] bytes;
- if ( charsetName == null || charsetName == "" )
- bytes = contents.getBytes();
- else
- bytes = contents.getBytes( charsetName );
- InputStream is = new ByteArrayInputStream( bytes );
-
- boolean contentsDiffer = true;
-
- if ( !file.exists() )
- {
- file.create( is, true, progressMonitor );
- }
- else
- {
- // Check if the content has changed
- InputStream oldData = null;
- try {
- oldData = new BufferedInputStream(file.getContents());
- contentsDiffer = !compareStreams(oldData, is);
- }
- catch (CoreException ce) {
- // Do nothing. Assume the new content is different
- }
- finally {
- is.reset();
- if (oldData != null) {
- try {
- oldData.close();
- }
- catch (IOException ioe)
- {}
- }
- }
- if (contentsDiffer) {
- makeReadOnly( file, false );
- file.setContents( is, true, true, progressMonitor );
- }
- }
-
- file.setDerived( true );
-
- makeReadOnly( file, true );
-
- updateFileMaps( typeName, parentFile, file );
- return new FileGenerationResult(file, contentsDiffer);
- }
- catch ( Throwable t )
- {
- t.printStackTrace();
- }
-
- return null;
- }
-
- /**
- * Return true if the content of the streams is identical,
- * false if not.
- */
- private static boolean compareStreams(InputStream is1, InputStream is2) {
- try {
- int b1 = is1.read();
- while(b1 != -1) {
- int b2 = is2.read();
- if(b1 != b2) {
- return false;
- }
- b1 = is1.read();
- }
-
- int b2 = is2.read();
- if(-1 != b2) {
- return false;
- }
- return true;
- }
- catch (IOException ioe) {
- return false;
- }
- }
-
- /**
- * TODO: figure out how to create a working copy with a client-specified character set
- *
- *
- * @param parentCompilationUnit
- * @param typeName
- * @param contents
- * @param workingCopyOwner
- * @param problemRequestor
- * @param progressMonitor
- * @return
- */
- public synchronized FileGenerationResult generateFileDuringReconcile(
- ICompilationUnit parentCompilationUnit, String typeName,
- String contents, WorkingCopyOwner workingCopyOwner,
- IProblemRequestor problemRequestor, IProgressMonitor progressMonitor )
- {
- ICompilationUnit workingCopy = null;
- FileGenerationResult result = null;
- try
- {
- //
- // get working copy (either from cache or create a new one)
- //
- workingCopy = getCachedWorkingCopy( parentCompilationUnit, typeName );
-
- if ( workingCopy == null )
- {
- // create a new working copy
- workingCopy = createNewWorkingCopy(
- parentCompilationUnit, typeName, contents,
- workingCopyOwner, problemRequestor, progressMonitor);
- workingCopy.reconcile(AST.JLS3, true, workingCopyOwner,
- progressMonitor);
- result = new FileGenerationResult((IFile)workingCopy.getResource(), true);
- }
- else
- {
-
- //
- // Update working copy's buffer with the contents of the type
- //
- boolean modified = updateWorkingCopy( contents, workingCopy, workingCopyOwner, progressMonitor );
- result = new FileGenerationResult((IFile)workingCopy.getResource(), modified);
- }
-
- return result;
- }
- catch (JavaModelException jme)
- {
- jme.printStackTrace();
- }
- catch (CoreException ce)
- {
- ce.printStackTrace();
- }
- return new FileGenerationResult((IFile)workingCopy.getResource(), true);
- }
-
-
- public synchronized boolean isGeneratedFile( IFile f )
- {
- Set<IFile> s = _derivedFile2Parents.get( f );
- if ( s == null || s.isEmpty() )
- return false;
- else
- return true;
- }
-
- public synchronized boolean isParentFile( IFile f )
- {
- Set<IFile> s = _parent2DerivedFiles.get( f );
- if ( s == null || s.isEmpty() )
- return false;
- else
- return true;
- }
-
-
- /**
- * @param parent
- * @return set of Strings which are the type names known to be generated
- * by the specified parent.
- */
- public synchronized Set<String> getGeneratedTypesForParent( IFile parent )
- {
- Set<String> s = _parent2TypeNames.get( parent );
- if ( s == null )
- s = Collections.emptySet();
- return s;
- }
-
- /**
- *
- * @param parent
- * @return Set of IFile instances that are the files known to be generated
- * by this parent
- */
- public synchronized Set<IFile> getGeneratedFilesForParent( IFile parent )
- {
- Set<IFile> s = _parent2DerivedFiles.get( parent );
- if (s == null )
- s = Collections.emptySet();
- return s;
- }
-
- public synchronized void discardGeneratedWorkingCopy( String typeName, ICompilationUnit parentCompilationUnit )
- throws JavaModelException
- {
- discardGeneratedWorkingCopy( typeName, parentCompilationUnit, true );
- }
-
- private void discardGeneratedWorkingCopy( String typeName, ICompilationUnit parentCompilationUnit, boolean deleteFromParent2TypeNames )
- throws JavaModelException
- {
- if ( deleteFromParent2TypeNames )
- {
- Set<String> typeNames = _parent2TypeNames.get( parentCompilationUnit.getResource() );
-
- if ( typeNames == null ) throw new RuntimeException( "Unexpected null entry in _parent2TypeNames map.");
- if ( ! typeNames.contains( typeName )) throw new RuntimeException ("type names set didn't contain expected value");
-
- typeNames.remove( typeName );
- }
-
- Set<ICompilationUnit> parents = _typeName2Parents.get( typeName );
-
- // TODO: change these to assertions
- if ( parents == null ) throw new RuntimeException( "parents == null and it shouldnt");
- if ( ! parents.contains( parentCompilationUnit )) throw new RuntimeException("parents set should contain parentCompilationUnit");
- parents.remove( parentCompilationUnit );
-
- if ( parents.size() == 0 )
- {
- ICompilationUnit cu = _typeName2WorkingCopy.get( typeName );
-
- if ( cu == null ) throw new RuntimeException( "compilation unit is null and it shouldn't be");
-
- _typeName2WorkingCopy.remove( typeName );
- cu.discardWorkingCopy();
- }
- }
-
- public synchronized void parentWorkingCopyDiscarded( ICompilationUnit parentCompilationUnit )
- throws JavaModelException
- {
- Set<String> typeNames = _parent2TypeNames.get( parentCompilationUnit.getResource() );
- if ( typeNames == null || typeNames.size() == 0 )
- return;
-
- Iterator<String> it = typeNames.iterator();
- while ( it.hasNext() )
- {
- String typeName = it.next();
- it.remove();
- discardGeneratedWorkingCopy( typeName, parentCompilationUnit, false );
- }
- }
-
- public synchronized void parentFileDeleted( IFile parent, IProgressMonitor monitor )
- throws CoreException
- {
- Set<IFile> derivedFiles = _parent2DerivedFiles.get( parent );
-
- Iterator<IFile> it = derivedFiles.iterator();
- while ( it.hasNext() )
- {
- IFile generatedFile = it.next();
- it.remove();
- deleteGeneratedFile( generatedFile, parent, monitor, false );
- }
- }
-
- public synchronized boolean deleteGeneratedFile(IFile fileToDelete, IFile parent, IProgressMonitor progressMonitor )
- throws CoreException
- {
- return deleteGeneratedFile( fileToDelete, parent, progressMonitor, true );
- }
-
- private boolean deleteGeneratedFile(IFile fileToDelete, IFile parent, IProgressMonitor progressMonitor, boolean deleteFromParent2DerivedFiles )
- throws CoreException
- {
- // update _parents2DerivedFiles map
- if ( deleteFromParent2DerivedFiles )
- {
- Set<IFile> derivedFiles = _parent2DerivedFiles.get( parent );
-
- // assertions
- if ( derivedFiles == null ) throw new RuntimeException( "derivedFiles is null and it shouldn't be");
- if ( ! derivedFiles.contains( fileToDelete )) throw new RuntimeException( "derivedFiles does not contain fileToDelete");
-
- derivedFiles.remove( fileToDelete );
- }
-
- // update _derivedFile2Parents map and delete file if it has no other parents
- Set<IFile> parents = _derivedFile2Parents.get( fileToDelete );
-
- // assertions
- if( parents == null ) throw new RuntimeException( " parents is null and it shouldn't be" );
- if( ! parents.contains( parent )) throw new RuntimeException( "parents set does not contain parent" );
-
- parents.remove( parent );
-
- boolean deleted = false;
- if ( parents.size() == 0 )
- {
- fileToDelete.delete( true, true, progressMonitor );
- deleted = true;
- }
- return deleted;
- }
-
- public synchronized void generatedFileDeleted( IFile deletedFile, IProgressMonitor progressMonitor )
- {
- Set<IFile> parents = _derivedFile2Parents.get( deletedFile );
- if ( parents == null || parents.isEmpty() )
- return;
-
- String typeName = getTypeNameForDerivedFile( deletedFile );
-
- Iterator<IFile> it = parents.iterator();
- while ( it.hasNext() )
- {
- IFile parent = it.next();
- Set<IFile> s = _parent2DerivedFiles.get( parent );
- s.remove( deletedFile );
-
- Set<String> types = _parent2TypeNames.get( parent );
- types.remove( typeName );
- }
-
- _derivedFile2Parents.remove( deletedFile );
-
- _typeName2Parents.remove( typeName );
-
- _typeName2WorkingCopy.remove( typeName );
- }
-
- /**
- * given file f, return the typename corresponding to the file. This assumes
- * that derived files use java naming rules (i.e., type "a.b.c" will be file
- * "a/b/c.java".
- */
- private String getTypeNameForDerivedFile( IFile f )
- {
- IPath p = f.getFullPath();
-
- IProject project = f.getProject();
- IFolder folder = project.getFolder( GENERATED_SOURCE_FOLDER_NAME );
- IPath generatedSourcePath = folder.getFullPath();
-
- int count = p.matchingFirstSegments( generatedSourcePath );
- p = p.removeFirstSegments( count );
-
- String s = p.toPortableString();
- int idx = s.lastIndexOf( '.' );
- s = p.toPortableString().replace( '/', '.' );
- return s.substring( 0, idx );
- }
-
- //
- // check cache to see if we already have a working copy
- //
- private ICompilationUnit getCachedWorkingCopy( ICompilationUnit parentCompilationUnit, String typeName )
- {
- ICompilationUnit workingCopy = (ICompilationUnit) _typeName2WorkingCopy.get( typeName );
- if ( workingCopy != null )
- updateMaps( typeName, parentCompilationUnit, workingCopy );
-
- return workingCopy;
- }
-
- private ICompilationUnit createNewWorkingCopy(ICompilationUnit parentCompilationUnit, String typeName,
- String contents, WorkingCopyOwner workingCopyOwner,
- IProblemRequestor problemRequestor, IProgressMonitor progressMonitor)
- throws CoreException, JavaModelException
- {
- IProject project = parentCompilationUnit.getResource().getProject();
- JavaProject jp = (JavaProject) parentCompilationUnit.getJavaProject();
-
- //
- // create folder for generated source files
- //
- IFolder folder = project.getFolder( GENERATED_SOURCE_FOLDER_NAME );
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- if (!folder.exists())
- folder.create(true, true, null);
-
- //
- // make sure __generated_src dir is on the cp if not already
- //
- updateProjectClasspath( jp, folder, progressMonitor );
-
- //
- // figure out package part of type & file name
- //
- String pkgName;
- String fname;
- int idx = typeName.lastIndexOf( '.' );
- if ( idx > 0 )
- {
- pkgName = typeName.substring( 0, idx );
- fname =
- typeName.substring(idx + 1, typeName.length()) + ".java";
- }
- else
- {
- pkgName = "";
- fname = typeName + ".java";
- }
-
- //
- // create compilation unit
- //
- IPackageFragmentRoot root = jp.getPackageFragmentRoot(folder);
- IPackageFragment pkgFragment =
- root.createPackageFragment( pkgName, true, null );
-
- ICompilationUnit cu = pkgFragment.getCompilationUnit( fname );
- if ( cu == null || ! cu.getResource().exists() )
- {
- cu = pkgFragment.createCompilationUnit(
- fname, contents, true, progressMonitor );
- }
- else
- {
- makeReadOnly( cu, false );
- }
-
- //
- // TODO: can we call getWorkingCopy here?
- //
- cu.becomeWorkingCopy(problemRequestor, progressMonitor);
- ICompilationUnit workingCopy = cu;
-
- //
- // update maps
- //
- updateMaps( typeName, parentCompilationUnit, workingCopy );
-
- // we save this here since the resource has to exist on disk
- workingCopy.commitWorkingCopy( true, progressMonitor );
-
- //
- // make the file derived so that it is not checked into source control.
- //
- makeDerived( workingCopy );
-
- //
- // make working copy read-only
- //
- makeReadOnly( workingCopy, true );
-
-
- return workingCopy;
-
- }
-
- private void makeReadOnly( ICompilationUnit cu, boolean readOnly )
- throws CoreException
- {
- IResource r = cu.getResource();
- makeReadOnly( r, readOnly );
- }
-
- /**
- * make the compilation unit read-only
- */
- private void makeReadOnly( IResource r, boolean readOnly )
- throws CoreException
- {
- if ( r.exists() )
- {
- ResourceAttributes ra = r.getResourceAttributes();
- if (ra == null)
- ra = new ResourceAttributes();
- ra.setReadOnly( readOnly );
- r.setResourceAttributes(ra);
- }
- }
-
- private void makeDerived( ICompilationUnit cu )
- throws CoreException
- {
- IResource r = cu.getResource();
- if ( r.exists() )
- r.setDerived( true );
-
- }
-
- /**
- * Returns true if the file was modified
- */
- private static boolean updateWorkingCopy(
- String contents, ICompilationUnit workingCopy,
- WorkingCopyOwner workingCopyOwner, IProgressMonitor progressMonitor )
- throws JavaModelException
- {
- IBuffer b = workingCopy.getBuffer();
- char[] oldBuf = b.getCharacters();
- // Diff the contents, and only set if they differ
- if (oldBuf.length == contents.length()) {
- boolean contentsMatch = true;
- for (int i=0; i<oldBuf.length; i++) {
- if (oldBuf[i] != contents.charAt(i)) {
- contentsMatch = false;
- break;
- }
- }
- if (contentsMatch) {
- // No change, no need to update buffer
- return false;
- }
- }
-
- b.setContents(contents);
- workingCopy.reconcile(AST.JLS3, true, workingCopyOwner,
- progressMonitor);
- return true;
- }
-
- private void updateMaps( String typeName, ICompilationUnit parentCompilationUnit, ICompilationUnit workingCopy )
- {
- IFile parentFile = (IFile) parentCompilationUnit.getResource();
- IFile generatedFile = (IFile) workingCopy.getResource();
- updateFileMaps( typeName, parentFile, generatedFile );
-
- // type name -> set of parent compilation unit
- Set<ICompilationUnit> s = _typeName2Parents.get( typeName );
- if ( s == null )
- {
- s = new HashSet();
- _typeName2Parents.put( typeName, s );
- }
- s.add( parentCompilationUnit );
-
- // type name -> working copy
- ICompilationUnit cu = (ICompilationUnit)_typeName2WorkingCopy.get( typeName );
- if ( cu != null )
- {
- //assert( cu.equals( workingCopy ) ) : "unexpected different instances of working copy for the same type";
- if ( !cu.equals(workingCopy) ) throw new RuntimeException( "unexpected different instances of working copy for the same type" );
- }
- else
- _typeName2WorkingCopy.put( typeName, workingCopy );
- }
-
- private void updateFileMaps( String typeName, IFile parentFile, IFile generatedFile )
- {
- // parent IFile -> set of generated type name
- Set<String> stringSet = _parent2TypeNames.get( parentFile );
- if ( stringSet == null )
- {
- stringSet = new HashSet<String>();
- _parent2TypeNames.put( parentFile, stringSet );
- }
- stringSet.add( typeName );
-
-
- // add parent file -> set of derived files
- Set<IFile> fileSet = _parent2DerivedFiles.get( parentFile );
- if ( fileSet == null )
- {
- fileSet = new HashSet();
- _parent2DerivedFiles.put( parentFile, fileSet );
- }
- fileSet.add( generatedFile );
-
-
- // add derived file -> set of parent files
- fileSet = _derivedFile2Parents.get( generatedFile );
- if ( fileSet == null )
- {
- fileSet = new HashSet();
- _derivedFile2Parents.put( generatedFile, fileSet );
- }
- fileSet.add( parentFile );
- }
-
- private void updateProjectClasspath( JavaProject jp, IFolder folder, IProgressMonitor progressMonitor )
- throws JavaModelException
- {
- IClasspathEntry[] cp = jp.getRawClasspath();
- IClasspathEntry generatedSourceClasspathEntry =
- JavaCore.newSourceEntry(folder.getFullPath());
- boolean found = false;
- for (int i = 0; i < cp.length; i++)
- {
- if (cp[i].equals(generatedSourceClasspathEntry))
- {
- found = true;
- break;
- }
- }
- if (!found)
- {
- IClasspathEntry[] newCp = new IClasspathEntry[cp.length + 1];
- System.arraycopy(cp, 0, newCp, 0, cp.length);
- newCp[newCp.length - 1] = generatedSourceClasspathEntry;
- jp.setRawClasspath(newCp, progressMonitor );
- }
- }
-
- public synchronized void projectClosed()
- {
- // discard all working copies
- Collection<ICompilationUnit> workingCopies = _typeName2WorkingCopy.values();
- for ( ICompilationUnit wc : workingCopies )
- {
- try
- {
- wc.discardWorkingCopy();
- }
- catch ( JavaModelException jme )
- {
- jme.printStackTrace();
- }
- }
-
- // clear out the working copy maps
- _typeName2Parents.clear();
- _typeName2WorkingCopy.clear();
- }
-
- public synchronized void projectClean( boolean deleteFiles )
- {
- projectClosed();
-
- // delete the generated source dir
- if ( deleteFiles )
- {
- IFolder f = _project.getFolder( GENERATED_SOURCE_FOLDER_NAME );
- if ( f != null && f.exists() )
- {
- // delete the contents of the generated source folder, but don't delete
- // the generated source folder because that will cause a classpath change,
- // which will force the next build to be a full build.
- try
- {
- IResource[] members = f.members();
- for ( int i = 0; i<members.length; i++ )
- members[i].delete( true, null );
- }
- catch ( CoreException ce )
- {
- ce.printStackTrace();
- }
- }
- }
-
- // clear out all the file maps
- _parent2DerivedFiles.clear();
- _derivedFile2Parents.clear();
- _parent2TypeNames.clear();
- }
-
- public synchronized void projectDeleted()
- {
- //
- // remove this project from the managers map. Some other clients may still
- // have a reference to this, but that should be fine since the project is being
- // deleted. We'll just empty out member fields rather than
- // setting them to null to avoid NPEs.
- //
- synchronized( this.getClass() )
- {
- MANAGERS_MAP.remove( _project );
- }
-
- // TODO: eventually make this true. Right now, the resource tree is locked
- // when we get the project-deleted event, so we can't delete any files.
- projectClean( false );
- }
-
- /**
- * map from IFile of parent file to Set <IFile>of derived files
- */
- private Map<IFile, Set<IFile>> _parent2DerivedFiles = new HashMap();
-
- /**
- * map from IFile of dervied file to Set <IFile>of parent files
- */
- private Map<IFile, Set<IFile>> _derivedFile2Parents = new HashMap();
-
- /**
- * map from IFile of parent working copy to Set
- * <String> of type names generated by that file
- *
- * Map<IFile, Set<String>>
- */
- private Map<IFile, Set<String>> _parent2TypeNames = new HashMap();
-
- /**
- * map from typename of generated file to Set<ICompilationUnit>of parent
- * working copies
- *
- * Map<String, Set<ICompilationUnit>>
- */
- private Map<String, Set<ICompilationUnit>> _typeName2Parents = new HashMap();
-
- /**
- * Map from type name to the working copy in memory of that type name
- *
- * Map<String, ICompilationUnit>
- */
- private Map<String, ICompilationUnit> _typeName2WorkingCopy = new HashMap();
-
-
- private static boolean _initialized = false;
-
- private static final String GENERATED_SOURCE_FOLDER_NAME = "__generated_src";
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/ResourceChangedListener.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/ResourceChangedListener.java
deleted file mode 100644
index bc544bc..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/ResourceChangedListener.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.generatedfile;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.runtime.CoreException;
-
-public class ResourceChangedListener implements IResourceChangeListener
-{
- /* package */ ResourceChangedListener()
- {
- }
-
- public void resourceChanged(IResourceChangeEvent event)
- {
- if ( event.getType() == IResourceChangeEvent.PRE_BUILD )
- {
- try
- {
- event.getDelta().accept( new PreBuildVisitor() );
- }
- catch ( CoreException ce )
- {
- // TODO: handle exception here.
- ce.printStackTrace();
- }
- }
- else if ( event.getType() == IResourceChangeEvent.PRE_CLOSE )
- {
- IProject p = (IProject)event.getResource();
- GeneratedFileManager gfm = GeneratedFileManager.getGeneratedFileManager( p );
- gfm.projectClosed();
- }
- else if ( event.getType() == IResourceChangeEvent.PRE_DELETE )
- {
- // TODO: need to update projectDeleted() to delete the generated_src folder
- // in an async thread. The resource tree is locked here.
- IProject p = (IProject)event.getResource();
- GeneratedFileManager gfm = GeneratedFileManager.getGeneratedFileManager( p );
- gfm.projectDeleted();
- }
- }
-
- public class PreBuildVisitor implements IResourceDeltaVisitor
- {
-
- public boolean visit(IResourceDelta delta) throws CoreException
- {
- IResource r = delta.getResource();
-
- if ( delta.getKind() == IResourceDelta.REMOVED && r instanceof IFile)
- {
- for (GeneratedFileManager gfm : GeneratedFileManager.getGeneratedFileManagers()) {
- IFile f = (IFile)r;
- if ( gfm.isParentFile( f ) )
- {
- gfm.parentFileDeleted( (IFile) r, null /* progress monitor */ );
- }
- else if ( gfm.isGeneratedFile( f ) )
- {
- gfm.generatedFileDeleted( f, null /*progress monitor */ );
- }
- }
- }
-
- if ( delta.getKind() == IResourceDelta.REMOVED && r instanceof IFolder )
- {
- // handle delete of generated source folder
- }
-
- return true;
- }
- }
-
-
-
-
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/ArrayTypeImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/ArrayTypeImpl.java
deleted file mode 100644
index efba7dc..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/ArrayTypeImpl.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.type;
-
-import com.sun.mirror.type.ArrayType;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.util.TypeVisitor;
-import org.eclipse.jdt.apt.core.internal.EclipseMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.BindingKey;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-public class ArrayTypeImpl implements ArrayType, EclipseMirrorImpl
-{
- private final ITypeBinding _arrayBinding;
- private final ProcessorEnvImpl _env;
- public ArrayTypeImpl(final ITypeBinding binding, ProcessorEnvImpl env)
- {
- _arrayBinding = binding;
- _env = env;
- assert _arrayBinding != null && _arrayBinding.isArray();
- assert env != null : "missing environment";
- }
-
- public void accept(TypeVisitor visitor)
- {
- visitor.visitTypeMirror(this);
- visitor.visitArrayType(this);
- }
-
- public TypeMirror getComponentType()
- {
- final ITypeBinding elementType = _arrayBinding.getElementType();
- final int dimension = _arrayBinding.getDimensions();
- // guarding around error cases.
- if( dimension == 0 ) return null;
- final ITypeBinding componentType;
- if( dimension == 1 ) // the element type is the component type.
- componentType = elementType;
- else{
- final ITypeBinding leaf = elementType.getElementType();
- final String componentKey = BindingKey.createArrayTypeBindingKey(leaf.getKey(), dimension - 1);
- componentType = _env.getTypeBinding(componentKey);
- if( componentType == null )
- throw new IllegalStateException("unknown component type for " + _arrayBinding);
- }
-
- final TypeMirror mirror = Factory.createTypeMirror(componentType, _env);
- if( mirror == null )
- return Factory.createErrorClassType(componentType);
- return mirror;
- }
-
- public String toString(){ return _arrayBinding.toString(); }
-
- public boolean equals(Object obj)
- {
- if( obj instanceof ArrayTypeImpl )
- return _arrayBinding == ((ArrayTypeImpl)obj)._arrayBinding;
- return false;
- }
-
- public ITypeBinding getArrayBinding(){ return _arrayBinding; }
-
- public int hashCode(){ return _arrayBinding.hashCode(); }
-
- public MirrorKind kind(){ return MirrorKind.TYPE_ARRAY; }
-
- public ProcessorEnvImpl getEnvironment(){ return _env; }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/ErrorType.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/ErrorType.java
deleted file mode 100644
index 82af0f7..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/ErrorType.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.type;
-
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.ClassDeclaration;
-import com.sun.mirror.declaration.InterfaceDeclaration;
-import com.sun.mirror.type.AnnotationType;
-import com.sun.mirror.type.ClassType;
-import com.sun.mirror.type.DeclaredType;
-import com.sun.mirror.type.InterfaceType;
-import com.sun.mirror.type.ReferenceType;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.util.TypeVisitor;
-import java.util.Collection;
-import java.util.Collections;
-import org.eclipse.jdt.apt.core.internal.EclipseMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-
-/**
- * This is the error type marker
- */
-public abstract class ErrorType implements DeclaredType, ReferenceType, EclipseMirrorImpl
-{
- final String _name;
-
- ErrorType(final String name){
- _name = name;
- }
-
- public Collection<TypeMirror> getActualTypeArguments(){ return Collections.emptyList(); }
-
- public DeclaredType getContainingType(){ return null; }
-
- public String toString(){ return _name; }
-
- public void accept(TypeVisitor visitor)
- {
- visitor.visitTypeMirror(this);
- visitor.visitDeclaredType(this);
- visitor.visitReferenceType(this);
- }
-
- public Collection<InterfaceType> getSuperinterfaces(){ return Collections.emptyList(); }
-
- public MirrorKind kind(){ return MirrorKind.TYPE_ERROR; }
-
- public ProcessorEnvImpl getEnvironment(){ return null; }
-
- public static final class ErrorClass extends ErrorType implements ClassType
- {
- public ErrorClass(final String name){ super(name); }
-
- public void accept(TypeVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitClassType(this);
- }
-
- public ClassType getSuperclass()
- {
- return null;
- }
-
- public ClassDeclaration getDeclaration(){ return null; }
-
- }
-
- public static class ErrorInterface extends ErrorType implements InterfaceType
- {
- public ErrorInterface(final String name){ super(name); }
-
- public void accept(TypeVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitInterfaceType(this);
- }
-
- public InterfaceDeclaration getDeclaration(){ return null; }
- }
-
- public static final class ErrorAnnotation extends ErrorInterface implements AnnotationType
- {
- public ErrorAnnotation(final String name){ super(name); }
-
- public void accept(TypeVisitor visitor)
- {
- super.accept(visitor);
- visitor.visitAnnotationType(this);
- }
-
- public AnnotationTypeDeclaration getDeclaration(){ return null; }
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/PrimitiveTypeImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/PrimitiveTypeImpl.java
deleted file mode 100644
index c7e86ce..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/PrimitiveTypeImpl.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.type;
-
-import com.sun.mirror.type.PrimitiveType;
-import com.sun.mirror.util.TypeVisitor;
-import org.eclipse.jdt.apt.core.internal.EclipseMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-public class PrimitiveTypeImpl implements PrimitiveType, EclipseMirrorImpl
-{
- private final ITypeBinding _binding;
-
- public PrimitiveTypeImpl(ITypeBinding binding)
- {
- assert binding != null;
- _binding = binding;
- }
- public void accept(TypeVisitor visitor)
- {
- visitor.visitTypeMirror(this);
- visitor.visitPrimitiveType(this);
- }
-
- public PrimitiveType.Kind getKind()
- {
- final String name = getTypeBinding().getName();
- if( "int".equals(name) )
- return PrimitiveType.Kind.INT;
- else if( "byte".equals(name) )
- return PrimitiveType.Kind.BYTE;
- else if( "short".equals(name) )
- return PrimitiveType.Kind.SHORT;
- else if( "char".equals(name) )
- return PrimitiveType.Kind.CHAR;
- else if( "long".equals(name) )
- return PrimitiveType.Kind.LONG;
- else if( "float".equals(name) )
- return PrimitiveType.Kind.FLOAT;
- else if( "double".equals(name) )
- return PrimitiveType.Kind.DOUBLE;
- else if( "boolean".equals(name))
- return PrimitiveType.Kind.BOOLEAN;
- else
- throw new IllegalStateException("unrecognized primitive type " + _binding);
- }
-
- public String toString(){ return _binding.getName(); }
-
- public ITypeBinding getTypeBinding(){ return _binding; }
-
- public MirrorKind kind(){ return MirrorKind.TYPE_PRIMITIVE; }
-
- public boolean equals(final Object obj)
- {
- try{
- return this._binding.isEqualTo( ((PrimitiveTypeImpl)obj)._binding );
- }
- catch(ClassCastException e){
- return false;
- }
- }
-
- public ProcessorEnvImpl getEnvironment(){ return null; }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/VoidTypeImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/VoidTypeImpl.java
deleted file mode 100644
index 22977f5..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/VoidTypeImpl.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.type;
-
-import com.sun.mirror.type.VoidType;
-import com.sun.mirror.util.TypeVisitor;
-import org.eclipse.jdt.apt.core.internal.EclipseMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-public class VoidTypeImpl implements VoidType, EclipseMirrorImpl
-{
- private final ITypeBinding _binding;
-
- public VoidTypeImpl(final ITypeBinding binding){
- assert binding != null : "missing binding";
- _binding = binding;
- }
-
- public void accept(TypeVisitor visitor)
- {
- visitor.visitTypeMirror(this);
- visitor.visitVoidType(this);
- }
-
- public String toString(){ return "void"; }
-
- public ITypeBinding getTypeBinding(){return _binding;}
-
- public MirrorKind kind(){ return MirrorKind.TYPE_VOID; }
-
- public ProcessorEnvImpl getEnvironment(){ return null; }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/WildcardTypeImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/WildcardTypeImpl.java
deleted file mode 100644
index c62f106..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/WildcardTypeImpl.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.type;
-
-import com.sun.mirror.type.ReferenceType;
-import com.sun.mirror.type.WildcardType;
-import com.sun.mirror.util.TypeVisitor;
-import java.util.Collection;
-import java.util.Collections;
-import org.eclipse.jdt.apt.core.internal.EclipseMirrorImpl.MirrorKind;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-public class WildcardTypeImpl implements WildcardType
-{
- private final ITypeBinding _binding;
- private final ProcessorEnvImpl _env;
-
- public WildcardTypeImpl(ITypeBinding binding, ProcessorEnvImpl env)
- {
- _binding = binding;
- _env = env;
- assert _binding != null && _binding.isWildcardType();
- assert env != null : "missing environment";
- }
-
- public void accept(TypeVisitor visitor)
- {
- visitor.visitTypeMirror(this);
- visitor.visitWildcardType(this);
- }
-
- public Collection<ReferenceType> getLowerBounds()
- {
- final ITypeBinding bound = _binding.getBound();
- // no bound or has an upper bound.
- if( bound == null || _binding.isUpperbound() )
- return Collections.emptyList();
- ReferenceType mirror = Factory.createReferenceType(bound, _env);
- if( mirror == null )
- mirror = Factory.createErrorClassType(bound);
- return Collections.singletonList(mirror);
- }
-
- public Collection<ReferenceType> getUpperBounds()
- {
- final ITypeBinding bound = _binding.getBound();
- // no bound or has a lower bound.
- if( bound == null || !_binding.isUpperbound() )
- return Collections.emptyList();
- ReferenceType mirror = Factory.createReferenceType(bound, _env);
- if( mirror == null )
- mirror = Factory.createErrorClassType(bound);
- return Collections.singletonList(mirror);
- }
-
- public String toString(){ return _binding.toString(); }
- public int hashCode(){ return _binding.hashCode(); }
- public boolean equals(Object obj)
- {
- if(obj instanceof WildcardTypeImpl )
- return ((WildcardTypeImpl)obj)._binding.isEqualTo(_binding);
- return false;
- }
-
- public MirrorKind kind(){ return MirrorKind.TYPE_WILDCARD; }
-
- public ITypeBinding getWildcardBinding(){ return _binding; }
-
- public ProcessorEnvImpl getEnvironment(){ return _env; }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/DeclarationsUtil.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/DeclarationsUtil.java
deleted file mode 100644
index 06cb9ea..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/DeclarationsUtil.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.util;
-
-import org.eclipse.jdt.apt.core.internal.EclipseMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.NonEclipseImplementationException;
-import org.eclipse.jdt.apt.core.internal.declaration.DeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.MemberDeclarationImpl;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.IPackageBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jdt.core.dom.Modifier;
-
-import com.sun.mirror.declaration.MemberDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.util.Declarations;
-
-public class DeclarationsUtil implements Declarations
-{
- public boolean hides(MemberDeclaration sub, MemberDeclaration sup) {
-
- // A declaration cannot hide itself
- if (sub == sup || sub.equals(sup))
- return false;
-
- MemberDeclarationImpl subImpl = (MemberDeclarationImpl)sub;
- MemberDeclarationImpl supImpl = (MemberDeclarationImpl)sup;
-
- IBinding subBinding = subImpl.getDeclarationBinding();
- IBinding supBinding = supImpl.getDeclarationBinding();
-
-
- // Hiding can only take place between declarations of the same kind and name,
- // and types, variables and methods
- int subKind = subBinding.getKind();
- int supKind = supBinding.getKind();
- if (subKind != supKind || subKind == IBinding.PACKAGE)
- return false;
- if (!subBinding.getName().equals(supBinding.getName()))
- return false;
-
- // Methods must be both static and the sub a subsignature of the sup
- if (subKind == IBinding.METHOD) {
- boolean allowed = false;
- int modifiers = subBinding.getModifiers();
- if ((modifiers & Modifier.STATIC) == Modifier.STATIC) {
- IMethodBinding methodBinding = (IMethodBinding)subBinding;
- if (methodBinding.isSubsignature((IMethodBinding)supBinding)) {
- allowed = true;
- }
- }
- if (!allowed)
- return false;
- }
-
- // sub's enclosing class must be a subclass of sup's
- ITypeBinding subClass = getDeclaringClass(subBinding);
- ITypeBinding supClass = getDeclaringClass(supBinding);
- if (subClass == null || supClass == null)
- return false;
- if (!subClass.isSubTypeCompatible(supClass))
- return false;
-
- // sup must be visible from sub
- if (!isVisibleForHiding(supClass, supClass, supBinding.getModifiers()))
- return false;
-
- return true;
- }
-
- /**
- * Is a method, field, type visible from the viewer?
- * That is, do accessibility rules allow it? (public, protected, etc.)<P>
- *
- * Note that we make an assumption about protected here since
- * its use in hides() already determines that the declaringTarget
- * must be a subclass of the declaringViewer.
- */
- private static boolean isVisibleForHiding(
- final ITypeBinding declaringTarget,
- final ITypeBinding declaringViewer,
- final int modifiers) {
-
- // Public is always visible
- if ((modifiers & Modifier.PUBLIC) == Modifier.PUBLIC)
- return true;
- if ((modifiers & Modifier.PRIVATE) == Modifier.PRIVATE) {
- // Must be the same class
- if (declaringTarget.equals(declaringViewer))
- return true;
- else
- return false;
- }
- if ((modifiers & Modifier.PROTECTED) == Modifier.PROTECTED) {
- // We've already checked for subclassing
- return true;
- }
- // Package-friendly (no accessibility modifier)
- // Classes must be in the same package
- IPackageBinding targetPackage = declaringTarget.getPackage();
- IPackageBinding viewerPackage = declaringViewer.getPackage();
- return targetPackage.equals(viewerPackage);
- }
-
- public boolean overrides(MethodDeclaration sub, MethodDeclaration sup) {
- final IMethodBinding subBinding = (IMethodBinding)getBinding(sub);
- final IMethodBinding supBinding = (IMethodBinding)getBinding(sup);
- if(subBinding == null || supBinding == null) return false;
- return subBinding.overrides(supBinding);
- }
-
- private static IBinding getBinding(MemberDeclaration memberDecl)
- throws NonEclipseImplementationException
- {
- if( memberDecl == null ) return null;
- if( memberDecl instanceof EclipseMirrorImpl ){
- return ((DeclarationImpl)memberDecl).getDeclarationBinding();
- }
- throw new NonEclipseImplementationException("only applicable to eclipse type system objects." +
- " Found " + memberDecl.getClass().getName());
- }
-
- private static ITypeBinding getDeclaringClass(IBinding binding) {
- int kind = binding.getKind();
- if (kind == IBinding.TYPE)
- return ((ITypeBinding)binding).getDeclaringClass();
- if (kind == IBinding.METHOD)
- return ((IMethodBinding)binding).getDeclaringClass();
- if (kind == IBinding.VARIABLE)
- return ((IVariableBinding)binding).getDeclaringClass();
-
- // Package binding -- no declaring class
- return null;
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/Factory.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/Factory.java
deleted file mode 100644
index 39b3eb8..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/Factory.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.util;
-
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.AnnotationValue;
-import com.sun.mirror.type.AnnotationType;
-import com.sun.mirror.type.ClassType;
-import com.sun.mirror.type.InterfaceType;
-import com.sun.mirror.type.TypeMirror;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jdt.apt.core.internal.EclipseMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.AnnotationDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.AnnotationElementDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.AnnotationMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.AnnotationValueImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.ClassDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.ConstructorDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.DeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.EnumConstantDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.EnumDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.FieldDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.InterfaceDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.MethodDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.TypeDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.TypeParameterDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.type.ArrayTypeImpl;
-import org.eclipse.jdt.apt.core.internal.type.ErrorType;
-import org.eclipse.jdt.apt.core.internal.type.WildcardTypeImpl;
-import org.eclipse.jdt.core.dom.IResolvedAnnotation;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-
-public class Factory
-{
- public static TypeDeclarationImpl createReferenceType(ITypeBinding binding, ProcessorEnvImpl env)
- {
- if(binding == null || binding.isNullType()) return null;
- TypeDeclarationImpl mirror = null;
- // must test for annotation type before interface since annotation
- // is an interface
- if( binding.isAnnotation() )
- mirror = new AnnotationDeclarationImpl(binding, env);
- else if (binding.isInterface() )
- mirror = new InterfaceDeclarationImpl(binding, env);
- // must test for enum first since enum is also a class.
- else if( binding.isEnum() )
- mirror = new EnumDeclarationImpl(binding, env);
- else if( binding.isClass() )
- mirror = new ClassDeclarationImpl(binding, env);
- else
- throw new IllegalStateException("cannot create type declaration from " + binding);
-
- return mirror;
- }
-
- public static DeclarationImpl createDeclaration(IBinding binding, ProcessorEnvImpl env)
- {
- if(binding == null) return null;
-
- switch(binding.getKind())
- {
- case IBinding.TYPE:
- final ITypeBinding typeBinding = (ITypeBinding)binding;
- if( typeBinding.isAnonymous() || typeBinding.isArray() ||
- typeBinding.isWildcardType() || typeBinding.isPrimitive() )
- throw new IllegalStateException("failed to create declaration from " + binding);
- return createReferenceType(typeBinding, env);
- case IBinding.VARIABLE:
- final IVariableBinding varBinding = (IVariableBinding)binding;
- if(varBinding.isEnumConstant())
- return new EnumConstantDeclarationImpl(varBinding, env);
- else
- return new FieldDeclarationImpl(varBinding, env);
- case IBinding.METHOD:
- final IMethodBinding method = (IMethodBinding)binding;
- if( method.isConstructor() )
- return new ConstructorDeclarationImpl(method, env);
- final ITypeBinding declaringType = method.getDeclaringClass();
- if( declaringType != null && declaringType.isAnnotation() )
- return new AnnotationElementDeclarationImpl(method, env);
- else
- return new MethodDeclarationImpl(method, env);
- default:
- throw new IllegalStateException("failed to create declaration from " + binding);
- }
- }
-
- public static TypeMirror createTypeMirror(ITypeBinding binding, ProcessorEnvImpl env)
- {
- if( binding == null ) return null;
-
- if( binding.isPrimitive() ){
- if( "int".equals(binding.getName()) )
- return env.getIntType();
- else if( "byte".equals(binding.getName()) )
- return env.getByteType();
- else if( "short".equals(binding.getName()) )
- return env.getShortType();
- else if( "char".equals(binding.getName()) )
- return env.getCharType();
- else if( "long".equals(binding.getName()) )
- return env.getLongType();
- else if( "float".equals(binding.getName()) )
- return env.getFloatType();
- else if( "double".equals(binding.getName()) )
- return env.getDoubleType();
- else if( "boolean".equals(binding.getName()))
- return env.getBooleanType();
- else if( "void".equals(binding.getName()) )
- return env.getVoidType();
- else
- throw new IllegalStateException("unrecognized primitive type: " + binding);
- }
- else if( binding.isArray() )
- return new ArrayTypeImpl(binding, env);
- else if( binding.isWildcardType() ){
- return new WildcardTypeImpl(binding, env);
- }
- else if( binding.isTypeVariable() )
- return new TypeParameterDeclarationImpl(binding, env);
- else
- return createReferenceType(binding, env);
- }
-
- /**
- * @param annotation the ast node.
- * @param annotated the declaration that <code>annotation</code> annotated
- * @param env
- * @return a newly created {@link AnnotationMirror} object
- */
- public static AnnotationMirror createAnnotationMirror(final IResolvedAnnotation annotation,
- final DeclarationImpl annotated,
- final ProcessorEnvImpl env)
- {
- return new AnnotationMirrorImpl(annotation, annotated, env);
- }
-
- /**
- * Build an {@link AnnotationValue} object based on the given dom value.
- * @param domValue default value according to the DOM API.
- * @param decl the element declaration whose default value is <code>domValue</code>
- * if {@link #domValue} is an annotation, then this is the declaration it annotated.
- * In all other case, this parameter is ignored.
- * @param env
- * @return an annotation value
- */
- public static AnnotationValue createDefaultValue(Object domValue,
- AnnotationElementDeclarationImpl decl,
- ProcessorEnvImpl env)
- {
- if( domValue == null ) return null;
- final Object converted = convertDOMValueToMirrorValue(domValue, null, decl, decl, env);
- return createAnnotationValue(converted, null, -1, decl, env);
- }
-
- /**
- * Build an {@link AnnotationValue} object based on the given dom value.
- * @param domValue annotation member value according to the DOM API.
- * @param elementName the name of the member value
- * @param anno the annotation that directly contains <code>domValue</code>
- * @param env
- * @return an annotation value
- */
- public static AnnotationValue createAnnotationMemberValue(Object domValue,
- String elementName,
- AnnotationMirrorImpl anno,
- ProcessorEnvImpl env)
- {
- if( domValue == null ) return null;
- final Object converted = convertDOMValueToMirrorValue(domValue, elementName, anno, anno.getAnnotatedDeclaration(), env);
- return createAnnotationValue(converted, elementName, -1, anno, env);
- }
-
- private static AnnotationValue createAnnotationValue(Object convertedValue,
- String name,
- int index,
- EclipseMirrorImpl mirror,
- ProcessorEnvImpl env)
- {
- if( convertedValue == null ) return null;
- if( mirror instanceof AnnotationMirrorImpl )
- return new AnnotationValueImpl(convertedValue, name, index, (AnnotationMirrorImpl)mirror, env);
- else
- return new AnnotationValueImpl(convertedValue, index, (AnnotationElementDeclarationImpl)mirror, env);
- }
-
-
- /**
- * Building an annotation value object based on the dom value.
- *
- * @param dom the dom value to convert to the mirror specification.
- * @see com.sun.mirror.declaration.AnnotationValue.getObject()
- * @param name the name of the element if <code>domValue</code> is an
- * element member value of an annotation
- * @param parent the parent of this annotation value.
- * @param decl if <code>domValue</code> is a default value, then this is the
- * annotation element declaration where the default value originates
- * if <code>domValue</code> is an annotation, then <code>decl</code>
- * is the declaration that it annotates.
- */
- private static Object convertDOMValueToMirrorValue(Object domValue,
- String name,
- EclipseMirrorImpl parent,
- DeclarationImpl decl,
- ProcessorEnvImpl env)
- {
- if( domValue == null ) return null;
- else if(domValue instanceof Boolean ||
- domValue instanceof Byte ||
- domValue instanceof Character ||
- domValue instanceof Double ||
- domValue instanceof Float ||
- domValue instanceof Integer ||
- domValue instanceof Long ||
- domValue instanceof Short ||
- domValue instanceof String )
- return domValue;
- else if( domValue instanceof IVariableBinding )
- {
- return Factory.createDeclaration((IVariableBinding)domValue, env);
- }
- else if (domValue instanceof Object[])
- {
- final Object[] elements = (Object[])domValue;
- final int len = elements.length;
- final List<AnnotationValue> annoValues = new ArrayList<AnnotationValue>(len);
- for( int i=0; i<len; i++ ){
- if( elements[i] == null ) continue;
- // can't have multi-dimensional array.
- // there should be already a java compile time error
- else if( elements[i] instanceof Object[] )
- return null;
- final AnnotationValue annoValue = createAnnotationValue(elements[i], name, i, parent, env);
- if( annoValue != null )
- annoValues.add(annoValue);
- }
- return annoValues;
- }
- // caller should have caught this case.
- else if( domValue instanceof ITypeBinding )
- return Factory.createTypeMirror((ITypeBinding)domValue, env);
-
- else if( domValue instanceof IResolvedAnnotation )
- {
- return Factory.createAnnotationMirror((IResolvedAnnotation)domValue, decl, env);
- }
-
- // should never reach this point
- throw new IllegalStateException("cannot build annotation value object from " + domValue);
- }
-
- public static InterfaceType createErrorInterfaceType(final ITypeBinding binding)
- {
- return new ErrorType.ErrorInterface(binding.getName());
- }
-
- public static ClassType createErrorClassType(final ITypeBinding binding)
- {
- return new ErrorType.ErrorClass(binding.getName());
- }
-
- public static AnnotationType createErrorAnnotationType(final ITypeBinding binding)
- {
- return new ErrorType.ErrorAnnotation(binding.getName());
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FileSystemUtil.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FileSystemUtil.java
deleted file mode 100644
index ae30a68..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FileSystemUtil.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.apt.core.internal.util;
-
-import java.io.File;
-
-/**
- * Simple utility class to encapsulate an mkdirs() that avoids a timing issue
- * in the jdk.
- */
-public class FileSystemUtil
-{
- public static void mkdirs( File parent )
- {
- if ( parent == null )
- return;
-
- // It is necessary to synchronize to prevent timing issues while creating the parent directories
- // We can be codegening multiple files that go into the same directory at the same time.
- synchronized (FileSystemUtil.class) {
- if (!parent.exists()) {
- boolean succeed = false;
- for (int i = 0 ; !succeed && i < 5 ; i++)
- succeed = parent.mkdirs();
- }
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/PackageUtil.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/PackageUtil.java
deleted file mode 100644
index 7594216..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/PackageUtil.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package org.eclipse.jdt.apt.core.internal.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.search.IJavaSearchConstants;
-import org.eclipse.jdt.core.search.IJavaSearchScope;
-import org.eclipse.jdt.core.search.SearchEngine;
-import org.eclipse.jdt.core.search.SearchMatch;
-import org.eclipse.jdt.core.search.SearchParticipant;
-import org.eclipse.jdt.core.search.SearchPattern;
-import org.eclipse.jdt.core.search.SearchRequestor;
-
-import com.sun.mirror.declaration.ClassDeclaration;
-import com.sun.mirror.declaration.EnumDeclaration;
-import com.sun.mirror.declaration.InterfaceDeclaration;
-import com.sun.mirror.declaration.PackageDeclaration;
-
-/**
- * Utility class for dealing with packages, using
- * Eclipse's underlying SearchEngine
- */
-public class PackageUtil {
-
- private PackageUtil() {}
-
- public static IPackageFragment[] getPackageFragments(
- final String packageName,
- final ProcessorEnvImpl env) {
-
- IJavaProject project = env.getJavaProject();
- List<IPackageFragment> packages = new ArrayList<IPackageFragment>();
- try {
- IPackageFragmentRoot[] roots = project.getAllPackageFragmentRoots();
- for (IPackageFragmentRoot root : roots) {
- IPackageFragment fragment = root.getPackageFragment(packageName);
- if (fragment != null)
- packages.add(fragment);
- }
- }
- catch (JavaModelException e) {
- return new IPackageFragment[0];
- }
-
- return packages.toArray(new IPackageFragment[packages.size()]);
- }
-
- public static Collection<ClassDeclaration> getClasses(
- final PackageDeclaration pkg,
- final ProcessorEnvImpl env) {
-
- List<IType> types = getTypesInPackage(pkg.getQualifiedName(), env);
- List<ClassDeclaration> classes = new ArrayList<ClassDeclaration>();
- for (IType type : types) {
- try {
- if (type.isClass()) {
- classes.add((ClassDeclaration)env.getTypeDeclaration(type));
- }
- }
- catch (JavaModelException ex) {} // No longer exists, don't return it
- }
-
- return classes;
- }
-
- public static Collection<EnumDeclaration> getEnums(
- final PackageDeclaration pkg,
- final ProcessorEnvImpl env) {
-
- List<IType> types = getTypesInPackage(pkg.getQualifiedName(), env);
- List<EnumDeclaration> enums = new ArrayList<EnumDeclaration>();
- for (IType type : types) {
- try {
- if (type.isEnum()) {
- enums.add((EnumDeclaration)env.getTypeDeclaration(type));
- }
- }
- catch (JavaModelException ex) {} // No longer exists, don't return it
- }
-
- return enums;
-
- }
-
- public static Collection<InterfaceDeclaration> getInterfaces(
- final PackageDeclaration pkg,
- final ProcessorEnvImpl env) {
-
- List<IType> types = getTypesInPackage(pkg.getQualifiedName(), env);
- List<InterfaceDeclaration> interfaces = new ArrayList<InterfaceDeclaration>();
- for (IType type : types) {
- try {
- if (type.isInterface()) {
- interfaces.add((InterfaceDeclaration)env.getTypeDeclaration(type));
- }
- }
- catch (JavaModelException ex) {} // No longer exists, don't return it
- }
-
- return interfaces;
- }
-
- private static List<IType> getTypesInPackage(
- final String packageName,
- final ProcessorEnvImpl env) {
-
- if (packageName == null)
- throw new IllegalArgumentException("packageName cannot be null");
- if (env == null)
- throw new IllegalArgumentException("env cannot be null");
-
- final IJavaProject project = env.getJavaProject();
-
- final List<IType> types = new ArrayList<IType>();
-
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {project});
- SearchPattern pattern = SearchPattern.createPattern(
- packageName + ".*",
- IJavaSearchConstants.TYPE,
- IJavaSearchConstants.DECLARATIONS,
- SearchPattern.R_PATTERN_MATCH);
- assert pattern != null : "Failed to create a SearchPattern for the following package name: " + packageName;
-
- SearchRequestor requestor = new SearchRequestor() {
- public void acceptSearchMatch(SearchMatch match) {
- IType type = (IType)match.getElement();
- types.add(type);
- }
- };
-
- SearchEngine engine = new SearchEngine();
- try {
- engine.search(
- pattern,
- new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
- scope,
- requestor,
- null);
- }
- catch (CoreException ce) {
- // We'll return the empty array later
- }
- return types;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/SourcePositionImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/SourcePositionImpl.java
deleted file mode 100644
index 0a8438b..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/SourcePositionImpl.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.util;
-
-import com.sun.mirror.util.SourcePosition;
-import java.io.File;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.core.internal.EclipseMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.AnnotationMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.AnnotationValueImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.DeclarationImpl;
-
-public class SourcePositionImpl implements SourcePosition
-{
- private final int _startingOffset;
- private final int _length;
- private final int _line;
- /** the back pointer to the declaration that created this object */
- private final EclipseMirrorImpl _decl;
-
- public SourcePositionImpl(final int startingOffset,
- final int length,
- final int line,
- final DeclarationImpl decl)
- {
- _startingOffset = startingOffset;
- _length = length;
- _line = line;
- _decl = decl;
- assert decl != null : "missing declaration [decl] == null.";
- }
-
- public SourcePositionImpl(final int startingOffset,
- final int length,
- final int line,
- final AnnotationValueImpl decl )
- {
- _startingOffset = startingOffset;
- _length = length;
- _line = line;
- _decl = decl;
- assert decl != null : "missing declaration [decl] == null.";
- }
-
- public SourcePositionImpl(final int startingOffset,
- final int length,
- final int line,
- final AnnotationMirrorImpl decl )
- {
- _startingOffset = startingOffset;
- _length = length;
- _line = line;
- _decl = decl;
- assert decl != null : "missing declaration [decl] == null.";
- }
-
- public int line(){ return _line; }
- public int column(){ return 0; /* TODO: fix me */ }
- public File file(){
- IResource resource = getResource();
- if( resource == null ) return null;
- final IPath absPath = resource.getRawLocation();
- if(absPath == null) return null;
- return new File( absPath.toOSString() );
- }
-
- // for use in IDE mode for squiggling.
- public int getStartingOffset(){ return _startingOffset; }
- public int getEndingOffset(){ return _startingOffset + _length; }
- public int getLength(){ return _length; }
- public IResource getResource(){
- if( _decl instanceof DeclarationImpl )
- return ((DeclarationImpl)_decl).getResource();
- else if( _decl instanceof AnnotationMirrorImpl )
- return ((AnnotationMirrorImpl)_decl).getResouce();
- else if( _decl instanceof AnnotationValueImpl )
- return ((AnnotationValueImpl)_decl).getResource();
-
- throw new IllegalStateException();
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/TypesUtil.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/TypesUtil.java
deleted file mode 100644
index ba9ac51..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/TypesUtil.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.util;
-
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.declaration.TypeParameterDeclaration;
-import com.sun.mirror.type.ArrayType;
-import com.sun.mirror.type.DeclaredType;
-import com.sun.mirror.type.PrimitiveType;
-import com.sun.mirror.type.ReferenceType;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.type.TypeVariable;
-import com.sun.mirror.type.VoidType;
-import com.sun.mirror.type.WildcardType;
-import com.sun.mirror.util.Types;
-import java.util.Collection;
-import org.eclipse.jdt.apt.core.internal.EclipseMirrorImpl;
-import org.eclipse.jdt.apt.core.internal.NonEclipseImplementationException;
-import org.eclipse.jdt.apt.core.internal.declaration.TypeDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.TypeParameterDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.apt.core.internal.type.ArrayTypeImpl;
-import org.eclipse.jdt.apt.core.internal.type.PrimitiveTypeImpl;
-import org.eclipse.jdt.apt.core.internal.type.VoidTypeImpl;
-import org.eclipse.jdt.apt.core.internal.type.WildcardTypeImpl;
-import org.eclipse.jdt.core.BindingKey;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-public class TypesUtil implements Types
-{
- private static final String[] NO_ARGS = new String[0];
- private final ProcessorEnvImpl _env;
-
- public static void main(String[] args){}
-
- public TypesUtil(ProcessorEnvImpl env){
- _env = env;
- assert env != null : "null environment."; //$NON-NLS-1$
- }
-
- public ArrayType getArrayType(TypeMirror componentType)
- {
- if( componentType == null ) return null;
- if( componentType instanceof EclipseMirrorImpl ){
- final EclipseMirrorImpl impl = (EclipseMirrorImpl)componentType;
- // the leaf type of the array
- final ITypeBinding leaf;
- final int dimension;
- switch( impl.kind() )
- {
- case TYPE_ERROR:
- throw new IllegalArgumentException("cannot create an array from error type"); //$NON-NLS-1$
- case TYPE_VOID:
- throw new IllegalArgumentException("cannot create an array from void type"); //$NON-NLS-1$
- case TYPE_PRIMITIVE:
- leaf = ((PrimitiveTypeImpl)componentType).getTypeBinding();
- dimension = 1;
- break;
- case TYPE_ARRAY:
- final ITypeBinding array = ((ArrayTypeImpl)componentType).getArrayBinding();
- dimension = array.getDimensions() + 1;
- leaf = array.getElementType();
- break;
- case TYPE_WILDCARD:
- leaf = ((WildcardTypeImpl)componentType).getWildcardBinding();
- dimension = 1;
- break;
- default:
- leaf = ((TypeDeclarationImpl)componentType).getTypeBinding();
- dimension = 1;
- }
- if( leaf == null || leaf.isParameterizedType() )
- throw new IllegalArgumentException("illegal component type: " + componentType); //$NON-NLS-1$
-
- final String bindingKey = BindingKey.createArrayTypeBindingKey(leaf.getKey(), dimension);
- final ITypeBinding arrayType = _env.getTypeBinding(bindingKey);
- if(arrayType == null)
- return null;
- return (ArrayType)Factory.createTypeMirror(arrayType, _env);
- }
-
- throw new NonEclipseImplementationException("only applicable to eclipse type system objects." +
- " Found " + componentType.getClass().getName());
-
- }
-
- /**
- * @param outer a type
- * @param inner the simple name of the nested class
- * @return the binding that correspond to <code>outer.getQualifiedName()</code>.<code>inner</code>
- * or null if it cannot be located.
- */
- private ITypeBinding findMemberType(ITypeBinding outer, String inner )
- {
- if( outer == null || inner == null ) return null;
-
- outer = outer.getTypeDeclaration();
-
- final ITypeBinding[] nestedTypes = outer.getDeclaredTypes();
- // first we search throw the ones that are directly declared within 'outer'
- for( ITypeBinding nestedType : nestedTypes ){
- if( inner.equals(nestedType.getName()) )
- return nestedType;
- }
- // then we look up the hierachy chain.
- // first we search the super type
- ITypeBinding result = findMemberType(outer.getSuperclass(), inner);
- if( result != null ) return result;
-
- // then the super interfaces
- final ITypeBinding[] interfaces = outer.getInterfaces();
- for( ITypeBinding interfaceType : interfaces ){
- result = findMemberType(interfaceType, inner);
- if( result != null ) return result;
- }
-
- // can't find it.
- return null;
- }
-
- public com.sun.mirror.type.DeclaredType getDeclaredType(DeclaredType containing, TypeDeclaration decl, TypeMirror... typeArgs)
- {
- if( decl == null ) return null;
-
- final ITypeBinding outerBinding = getTypeBinding(containing);
- final ITypeBinding memberBinding;
-
- if( containing == null )
- memberBinding = getTypeBinding(decl);
- else{
- if( outerBinding.isGenericType() )
- throw new IllegalArgumentException("[containing], " + containing + ", is a generic type."); //$NON-NLS-1$ //$NON-NLS-2$
- // make sure 'decl' is a valid member of 'outerBinding'
- memberBinding = findMemberType(outerBinding, decl.getSimpleName() );
- if( memberBinding == null )
- throw new IllegalArgumentException(decl + " is not a member type of " + containing ); //$NON-NLS-1$
- }
-
- final int numArgs = typeArgs == null ? 0 : typeArgs.length;
-
- if( memberBinding.isGenericType() ){
- final String[] argKeys = numArgs == 0 ? NO_ARGS : new String[numArgs];
- for( int i=0; i<numArgs; i++ ){
- final ITypeBinding binding = getTypeBinding(typeArgs[i]);
- assert binding != null : "failed to get binding mirror type";
- argKeys[i] = binding.getKey();
- }
-
- final ITypeBinding[] typeParams = memberBinding.getTypeParameters();
- final int numTypeParams = typeParams == null ? 0 : typeParams.length;
- if( numTypeParams != numArgs )
- throw new IllegalArgumentException("type, " + memberBinding + ", require " + numTypeParams + " type arguments " +
- "but found " + numArgs );
-
- final String typeKey = BindingKey.createParameterizedTypeBindingKey(memberBinding.getKey(), argKeys);
- final ITypeBinding resultBinding = _env.getTypeBinding(typeKey);
- return (DeclaredType)Factory.createReferenceType(resultBinding, _env);
- }
- else{
- if( numArgs != 0 )
- throw new IllegalArgumentException("type, " + memberBinding + " is not a generic type and cannot have type arguments.");
- // simple case, turning a non-generic TypeDeclaration into a DeclaredType
- return (DeclaredType)decl;
- }
- }
-
- public com.sun.mirror.type.DeclaredType getDeclaredType(TypeDeclaration decl, TypeMirror... typeArgs)
- {
- return getDeclaredType(null, decl, typeArgs);
- }
-
- public TypeMirror getErasure(TypeMirror t)
- {
- if( t == null ) return null;
-
- if(t instanceof EclipseMirrorImpl){
- final EclipseMirrorImpl impl = (EclipseMirrorImpl)t;
- final ITypeBinding binding;
- switch( impl.kind() )
- {
- case TYPE_PRIMITIVE:
- case TYPE_VOID:
- case TYPE_ERROR:
- return t;
- case TYPE_ARRAY:
- binding = ((ArrayTypeImpl)t).getArrayBinding();
- break;
- case TYPE_WILDCARD:
- binding = ((WildcardTypeImpl)t).getWildcardBinding();
- break;
- default:
- binding = ((TypeDeclarationImpl)t).getTypeBinding();
- }
- final ITypeBinding erasure = binding.getErasure();
- if( erasure == binding ) return t;
- TypeMirror m_erasure = Factory.createTypeMirror(erasure, impl.getEnvironment() );
- if( m_erasure == null )
- return Factory.createErrorClassType(erasure);
- return m_erasure;
- }
-
- throw new NonEclipseImplementationException("only applicable to eclipse type system objects." +
- " Found " + t.getClass().getName());
- }
-
- public PrimitiveType getPrimitiveType(PrimitiveType.Kind kind)
- {
- if( kind == null ) return null;
- switch(kind)
- {
- case BOOLEAN: return _env.getBooleanType();
- case BYTE: return _env.getByteType();
- case CHAR: return _env.getCharType();
- case DOUBLE: return _env.getDoubleType();
- case FLOAT: return _env.getFloatType();
- case INT: return _env.getIntType();
- case LONG: return _env.getLongType();
- case SHORT: return _env.getShortType();
-
- default: throw new IllegalStateException("unknown primitive kind : " + kind);
- }
- }
-
- public TypeVariable getTypeVariable(TypeParameterDeclaration tparam)
- {
- if( tparam == null ) return null;
- if( tparam instanceof TypeParameterDeclarationImpl)
- return (TypeVariable) tparam;
-
- throw new NonEclipseImplementationException("only applicable to eclipse type system objects." +
- " Found " + tparam.getClass().getName());
- }
-
- public VoidType getVoidType()
- {
- return _env.getVoidType();
- }
-
- public WildcardType getWildcardType(Collection<ReferenceType> upperBounds, Collection<ReferenceType> lowerBounds)
- {
- final String boundKey;
- final char boundKind;
- final int upperBoundCount = upperBounds == null ? 0 : upperBounds.size();
- final int lowerBoundCount = lowerBounds == null ? 0 : lowerBounds.size();
- if( upperBoundCount == 0 && lowerBoundCount == 0 ){
- boundKey = null;
- boundKind = Signature.C_STAR;
- }
- else if( upperBoundCount == 1 && lowerBoundCount == 0){
- final ITypeBinding binding = getTypeBinding(upperBounds.iterator().next());
- boundKey = binding.getKey();
- boundKind = Signature.C_EXTENDS;
- }
- else if(lowerBoundCount == 1 && upperBoundCount == 0){
- final ITypeBinding binding = getTypeBinding(lowerBounds.iterator().next());
- boundKey = binding.getKey();
- boundKind = Signature.C_SUPER;
- }
- else
- throw new IllegalArgumentException("Wildcard can only have a upper bound, a lower bound or be unbounded.");
-
- final String wildcardkey = BindingKey.createWilcardTypeBindingKey(boundKey, boundKind);
- final ITypeBinding wildcard = _env.getTypeBinding(wildcardkey);
- return (WildcardType)Factory.createTypeMirror(wildcard, _env);
- }
-
- /**
- * @return true iff t2 = t1 does not require explicit casting and not cause an error.
- */
- public boolean isAssignable(TypeMirror t1, TypeMirror t2)
- {
- final ITypeBinding left = getTypeBinding(t1);
- final ITypeBinding right = getTypeBinding(t2);
-
- if( left == right ) return true;
- else if( left == null || right == null ) return false;
- return right.isAssignmentCompatible(left);
- }
-
- public boolean isSubtype(TypeMirror t1, TypeMirror t2)
- {
- final ITypeBinding b1 = getTypeBinding(t1);
- final ITypeBinding b2 = getTypeBinding(t2);
- if( b1 == null || b2 == null ) return false;
-
- return b1.isSubTypeCompatible(b2);
- }
-
- /**
- * @return the binding correspond to the given type.
- * Return null if the type is an error marker.
- * @throws NonEclipseImplementationException
- */
-
- public static ITypeBinding getTypeBinding(TypeMirror type)
- throws NonEclipseImplementationException
- {
- if(type == null ) return null;
- if( type instanceof EclipseMirrorImpl ){
- final EclipseMirrorImpl impl = (EclipseMirrorImpl)type;
- switch(impl.kind() )
- {
- case TYPE_PRIMITIVE: return ((PrimitiveTypeImpl)type).getTypeBinding();
- case TYPE_VOID: return ((VoidTypeImpl)type).getTypeBinding();
- case TYPE_ERROR: return null;
- case TYPE_ARRAY: return ((ArrayTypeImpl)type).getArrayBinding();
- case TYPE_WILDCARD: return ((WildcardTypeImpl)type).getWildcardBinding();
- default: return ((TypeDeclarationImpl)type).getTypeBinding();
- }
- }
-
- throw new NonEclipseImplementationException("only applicable to eclipse type system objects." +
- " Found " + type.getClass().getName());
- }
-
- /**
- * @return the binding correspond to the given type.
- * @throws NonEclipseImplementationException
- */
- public static ITypeBinding getTypeBinding(TypeDeclaration type)
- throws NonEclipseImplementationException
- {
- if(type == null ) return null;
- if( type instanceof EclipseMirrorImpl ){
- return ((TypeDeclarationImpl)type).getTypeBinding();
- }
- throw new NonEclipseImplementationException("only applicable to eclipse type system objects." +
- " Found " + type.getClass().getName());
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/AptUtil.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/AptUtil.java
deleted file mode 100644
index bae8649..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/AptUtil.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.util;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.ProcessorEnvImpl;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.ToolFactory;
-import org.eclipse.jdt.core.compiler.IScanner;
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
-import org.eclipse.jdt.core.compiler.InvalidInputException;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-
-public class AptUtil {
-
- /**
- * scan the source code to see if there are any annotation tokens
- */
- public static boolean hasAnnotationInstance( IFile f )
- {
- try
- {
- char[] source = ProcessorEnvImpl.getFileContents( f );
- return hasAnnotationInstance( source );
- }
- catch( Exception ioe )
- {
- return false;
- }
- }
-
- public static boolean hasAnnotationInstance( ICompilationUnit cu )
- {
- try
- {
- IBuffer b = cu.getBuffer();
- if ( b == null )
- return false;
- char[] source = b.getCharacters();
- return hasAnnotationInstance( source );
- }
- catch( JavaModelException jme )
- {
- return false;
- }
- }
-
- public static boolean hasAnnotationInstance( char[] source )
- {
- try
- {
- if ( source == null )
- return false;
- IScanner scanner = ToolFactory.createScanner(
- false, false, false, CompilerOptions.VERSION_1_5 );
- scanner.setSource( source );
- int token = scanner.getNextToken();
- while ( token != ITerminalSymbols.TokenNameEOF )
- {
- token = scanner.getNextToken();
- if ( token == ITerminalSymbols.TokenNameAT )
- {
- //
- // found an @ sign, see if next token is "interface"
- // @interface is an annotation decl and not an annotation
- // instance.
- //
- token = scanner.getNextToken();
- if ( token != ITerminalSymbols.TokenNameinterface )
- return true;
- }
- }
- return false;
- }
- catch( InvalidInputException iie )
- {
- // lex error, so report false
- return false;
- }
- catch( Exception e )
- {
- // TODO: deal with this exception
- e.printStackTrace();
- return false;
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/EclipseMessager.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/EclipseMessager.java
deleted file mode 100644
index 1ba9beb..0000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/EclipseMessager.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * tyeung@bea.com - initial API
- *******************************************************************************/
-package org.eclipse.jdt.apt.core.util;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-
-import com.sun.mirror.apt.Messager;
-
-/**
- * Extend the APT {@link Messager} to allow the registrating of diagnostics on ast nodes.
- */
-public interface EclipseMessager extends Messager
-{
- /**
- * Print an error message on the given AST node.
- * The AST node must came from the AST that is associated with the environment.
- * @param node
- * @param msg the error message
- * @throws IllegalArgumentException if <code>node</code> or <code>msg</code> is null.
- * Also, if the node did not come from the ast in the environment.
- */
- void printError(ASTNode node, String msg);
-
- /**
- * Print a warning on the given AST node.
- * The AST node must came from the AST that is associated with the environment.
- * @param node
- * @param msg the warning message
- * @throws IllegalArgumentException if <code>node</code> or <code>msg</code> is null.
- * Also, if the node did not come from the ast in the environment.
- */
- void printWarning(ASTNode node, String msg);
-
- /**
- * Print a notice on the given AST node.
- * The AST node must came from the AST that is associated with the environment.
- * @param node
- * @param msg the warning message
- * @throws IllegalArgumentException if <code>node</code> or <code>msg</code> is null.
- * Also, if the node did not come from the ast in the environment.
- */
- void printNotice(ASTNode node, String msg);
-}
diff --git a/org.eclipse.jdt.apt.tests/.classpath b/org.eclipse.jdt.apt.tests/.classpath
deleted file mode 100644
index 8aa64f9..0000000
--- a/org.eclipse.jdt.apt.tests/.classpath
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src">
- <attributes>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <attributes>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JRE 1.5.0">
- <attributes>
- </attributes>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jdt.apt.tests/.cvsignore b/org.eclipse.jdt.apt.tests/.cvsignore
deleted file mode 100755
index c5e82d7..0000000
--- a/org.eclipse.jdt.apt.tests/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/.project b/org.eclipse.jdt.apt.tests/.project
deleted file mode 100644
index c6eff21..0000000
--- a/org.eclipse.jdt.apt.tests/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.apt.tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.jdt.apt.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jdt.apt.tests/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 6643746..0000000
--- a/org.eclipse.jdt.apt.tests/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-#Thu Mar 10 17:18:57 PST 2005
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/org.eclipse.jdt.apt.tests/build.properties b/org.eclipse.jdt.apt.tests/build.properties
deleted file mode 100644
index 2e1f7ba..0000000
--- a/org.eclipse.jdt.apt.tests/build.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-source.apt.jar = src/
-output.apt.jar = bin/
-bin.includes = plugin.xml,\
- apttests.jar
diff --git a/org.eclipse.jdt.apt.tests/plugin.xml b/org.eclipse.jdt.apt.tests/plugin.xml
deleted file mode 100644
index 4dd671c..0000000
--- a/org.eclipse.jdt.apt.tests/plugin.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.jdt.apt.tests"
- name="Annotation Processor Test Plugin"
- version="1.0.0"
- provider-name=""
- class="org.eclipse.jdt.apt.tests.plugin.AptTestsPlugin">
-
- <runtime>
- <library name="apttests.jar">
- <export name="*"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.apache.ant"/>
- <import plugin="org.junit"/>
- <import plugin="org.eclipse.jdt.apt.core"/>
- <import plugin="org.eclipse.jdt.core.tests.compiler"/>
- <import plugin="org.eclipse.jdt.core"/>
- <import plugin="org.eclipse.test.performance"/>
- <import plugin="org.eclipse.jdt.core.tests.model"/>
- <import plugin="org.eclipse.jdt.core.tests.builder"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.core.runtime"/>
- </requires>
-
- <extension
- point="org.eclipse.jdt.apt.core.annotationProcessorFactory">
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotationProcessorFactory"
- enableDefault="true">
- </factory>
- </extension>
-
- <extension
- point="org.eclipse.jdt.apt.core.annotationProcessorFactory">
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.extradependency.ExtraDependencyAnnotationProcessorFactory"
- enableDefault="true">
- </factory>
- </extension>
-
- <extension
- point="org.eclipse.jdt.apt.core.annotationProcessorFactory">
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.noop.NoOpAnnotationProcessorFactory"
- enableDefault="true">
- </factory>
- </extension>
-
- <extension
- point="org.eclipse.jdt.apt.core.annotationProcessorFactory">
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.mirrortest.MirrorTestAnnotationProcessorFactory"
- enableDefault="true">
- </factory>
- </extension>
-
- <extension
- point="org.eclipse.jdt.apt.core.annotationProcessorFactory">
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.nestedhelloworld.NestedHelloWorldAnnotationProcessorFactory"
- enableDefault="true">
- </factory>
- </extension>
-
-</plugin>
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java
deleted file mode 100644
index eb4b38a..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java
+++ /dev/null
@@ -1,494 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.tests.builder.Problem;
-import org.eclipse.jdt.core.tests.builder.Tests;
-import org.eclipse.jdt.core.tests.util.Util;
-
-public class AptBuilderTests extends Tests
-{
-
- public AptBuilderTests(String name)
- {
- super( name );
- }
-
- public static Test suite()
- {
- return new TestSuite( AptBuilderTests.class );
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
-
- // project will be deleted by super-class's tearDown() method
- IPath projectPath = env.addProject( getProjectName(), "1.5" ); //$NON-NLS-1$
- env.addExternalJars( projectPath, Util.getJavaClassLibs() );
- fullBuild( projectPath );
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$
-
- env.addPackageFragmentRoot( projectPath, "src" ); //$NON-NLS-1$
- env.setOutputFolder( projectPath, "bin" ); //$NON-NLS-1$
-
- TestUtil.createAndAddAnnotationJar( env
- .getJavaProject( projectPath ) );
- }
-
- public static String getProjectName()
- {
- return AptBuilderTests.class.getName() + "Project";
- }
-
- public IPath getSourcePath()
- {
- IProject project = env.getProject( getProjectName() );
- IFolder srcFolder = project.getFolder( "src" );
- IPath srcRoot = srcFolder.getFullPath();
- return srcRoot;
- }
-
- public void testGeneratedFileInBuilder() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code = "package p1;\n"
- + "//import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;"
- + "\n" + "public class A " + "\n" + "{"
- + " //@HelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " generatedfilepackage.GeneratedFileTest.helloWorld();"
- + "\n" + " }" + "\n" + "}" + "\n";
-
-
- IPath p1aPath = env.addClass( srcRoot, "p1", "A", //$NON-NLS-1$ //$NON-NLS-2$
- code );
-
- fullBuild( project.getFullPath() );
-
- expectingOnlyProblemsFor( p1aPath );
- expectingOnlySpecificProblemFor( p1aPath, new Problem(
- "A", "generatedfilepackage cannot be resolved", p1aPath ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- code = "package p1;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;"
- + "\n" + "public class A " + "\n" + "{"
- + " @HelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " generatedfilepackage.GeneratedFileTest.helloWorld();"
- + "\n" + " }" + "\n" + "}" + "\n";
-
- env.addClass( srcRoot, "p1", "A", code );
- fullBuild( project.getFullPath() );
-
- expectingOnlyProblemsFor( new IPath[0] );
- }
-
- /**
- * This test makes sure we run apt on generated files during build
- */
- public void testNestedGeneratedFileInBuilder() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code = "package p1;\n"
- + "//import org.eclipse.jdt.apt.tests.annotations.nestedhelloworld.NestedHelloWorldAnnotation;"
- + "\n" + "public class A " + "\n" + "{"
- + " //@NestedHelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " generatedfilepackage.GeneratedFileTest.helloWorld();"
- + "\n" + " }" + "\n" + "}" + "\n";
-
-
- IPath p1aPath = env.addClass( srcRoot, "p1", "A", //$NON-NLS-1$ //$NON-NLS-2$
- code );
-
- fullBuild( project.getFullPath() );
-
- expectingOnlyProblemsFor( p1aPath );
- expectingOnlySpecificProblemFor( p1aPath, new Problem(
- "A", "generatedfilepackage cannot be resolved", p1aPath ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- code = "package p1;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.nestedhelloworld.NestedHelloWorldAnnotation;"
- + "\n" + "public class A " + "\n" + "{"
- + " @NestedHelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " generatedfilepackage.GeneratedFileTest.helloWorld();"
- + "\n" + " }" + "\n" + "}" + "\n";
-
- env.addClass( srcRoot, "p1", "A", code );
- fullBuild( project.getFullPath() );
-
- expectingOnlyProblemsFor( new IPath[0] );
- }
-
-
-
- /**
- * This test makes sure that our extra-dependency stuff is hooked up in the build.
- * Specifically, we test to make sure that Extra dependencies only appear when
- * an annotation processor looks up a type by name. We also test that expected
- * build output is there because of the dependency.
- */
- public void testExtraDependencies()
- {
- String codeA = "package p1.p2.p3.p4;\n"
- + "public class A { B b; D d; }";
-
- String codeB1 = "package p1.p2.p3.p4;\n"
- + "public class B { }";
-
- String codeB2 = "package p1.p2.p3.p4;\n"
- + "public class B { public static void main( String[] argv ) {} }";
-
- String codeC = "package p1.p2.p3.p4;\n"
- + "public class C { }";
-
- String codeD = "package p1.p2.p3.p4;\n"
- + "public class D { }";
-
- String codeE = "package p1.p2.p3.p4;\n"
- + "public class E { }";
-
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- env.addClass( srcRoot, "p1.p2.p3.p4", "A", //$NON-NLS-1$ //$NON-NLS-2$
- codeA );
-
- env.addClass( srcRoot, "p1.p2.p3.p4", "B", //$NON-NLS-1$ //$NON-NLS-2$
- codeB1 );
-
- env.addClass( srcRoot, "p1.p2.p3.p4", "C", //$NON-NLS-1$ //$NON-NLS-2$
- codeC );
-
- env.addClass( srcRoot, "p1.p2.p3.p4", "D", //$NON-NLS-1$ //$NON-NLS-2$
- codeD );
-
- env.addClass( srcRoot, "p1.p2.p3.p4", "E", //$NON-NLS-1$ //$NON-NLS-2$
- codeE );
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- // touch B - make sure its public shape changes.
- env.addClass( srcRoot, "p1.p2.p3.p4", "B", //$NON-NLS-1$ //$NON-NLS-2$
- codeB2 );
-
- incrementalBuild( project.getFullPath() );
- expectingNoProblems();
- expectingCompiledClasses(new String[]{"p1.p2.p3.p4.B", "p1.p2.p3.p4.A"}); //$NON-NLS-1$ //$NON-NLS-2$
- expectingCompilingOrder(new String[]{"p1.p2.p3.p4.B", "p1.p2.p3.p4.A"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- //
- // Now have p1.p2.p3.p4.A w/ an anontation whose processor looks up p1.p2.p3.p4.C by name
- //
-
- // new code for A with an annotation processor that should introduce a dep on C
- codeA = "package p1.p2.p3.p4;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.extradependency.ExtraDependencyAnnotation;" + "\n"
- + "@ExtraDependencyAnnotation" + "\n"
- + "public class A { B b; D d; }";
-
- env.addClass( srcRoot, "p1.p2.p3.p4", "A", //$NON-NLS-1$ //$NON-NLS-2$
- codeA );
- env.addClass( srcRoot, "p1.p2.p3.p4", "B", //$NON-NLS-1$ //$NON-NLS-2$
- codeB1 );
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- // touch B
- env.addClass( srcRoot, "p1.p2.p3.p4", "B", //$NON-NLS-1$ //$NON-NLS-2$
- codeB2 );
-
- incrementalBuild( project.getFullPath() );
- expectingNoProblems();
-
- //
- // Note that p1.p2.p3.p4.A is showing up twice because it has annotations, and we need to
- // parse the source, parsing runs through the compiler, and this registers the
- // file a second time with the Compiler#DebugRequestor
- //
- expectingCompiledClasses(new String[]{"p1.p2.p3.p4.B", "p1.p2.p3.p4.A", "p1.p2.p3.p4.A", "p1.p2.p3.p4.C"}); //$NON-NLS-1$ //$NON-NLS-2$
- expectingCompilingOrder(new String[]{"p1.p2.p3.p4.B", "p1.p2.p3.p4.A", "p1.p2.p3.p4.C", "p1.p2.p3.p4.A"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- //
- // now make sure that p1.p2.p3.p4.C is not compiled when A uses NoOp Annotation
- //
-
- // new code for A with an annotation processor that should introduce a dep on C
- codeA = "package p1.p2.p3.p4;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.noop.NoOpAnnotation;" + "\n"
- + "@NoOpAnnotation" + "\n"
- + "public class A { B b; D d; }";
-
- env.addClass( srcRoot, "p1.p2.p3.p4", "A", //$NON-NLS-1$ //$NON-NLS-2$
- codeA );
- env.addClass( srcRoot, "p1.p2.p3.p4", "B", //$NON-NLS-1$ //$NON-NLS-2$
- codeB1 );
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- // touch B
- env.addClass( srcRoot, "p1.p2.p3.p4", "B", //$NON-NLS-1$ //$NON-NLS-2$
- codeB2 );
-
- incrementalBuild( project.getFullPath() );
- expectingNoProblems();
-
- //
- // Note that p1.p2.p3.p4.A is showing up twice because it has annotations, and we need to
- // parse the source, parsing runs through the compiler, and this registers the
- // file a second time with the Compiler#DebugRequestor
- //
- expectingCompiledClasses(new String[]{"p1.p2.p3.p4.B", "p1.p2.p3.p4.A", "p1.p2.p3.p4.A" }); //$NON-NLS-1$ //$NON-NLS-2$
- expectingCompilingOrder(new String[]{"p1.p2.p3.p4.B", "p1.p2.p3.p4.A", "p1.p2.p3.p4.A" }); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Test that we do not recompile generated files that are
- * not changed even as their parent is modified.
- */
- public void testCaching()
- {
- String code = "package p1;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;"
- + "\n" + "public class A " + "\n" + "{"
- + " @HelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " generatedfilepackage.GeneratedFileTest.helloWorld();"
- + "\n"
- + " }"
- + "\n"
- + "}"
- + "\n";
-
- String modifiedCode = "package p1;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;"
- + "\n" + "public class A " + "\n" + "{"
- + " @HelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " generatedfilepackage.GeneratedFileTest.helloWorld();"
- + "\n"
- + " }"
- + "\n"
- + " public static void otherMethod()" + "\n" + " {"
- + " System.out.println();\n"
- + " }"
- + "}"
- + "\n";
-
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- env.addClass( srcRoot, "p1", "A", //$NON-NLS-1$ //$NON-NLS-2$
- code );
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- expectingCompiledClasses(new String[] {"p1.A", "p1.A", "generatedfilepackage.GeneratedFileTest"}); //$NON-NLS-1 //$NON_NLS-2$
-
- // build this again. The first build would have caused a classpath change by adding in the
- // generated-src dir, and a classpath change causes a full build
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- expectingCompiledClasses(new String[] {"p1.A", "p1.A", "generatedfilepackage.GeneratedFileTest"}); //$NON-NLS-1 //$NON_NLS-2$
-
-
- // touch A - make sure its public shape changes.
- env.addClass( srcRoot, "p1", "A", //$NON-NLS-1$ //$NON-NLS-2$
- modifiedCode );
-
- incrementalBuild( project.getFullPath() );
- expectingNoProblems();
- expectingCompiledClasses(new String[]{"p1.A", "p1.A"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- /**
- * This test makes sure that we delete generated files when the parent file
- * is deleted. We also make sure that multi-parent support is working.
- */
- public void testDeletedParentFile() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String a1Code = "package p1; " + "\n"
- + "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;" + "\n"
- + "@HelloWorldAnnotation" + "\n"
- + "public class A1 {}";
- String a2Code = "package p1; " + "\n"
- + "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;" + "\n"
- + "@HelloWorldAnnotation" + "\n"
- + "public class A2 {}";
- String bCode = "package p1; " + "\n"
- + "public class B { generatedfilepackage.GeneratedFileTest gft; }";
-
- IPath p1a1Path = env.addClass( srcRoot, "p1", "A1", //$NON-NLS-1$ //$NON-NLS-2$
- a1Code );
- IPath p1a2Path = env.addClass( srcRoot, "p1", "A2", //$NON-NLS-1$ //$NON-NLS-2$
- a2Code );
- IPath p1bPath = env.addClass( srcRoot, "p1", "B", //$NON-NLS-1$ //$NON-NLS-2$
- bCode );
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- // now delete file A1 and make sure we still have no problems
- env.removeFile( p1a1Path );
-
- // sleep to let the resource-change event fire
- sleep( 1000 );
-
- incrementalBuild( project.getFullPath() );
-
- expectingNoProblems();
-
- // now delete file A2 and make sure we have a problem on B
- env.removeFile( p1a2Path );
-
- // sleep to let the resource-change event fire
- sleep( 1000 );
-
- incrementalBuild( project.getFullPath() );
- expectingOnlyProblemsFor( p1bPath );
- expectingOnlySpecificProblemFor( p1bPath, new Problem(
- "B", "generatedfilepackage.GeneratedFileTest cannot be resolved to a type", p1bPath ) ); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testStopGeneratingFileInBuilder_FullBuild()
- {
- internalTestStopGeneratingFileInBuilder( true );
- }
-
- public void testStopGeneratingFileInBuilder_IncrementalBuild()
- {
- internalTestStopGeneratingFileInBuilder( false );
- }
-
- private void internalTestStopGeneratingFileInBuilder( boolean fullBuild )
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code = "package p1;\n"
- + "//import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;"
- + "\n" + "public class A " + "\n" + "{"
- + " //@HelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " generatedfilepackage.GeneratedFileTest.helloWorld();"
- + "\n" + " }" + "\n" + "}" + "\n";
-
-
- IPath p1aPath = env.addClass( srcRoot, "p1", "A", //$NON-NLS-1$ //$NON-NLS-2$
- code );
-
- if ( fullBuild )
- fullBuild( project.getFullPath() );
- else
- incrementalBuild( project.getFullPath() );
-
-
- expectingOnlyProblemsFor( p1aPath );
- expectingOnlySpecificProblemFor( p1aPath, new Problem(
- "A", "generatedfilepackage cannot be resolved", p1aPath ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- code = "package p1;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;"
- + "\n" + "public class A " + "\n" + "{"
- + " @HelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " generatedfilepackage.GeneratedFileTest.helloWorld();"
- + "\n" + " }" + "\n" + "}" + "\n";
-
- env.addClass( srcRoot, "p1", "A", code );
- if ( fullBuild )
- fullBuild( project.getFullPath() );
- else
- incrementalBuild( project.getFullPath() );
-
- expectingOnlyProblemsFor( new IPath[0] );
-
- // do a full build again. This is necessary because generating the file
- // caused a classpath change, so the next inremental build will end up being
- // a full build because of the classpath change
- if ( ! fullBuild )
- fullBuild( project.getFullPath() );
-
- // now remove the annotation. The generated file should go away
- // and we should see errors again
- code = "package p1;\n"
- + "//import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;"
- + "\n" + "public class A " + "\n" + "{"
- + " //@HelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " generatedfilepackage.GeneratedFileTest.helloWorld();"
- + "\n" + " }" + "\n" + "}" + "\n";
-
- env.addClass( srcRoot, "p1", "A", code );
-
- if ( fullBuild )
- fullBuild( project.getFullPath() );
- else
- incrementalBuild( project.getFullPath() );
-
- expectingOnlyProblemsFor( p1aPath );
- String expectedError;
- if ( fullBuild )
- expectedError = "generatedfilepackage cannot be resolved";
- else
- expectedError = "generatedfilepackage.GeneratedFileTest cannot be resolved to a type";
-
- expectingOnlySpecificProblemFor( p1aPath,
- new Problem( "A", expectedError, p1aPath ) ); //$NON-NLS-1$
- }
-
- private static void sleep( long millis )
- {
- long end = System.currentTimeMillis() + millis;
- while ( millis > 0 )
- {
- try
- {
- Thread.sleep( millis );
- }
- catch ( InterruptedException ie )
- {}
- millis = end - System.currentTimeMillis();
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptReconcileTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptReconcileTests.java
deleted file mode 100644
index a404b2f..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptReconcileTests.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests;
-
-import java.io.File;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.WorkingCopyOwner;
-import org.eclipse.jdt.core.tests.model.ModifyingResourceTests;
-
-public class AptReconcileTests extends ModifyingResourceTests
-{
- public AptReconcileTests(String name)
- {
- super( name );
- }
-
- public static Test suite() {
- return new TestSuite(AptReconcileTests.class);
- }
-
- public void testGeneratedFile() throws Throwable
- {
- String fname = TEST_FOLDER + "/A.java";
- try
- {
-
- //
- // first make sure errors are present when the annotation
- // is commented out
- //
- String codeWithErrors = "package test;" + "\n" +
- "//import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;" + "\n" +
- "public class A " + "\n" +
- "{" + "\n" +
- " //@HelloWorldAnnotation" + "\n" +
- " public static void main( String[] argv )" + "\n" +
- " {" + "\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();" + "\n" +
- " }" + "\n" +
- "}";
-
- createFile( fname, codeWithErrors );
- this._problemRequestor = new ProblemRequestor();
-
- setUpWorkingCopy( fname, codeWithErrors );
- this._workingCopy.reconcile( ICompilationUnit.NO_AST, true, null,
- null );
-
- String expectedProblems = "----------\n" +
- "1. ERROR in /org.eclipse.jdt.apt.tests.AptReconcileTestsProject/src/test/A.java (at line 8)\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();\n" +
- " ^^^^^^^^^^^^^^^^^^^^\n" +
- "generatedfilepackage cannot be resolved\n" +
- "----------\n" +
- "----------\n" +
- "2. ERROR in /org.eclipse.jdt.apt.tests.AptReconcileTestsProject/src/test/A.java (at line 8)\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();\n" +
- " ^^^^^^^^^^^^^^^^^^^^\n" +
- "generatedfilepackage cannot be resolved\n" +
- "----------\n";
-
- assertProblems( "Unexpected problems", expectedProblems );
-
-
- //
- // now make sure errors go away when annotations are present
- //
- String codeWithOutErrors = "package test;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;" + "\n" +
- "public class A " + "\n" +
- "{" + "\n" +
- " @HelloWorldAnnotation" + "\n" +
- " public static void main( String[] argv )" + "\n" +
- " {" + "\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();" + "\n" +
- " }" + "\n" +
- "}";
-
- setWorkingCopyContents( codeWithOutErrors );
- this._workingCopy.reconcile( ICompilationUnit.NO_AST, true, null,
- null );
-
- assertProblems( "UnexpectedProblems", "----------\n----------\n" );
-
- }
- catch( Throwable e )
- {
- e.printStackTrace();
- throw e;
- }
- finally
- {
- deleteFile( fname );
- }
- }
-
-
- /**
- * This tests an annotation that generates a file with an annotation that
- * generates a file that should fix an error in the parent file.
- * @throws Throwable
- */
- public void testNestedGeneratedFile() throws Throwable
- {
- String fname = TEST_FOLDER + "/A.java";
- try
- {
-
- //
- // first make sure errors are present when the annotation
- // is commented out
- //
- String codeWithErrors = "package test;" + "\n" +
- "//import org.eclipse.jdt.apt.tests.annotations.nestedhelloworld.NestedHelloWorldAnnotation;" + "\n" +
- "public class A " + "\n" +
- "{" + "\n" +
- " //@NestedHelloWorldAnnotation" + "\n" +
- " public static void main( String[] argv )" + "\n" +
- " {" + "\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();" + "\n" +
- " }" + "\n" +
- "}";
-
- createFile( fname, codeWithErrors );
- this._problemRequestor = new ProblemRequestor();
-
- setUpWorkingCopy( fname, codeWithErrors );
- this._workingCopy.reconcile( ICompilationUnit.NO_AST, true, null,
- null );
-
- String expectedProblems = "----------\n" +
- "1. ERROR in /org.eclipse.jdt.apt.tests.AptReconcileTestsProject/src/test/A.java (at line 8)\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();\n" +
- " ^^^^^^^^^^^^^^^^^^^^\n" +
- "generatedfilepackage cannot be resolved\n" +
- "----------\n" +
- "----------\n" +
- "2. ERROR in /org.eclipse.jdt.apt.tests.AptReconcileTestsProject/src/test/A.java (at line 8)\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();\n" +
- " ^^^^^^^^^^^^^^^^^^^^\n" +
- "generatedfilepackage cannot be resolved\n" +
- "----------\n";
-
- assertProblems( "Unexpected problems", expectedProblems );
-
-
- //
- // now make sure errors go away when annotations are present
- //
- String codeWithOutErrors = "package test;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.nestedhelloworld.NestedHelloWorldAnnotation;" + "\n" +
- "public class A " + "\n" +
- "{" + "\n" +
- " @NestedHelloWorldAnnotation" + "\n" +
- " public static void main( String[] argv )" + "\n" +
- " {" + "\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();" + "\n" +
- " }" + "\n" +
- "}";
-
- setWorkingCopyContents( codeWithOutErrors );
- this._workingCopy.reconcile( ICompilationUnit.NO_AST, true, null,
- null );
-
- assertProblems( "UnexpectedProblems", "----------\n----------\n" );
-
- }
- catch( Throwable e )
- {
- e.printStackTrace();
- throw e;
- }
- finally
- {
- deleteFile( fname );
- }
- }
-
-
-
-
- public void setUp() throws Exception
- {
- try
- {
- super.setUp();
-
- this._problemRequestor = new ProblemRequestor();
-
- final IJavaProject project = createJavaProject( TEST_PROJECT,
- new String[] { "src" }, new String[] { "JCL15_LIB" },
- "bin", "1.5" );
- project.getProject().refreshLocal( IResource.DEPTH_INFINITE, null );
-
- _classesJarFile = TestUtil.createAndAddAnnotationJar( project );
-
- IFolder testFolder = createFolder( TEST_FOLDER );
- if ( !testFolder.exists() )
- testFolder.create( true, false, null );
- }
- catch ( Exception t )
- {
- t.printStackTrace();
- throw t;
- }
- catch ( Throwable t )
- {
- t.printStackTrace();
- throw new RuntimeException( t );
- }
- }
-
- public void tearDown() throws Exception
- {
- if( this._workingCopy != null )
- this._workingCopy.discardWorkingCopy();
-
- deleteFile( _classesJarFile );
- deleteFolder( TEST_FOLDER );
- deleteProject( TEST_PROJECT );
- super.tearDown();
- }
-
-
- /***************************************************************************
- *
- * copied from ReconcilerTests...
- *
- */
-
- private void setWorkingCopyContents(String contents)
- throws JavaModelException
- {
- this._workingCopy.getBuffer().setContents( contents );
- this._problemRequestor.initialize( contents.toCharArray() );
- }
-
- private void setUpWorkingCopy(String path, String contents)
- throws JavaModelException
- {
- if( this._workingCopy != null )
- this._workingCopy.discardWorkingCopy();
- this._workingCopy = getCompilationUnit( path ).getWorkingCopy(
- new WorkingCopyOwner()
- {}, this._problemRequestor, null );
- setWorkingCopyContents( contents );
- this._workingCopy.makeConsistent( null );
- }
-
- protected void assertProblems(String message, String expected)
- {
- assertProblems( message, expected, this._problemRequestor );
- }
-
- /** *********************************************************************** */
-
-
- protected ICompilationUnit _workingCopy;
-
- protected ProblemRequestor _problemRequestor;
-
- public static final String TEST_PROJECT = AptReconcileTests.class.getName() + "Project";
-
- public static final String TEST_FOLDER = "/" + TEST_PROJECT
- + "/src/test";
-
- private File _classesJarFile;
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorTests.java
deleted file mode 100644
index de206bb..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorTests.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * jgarms@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.tests.annotations.mirrortest.CodeExample;
-import org.eclipse.jdt.apt.tests.annotations.mirrortest.MirrorTestAnnotationProcessor;
-import org.eclipse.jdt.core.tests.builder.Tests;
-import org.eclipse.jdt.core.tests.util.Util;
-
-public class MirrorTests extends Tests {
-
- public MirrorTests(final String name) {
- super( name );
- }
-
- public static Test suite() {
- return new TestSuite( MirrorTests.class );
- }
-
- public void setUp() throws Exception {
- super.setUp();
-
- // project will be deleted by super-class's tearDown() method
- IPath projectPath = env.addProject( getProjectName(), "1.5" ); //$NON-NLS-1$
- env.addExternalJars( projectPath, Util.getJavaClassLibs() );
- fullBuild( projectPath );
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$
-
- env.addPackageFragmentRoot( projectPath, "src" ); //$NON-NLS-1$
- env.setOutputFolder( projectPath, "bin" ); //$NON-NLS-1$
-
- TestUtil.createAndAddAnnotationJar( env
- .getJavaProject( projectPath ) );
- }
-
- public static String getProjectName() {
- return MirrorTests.class.getName() + "Project";
- }
-
- public IPath getSourcePath() {
- IProject project = env.getProject( getProjectName() );
- IFolder srcFolder = project.getFolder( "src" );
- IPath srcRoot = srcFolder.getFullPath();
- return srcRoot;
- }
-
- /**
- * Runs the MirrorTestAnnotationProcessor, which contains
- * the actual tests
- */
- public void testMirror() throws Exception {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code = CodeExample.CODE;
-
- env.addClass(
- srcRoot,
- CodeExample.CODE_PACKAGE,
- CodeExample.CODE_CLASS_NAME,
- code );
-
- fullBuild( project.getFullPath() );
-
- expectingNoProblems();
-
- assertEquals(MirrorTestAnnotationProcessor.NO_ERRORS,
- MirrorTestAnnotationProcessor.ERROR);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestAll.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestAll.java
deleted file mode 100644
index e9af6e5..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestAll.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * wharley@bea.com - initial API and implementation
- *******************************************************************************/
-
-
-package org.eclipse.jdt.apt.tests;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Run all annotation processor tests.
- * Annotation processors may be registered by using this test plugin to extend
- * <code>org.eclipse.jdt.apt.core.annotationProcessorFactory</code>, providing
- * the name of an annotation processor factory class implemented in this plugin.
- */
-public class TestAll extends TestCase {
-
- public TestAll(String testName)
- {
- super(testName);
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(AptReconcileTests.suite());
- suite.addTest(AptBuilderTests.suite() );
- suite.addTest(MirrorTests.suite());
-
- return suite;
-
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestUtil.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestUtil.java
deleted file mode 100644
index 486d04a..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestUtil.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 BEA Systems, Inc, IBM Corporation, and others
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-import org.eclipse.core.internal.localstore.FileSystemResourceManager;
-import org.eclipse.core.internal.resources.Workspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.jdt.apt.tests.plugin.AptTestsPlugin;
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.internal.core.ClasspathEntry;
-
-public class TestUtil
-{
-
- /**
- * creates the annotation jar. Returns the java.io.File of the jar that was created.
- */
- public static File createAndAddAnnotationJar( IJavaProject project )
- throws IOException, JavaModelException
- {
- //
- // add annotations jar as part of the project
- //
- IPath projectPath = getProjectPath( project );
- File jarFile = new File( projectPath.toFile(), "Classes.jar" );
- String classesJarPath = jarFile.getAbsolutePath();
- TestUtil.createAnnotationJar( classesJarPath );
- addLibraryEntry( project, new Path(classesJarPath), null /*srcAttachmentPath*/,
- null /*srcAttachmentPathRoot*/, null /*accessibleFiles*/, null/*nonAccessibleFiles*/, true );
- return new File(classesJarPath);
- }
-
- public static void createAnnotationJar(String jarPath)
- throws IOException
- {
- //
- // This filter only accepts classes in the package ANNOTATIONS_PKG.
- // This way, we can jar up these files and have them available to the
- // project
- // so code can reference types in there.
- //
- FileFilter filter = new FileFilter()
- {
- public boolean accept(File pathname)
- {
- IPath f = new Path( pathname.getAbsolutePath() );
-
- int nsegments = f.matchingFirstSegments( new Path(
- getPluginClassesDir() ) );
- boolean ok = true;
- int min = Math.min( f.segmentCount() - nsegments,
- ANNOTATIONS_PKG_PARTS.length );
- for( int i = nsegments, j = 0; j < min; i++, j++ )
- {
- if( !f.segment( i ).equals( ANNOTATIONS_PKG_PARTS[j] ) )
- {
- ok = false;
- break;
- }
- }
- return ok;
- }
- };
- zip( new File( getPluginClassesDir() ), jarPath, filter );
- }
-
- public static IPath getProjectPath( IJavaProject project )
- {
- Workspace workspace = (Workspace)ResourcesPlugin.getWorkspace();
- FileSystemResourceManager fileSystemMgr = workspace.getFileSystemManager();
- IPath p = fileSystemMgr.locationFor( project.getResource() );
- return p;
- }
-
-
- public static String getPluginClassesDir()
- {
- return getFileInPlugin( AptTestsPlugin.getDefault(), new Path( "/bin" ) )
- .getAbsolutePath();
- }
-
- public static java.io.File getFileInPlugin(Plugin plugin, IPath path)
- {
- try
- {
- URL installURL = plugin.getBundle().getEntry( path.toString() );
- URL localURL = Platform.asLocalURL( installURL );
- return new java.io.File( localURL.getFile() );
- }
- catch( IOException e )
- {
- return null;
- }
- }
-
- public static void zip(File rootDir, String zipPath, FileFilter filter)
- throws IOException
- {
- ZipOutputStream zip = null;
- try
- {
- zip = new ZipOutputStream( new FileOutputStream( zipPath ) );
- // +1 for last slash
- zip( rootDir, zip, rootDir.getPath().length() + 1, filter );
- }
- finally
- {
- if( zip != null )
- {
- zip.close();
- }
- }
- }
-
- private static void zip(File dir, ZipOutputStream zip, int rootPathLength,
- FileFilter filter) throws IOException
- {
- String[] list = dir.list();
- if( list != null )
- {
- for( int i = 0, length = list.length; i < length; i++ )
- {
- String name = list[i];
- File file = new File( dir, name );
- if( filter == null || filter.accept( file ) )
- {
- if( file.isDirectory() )
- {
- zip( file, zip, rootPathLength, filter );
- }
- else
- {
- String path = file.getPath();
- path = path.substring( rootPathLength );
- ZipEntry entry = new ZipEntry( path.replace( '\\', '/' ) );
- zip.putNextEntry( entry );
- zip.write( org.eclipse.jdt.internal.compiler.util.Util
- .getFileByteContent( file ) );
- zip.closeEntry();
- }
- }
- }
- }
- }
-
- public static void addLibraryEntry(IJavaProject project, IPath path, IPath srcAttachmentPath, IPath srcAttachmentPathRoot, IPath[] accessibleFiles, IPath[] nonAccessibleFiles, boolean exported) throws JavaModelException{
- IClasspathEntry[] entries = project.getRawClasspath();
- int length = entries.length;
- System.arraycopy(entries, 0, entries = new IClasspathEntry[length + 1], 1, length);
- entries[0] = JavaCore.newLibraryEntry(
- path,
- srcAttachmentPath,
- srcAttachmentPathRoot,
- ClasspathEntry.getAccessRules(accessibleFiles, nonAccessibleFiles),
- new IClasspathAttribute[0],
- exported);
- project.setRawClasspath(entries, null);
- }
-
-
- public static final String ANNOTATIONS_PKG = "org.eclipse.jdt.apt.tests.annotations";
-
- public static final String[] ANNOTATIONS_PKG_PARTS = ANNOTATIONS_PKG
- .split( "\\." );
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotation.java
deleted file mode 100644
index e63c48b..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotation.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.extradependency;
-
-public @interface ExtraDependencyAnnotation
-{
- String value() default "";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotationProcessor.java
deleted file mode 100644
index b515ce9..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotationProcessor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.extradependency;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-
-public class ExtraDependencyAnnotationProcessor implements AnnotationProcessor
-{
-
- public ExtraDependencyAnnotationProcessor(AnnotationProcessorEnvironment env)
- {
- _env = env;
- }
-
- public void process()
- {
- _env.getTypeDeclaration( "p1.p2.p3.p4.C" );
- }
-
- AnnotationProcessorEnvironment _env;
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotationProcessorFactory.java
deleted file mode 100644
index d59c79d..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.extradependency;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class ExtraDependencyAnnotationProcessorFactory implements
-AnnotationProcessorFactory
-{
-
- public Collection<String> supportedOptions() {
- return Collections.emptyList();
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return annotations;
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env)
- {
- return new ExtraDependencyAnnotationProcessor( env );
- }
-
- private static ArrayList<String> annotations = new ArrayList<String>();
-
- {
- annotations.add( ExtraDependencyAnnotation.class.getName() );
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotation.java
deleted file mode 100644
index 99912fd..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotation.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.helloworld;
-
-public @interface HelloWorldAnnotation
-{
- String value() default "";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotationProcessor.java
deleted file mode 100644
index 38eb6a0..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotationProcessor.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.helloworld;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Filer;
-
-public class HelloWorldAnnotationProcessor implements AnnotationProcessor
-{
-
- public HelloWorldAnnotationProcessor(AnnotationProcessorEnvironment env)
- {
- _env = env;
- }
-
- public void process()
- {
- try
- {
- Filer f = getEnvironment().getFiler();
- PrintWriter pw = f
- .createSourceFile( getPackageName() + "." + getTypeName() );
- pw.print( getCode() );
- pw.close();
- }
- catch( IOException ioe )
- {
- ioe.printStackTrace();
- }
- }
-
- public AnnotationProcessorEnvironment getEnvironment()
- {
- return _env;
- }
-
- public String getCode() { return CODE; }
- public String getPackageName() { return "generatedfilepackage"; }
- public String getTypeName() { return "GeneratedFileTest"; }
-
- AnnotationProcessorEnvironment _env;
-
- protected final static String PACKAGE_NAME = "";
-
- protected final static String TYPE_NAME = "";
-
- protected String CODE = "package "
- + getPackageName()
- + ";"
- + "\n"
- + "public class "
- + getTypeName()
- + "\n"
- + "{"
- + "\n"
- + " public static void helloWorld()"
- + "\n"
- + " {"
- + "\n"
- + " System.out.println( \"Hello, world! I am a generated file!\" ); "
- + "\n" + " }" + "\n"
- + "}";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotationProcessorFactory.java
deleted file mode 100644
index 19944eb..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.helloworld;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class HelloWorldAnnotationProcessorFactory implements
-AnnotationProcessorFactory
-{
-
- public Collection<String> supportedOptions() {
- return Collections.emptyList();
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return annotations;
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env)
- {
- return new HelloWorldAnnotationProcessor( env );
- }
-
- private static ArrayList<String> annotations = new ArrayList<String>();
-
- {
- annotations.add( HelloWorldAnnotation.class.getName() );
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/CodeExample.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/CodeExample.java
deleted file mode 100644
index 3db6e22..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/CodeExample.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * jgarms@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-
-package org.eclipse.jdt.apt.tests.annotations.mirrortest;
-
-/**
- * Holds information for the mirror tests.
- */
-public class CodeExample {
-
- public static final String CODE_PACKAGE = "mirrortestpackage";
-
- public static final String CODE_CLASS_NAME = "MirrorTestClass";
-
- public static final String CODE_FULL_NAME = CODE_PACKAGE + "." + CODE_CLASS_NAME;
-
- public static final String CODE =
- "package mirrortestpackage;\n" +
- "\n" +
- "import java.io.Serializable;\n" +
- "import org.eclipse.jdt.apt.tests.annotations.mirrortest.MirrorTestAnnotation;\n" +
- "\n" +
- "public class MirrorTestClass implements Serializable {\n" +
- "\n" +
- " private static final String STATIC_FIELD = \"Static Field\";\n" +
- "\n" +
- " private static final long serialVersionUID = 42L;\n" +
- "\n" +
- " private String field;\n" +
- "\n" +
- " public MirrorTestClass() {\n" +
- " field = \"Field\";\n" +
- " }\n" +
- "\n" +
- " @MirrorTestAnnotation\n" +
- " public static Object staticMethod() {\n" +
- " return null;\n" +
- " }\n" +
- "\n" +
- " public String stringMethod() {\n" +
- " return null;\n" +
- " }\n" +
- "\n" +
- "\n" +
- " public String toString() {\n" +
- " return null;\n" +
- " }\n" +
- "\n" +
- " private static class InnerClass extends MirrorTestClass {\n" +
- "\n" +
- " private static final long serialVersionUID = 148L;\n" +
- "\n" +
- " public static Object staticMethod() {\n" +
- " return null;\n" +
- " }\n" +
- "\n" +
- " }\n" +
- "}";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotation.java
deleted file mode 100644
index d342778..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotation.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * jgarms@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-
-package org.eclipse.jdt.apt.tests.annotations.mirrortest;
-
-/**
- * Annotation for testing the Mirror API implementation.
- * Work takes place in the MirrorTestAnnotationProcessor.
- *
- */
-public @interface MirrorTestAnnotation {
-
- String value() default "";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotationProcessor.java
deleted file mode 100644
index 2c19b3e..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotationProcessor.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * jgarms@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-
-package org.eclipse.jdt.apt.tests.annotations.mirrortest;
-
-import java.util.Collection;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.ClassDeclaration;
-import com.sun.mirror.declaration.EnumDeclaration;
-import com.sun.mirror.declaration.FieldDeclaration;
-import com.sun.mirror.declaration.InterfaceDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.PackageDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.declaration.TypeParameterDeclaration;
-import com.sun.mirror.type.InterfaceType;
-import com.sun.mirror.util.Declarations;
-
-public class MirrorTestAnnotationProcessor implements AnnotationProcessor {
-
- public static final String NO_ERRORS = "NO ERRORS";
-
- /** Used by the test harness to verify that no errors were encountered **/
- public static String ERROR = NO_ERRORS;
-
- private final AnnotationProcessorEnvironment env;
-
- public MirrorTestAnnotationProcessor(AnnotationProcessorEnvironment env) {
- this.env = env;
- }
-
- public void process() {
- try {
- Collection<TypeDeclaration> decls = env.getSpecifiedTypeDeclarations();
- TypeDeclaration decl = null;
- for (TypeDeclaration declTemp : decls) {
- if (CodeExample.CODE_FULL_NAME.equals(declTemp.getQualifiedName()))
- decl = declTemp;
- }
- testTypeDecl(decl);
- testDeclarationsUtil(decl);
- testPackageImpl();
- }
- catch (Throwable t) {
- if (ERROR == null) {
- ERROR = t.toString();
- }
- t.printStackTrace();
- }
- }
-
- private void testTypeDecl(TypeDeclaration typeDecl) {
- assertEquals("Type name",
- CodeExample.CODE_PACKAGE + "." + CodeExample.CODE_CLASS_NAME,
- typeDecl.getQualifiedName());
-
- PackageDeclaration pkg = typeDecl.getPackage();
- assertEquals("Package", CodeExample.CODE_PACKAGE, pkg.getQualifiedName());
-
- // TODO: test the actual contents, not just sizes of the results
- Collection<FieldDeclaration> fields = typeDecl.getFields();
- assertEquals("Number of fields: " + fields, 3, fields.size());
-
- Collection<TypeParameterDeclaration> typeParams = typeDecl.getFormalTypeParameters();
- assertEquals("Number of type params", 0, typeParams.size());
-
- Collection<? extends MethodDeclaration> methods = typeDecl.getMethods();
- assertEquals("Number of methods", 3, methods.size());
-
- Collection<TypeDeclaration> nestedTypes = typeDecl.getNestedTypes();
- assertEquals("Number of nested types", 1, nestedTypes.size());
-
- Collection<InterfaceType> supers = typeDecl.getSuperinterfaces();
- assertEquals("Number of supers", 1, supers.size());
- }
-
- private void testPackageImpl() {
- PackageDeclaration pkg = env.getPackage("org.eclipse.jdt.apt.tests.annotations.mirrortest");
- assertEquals("Package name", "org.eclipse.jdt.apt.tests.annotations.mirrortest", pkg.getQualifiedName());
- // Not sure if this is the best way to test -- can we count on the number of classes
- // remaining the same in java.util?
-
- pkg = env.getPackage("java");
- assertEquals("Package name", "java", pkg.getQualifiedName());
- assertEquals("Number of classes in java", 0, pkg.getClasses().size());
-
- pkg = env.getPackage("java.util");
- assertEquals("Package name", "java.util", pkg.getQualifiedName());
-
- Collection<ClassDeclaration> classes = pkg.getClasses();
- assertEquals("Number of classes in java.util", 79, classes.size());
-
- Collection<EnumDeclaration> enums = pkg.getEnums();
- assertEquals("Number of enums in java.util", 0, enums.size());
-
- Collection<InterfaceDeclaration> interfaces = pkg.getInterfaces();
- assertEquals("Number of interfaces in java.util", 15, interfaces.size());
- }
-
- private void testDeclarationsUtil(TypeDeclaration typeDecl) {
- Declarations utils = env.getDeclarationUtils();
- TypeDeclaration objType = env.getTypeDeclaration("java.lang.Object");
-
- // Test negative case
- assertTrue("Class hides Object", !utils.hides(typeDecl, objType));
-
- // Test positive case
- TypeDeclaration innerClass = typeDecl.getNestedTypes().iterator().next();
-
- MethodDeclaration innerMethod = null;
- for (MethodDeclaration method : innerClass.getMethods()) {
- if (method.getSimpleName().equals("staticMethod")) {
- innerMethod = method;
- break;
- }
- }
-
- MethodDeclaration outerMethod = null;
- for (MethodDeclaration method : typeDecl.getMethods()) {
- if (method.getSimpleName().equals("staticMethod")) {
- outerMethod = method;
- break;
- }
- }
- assertTrue("inner's staticMethod() should hide MirrorTestClass'", utils.hides(innerMethod, outerMethod));
- }
-
- private void assertEquals(String reason, String expected, String actual) {
- if (expected == actual)
- return;
- if (expected != null && expected.equals(actual))
- return;
- fail("Expected " + expected + ", but saw " + actual + ". Reason: " + reason);
- }
-
- private void assertEquals(String reason, int expected, int actual) {
- if (expected == actual)
- return;
- fail("Expected " + expected + ", but saw " + actual + ". Reason: " + reason);
- }
-
- private void assertTrue(String reason, boolean expected) {
- if (!expected)
- fail(reason);
- }
-
- private void fail(final String reason) {
- ERROR = reason;
- throw new IllegalStateException("Failed during test: " + reason);
- }
-
-
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotationProcessorFactory.java
deleted file mode 100644
index bb71882..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * jgarms@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-
-package org.eclipse.jdt.apt.tests.annotations.mirrortest;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class MirrorTestAnnotationProcessorFactory implements AnnotationProcessorFactory {
-
- public Collection<String> supportedOptions() {
- return Collections.emptyList();
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return ANNOTATIONS;
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> typeDecls, AnnotationProcessorEnvironment env) {
- return new MirrorTestAnnotationProcessor(env);
- }
-
- private static ArrayList<String> ANNOTATIONS = new ArrayList<String>();
-
- static {
- ANNOTATIONS.add( MirrorTestAnnotation.class.getName() );
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotation.java
deleted file mode 100644
index be47a9f..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotation.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.nestedhelloworld;
-
-public @interface NestedHelloWorldAnnotation
-{
- String value() default "";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotationProcessor.java
deleted file mode 100644
index 58f3fee..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotationProcessor.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-
-package org.eclipse.jdt.apt.tests.annotations.nestedhelloworld;
-
-import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;
-import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotationProcessor;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-
-
-public class NestedHelloWorldAnnotationProcessor extends
- HelloWorldAnnotationProcessor {
-
- public NestedHelloWorldAnnotationProcessor(AnnotationProcessorEnvironment env)
- {
- super( env );
- }
-
- public String getCode() { return CODE; }
-
- private final String CODE =
- "package " + getPackageName() + ";" + "\n" +
- "@" + HelloWorldAnnotation.class.getName() + "\n" +
- "public class NestedHelloWorldAnnotationGeneratedClass " + "\n" +
- "{ }";
-
- public String getPackageName() { return "nested.hello.world.generatedclass.pkg"; }
- public String getTypeName() { return "NestedHelloWorldAnnotationGeneratedClass"; }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotationProcessorFactory.java
deleted file mode 100644
index 5b104f5..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-
-package org.eclipse.jdt.apt.tests.annotations.nestedhelloworld;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class NestedHelloWorldAnnotationProcessorFactory implements
- AnnotationProcessorFactory
-{
-
- public Collection<String> supportedOptions() {
- return Collections.emptyList();
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return annotations;
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env)
- {
- return new NestedHelloWorldAnnotationProcessor( env );
- }
-
- private static ArrayList<String> annotations = new ArrayList<String>();
-
- {
- annotations.add( NestedHelloWorldAnnotation.class.getName() );
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotation.java
deleted file mode 100644
index 210c0f2..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotation.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.noop;
-
-public @interface NoOpAnnotation
-{
- String value() default "";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotationProcessor.java
deleted file mode 100644
index 0caaaa4..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotationProcessor.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.noop;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-
-public class NoOpAnnotationProcessor implements AnnotationProcessor
-{
-
- public NoOpAnnotationProcessor(AnnotationProcessorEnvironment env)
- {
- _env = env;
- }
-
- public void process()
- {
- }
-
- AnnotationProcessorEnvironment _env;
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotationProcessorFactory.java
deleted file mode 100644
index 3f8fbdb..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.noop;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class NoOpAnnotationProcessorFactory implements
-AnnotationProcessorFactory
-{
-
- public Collection<String> supportedOptions() {
- return Collections.emptyList();
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return annotations;
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env)
- {
- return new NoOpAnnotationProcessor( env );
- }
-
- private static ArrayList<String> annotations = new ArrayList<String>();
-
- {
- annotations.add( NoOpAnnotation.class.getName() );
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/jdtcoretests/AllJdtCoreTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/jdtcoretests/AllJdtCoreTests.java
deleted file mode 100644
index 96cf108..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/jdtcoretests/AllJdtCoreTests.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.jdtcoretests;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class AllJdtCoreTests extends TestCase {
-
- public AllJdtCoreTests(String testName)
- {
- super(testName);
- }
-
-
- public static Class[] getAllTestClasses()
- {
- //
- // please be careful of the ordering of the test classes below.
- // the tests passing successfully seems to be dependent on the order
- // the test classes are specified.
- //
- Class[] classes = {
- org.eclipse.jdt.core.tests.builder.Tests.class,
- org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests.class,
- org.eclipse.jdt.core.tests.dom.RunAllTests.class,
- org.eclipse.jdt.core.tests.model.AllJavaModelTests.class,
- org.eclipse.jdt.core.tests.compiler.parser.TestAll.class,
- org.eclipse.jdt.core.tests.eval.TestAll.class,
- org.eclipse.jdt.core.tests.compiler.regression.TestAll.class
- };
-
- return classes;
- }
-
- public static TestSuite suite()
- {
- TestSuite ts = new TestSuite( AllJdtCoreTests.class.getName() );
-
- Class[] testClasses = getAllTestClasses();
- for( int i = 0; i < testClasses.length; i++ )
- {
- Class testClass = testClasses[i];
-
- // call the suite() method and add the resulting suite
- // to the suite
- try
- {
- Method suiteMethod = testClass.getDeclaredMethod(
- "suite", new Class[0] ); //$NON-NLS-1$
- Test suite = ( Test ) suiteMethod.invoke( null, new Object[0] );
- ts.addTest( suite );
- }
- catch( IllegalAccessException e )
- {
- e.printStackTrace();
- }
- catch( InvocationTargetException e )
- {
- e.getTargetException().printStackTrace();
- }
- catch( NoSuchMethodException e )
- {
-
- }
- }
- return ts;
- }
-
-}
-
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/plugin/AptTestsPlugin.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/plugin/AptTestsPlugin.java
deleted file mode 100644
index 07847e8..0000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/plugin/AptTestsPlugin.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.plugin;
-
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.BundleContext;
-
-public class AptTestsPlugin extends Plugin {
-
- public AptTestsPlugin() {
- _default = this;
- }
-
- public void start(BundleContext context) throws Exception {
- super.start( context );
- }
-
- public void stop(BundleContext context) throws Exception {
- super.stop( context );
- }
-
- public static AptTestsPlugin getDefault() {
- return _default;
- }
-
- private static AptTestsPlugin _default;
-
-}
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index 2dcc587..3dce6ea 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -41,7 +41,7 @@
<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK 3.1M7 - ?th May 2005
+Eclipse SDK 3.1M7 - 12th May 2005 - 3.1 MILESTONE 7
<br>Project org.eclipse.jdt.core v_556
(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_556">cvs</a>).
<h2>
@@ -64,7 +64,9 @@
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=93727">93727</a>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=94928">94928</a>
+[1.5][compiler] NPE in ParameterizedGenericMethodBinding generated by making method generic
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=93727">93727</a>
Code Formatter fails with Method Parameter Annotations
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=93075">93075</a>
Invalid source ranges for nested ParameterizedTypes
@@ -107,8 +109,8 @@
<li> Code Assist provide the enclosing type reference when cursor is inside a type argument
and the completion token is empty (in the same way as method calls).
<pre>
-p.q.X<<complete here>> // p.q.X<T,U> is proposed.
-p.q.X<Object, <complete here>> //p.q.X<T,U> is proposed
+p.q.X<<complete here>> // p.q.X<T,U> is proposed.
+p.q.X<Object, <complete here>> //p.q.X<T,U> is proposed
</pre>
</li>
<li> Code Assist provide the enclosing annotation reference when completion is inside an annotation argument
@@ -195,7 +197,7 @@
<li>javadoc : invalid javadoc</li>
<li>localHiding : local variable hiding another variable</li>
<li>maskedCatchBlock : hidden catch block</li>
- <li>nls : string literal lacking non-nls tag //$NON-NLS-<n>$</li>
+ <li>nls : string literal lacking non-nls tag //$NON-NLS-<n>$</li>
<li>noEffectAssign : assignment without effect</li>
<li>over-ann : missing @Override annotation</li>
<li>pkgDefaultMethod : attempt to override package-default method</li>