Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jdt.apt.core/.classpath7
-rwxr-xr-xorg.eclipse.jdt.apt.core/.cvsignore2
-rw-r--r--org.eclipse.jdt.apt.core/.options12
-rw-r--r--org.eclipse.jdt.apt.core/.project29
-rw-r--r--org.eclipse.jdt.apt.core/.settings/org.eclipse.core.resources.prefs5
-rw-r--r--org.eclipse.jdt.apt.core/.settings/org.eclipse.jdt.core.prefs66
-rw-r--r--org.eclipse.jdt.apt.core/META-INF/MANIFEST.MF28
-rw-r--r--org.eclipse.jdt.apt.core/about.html74
-rw-r--r--org.eclipse.jdt.apt.core/build.properties20
-rw-r--r--org.eclipse.jdt.apt.core/build_notes.html190
-rw-r--r--org.eclipse.jdt.apt.core/howtobuildme.txt74
-rw-r--r--org.eclipse.jdt.apt.core/mirror-api-license.txt28
-rw-r--r--org.eclipse.jdt.apt.core/plugin.properties18
-rw-r--r--org.eclipse.jdt.apt.core/plugin.xml72
-rw-r--r--org.eclipse.jdt.apt.core/schema/annotationProcessorFactory.exsd181
-rw-r--r--org.eclipse.jdt.apt.core/scripts/build-sdk-prime.cmd161
-rw-r--r--org.eclipse.jdt.apt.core/scripts/exportplugin.xml77
-rw-r--r--org.eclipse.jdt.apt.core/scripts/make_set_date_suffix_cmd.sh2
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessor.java67
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessorEnvironment.java184
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessorFactory.java110
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessorListener.java42
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessors.java125
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/Filer.java157
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/Messager.java95
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/RoundCompleteEvent.java76
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/RoundCompleteListener.java49
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/RoundState.java66
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/package.html47
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationMirror.java88
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationTypeDeclaration.java58
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationTypeElementDeclaration.java58
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationValue.java83
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ClassDeclaration.java90
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ConstructorDeclaration.java45
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/Declaration.java170
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/EnumConstantDeclaration.java49
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/EnumDeclaration.java56
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ExecutableDeclaration.java86
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/FieldDeclaration.java80
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/InterfaceDeclaration.java58
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/MemberDeclaration.java58
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/MethodDeclaration.java60
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/Modifier.java79
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/PackageDeclaration.java102
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ParameterDeclaration.java55
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/TypeDeclaration.java147
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/TypeParameterDeclaration.java70
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/package.html49
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/AnnotationType.java53
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/ArrayType.java54
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/ClassType.java75
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/DeclaredType.java112
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/EnumType.java53
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/InterfaceType.java60
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/MirroredTypeException.java85
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/MirroredTypesException.java95
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/PrimitiveType.java68
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/ReferenceType.java46
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/TypeMirror.java86
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/TypeVariable.java58
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/VoidType.java50
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/WildcardType.java75
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/type/package.html47
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationFilter.java320
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationScanner.java268
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationVisitor.java150
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationVisitors.java104
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/util/Declarations.java70
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SimpleDeclarationVisitor.java217
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SimpleTypeVisitor.java176
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SourceOrderDeclScanner.java254
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SourcePosition.java73
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/util/TypeVisitor.java138
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/util/Types.java190
-rw-r--r--org.eclipse.jdt.apt.core/src/com/sun/mirror/util/package.html47
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/build/AptBuilder.java80
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/build/JdtApt.java81
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/build/package.html16
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EclipseAnnotationProcessorEnvironment.java66
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EclipseAnnotationProcessorFactory.java41
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EnvironmentFactory.java48
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/Phase.java27
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/package.html19
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/APTDispatchRunnable.java876
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AnnotationProcessorFactoryLoader.java811
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptCompilationParticipant.java291
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptPlugin.java253
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptProject.java136
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/ClassServiceFactory.java44
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/ExtJarFactoryContainer.java52
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/FactoryPluginManager.java268
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/IServiceFactory.java30
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/JarClassLoader.java323
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/JarFactoryContainer.java131
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/LoadFailureHandler.java134
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/Messages.java38
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/NonEclipseImplementationException.java25
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/PluginFactoryContainer.java73
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/VarJarFactoryContainer.java66
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/WkspJarFactoryContainer.java79
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/build/Messages.java32
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/build/messages.properties10
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedAnnotationElementDeclarationImpl.java132
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedConstructorDeclarationImpl.java37
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedDeclarationImpl.java214
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedExecutableDeclarationImpl.java110
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedFieldDeclarationImpl.java122
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedMemberDeclarationImpl.java87
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedMethodDeclarationImpl.java62
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationDeclarationImpl.java56
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationElementDeclarationImpl.java71
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationMirrorImpl.java288
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationValueImpl.java193
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/BinaryParameterDeclarationImpl.java154
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ClassDeclarationImpl.java151
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ConstructorDeclarationImpl.java53
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/DeclarationImpl.java107
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EclipseDeclarationImpl.java198
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EclipseMirrorObject.java54
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EclipseMirrorType.java27
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EnumConstantDeclarationImpl.java40
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EnumDeclarationImpl.java72
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ExecutableDeclarationImpl.java81
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ExecutableUtil.java212
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/FieldDeclarationImpl.java100
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/InterfaceDeclarationImpl.java55
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MemberDeclarationImpl.java116
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MethodDeclarationImpl.java80
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/PackageDeclarationImpl.java247
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/PackageDeclarationImplNoBinding.java97
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/SourceParameterDeclarationImpl.java117
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/TypeDeclarationImpl.java384
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/TypeParameterDeclarationImpl.java169
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/APTProblem.java121
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/AbstractCompilationEnv.java360
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/AnnotationInvocationHandler.java310
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BaseProcessorEnv.java989
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BinaryFileOutputStream.java120
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BuildEnv.java615
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BuildFilerImpl.java191
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/EclipseRoundCompleteEvent.java38
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/EncodedFileOutputStream.java63
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/EnvUtil.java218
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/FilerImpl.java103
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ITypeConstants.java25
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/JavaSourceFilePrintWriter.java75
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/MarkerInfo.java70
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/MessagerImpl.java239
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/NoOpOutputStream.java37
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/NoOpPrintWriter.java21
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ReconcileEnv.java145
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ReconcileFilerImpl.java74
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/ClasspathUtil.java222
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/CompilationUnitHelper.java183
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/FileGenerationResult.java39
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileManager.java1531
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileMap.java364
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedResourceChangeListener.java223
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedSourceFolderManager.java507
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/WorkingCopyCleanupListener.java71
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/messages.properties13
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/ArrayTypeImpl.java106
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/ErrorType.java145
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/PrimitiveTypeImpl.java82
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/VoidTypeImpl.java51
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/WildcardTypeImpl.java90
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/AnnotationScanner.java129
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/AptCorePreferenceInitializer.java35
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/CharArrayAnnotationScanner.java33
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/DeclarationsUtil.java154
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/Factory.java711
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FactoryContainer.java99
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FactoryPath.java248
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FactoryPathUtil.java443
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FileSystemUtil.java219
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/InputStreamAnnotationScanner.java31
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/ManyToMany.java365
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/Messages.java35
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/PackageUtil.java49
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/ReaderAnnotationScanner.java30
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/ScannerUtil.java145
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/SourcePositionImpl.java115
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/TypesUtil.java312
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/Visitors.java421
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/messages.properties10
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/AptConfig.java936
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/AptPreferenceConstants.java89
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/AptUtil.java65
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/EclipseMessager.java160
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/IFactoryPath.java102
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/package.html17
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/.classpath7
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/.cvsignore1
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/.options3
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/.project28
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/META-INF/MANIFEST.MF22
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/about.html28
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/build.properties19
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/plugin.properties13
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/plugin.xml37
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/Apt6CompilationParticipant.java29
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/Apt6Plugin.java137
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeAnnotationProcessorManager.java138
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeBuildProcessingEnvImpl.java35
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeMessagerImpl.java90
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeProcessingEnvImpl.java155
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeReconcileProcessingEnvImpl.java35
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeFilerImpl.java202
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeInputFileObject.java118
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeJavaSourceOutputStream.java80
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream.java124
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeOutputFileObject.java49
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeOutputJavaFileObject.java107
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeOutputNonSourceFileObject.java92
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/.classpath7
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/.cvsignore1
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/.project28
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF21
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/META-INF/services/javax.annotation.processing.Processor3
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/about.html28
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/annotations.jardesc16
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/build.properties25
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/lib/annotations.jarbin1607 -> 0 bytes
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/plugin.properties12
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/plugin.xml19
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer01a/Parent01.java23
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer01b/Parent01.java23
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer02a/Parent02.java26
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer02b/Parent02.java24
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/resources/targets/infrastructure/NoAnno.java23
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/Apt6TestsPlugin.java27
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/FilerTests.java197
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/IdeTestUtils.java175
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/InfrastructureTests.java90
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/ProcessorTestStatus.java108
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/ScalingTests.java116
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestAll.java42
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestBase.java133
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestUtils.java53
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/annotations/FilerTestTrigger.java28
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/annotations/GenClass6.java50
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/annotations/Message6.java31
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/processors/filertester/FilerTesterProc.java184
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/processors/genclass6/GenClass6Proc.java204
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/processors/message6/Message6Proc.java86
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/test.xml56
-rw-r--r--org.eclipse.jdt.apt.tests/.classpath9
-rwxr-xr-xorg.eclipse.jdt.apt.tests/.cvsignore2
-rw-r--r--org.eclipse.jdt.apt.tests/.project28
-rw-r--r--org.eclipse.jdt.apt.tests/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--org.eclipse.jdt.apt.tests/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--org.eclipse.jdt.apt.tests/META-INF/MANIFEST.MF42
-rw-r--r--org.eclipse.jdt.apt.tests/about.html28
-rw-r--r--org.eclipse.jdt.apt.tests/build.properties19
-rw-r--r--org.eclipse.jdt.apt.tests/plugin.properties12
-rw-r--r--org.eclipse.jdt.apt.tests/plugin.xml77
-rw-r--r--org.eclipse.jdt.apt.tests/resources.jardesc16
-rw-r--r--org.eclipse.jdt.apt.tests/resources/question.jarbin3758 -> 0 bytes
-rw-r--r--org.eclipse.jdt.apt.tests/src-resources/notypes/package-info.java1
-rw-r--r--org.eclipse.jdt.apt.tests/src-resources/question/AnnotationTest.java68
-rw-r--r--org.eclipse.jdt.apt.tests/src-resources/question/Color.java3
-rw-r--r--org.eclipse.jdt.apt.tests/src-resources/question/RTInvisibleAnno.java5
-rw-r--r--org.eclipse.jdt.apt.tests/src-resources/question/RTVisibleAnno.java23
-rw-r--r--org.eclipse.jdt.apt.tests/src-resources/question/SimpleAnnotation.java10
-rw-r--r--org.eclipse.jdt.apt.tests/src-resources/question/package-info.java1
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/APITests.java188
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/APTTestBase.java377
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationValueConversionTests.java780
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java707
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptReconcileTests.java556
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/DeclarationVisitorTests.java406
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ExceptionHandlingTests.java198
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ExpectedProblem.java74
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/FactoryLoaderTests.java186
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/FileGenerationTests.java232
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/JavaVersionTests.java91
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ListenerTests.java57
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorDeclarationTests.java280
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorTests.java101
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorUtilTests.java83
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MixedModeTesting.java188
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PerfTests.java160
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PreferencesTests.java330
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests.java162
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java338
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/RegressionTests.java291
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ScalingTests.java127
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ScannerTests.java125
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestAll.java59
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestUtil.java462
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TypeVisitorTests.java363
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/BaseFactory.java52
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/BaseProcessor.java84
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/ProcessorTestStatus.java106
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/ProcessorUtil.java109
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/APIAnnotationProcessorFactory.java200
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/AssignableTo.java21
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/Common.java18
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/SubtypeOf.java21
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/GenBean.java15
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/GenBean2.java15
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round1GenAnnotationFactory.java44
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round1GenAnnotationProcessor.java53
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round2GenAnnotationFactory.java44
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round2GenAnnotationProcessor.java41
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/exceptionhandling/ExceptionHandlingAnnotation.java20
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/exceptionhandling/ExceptionHandlingProcessor.java48
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/exceptionhandling/ExceptionHandlingProcessorFactory.java29
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotation.java18
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotationProcessor.java28
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotationProcessorFactory.java36
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FileGenLocationAnnotation.java18
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FileGenLocationAnnotationProcessor.java63
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FileGenLocationAnnotationProcessorFactory.java36
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FirstGenAnnotation.java18
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FirstGenAnnotationProcessor.java53
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FirstGenAnnotationProcessorFactory.java36
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/SecondGenAnnotation.java18
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/SecondGenAnnotationProcessor.java66
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/SecondGenAnnotationProcessorFactory.java36
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/TextGenAnnotation.java17
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/TextGenAnnotationProcessor.java62
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/TextGenAnnotationProcessorFactory.java34
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/generic/AbstractGenericProcessor.java45
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/generic/GenericAnnotation.java12
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/generic/GenericFactory.java35
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotation.java18
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotationProcessor.java80
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotationProcessorFactory.java43
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldWildcardAnnotationProcessorFactory.java39
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/listener/ListenerAnnotation.java20
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/listener/ListenerAnnotationProcessorFactory.java40
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/listener/ListenerProcessor.java55
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerAnnotation.java21
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerAnnotationProcessor.java70
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerAnnotationProcessorFactory.java38
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerCodeExample.java83
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/ASTBasedMirrorDeclarationProcessorFactory.java128
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/CodeExample.java69
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/DefaultConstantAnnotationFactory.java30
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/DefaultConstantProcessor.java89
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationCodeExample.java49
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationTestAnnotation.java18
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationTestAnnotationProcessor.java328
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationTestAnnotationProcessorFactory.java36
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotation.java24
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotationProcessor.java136
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotationProcessorFactory.java34
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestAnnotation.java16
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestAnnotationProcessor.java189
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestAnnotationProcessorFactory.java35
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestCodeExample.java68
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotation.java18
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotationProcessor.java71
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotationProcessorFactory.java44
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotation.java18
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotationProcessor.java20
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotationProcessorFactory.java36
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/Pause.java20
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessor.java58
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessorFactory.java38
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/AnnotationReader.java43
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/ReadAnnotationTypeProcessor.java51
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/ReadAnnotationTypeProcessorFactory.java28
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/SimpleAnnotation.java18
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readannotation/CodeExample.java162
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readannotation/ReadAnnotationProcessor.java198
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readannotation/ReadAnnotationProcessorFactory.java35
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/Annotation.java19
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/AnnotationWithArray.java20
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/RefAnnotation.java19
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/RefAnnotationWithArray.java20
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/ValueConversionProcessor.java463
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/ValueConversionProcessorFactory.java36
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/jdtcoretests/AllJdtCoreTests.java47
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/plugin/AptTestsPlugin.java38
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory4
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/Batch.java15
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchAnnotationFactory.java41
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchGen.java15
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchGenAnnotationFactory.java100
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchProcessor.java74
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/Color.java16
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorAnnotation.java17
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorAnnotationProcessor.java62
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorAnnotationProcessorFactory.java38
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorTestCodeExample.java32
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorWrapper.java16
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestAnnotation.java19
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestAnnotationProcessor.java94
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestAnnotationProcessorFactory.java50
-rw-r--r--org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestCodeExample.java31
-rw-r--r--org.eclipse.jdt.apt.tests/test.xml56
-rw-r--r--org.eclipse.jdt.apt.ui/.classpath7
-rw-r--r--org.eclipse.jdt.apt.ui/.cvsignore1
-rw-r--r--org.eclipse.jdt.apt.ui/.project28
-rw-r--r--org.eclipse.jdt.apt.ui/.settings/org.eclipse.core.resources.prefs5
-rw-r--r--org.eclipse.jdt.apt.ui/.settings/org.eclipse.jdt.core.prefs69
-rw-r--r--org.eclipse.jdt.apt.ui/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--org.eclipse.jdt.apt.ui/META-INF/MANIFEST.MF20
-rw-r--r--org.eclipse.jdt.apt.ui/about.html28
-rw-r--r--org.eclipse.jdt.apt.ui/build.properties15
-rw-r--r--org.eclipse.jdt.apt.ui/plugin.properties18
-rw-r--r--org.eclipse.jdt.apt.ui/plugin.xml59
-rw-r--r--org.eclipse.jdt.apt.ui/scripts/exportplugin.xml62
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/AptUIPlugin.java98
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/Messages.java31
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/messages.properties8
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AdvancedFactoryPathOptionsDialog.java130
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AptConfigurationBlock.java600
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AptPreferencePage.java71
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/BaseConfigurationBlock.java936
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/BasePreferencePage.java127
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/FactoryPathConfigurationBlock.java742
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/FactoryPathPreferencePage.java67
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/Messages.java112
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/ProcessorOptionInputDialog.java135
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/messages.properties50
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/ExceptionHandler.java134
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/IAptHelpContextIds.java32
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/Messages.java31
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/messages.properties8
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/.classpath8
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/.cvsignore2
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/.project28
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/.settings/org.eclipse.jdt.core.prefs62
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/.settings/org.eclipse.pde.prefs16
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/META-INF/MANIFEST.MF21
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/README.TXT5
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/about.html28
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/apttestprocessors.jardesc16
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/build.properties23
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jarbin142389 -> 0 bytes
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/plugin.properties12
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/META-INF/services/javax.annotation.processing.Processor12
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/CheckArgs.java20
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/GenClass.java23
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/GenResource.java40
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/InheritedAnno.java21
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/TypedAnnos.java75
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/BaseProcessor.java50
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/IXMLNames.java41
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/XMLComparer.java761
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/XMLConverter.java281
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/checkargs/CheckArgsProc.java73
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/ElementProc.java818
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elementutils/ElementUtilsProc.java950
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/filer/FilerProc.java163
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/genclass/GenClassProc.java149
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/generics/GenericsProc.java234
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/inherited/InheritedAnnoProc.java228
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/messager/MessagerProc.java297
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/negative/NegativeModelProc.java697
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/typemirror/TypeMirrorProc.java185
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/typeutils/TypeUtilsProc.java191
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/visitors/VisitorProc.java334
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/HasCheckArgs.java23
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/HasGenClass.java29
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/TwoAnnotations.java24
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/X.java9
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/inheritedanno/InheritanceA.java59
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/inheritedanno/NotInheritedAnno.java8
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/p/Y.java3
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/p/Z.java3
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pa/AnnoZ.java13
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pb/D.java22
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pb/E.java15
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pb/F.java33
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/filer/FilerTarget1.java27
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/A.java33
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/AnnoZ.java16
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/ExceptionA.java12
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/IA.java12
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/AB.java21
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/AC.java52
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/D.java21
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/IB.java12
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/IC.java12
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/AnnoX.java15
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/AnnoY.java12
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/AnnotatedWithManyTypes.java35
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/Deprecation.java37
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/F.java147
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/G.java40
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/H.java31
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/IF.java16
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/J.java20
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/Overriding.java35
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative1.java25
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative2.java29
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative3.java23
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative4.java30
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative5.java28
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative6.java25
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative7.java28
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pz/Anno2.java12
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AllTests.java34
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchDispatchTests.java248
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchTestUtils.java482
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/FilerTests.java93
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/MessagerTests.java96
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/ModelTests.java140
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/ModelUtilTests.java100
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/NegativeTests.java164
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/TestUtils.java53
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/test.xml52
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/things-to-test.txt13
-rw-r--r--org.eclipse.jdt.compiler.apt/.classpath7
-rw-r--r--org.eclipse.jdt.compiler.apt/.project28
-rw-r--r--org.eclipse.jdt.compiler.apt/.settings/org.eclipse.jdt.core.prefs62
-rw-r--r--org.eclipse.jdt.compiler.apt/META-INF/MANIFEST.MF13
-rw-r--r--org.eclipse.jdt.compiler.apt/about.html28
-rw-r--r--org.eclipse.jdt.compiler.apt/build.properties22
-rw-r--r--org.eclipse.jdt.compiler.apt/compiler_apt_fragment.properties12
-rw-r--r--org.eclipse.jdt.compiler.apt/customBuildCallbacks.xml200
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/AnnotationDiscoveryVisitor.java154
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/AptProblem.java60
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseAnnotationProcessorManager.java162
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseMessagerImpl.java159
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java165
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchAnnotationProcessorManager.java237
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchFilerImpl.java134
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchMessagerImpl.java78
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchProcessingEnvImpl.java144
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/HookedJavaFileObject.java241
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/IProcessorProvider.java47
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/ProcessorInfo.java176
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundDispatcher.java173
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundEnvImpl.java228
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationMirrorImpl.java521
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationValueImpl.java265
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ArrayTypeImpl.java55
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/DeclaredTypeImpl.java119
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementImpl.java159
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl.java671
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeElement.java152
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeImpl.java77
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableElementImpl.java335
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableTypeImpl.java125
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java707
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/IElementInfo.java30
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/NameImpl.java95
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/NoTypeImpl.java69
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/PackageElementImpl.java125
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/PrimitiveTypeImpl.java84
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java266
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeMirrorImpl.java110
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeParameterElementImpl.java169
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeVariableImpl.java85
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypesImpl.java453
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java179
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/WildcardTypeImpl.java68
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/Archive.java102
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/ArchiveFileObject.java222
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java1145
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileObject.java205
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/ManyToMany.java364
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/Options.java235
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/Util.java207
-rw-r--r--org.eclipse.jdt.core/buildnotes_jdt-core.html2
563 files changed, 1 insertions, 65116 deletions
diff --git a/org.eclipse.jdt.apt.core/.classpath b/org.eclipse.jdt.apt.core/.classpath
deleted file mode 100644
index 304e86186a..0000000000
--- a/org.eclipse.jdt.apt.core/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <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 1fe7c80171..0000000000
--- 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/.options b/org.eclipse.jdt.apt.core/.options
deleted file mode 100644
index 8a4836f013..0000000000
--- a/org.eclipse.jdt.apt.core/.options
+++ /dev/null
@@ -1,12 +0,0 @@
-# Debug tracing for org.eclipse.jdt.core plugin
-# Includes traces needed for most client-visible problems
-org.eclipse.jdt.apt.core/debug=false
-
-# Debug tracing for file generation
-org.eclipse.jdt.apt.core/debug/generatedFiles=false
-
-# Debug tracing for internal data structures used in file generation
-org.eclipse.jdt.apt.core/debug/generatedFileMaps=false
-
-# Debug tracing for compilation environment
-org.eclipse.jdt.apt.core/debug/compilationEnv=false
diff --git a/org.eclipse.jdt.apt.core/.project b/org.eclipse.jdt.apt.core/.project
deleted file mode 100644
index 9c344714ba..0000000000
--- 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.core.resources.prefs b/org.eclipse.jdt.apt.core/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 86c2fda476..0000000000
--- a/org.eclipse.jdt.apt.core/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,5 +0,0 @@
-#Mon Mar 20 17:21:22 PST 2006
-eclipse.preferences.version=1
-encoding//src/org/eclipse/jdt/apt/core/internal/build/messages.properties=8859_1
-encoding//src/org/eclipse/jdt/apt/core/internal/messages.properties=8859_1
-encoding//src/org/eclipse/jdt/apt/core/internal/util/messages.properties=8859_1
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 f6b5b71e92..0000000000
--- a/org.eclipse.jdt.apt.core/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,66 +0,0 @@
-#Thu Sep 21 15:26:59 PDT 2006
-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.doc.comment.support=enabled
-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=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-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.invalidJavadoc=warning
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected
-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=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-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=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-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=warning
-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=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/org.eclipse.jdt.apt.core/META-INF/MANIFEST.MF b/org.eclipse.jdt.apt.core/META-INF/MANIFEST.MF
deleted file mode 100644
index e9c42f3207..0000000000
--- a/org.eclipse.jdt.apt.core/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,28 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jdt.apt.core; singleton:=true
-Bundle-Version: 3.3.100.qualifier
-Bundle-Localization: plugin
-Export-Package: com.sun.mirror.apt,
- com.sun.mirror.declaration,
- com.sun.mirror.type,
- com.sun.mirror.util,
- org.eclipse.jdt.apt.core.build,
- org.eclipse.jdt.apt.core.env,
- org.eclipse.jdt.apt.core.internal;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.apt.tests,org.eclipse.jdt.apt.ui,org.eclipse.jdt.apt.pluggable.tests",
- org.eclipse.jdt.apt.core.internal.build;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.apt.tests,org.eclipse.jdt.apt.ui,org.eclipse.jdt.apt.pluggable.tests",
- org.eclipse.jdt.apt.core.internal.declaration;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.apt.tests,org.eclipse.jdt.apt.ui,org.eclipse.jdt.apt.pluggable.tests",
- org.eclipse.jdt.apt.core.internal.env;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.apt.tests,org.eclipse.jdt.apt.ui,org.eclipse.jdt.apt.pluggable.tests",
- org.eclipse.jdt.apt.core.internal.generatedfile;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.apt.tests,org.eclipse.jdt.apt.ui,org.eclipse.jdt.apt.pluggable.tests",
- org.eclipse.jdt.apt.core.internal.type;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.apt.tests,org.eclipse.jdt.apt.ui,org.eclipse.jdt.apt.pluggable.tests",
- org.eclipse.jdt.apt.core.internal.util;x-friends:="org.eclipse.jdt.apt.pluggable.core,org.eclipse.jdt.apt.tests,org.eclipse.jdt.apt.ui,org.eclipse.jdt.apt.pluggable.tests",
- org.eclipse.jdt.apt.core.util
-Require-Bundle: org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
- org.apache.ant;bundle-version="[1.6.5,1.8)"
-Bundle-Activator: org.eclipse.jdt.apt.core.internal.AptPlugin
-Bundle-Vendor: %providerName
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Bundle-ActivationPolicy: lazy
diff --git a/org.eclipse.jdt.apt.core/about.html b/org.eclipse.jdt.apt.core/about.html
deleted file mode 100644
index 3648a8f5c4..0000000000
--- a/org.eclipse.jdt.apt.core/about.html
+++ /dev/null
@@ -1,74 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>May 31, 2006</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-<h3>Third Party Content</h3>
-
-<p>The Content includes items that have been sourced from third parties as set out below. If you
-did not receive this Content directly from the Eclipse Foundation, the following is provided
-for informational purposes only, and you should look to the Redistributor&rsquo;s license for
-terms and conditions of use.</p>
-
-<h4>Java Mirror API</h4>
-
-<p>The plug-in includes classes in the com.sun.mirror package (&quot;Java Mirror API&quot;).
-Your use of the Java Mirror API is governed by the terms and conditions of the following license:</p>
-
-<blockquote>
-<pre>
-Copyright (c) 2004, Sun Microsystems, Inc. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- * Neither the name of the Sun Microsystems, Inc. nor the names of
- its contributors may be used to endorse or promote products
- derived from this software without specific prior written
- permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-</pre>
-</blockquote>
-
-
-</body>
-</html> \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.core/build.properties b/org.eclipse.jdt.apt.core/build.properties
deleted file mode 100644
index dd6fc07bb9..0000000000
--- a/org.eclipse.jdt.apt.core/build.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2006 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
-###############################################################################
-jars.compile.order = .
-source.. = src/
-output.. = bin/
-bin.includes = plugin.xml,\
- .,\
- META-INF/,\
- about.html,\
- mirror-api-license.txt,\
- plugin.properties,\
- .options
-src.includes = about.html,\
- mirror-api-license.txt,\
- schema/
diff --git a/org.eclipse.jdt.apt.core/build_notes.html b/org.eclipse.jdt.apt.core/build_notes.html
deleted file mode 100644
index 3037ec964b..0000000000
--- a/org.eclipse.jdt.apt.core/build_notes.html
+++ /dev/null
@@ -1,190 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Build" content="Build">
- <title>Eclipse Platform Release Notes (3.4) - JDT Annotation Processing</title>
-</head>
-
-<body>
-
-<h1>Eclipse Platform Build Notes (3.4)<br>
-JDT Annotation Processing</h1>
-
-<p>Integration Build (February 25, 2008, 3:22 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
- </p>
-
-<p>Integration Build (February 11, 2008, 3:21 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=217002">Bug 217002</a>. Typo in javadoc for AptPreferenceConstants.PROCESSING_IN_EDITOR_DISABLED_OPTION (FIXED)<br>
- </p>
-
-<p>Integration Build (January 14, 2008, 11:49 a.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=213540">Bug 213540</a>. Support Filer.getResource() in IDE (FIXED)<br>
- </p>
-
-<p>Integration Build (January 07, 2008, 3:36 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=202956">Bug 202956</a>. APT should group their marker types (FIXED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=213539">Bug 213539</a>. Support Filer.createClassFile() in IDE (NEW)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=213917">Bug 213917</a>. [apt] env.getPackage() returns corrupt packages (FIXED)<br>
- </p>
-
-<p>Integration Build (November 20, 2007, 9:10 a.m.)</p>
- <p>Problem reports updated</p>
- <p>
- </p>
-
-<p>Integration Build (November 19, 2007, ? p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=209715">Bug 209715</a>. org.eclipse.jdt.apt.core.util.AptPreferenceConstants should clarify its specification (FIXED)<br>
- </p>
-
-<p>Integration Build (November 12, 2007, 8:26 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
- </p>
-
-<p>Integration Build (November 05, 2007, 5:36 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=208186">Bug 208186</a>. Don't set encoding of generated file unless it needs to change (FIXED)<br>
- </p>
-
-<p>Integration Build (October 26, 2007, 6:26 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=203241">Bug 203241</a>. [compiler] Missing warning when a serializable class without serialVersionUID is also abstract (FIXED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=206591">Bug 206591</a>. AnnotationProcessorEnvironment.getTypeUtils().isSubtype does not work as expected (NEW)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=207408">Bug 207408</a>. non-translated marker name %aptNonreconcileBatchMarkerName (FIXED)<br>
- </p>
-
-<p>Integration Build (October 15, 2007, 4:20 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=170692">Bug 170692</a>. Timeliness of problem removal with APT (FIXED)<br>
- </p>
-
-<p>Integration Build (October 02, 2007, 5:53 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=190612">Bug 190612</a>. Implement JavaFileObject.openOutputStream() in IDE (FIXED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=202548">Bug 202548</a>. APT plugins are missing .options files (FIXED)<br>
- </p>
-
-<p>Integration Build (September 20, 2007, 3:36 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=203900">Bug 203900</a>. Generated file dependencies not always serialized (NEW)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=204056">Bug 204056</a>. disabling annotation processing from UI does not clean build state (ASSIGNED)<br>
- </p>
-
-<p>Integration Build (September 16, 2007, 4:46 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
- </p>
-
-<p>Integration Build (September 13, 2007, 2:59 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=200124">Bug 200124</a>. [jsr269] Implement createResourceFile in IDE (FIXED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=201479">Bug 201479</a>. non-source generated files deleted improperly (FIXED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=201931">Bug 201931</a>. pluggable FilerTests fail sporadically (NEW)<br>
- </p>
-
-<p>Integration Build (August 27, 2007, 12:51 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
- </p>
-
-<p>Integration Build (August 20, 2007, 4:03 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=188559">Bug 188559</a>. Delete files generated by Java 6 processors during build (NEW)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=190617">Bug 190617</a>. [jsr269] processors not getting called on final round (ASSIGNED)<br>
- </p>
-
-<p>Integration Build (July 23, 2007, 3:16 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=190268">Bug 190268</a>. Need to perform a validateEdit() before setting encoding (FIXED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=193784">Bug 193784</a>. Proprietary licenses (FIXED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=197050">Bug 197050</a>. [jsr269] Support -XprintRounds and -XprintProcessorInfo (FIXED)<br>
- </p>
-
-<p>Integration Build (May 23, 2007, 9:07 a.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=186427">Bug 186427</a>. Need a finally block in AptDispatchRunnable.build (FIXED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=187135">Bug 187135</a>. AbortCompilationException when project is missing classes (FIXED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=188185">Bug 188185</a>. RTTG_ENABLED_OPTION should ignore -A (FIXED)<br>
- </p>
-
-<p>Integration Build (May 14, 2007, 6:20 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=171893">Bug 171893</a>. getPackage().getQualifiedName() is slow (FIXED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=186740">Bug 186740</a>. [PERF] discard cached Problems after each build (FIXED)<br>
- </p>
-
-<p>Integration Build (May 10, 2007, 5:05 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=178138">Bug 178138</a>. APT writes to the log when a factory path entry is missing (FIXED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=181869">Bug 181869</a>. IllegalArgumentException with annotation value syntax error (FIXED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=182364">Bug 182364</a>. Type checking is too aggressive (FIXED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=185220">Bug 185220</a>. IDE java 6 APT support needs a Messager (FIXED)<br>
- </p>
-
-<p>Integration Build (May 02, 2007, 12:55 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=184923">Bug 184923</a>. Deadlock in AnnotationProcessorFactoryLoader (FIXED)<br>
- </p>
-
-<p>Integration Build (May 01, 2007, 5:57 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=178690">Bug 178690</a>. Processors should be able to disable reconcile-time type deletion (NEW)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=185010">Bug 185010</a>. Catch processor exceptions lower on the stack during reconcile (NEW)<br>
- </p>
-
-<p>Integration Build (April 16, 2007, 7:16 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
- </p>
-
-<p>Integration Build (April 09, 2007, 6:36 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=180595">Bug 180595</a>. Permit modification of AnnotationProcessorListeners during callback (FIXED)<br>
- </p>
-
-<p>Integration Build (April 02, 2007, 5:59 p.m.)</p>
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=175794">Bug 175794</a>. Type generation causes reported problems to disappear (ASSIGNED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=177683">Bug 177683</a>. NPE in internal.util.Factory.createErrorClassType() (FIXED)<br>
- </p>
-
-<p>Integration Build (March 19, 2007, 00:10)</p>
- <p>Java 6 annotation processing</p>
- <p>
-In this integration build, the Java 6 annotation processing API (JSR-269) has been partly enabled. Not all aspects of the API are yet working.
-If you have specific use cases that need to be supported before you can to contribute testing, please feel free to enter bug reports
-against the JDT APT component, or email jdt-apt-dev@eclipse.org. Please provide as much detail as possible.
- </p>
-
- <p>Problem reports updated</p>
- <p>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=176883">Bug 176883</a>. Deleted files not being properly reported (FIXED)<br>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=176132">Bug 176132</a>. Add a flag to disable reconcile-time annotation processing (FIXED)<br>
- </p> \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.core/howtobuildme.txt b/org.eclipse.jdt.apt.core/howtobuildme.txt
deleted file mode 100644
index d00d470c44..0000000000
--- a/org.eclipse.jdt.apt.core/howtobuildme.txt
+++ /dev/null
@@ -1,74 +0,0 @@
-
-Eclipse APT Project - Developer Setup Instructions
-==================================================
-
-1. Install Eclipse SDK 3.1.
-
-2. Launch eclipse, creating a new Workspace. Say "C:\AptWorkspace".
-
-3. Install a 1.5 JRE for eclipse. To add it to Eclipse:
-
- a. go to the "Window" menu, and then choose "Preferences | Java | Installed JREs".
- b. click the add button and install the 1.5 JRE. You will need to name this "JRE 1.5.0".
- Make this the default JRE.
-
-4. Now you need to check out the various CVS projects from the eclipse CVS server.
-
- a. Configure your eclipse to point to the eclipse CVS repository:
- Open the "CVS Repository Exploring" Perspective.
- Then right-click in the CVS Repositories frame and select New->Repository Location.
- Fill in the following values:
-
- Host: dev.eclipse.org
- Repository path: /home/eclipse
- User: anonymous
- Password: <leave blank>
- Connection type: pserver
-
- b. Check out HEAD revisions of the following projects:
-
- org.eclipse.jdt.apt.core
- org.eclipse.jdt.apt.tests
- org.eclipse.jdt.apt.ui
- org.eclipse.test.performance
-
- To do this, open the :pserver:anonymous... node, and then
- the HEAD node. Right-click on the folders as named above, and select
- "Check out". This will copy all the files to your local machine.
-
- c. Refresh the branches. Right-click the top-level "Branches" node
- (adjacent to "HEAD"), and then select "Refresh Branches..."
- Select the following projects to be scanned for tags:
-
- org.eclipse.jdt.core
- org.eclipse.jdt.core.tests.builder
- org.eclipse.jdt.core.tests.compiler
- org.eclipse.jdt.core.tests.model
- org.eclipse.jdt.core.tests.performance
-
- d. Check out APT branch revisions of the following projects :
- Under Branches, there will now be an "APT" branch.
- Open that and select the following nodes:
-
- org.eclipse.jdt.core.tests.builder
- org.eclipse.jdt.core.tests.compiler
- org.eclipse.jdt.core.tests.model
- org.eclipse.jdt.core.tests.performance
- org.eclipse.jdt.core
-
- Then right-click each of them and select "Check out". This will take
- some time as all the files are copied to your local machine.
-
- You can now switch back to the "Java" Perspective.
-
-5. Copy the file tools.jar from the 1.5 JDK (%JDK_1.5_HOME%/lib/tools.jar)
- into the root of the org.eclipse.jdt.apt.core project,
- and then right-click that project and choose "Refresh".
-
-6. Ensure that the workspace builds with no problems that are error level.
- You will see a few warnings depending on the strictness of your warning
- settins.
-
-7. If you want to export the plugin, then you can run the ant script at
- org.eclipse.jdt.apt.core/scripts/exportplugin.xml
-
diff --git a/org.eclipse.jdt.apt.core/mirror-api-license.txt b/org.eclipse.jdt.apt.core/mirror-api-license.txt
deleted file mode 100644
index 32b9f30316..0000000000
--- a/org.eclipse.jdt.apt.core/mirror-api-license.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-Copyright (c) 2004, Sun Microsystems, Inc.All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- * Neither the name of the Sun Microsystems, Inc. nor the names of
- its contributors may be used to endorse or promote products
- derived from this software without specific prior written
- permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/org.eclipse.jdt.apt.core/plugin.properties b/org.eclipse.jdt.apt.core/plugin.properties
deleted file mode 100644
index 7f38659034..0000000000
--- a/org.eclipse.jdt.apt.core/plugin.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 BEA Systems Inc. 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:
-# BEA Systems Inc. - initial implementation
-###############################################################################
-providerName=Eclipse.org
-pluginName=Java Annotation Processing Core
-annotationProcessorFactoriesName=Annotation Processor Factories
-annotationProcessingName=Annotation Processing
-aptBatchMarkerName=Annotation Problem
-aptNonreconcileBatchMarkerName=Annotation Problem (build-only processor)
-aptBuildMarkerName=APT Build Problem
-aptConfigurationMarkerName=APT Configuration Problem \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.core/plugin.xml b/org.eclipse.jdt.apt.core/plugin.xml
deleted file mode 100644
index 041aeb6879..0000000000
--- a/org.eclipse.jdt.apt.core/plugin.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin>
-
-
-<!-- =================================================================================== -->
-<!-- Extension Point: Annotation Processor Factories -->
-<!-- =================================================================================== -->
-
-<extension-point
- id="annotationProcessorFactory"
- name="%annotationProcessorFactoriesName"
- schema="schema/annotationProcessorFactory.exsd"/>
-
-<!-- =================================================================================== -->
-<!-- Extension: Compilation Participant -->
-<!-- =================================================================================== -->
-<extension
- id="apt"
- name="%annotationProcessingName"
- point="org.eclipse.jdt.core.compilationParticipant">
- <compilationParticipant
- class="org.eclipse.jdt.apt.core.internal.AptCompilationParticipant"
- id="APT"
- requiredSourceLevel="1.5">
- <managedMarker markerType="org.eclipse.jdt.apt.core.compile.problem"/>
- <managedMarker markerType="org.eclipse.jdt.apt.core.nonreconcile.compile.problem"/>
- </compilationParticipant>
-</extension>
-
-<!-- =================================================================================== -->
-<!-- Extension: APT Problem -->
-<!-- =================================================================================== -->
-<extension id="compile.problem" point="org.eclipse.core.resources.markers" name="%aptBatchMarkerName">
- <super type="org.eclipse.jdt.core.problem"/>
- <persistent value="true"/>
-</extension>
-
-<extension id="nonreconcile.compile.problem" point="org.eclipse.core.resources.markers" name="%aptNonreconcileBatchMarkerName">
- <super type="org.eclipse.core.resources.problemmarker"/>
- <super type="org.eclipse.core.resources.textmarker"/>
- <persistent value="true"/>
-</extension>
-
-<extension id="buildproblem" point="org.eclipse.core.resources.markers" name="%aptBuildMarkerName">
- <super type="org.eclipse.core.resources.problemmarker"/>
- <super type="org.eclipse.core.resources.textmarker"/>
- <persistent value="true"/>
-</extension>
-
-<extension id="configproblem" point="org.eclipse.core.resources.markers" name="%aptConfigurationMarkerName">
- <super type="org.eclipse.core.resources.problemmarker"/>
- <super type="org.eclipse.core.resources.textmarker"/>
- <persistent value="true"/>
-</extension>
-
-<!-- =================================================================================== -->
-<!-- Extension: Headless Build -->
-<!-- =================================================================================== -->
-<extension
- id="aptBuild"
- point="org.eclipse.core.runtime.applications">
- <application>
- <run class="org.eclipse.jdt.apt.core.build.AptBuilder"/>
- </application>
-</extension>
-
-<extension
- point="org.eclipse.core.runtime.preferences">
- <initializer class="org.eclipse.jdt.apt.core.internal.util.AptCorePreferenceInitializer"/>
-</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 960995863c..0000000000
--- a/org.eclipse.jdt.apt.core/schema/annotationProcessorFactory.exsd
+++ /dev/null
@@ -1,181 +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>
- Plug-ins which contribute JSR-175 annotation processors should extend this extension point in order to participate in compilation.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="factories" minOccurs="0" maxOccurs="1"/>
- <element ref="java6processors" minOccurs="0" maxOccurs="1"/>
- </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="factories">
- <complexType>
- <sequence>
- <element ref="factory" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="enableDefault" type="boolean">
- <annotation>
- <documentation>
- true if this processor should be enabled by default. This value
-may be overridden via the annotation processing configuration settings. If not
-present this value defaults to true.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="factory">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- Qualified name of a class that implements com.sun.mirror.apt.AnnotationProcessorFactory and has a no-argument constructor.
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="com.sun.mirror.apt.AnnotationProcessorFactory"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="implements" type="string">
- <annotation>
- <documentation>
- Reserved. Do not use this attribute.
- </documentation>
- <appInfo>
- <meta.attribute deprecated="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="java6processors">
- <complexType>
- <sequence>
- <element ref="java6processor" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="enableDefault" type="boolean">
- <annotation>
- <documentation>
- true if this processor should be enabled by default. This value
-may be overridden via the annotation processing configuration settings. If not
-present this value defaults to true.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="java6processor">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- Qualified name of a class that implements javax.annotation.processing.Processor and has a no-argument constructor.
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="javax.annotation.processing.Processor"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 3.2
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- Example of a declaration of an &lt;code&gt;annotationProcessorFactory&lt;/code&gt;: &lt;pre&gt;
- &lt;extension
- point=&quot;org.eclipse.jdt.apt.core.annotationProcessorFactory&quot;&gt;
- &lt;factories enableDefault=&quot;true&quot;&gt;
- &lt;factory
- class=&quot;org.xyz.HelloWorldAnnotationProcessorFactory&quot;&gt;
- &lt;/factory&gt;
- &lt;factory
- class=&quot;org.xyz.GoodNightMoonAnnotationProcessorFactory&quot;&gt;
- &lt;/factory&gt;
- &lt;/factories&gt;
- &lt;/extension&gt;
-&lt;/pre&gt;
- </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>
- Copyright (c) 2005 BEA Systems, Inc and others.&lt;br&gt;
-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
-&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/org.eclipse.jdt.apt.core/scripts/build-sdk-prime.cmd b/org.eclipse.jdt.apt.core/scripts/build-sdk-prime.cmd
deleted file mode 100644
index aa262b0d6b..0000000000
--- a/org.eclipse.jdt.apt.core/scripts/build-sdk-prime.cmd
+++ /dev/null
@@ -1,161 +0,0 @@
-@echo off
-
-SETLOCAL
-
-pushd .
-
-
-REM
-REM TODO - Depending on how long this is supposed to live, convert this to ant. It was supposed to be a one-off hacky script, but it grew...
-REM
-
-if "%1"=="help" (
- @echo USAGE: build-sdk-prime.cmd [workspace-root] [original-eclipse-sdk.zip]
- GOTO :END_SCRIPT
-)
-
-if "%1"=="" (
- @echo you must specify a "workspace-root"
- @echo USAGE: build-sdk-prime.cmd [workspace-root] [original-eclipse-sdk.zip]
- GOTO :END_SCRIPT
-)
-
-if "%2"=="" (
- @echo you must specify a "original-eclipse-sdk.zip"
- @echo USAGE: build-sdk-prime.cmd [workspace-root] [original-eclipse-sdk.zip]
- GOTO :END_SCRIPT
-)
-
-
-if NOT EXIST "%1" (
- @echo workspace-root %1 does not exist
- @echo USAGE: build-sdk-prime.cmd [workspace-root] [original-eclipse-sdk.zip]
- GOTO :END_SCRIPT
-)
-
-if NOT EXIST "%2" (
- @echo eclipse sdk zip file %2 does not exist
- @echo USAGE: build-sdk-prime.cmd [workspace-root] [original-eclipse-sdk.zip]
- GOTO :END_SCRIPT
-)
-
-
-@set ROOT=%1
-@set FULL_SDK_ZIP=%2
-
-@set APT_VERSION=3.2.0.qualifier
-@set JDT_VERSION=3.2.0
-
-@set TEMPDIR=\temp\eclipse_sdk_mod
-
-@echo Creating working directory %TEMPDIR%
-if exist %TEMPDIR% rm -rf %TEMPDIR%
-mkdir %TEMPDIR%
-cd %TEMPDIR%
-@echo ...done.
-
-REM
-REM HACKHACK: the sh scripts generates a .cmd script which will set the variable DATE_SUFFIX
-REM to the output of the sh command `date +%Y%m%d-%H%M`. Yeah, yeah. I should have
-REM used ant for consistency.
-REM
-cd %TEMPDIR%
-sh %ROOT%\org.eclipse.jdt.apt.core\scripts\make_set_date_suffix_cmd.sh
-call set_date_suffix.cmd
-
-@set SDK_APT_ZIP=eclipse-SDK-APT-%DATE_SUFFIX%.zip
-@set FULL_SDK_APT_ZIP=%TEMPDIR%\%SDK_APT_ZIP%
-
-
-REM
-REM build plugins
-REM
-
-@echo Building jdt.apt.core, jdt.apt.ui and jdt.core plugins...
-
-cd %ROOT%\org.eclipse.jdt.apt.core
-cmd /c ant -f scripts\exportplugin.xml
-
-cd %ROOT%\org.eclipse.jdt.apt.ui
-cmd /c ant -f scripts\exportplugin.xml
-
-cd %ROOT%\org.eclipse.jdt.core
-cmd /c ant -f scripts\exportplugin.xml
-
-@echo ...finished building plugins.
-
-
-REM
-REM explode existing zip
-REM
-
-cd %TEMPDIR%
-
-@echo Exploding existing SDK zip file %FULL_SDK_ZIP%...
-jar xf %FULL_SDK_ZIP%
-@echo ... Done.
-
-REM
-REM update SDK with apt.ui plugin
-REM
-
-@echo Copying org.eclipse.jdt.apt.ui plugin jar and source zip...
-copy /Y %ROOT%\..\plugin-export\org.eclipse.jdt.apt.ui_%APT_VERSION%\org.eclipse.jdt.apt.ui_%APT_VERSION%.jar %TEMPDIR%\eclipse\plugins\
-mkdir %TEMPDIR%\eclipse\plugins\org.eclipse.jdt.source_%JDT_VERSION%\src\org.eclipse.jdt.apt.ui_%APT_VERSION%\
-copy /Y %ROOT%\..\plugin-export\org.eclipse.jdt.apt.ui_%APT_VERSION%\src.zip %TEMPDIR%\eclipse\plugins\org.eclipse.jdt.source_%JDT_VERSION%\src\org.eclipse.jdt.apt.ui_%APT_VERSION%\
-@echo ...Done
-
-REM
-REM update SDK with jdt core
-REM
-
-@echo Copying org.eclipse.jdt.core plugin jar and source zip...
-copy /Y %ROOT%\..\plugin-export\org.eclipse.jdt.core_%APT_VERSION%\org.eclipse.jdt.core_%APT_VERSION%.jar %TEMPDIR%\eclipse\plugins\
-mkdir %TEMPDIR%\eclipse\plugins\org.eclipse.jdt.source_%JDT_VERSION%\src\org.eclipse.jdt.core_%APT_VERSION%\
-copy /Y %ROOT%\..\plugin-export\org.eclipse.jdt.core_%APT_VERSION%\src.zip %TEMPDIR%\eclipse\plugins\org.eclipse.jdt.source_%JDT_VERSION%\src\org.eclipse.jdt.core_%APT_VERSION%\
-@echo ...Done
-
-REM
-REM copy apt-core src.zip to SDK's directory
-REM
-
-@echo Copying aptcore_src.zip...
-mkdir %TEMPDIR%\eclipse\plugins\org.eclipse.jdt.source_%JDT_VERSION%\src\org.eclipse.jdt.apt.core_%APT_VERSION%\
-copy /Y %ROOT%\..\plugin-export\org.eclipse.jdt.apt.core_%APT_VERSION%\aptcoresrc.zip %TEMPDIR%\eclipse\plugins\org.eclipse.jdt.source_%JDT_VERSION%\src\org.eclipse.jdt.apt.core_%APT_VERSION%\
-@echo ...done.
-
-REM
-REM explode the apt-core .zip file into the SDK directory
-REM
-
-@echo Exploding org.eclipse.jdt.apt.core_%APT_VERSION%.jar into SDK...
-mkdir %TEMPDIR%\eclipse\plugins\org.eclipse.jdt.apt.core_%APT_VERSION%
-cd %TEMPDIR%\eclipse\plugins\org.eclipse.jdt.apt.core_%APT_VERSION%
-jar xf %ROOT%\..\plugin-export\org.eclipse.jdt.apt.core_%APT_VERSION%\org.eclipse.jdt.apt.core_%APT_VERSION%.jar
-@echo ...Done.
-
-
-
-REM
-REM now zip up the new SDK
-REM
-
-@echo Zipping up %SDK_APT_ZIP%...
-cd %TEMPDIR%
-jar cf %FULL_SDK_APT_ZIP% eclipse
-@echo ...done.
-
-
-@echo ******************************************************************************
-@echo Modified Eclipse SDK.zip file is at:
-@echo %FULL_SDK_APT_ZIP%
-@echo ******************************************************************************
-
-
-:END_SCRIPT
-popd
-
-ENDLOCAL
-
-
-
diff --git a/org.eclipse.jdt.apt.core/scripts/exportplugin.xml b/org.eclipse.jdt.apt.core/scripts/exportplugin.xml
deleted file mode 100644
index c28cdc9211..0000000000
--- a/org.eclipse.jdt.apt.core/scripts/exportplugin.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Build script to create the apt.core plugin.
- This script assumes that the classes have already been compiled,
- and exist in the 'bin' subdirectory of the plugin project.
- The directory structure assumed by this script is as follows:
- [dev root]/
- [workspace]/
- [plugins]/
- org.eclipse.jdt.apt.core/
- bin/
- src/
- scripts/ // contains this script
- plugin-export/ // will be created if necessary
- org.eclipse.jdt.apt.core_[version]/
- org.eclipse.jdt.apt.core_[version].zip // will be created
-
--->
-
-<project name="${plugin}" default="export plug-in [_1.0.0]" basedir="..">
-
-<target name="export plug-in [_1.0.0]">
- <antcall target="zz_internal_export">
- <param name="plugin_version" value="3.2.0.qualifier"/>
- </antcall>
-</target>
-
-<target name="zz_internal_export">
-
- <tstamp/>
- <property name="export-dir" value="../../plugin-export" />
- <property name="plugin" value="org.eclipse.jdt.apt.core" />
- <property name="plugin-dir" value="${export-dir}/${plugin}_${plugin_version}"/>
-
- <echo message="TARGET: ${export-dir}" />
- <mkdir dir="${export-dir}" />
- <delete dir="${plugin-dir}" />
- <mkdir dir="${plugin-dir}" />
-
- <zip zipfile="${plugin-dir}/aptcore.jar">
- <fileset dir="bin" />
- </zip>
-
- <echo message="UPDATE ${plugin}_${plugin_version}.jar" />
- <zip zipfile="${plugin-dir}/${plugin}_${plugin_version}.jar">
- <fileset dir=".">
- <include name="mirrorapi.jar" />
- <include name="plugin.xml" />
- <include name="plugin.properties" />
- <include name="META-INF/**" />
- <include name=".options"/>
- </fileset>
- <fileset dir="${plugin-dir}">
- <include name="aptcore.jar"/>
- </fileset>
- </zip>
-
- <echo message="UPDATE ${plugin}_${plugin_version}.jar with aptcore.jar" />
- <zip zipfile="${plugin-dir}/aptcoresrc.zip">
- <fileset dir="src" />
- </zip>
-
-
-
- <echo message="UPDATE aptcoresrc.zip" />
- <zip zipfile="${plugin-dir}/aptcoresrc.zip">
- <fileset dir="src" />
- </zip>
-
- <echo message="UPDATE ${export-dir}/../${plugin}_${plugin_version}.zip" />
- <zip zipfile="${export-dir}/../${plugin}_${plugin_version}.zip"
- basedir="${export-dir}"
- includes="${plugin}_${plugin_version}/**" />
-</target>
-
-</project>
diff --git a/org.eclipse.jdt.apt.core/scripts/make_set_date_suffix_cmd.sh b/org.eclipse.jdt.apt.core/scripts/make_set_date_suffix_cmd.sh
deleted file mode 100644
index 73cffb7776..0000000000
--- a/org.eclipse.jdt.apt.core/scripts/make_set_date_suffix_cmd.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-
-echo set DATE_SUFFIX=`date +%Y%m%d-%H%M` > set_date_suffix.cmd
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessor.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessor.java
deleted file mode 100644
index 99dda7f069..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessor.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * @(#)AnnotationProcessor.java 1.2 04/02/10
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.apt;
-
-
-/**
- * An annotation processor, used to examine and process the
- * annotations of program elements. An annotation processor may,
- * for example, create new source files and XML documents to be used
- * in conjunction with the original code.
- *
- * <p> An annotation processor is constructed by a
- * {@linkplain AnnotationProcessorFactory factory}, which provides it with an
- * {@linkplain AnnotationProcessorEnvironment environment} that
- * encapsulates the state it needs.
- * Messages regarding warnings and errors encountered during processing
- * should be directed to the environment's {@link Messager},
- * and new files may be created using the environment's {@link Filer}.
- *
- * <p> Each annotation processor is created to process annotations
- * of a particular annotation type or set of annotation types.
- * It may use its environment to find the program elements with
- * annotations of those types. It may freely examine any other program
- * elements in the course of its processing.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.2 04/02/10
- * @since 1.5
- */
-
-public interface AnnotationProcessor {
-
- /**
- * Process all program elements supported by this annotation processor.
- */
- void process();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessorEnvironment.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessorEnvironment.java
deleted file mode 100644
index 24d75a363f..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessorEnvironment.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * @(#)AnnotationProcessorEnvironment.java 1.7 04/07/19
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.apt;
-
-
-import java.util.Collection;
-import java.util.Map;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.*;
-
-
-/**
- * The environment encapsulating the state needed by an annotation processor.
- * An annotation processing tool makes this environment available
- * to all annotation processors.
- *
- * <p> When an annotation processing tool is invoked, it is given a
- * set of type declarations on which to operate. These
- * are refered to as the <i>specified</i> types.
- * The type declarations said to be <i>included</i> in this invocation
- * consist of the specified types and any types nested within them.
- *
- * <p> {@link DeclarationFilter}
- * provides a simple way to select just the items of interest
- * when a method returns a collection of declarations.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.7 04/07/19
- * @since 1.5
- */
-
-public interface AnnotationProcessorEnvironment {
-
- /**
- * Returns the options passed to the annotation processing tool.
- * Options are returned in the form of a map from option name
- * (such as <tt>"-encoding"</tt>) to option value.
- * For an option with no value (such as <tt>"-help"</tt>), the
- * corresponding value in the map is <tt>null</tt>.
- *
- * <p> Options beginning with <tt>"-A"</tt> are <i>processor-specific.</i>
- * Such options are unrecognized by the tool, but intended to be used by
- * some annotation processor.
- *
- * @return the options passed to the tool
- */
- Map<String,String> getOptions();
-
- /**
- * Returns the messager used to report errors, warnings, and other
- * notices.
- *
- * @return the messager
- */
- Messager getMessager();
-
- /**
- * Returns the filer used to create new source, class, or auxiliary
- * files.
- *
- * @return the filer
- */
- Filer getFiler();
-
-
-
- /**
- * Returns the declarations of the types specified when the
- * annotation processing tool was invoked.
- *
- * @return the types specified when the tool was invoked, or an
- * empty collection if there were none
- */
- Collection<TypeDeclaration> getSpecifiedTypeDeclarations();
-
- /**
- * Returns the declaration of a package given its fully qualified name.
- *
- * @param name fully qualified package name, or "" for the unnamed package
- * @return the declaration of the named package, or null if it cannot
- * be found
- */
- PackageDeclaration getPackage(String name);
-
- /**
- * Returns the declaration of a type given its fully qualified name.
- *
- * @param name fully qualified type name
- * @return the declaration of the named type, or null if it cannot be
- * found
- */
- TypeDeclaration getTypeDeclaration(String name);
-
- /**
- * A convenience method that returns the declarations of the types
- * {@linkplain AnnotationProcessorEnvironment <i>included</i>}
- * in this invocation of the annotation processing tool.
- *
- * @return the declarations of the types included in this invocation
- * of the tool, or an empty collection if there are none
- */
- Collection<TypeDeclaration> getTypeDeclarations();
-
- /**
- * Returns the declarations annotated with the given annotation type.
- * Only declarations of the types
- * {@linkplain AnnotationProcessorEnvironment <i>included</i>}
- * in this invocation of the annotation processing tool, or
- * declarations of members, parameters, or type parameters
- * declared within those, are returned.
- *
- * @param a annotation type being requested
- * @return the declarations annotated with the given annotation type,
- * or an empty collection if there are none
- */
- Collection<Declaration> getDeclarationsAnnotatedWith(
- AnnotationTypeDeclaration a);
-
- /**
- * Returns an implementation of some utility methods for
- * operating on declarations.
- *
- * @return declaration utilities
- */
- Declarations getDeclarationUtils();
-
- /**
- * Returns an implementation of some utility methods for
- * operating on types.
- *
- * @return type utilities
- */
- Types getTypeUtils();
-
- /**
- * Add a listener. If the listener is currently registered to listen,
- * adding it again will have no effect.
- *
- * @param listener The listener to add.
- * @throws NullPointerException if the listener is null
- */
- void addListener(AnnotationProcessorListener listener);
-
-
- /**
- * Remove a listener. If the listener is not currently listening,
- * the method call does nothing.
- *
- * @param listener The listener to remove.
- * @throws NullPointerException if the listener is null
- */
- void removeListener(AnnotationProcessorListener listener);
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessorFactory.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessorFactory.java
deleted file mode 100644
index 203007c445..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessorFactory.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * @(#)AnnotationProcessorFactory.java 1.9 04/07/13
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.apt;
-
-
-import java.util.Collection;
-import java.util.Set;
-
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-
-/**
- * A factory for creating annotation processors.
- * Each factory is responsible for creating processors for one or more
- * annotation types.
- * The factory is said to <i>support</i> these types.
- *
- * <p> Each implementation of an <tt>AnnotationProcessorFactory</tt>
- * must provide a public no-argument constructor to be used by tools to
- * instantiate the factory.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.9 04/07/13
- * @since 1.5
- */
-
-public interface AnnotationProcessorFactory {
-
- /**
- * Returns the options recognized by this factory or by any of the
- * processors it may create.
- * Only {@linkplain AnnotationProcessorEnvironment#getOptions()
- * processor-specific} options are included, each of which begins
- * with <tt>"-A"</tt>. For example, if this factory recognizes
- * options such as <tt>-Adebug -Aloglevel=3</tt>, it will
- * return the strings <tt>"-Adebug"</tt> and <tt>"-Aloglevel"</tt>.
- *
- * <p> A tool might use this information to determine if any
- * options provided by a user are unrecognized by any processor,
- * in which case it may wish to report an error.
- *
- * @return the options recognized by this factory or by any of the
- * processors it may create, or an empty collection if none
- */
- Collection<String> supportedOptions();
-
- /**
- * Returns the names of the annotation types supported by this factory.
- * An element of the result may be the canonical (fully qualified) name
- * of a supported annotation type. Alternately it may be of the form
- * <tt>"<i>name</i>.*"</tt>
- * representing the set of all annotation types
- * with canonical names beginning with <tt>"<i>name</i>."</tt>
- * Finally, <tt>"*"</tt> by itself represents the set of all
- * annotation types.
- *
- * @return the names of the annotation types supported by this factory
- */
- Collection<String> supportedAnnotationTypes();
-
- /**
- * Returns an annotation processor for a set of annotation
- * types. The set will be empty if the factory supports
- * &quot;<tt>*</tt>&quot; and the specified type declarations have
- * no annotations. Note that the set of annotation types may be
- * empty for other reasons, such as giving the factory an
- * opportunity to register a listener. An
- * <tt>AnnotationProcessorFactory</tt> must gracefully handle an
- * empty set of annotations; an appropriate response to an empty
- * set will often be returning {@link AnnotationProcessors#NO_OP}.
- *
- * @param atds type declarations of the annotation types to be processed
- * @param env environment to use during processing
- * @return an annotation processor for the given annotation types,
- * or <tt>null</tt> if the types are not supported or the
- * processor cannot be created
- */
- AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env);
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessorListener.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessorListener.java
deleted file mode 100644
index 6ce0470c70..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessorListener.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * @(#)AnnotationProcessorListener.java 1.1 04/06/25
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.apt;
-
-/**
- * Superinterface for all annotation processor event listeners.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/06/25
- * @since 1.5
- */
-public interface AnnotationProcessorListener extends java.util.EventListener {}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessors.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessors.java
deleted file mode 100644
index 642da9ab84..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/AnnotationProcessors.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * @(#)AnnotationProcessors.java 1.2 04/06/21
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.apt;
-
-import java.util.*;
-
-/**
- * Utilities to create specialized annotation processors.
- *
- * @since 1.5
- * @author Joseph D. Darcy
- * @author Scott Seligman
- */
-public class AnnotationProcessors {
- static class NoOpAP implements AnnotationProcessor {
- NoOpAP() {}
- public void process(){}
- }
-
- /**
- * Combines multiple annotation processors into a simple composite
- * processor.
- * The composite processor functions by invoking each of its component
- * processors in sequence.
- */
- static class CompositeAnnotationProcessor implements AnnotationProcessor {
-
- private List<AnnotationProcessor> aps =
- new LinkedList<AnnotationProcessor>();
-
- /**
- * Constructs a new composite annotation processor.
- * @param aps the component annotation processors
- */
- public CompositeAnnotationProcessor(Collection<AnnotationProcessor> aps) {
- this.aps.addAll(aps);
- }
-
- /**
- * Constructs a new composite annotation processor.
- * @param aps the component annotation processors
- */
- public CompositeAnnotationProcessor(AnnotationProcessor... aps) {
- for(AnnotationProcessor ap: aps)
- this.aps.add(ap);
- }
-
- /**
- * Invokes the <tt>process</tt> method of each component processor,
- * in the order in which the processors were passed to the constructor.
- */
- public void process() {
- for(AnnotationProcessor ap: aps)
- ap.process();
- }
- }
-
-
- /**
- * An annotation processor that does nothing and has no state.
- * May be used multiple times.
- *
- * @since 1.5
- */
- public final static AnnotationProcessor NO_OP = new NoOpAP();
-
- /**
- * Constructs a new composite annotation processor. A composite
- * annotation processor combines multiple annotation processors
- * into one and functions by invoking each of its component
- * processors' process methods in sequence.
- *
- * @param aps The processors to create a composite of
- * @since 1.5
- */
- public static AnnotationProcessor getCompositeAnnotationProcessor(AnnotationProcessor... aps) {
- return new CompositeAnnotationProcessor(aps);
- }
-
- /**
- * Constructs a new composite annotation processor. A composite
- * annotation processor combines multiple annotation processors
- * into one and functions by invoking each of its component
- * processors' process methods in the sequence the processors are
- * returned by the collection's iterator.
- *
- * @param aps A collection of processors to create a composite of
- * @since 1.5
- */
- public static AnnotationProcessor getCompositeAnnotationProcessor(Collection<AnnotationProcessor> aps) {
- return new CompositeAnnotationProcessor(aps);
- }
-}
-
-
-
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/Filer.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/Filer.java
deleted file mode 100644
index f7ee38159d..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/Filer.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * @(#)Filer.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.apt;
-
-
-import java.io.*;
-
-
-/**
- * This interface supports the creation of new files by an
- * annotation processor.
- * Files created in this way will be known to the annotation processing
- * tool implementing this interface, better enabling the tool to manage them.
- * Four kinds of files are distinguished:
- * source files, class files, other text files, and other binary files.
- * The latter two are collectively referred to as <i>auxiliary</i> files.
- *
- * <p> There are two distinguished locations (subtrees within the
- * file system) where newly created files are placed:
- * one for new source files, and one for new class files.
- * (These might be specified on a tool's command line, for example,
- * using flags such as <tt>-s</tt> and <tt>-d</tt>.)
- * Auxiliary files may be created in either location.
- *
- * <p> During each run of an annotation processing tool, a file
- * with a given pathname may be created only once. If that file already
- * exists before the first attempt to create it, the old contents will
- * be deleted. Any subsequent attempt to create the same file during
- * a run will fail.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- * @since 1.5
- */
-
-public interface Filer {
-
- /**
- * Creates a new source file and returns a writer for it.
- * The file's name and path (relative to the root of all newly created
- * source files) is based on the type to be declared in that file.
- * If more than one type is being declared, the name of the principal
- * top-level type (the public one, for example) should be used.
- *
- * <p> The {@linkplain java.nio.charset.Charset charset} used to
- * encode the file is determined by the implementation.
- * An annotation processing tool may have an <tt>-encoding</tt>
- * flag or the like for specifying this. It will typically use
- * the platform's default encoding if none is specified.
- *
- * @param name canonical (fully qualified) name of the principal type
- * being declared in this file
- * @return a writer for the new file
- * @throws IOException if the file cannot be created
- */
- PrintWriter createSourceFile(String name) throws IOException;
-
- /**
- * Creates a new class file, and returns a stream for writing to it.
- * The file's name and path (relative to the root of all newly created
- * class files) is based on the name of the type being written.
- *
- * @param name canonical (fully qualified) name of the type being written
- * @return a stream for writing to the new file
- * @throws IOException if the file cannot be created
- */
- OutputStream createClassFile(String name) throws IOException;
-
- /**
- * Creates a new text file, and returns a writer for it.
- * The file is located along with either the
- * newly created source or newly created binary files. It may be
- * named relative to some package (as are source and binary files),
- * and from there by an arbitrary pathname. In a loose sense, the
- * pathname of the new file will be the concatenation of
- * <tt>loc</tt>, <tt>pkg</tt>, and <tt>relPath</tt>.
- *
- * <p> A {@linkplain java.nio.charset.Charset charset} for
- * encoding the file may be provided. If none is given, the
- * charset used to encode source files
- * (see {@link #createSourceFile(String)}) will be used.
- *
- * @param loc location of the new file
- * @param pkg package relative to which the file should be named,
- * or the empty string if none
- * @param relPath final pathname components of the file
- * @param charsetName the name of the charset to use, or null if none
- * is being explicitly specified
- * @return a writer for the new file
- * @throws IOException if the file cannot be created
- */
- PrintWriter createTextFile(Location loc,
- String pkg,
- File relPath,
- String charsetName) throws IOException;
-
- /**
- * Creates a new binary file, and returns a stream for writing to it.
- * The file is located along with either the
- * newly created source or newly created binary files. It may be
- * named relative to some package (as are source and binary files),
- * and from there by an arbitrary pathname. In a loose sense, the
- * pathname of the new file will be the concatenation of
- * <tt>loc</tt>, <tt>pkg</tt>, and <tt>relPath</tt>.
- *
- * @param loc location of the new file
- * @param pkg package relative to which the file should be named,
- * or the empty string if none
- * @param relPath final pathname components of the file
- * @return a stream for writing to the new file
- * @throws IOException if the file cannot be created
- */
- OutputStream createBinaryFile(Location loc,
- String pkg,
- File relPath) throws IOException;
-
-
- /**
- * Locations (subtrees within the file system) where new files are created.
- */
- enum Location {
- /** The location of new source files. */
- SOURCE_TREE,
- /** The location of new class files. */
- CLASS_TREE
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/Messager.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/Messager.java
deleted file mode 100644
index 0539124659..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/Messager.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * @(#)Messager.java 1.2 04/07/27
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.apt;
-
-
-import com.sun.mirror.util.SourcePosition;
-
-
-/**
- * A <tt>Messager</tt> provides the way for
- * an annotation processor to report error messages, warnings, and
- * other notices.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.2 04/07/27
- * @since 1.5
- */
-
-public interface Messager {
-
- /**
- * Prints an error message.
- * Equivalent to <tt>printError(null, msg)</tt>.
- * @param msg the message, or an empty string if none
- */
- void printError(String msg);
-
- /**
- * Prints an error message.
- * @param pos the position where the error occured, or null if it is
- * unknown or not applicable
- * @param msg the message, or an empty string if none
- */
- void printError(SourcePosition pos, String msg);
-
- /**
- * Prints a warning message.
- * Equivalent to <tt>printWarning(null, msg)</tt>.
- * @param msg the message, or an empty string if none
- */
- void printWarning(String msg);
-
- /**
- * Prints a warning message.
- * @param pos the position where the warning occured, or null if it is
- * unknown or not applicable
- * @param msg the message, or an empty string if none
- */
- void printWarning(SourcePosition pos, String msg);
-
- /**
- * Prints a notice.
- * Equivalent to <tt>printNotice(null, msg)</tt>.
- * @param msg the message, or an empty string if none
- */
- void printNotice(String msg);
-
- /**
- * Prints a notice.
- * @param pos the position where the noticed occured, or null if it is
- * unknown or not applicable
- * @param msg the message, or an empty string if none
- */
- void printNotice(SourcePosition pos, String msg);
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/RoundCompleteEvent.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/RoundCompleteEvent.java
deleted file mode 100644
index ce8dbcc73f..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/RoundCompleteEvent.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * @(#)RoundCompleteEvent.java 1.2 04/07/19
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.apt;
-
-/**
- * Event for the completion of a round of annotation processing.
- *
- * <p>While this class extends the serializable <tt>EventObject</tt>, it
- * cannot meaningfully be serialized because all of the annotation
- * processing tool's internal state would potentially be needed.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.2 04/07/19
- * @since 1.5
- */
-@SuppressWarnings("serial")
-public abstract class RoundCompleteEvent extends java.util.EventObject {
- private RoundState rs;
-
- /**
- * The current <tt>AnnotationProcessorEnvironment</tt> is regarded
- * as the source of events.
- *
- * @param source The source of events
- * @param rs The state of the round
- */
- protected RoundCompleteEvent(AnnotationProcessorEnvironment source,
- RoundState rs) {
- super(source);
- this.rs = rs;
- }
-
- /**
- * Return round state.
- */
- public RoundState getRoundState() {
- return rs;
- }
-
- /**
- * Return source.
- */
- public AnnotationProcessorEnvironment getSource() {
- return (AnnotationProcessorEnvironment)super.getSource();
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/RoundCompleteListener.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/RoundCompleteListener.java
deleted file mode 100644
index eebf9610b3..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/RoundCompleteListener.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * @(#)RoundCompleteListener.java 1.1 04/06/25
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.apt;
-
-/**
- * Listener for the completion of a round of annotation processing.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/06/25
- * @since 1.5
- */
-public interface RoundCompleteListener extends AnnotationProcessorListener {
- /**
- * Invoked after all processors for a round have run to completion.
- *
- * @param event An event for round completion
- */
- void roundComplete(RoundCompleteEvent event);
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/RoundState.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/RoundState.java
deleted file mode 100644
index f97462640a..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/RoundState.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * @(#)RoundState.java 1.1 04/06/25
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.apt;
-
-/**
- * Represents the status of a completed round of annotation processing.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/06/25
- * @since 1.5
- */
-public interface RoundState {
- /**
- * Returns <tt>true</tt> if this was the last round of annotation
- * processing; returns <tt>false</tt> if there will be a subsequent round.
- */
- boolean finalRound();
-
- /**
- * Returns <tt>true</tt> if an error was raised in this round of processing;
- * returns <tt>false</tt> otherwise.
- */
- boolean errorRaised();
-
- /**
- * Returns <tt>true</tt> if new source files were created in this round of
- * processing; returns <tt>false</tt> otherwise.
- */
- boolean sourceFilesCreated();
-
- /**
- * Returns <tt>true</tt> if new class files were created in this round of
- * processing; returns <tt>false</tt> otherwise.
- */
- boolean classFilesCreated();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/package.html b/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/package.html
deleted file mode 100644
index 4297c8b3bc..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/apt/package.html
+++ /dev/null
@@ -1,47 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<!--
- @(#)package.html 1.3 04/07/26
- Copyright (c) 2004, Sun Microsystems, Inc.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the Sun Microsystems, Inc. nor the names of
- its contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-</head>
-<body bgcolor="white">
-
-Classes used to communicate information between
-{@linkplain com.sun.mirror.apt.AnnotationProcessor annotation processors}
-and an annotation processing tool.
-
-<p>Note that the <code>apt</code> tool and its associated APIs may be
-changed or superseded in future j2se releases.
-
-@since 1.5
-</body>
-</html>
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationMirror.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationMirror.java
deleted file mode 100644
index 7b193d0235..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationMirror.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * @(#)AnnotationMirror.java 1.5 04/07/16
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-import java.util.Map;
-import com.sun.mirror.type.AnnotationType;
-import com.sun.mirror.util.SourcePosition;
-
-
-/**
- * Represents an annotation. An annotation associates a value with
- * each element of an annotation type.
- *
- * <p> Annotations should not be compared using reference-equality
- * ("<tt>==</tt>"). There is no guarantee that any particular
- * annotation will always be represented by the same object.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.5 04/07/16
- * @since 1.5
- */
-
-public interface AnnotationMirror {
-
- /**
- * Returns the annotation type of this annotation.
- *
- * @return the annotation type of this annotation
- */
- AnnotationType getAnnotationType();
-
- /**
- * Returns the source position of the beginning of this annotation.
- * Returns null if the position is unknown or not applicable.
- *
- * <p>This source position is intended for use in providing diagnostics,
- * and indicates only approximately where an annotation begins.
- *
- * @return the source position of the beginning of this annotation or
- * null if the position is unknown or not applicable
- */
- SourcePosition getPosition();
-
- /**
- * Returns this annotation's elements and their values.
- * This is returned in the form of a map that associates elements
- * with their corresponding values.
- * Only those elements and values explicitly present in the
- * annotation are included, not those that are implicitly assuming
- * their default values.
- * The order of the map matches the order in which the
- * elements appear in the annotation's source.
- *
- * @return this annotation's elements and their values,
- * or an empty map if there are none
- */
- Map<AnnotationTypeElementDeclaration, AnnotationValue> getElementValues();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationTypeDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationTypeDeclaration.java
deleted file mode 100644
index d53a9b4979..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationTypeDeclaration.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * @(#)AnnotationTypeDeclaration.java 1.2 04/04/20
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-import java.util.Collection;
-
-
-/**
- * Represents the declaration of an annotation type.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.2 04/04/20
- * @since 1.5
- */
-
-public interface AnnotationTypeDeclaration extends InterfaceDeclaration {
-
- /**
- * Returns the annotation type elements of this annotation type.
- * These are the methods that are directly declared in the type's
- * declaration.
- *
- * @return the annotation type elements of this annotation type,
- * or an empty collection if there are none
- */
- Collection<AnnotationTypeElementDeclaration> getMethods();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationTypeElementDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationTypeElementDeclaration.java
deleted file mode 100644
index 0c6e8ddbec..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationTypeElementDeclaration.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * @(#)AnnotationTypeElementDeclaration.java 1.3 04/04/20
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-/**
- * Represents an element of an annotation type.
- *
- * @author Joe Darcy
- * @author Scott Seligman
- * @version 1.3 04/04/20
- * @since 1.5
- */
-
-public interface AnnotationTypeElementDeclaration extends MethodDeclaration {
-
- /**
- * Returns the default value of this element.
- *
- * @return the default value of this element, or null if this element
- * has no default.
- */
- AnnotationValue getDefaultValue();
-
- /**
- * {@inheritDoc}
- */
- AnnotationTypeDeclaration getDeclaringType();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationValue.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationValue.java
deleted file mode 100644
index 250e1cbf6f..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/AnnotationValue.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * @(#)AnnotationValue.java 1.6 04/07/19
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-import com.sun.mirror.util.SourcePosition;
-
-/**
- * Represents a value of an annotation type element.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.6 04/07/19
- * @since 1.5
- */
-
-public interface AnnotationValue {
-
- /**
- * Returns the value.
- * The result has one of the following types:
- * <ul><li> a wrapper class (such as {@link Integer}) for a primitive type
- * <li> {@code String}
- * <li> {@code TypeMirror}
- * <li> {@code EnumConstantDeclaration}
- * <li> {@code AnnotationMirror}
- * <li> {@code Collection<AnnotationValue>}
- * (representing the elements, in order, if the value is an array)
- * </ul>
- *
- * @return the value
- */
- Object getValue();
-
- /**
- * Returns the source position of the beginning of this annotation value.
- * Returns null if the position is unknown or not applicable.
- *
- * <p>This source position is intended for use in providing diagnostics,
- * and indicates only approximately where an annotation value begins.
- *
- * @return the source position of the beginning of this annotation value or
- * null if the position is unknown or not applicable
- */
- SourcePosition getPosition();
-
- /**
- * Returns a string representation of this value.
- * This is returned in a form suitable for representing this value
- * in the source code of an annotation.
- *
- * @return a string representation of this value
- */
- String toString();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ClassDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ClassDeclaration.java
deleted file mode 100644
index 8c3e4a55bd..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ClassDeclaration.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * @(#)ClassDeclaration.java 1.3 04/02/20
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.type.ClassType;
-
-
-/**
- * Represents the declaration of a class.
- * For the declaration of an interface, see {@link InterfaceDeclaration}.
- * Provides access to information about the class, its members, and
- * its constructors.
- * Note that an {@linkplain EnumDeclaration enum} is a kind of class.
- *
- * <p> While a <tt>ClassDeclaration</tt> represents the <i>declaration</i>
- * of a class, a {@link ClassType} represents a class <i>type</i>.
- * See {@link TypeDeclaration} for more on this distinction.
- *
- * <p> {@link com.sun.mirror.util.DeclarationFilter}
- * provides a simple way to select just the items of interest
- * when a method returns a collection of declarations.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.3 04/02/20
- *
- * @see ClassType
- * @since 1.5
- */
-
-public interface ClassDeclaration extends TypeDeclaration {
-
- /**
- * Returns the class type directly extended by this class.
- * The only class with no superclass is <tt>java.lang.Object</tt>,
- * for which this method returns null.
- *
- * @return the class type directly extended by this class, or null
- * if there is none
- */
- ClassType getSuperclass();
-
- /**
- * Returns the constructors of this class.
- * This includes the default constructor if this class has
- * no constructors explicitly declared.
- *
- * @return the constructors of this class
- *
- * @see com.sun.mirror.util.DeclarationFilter
- */
- Collection<ConstructorDeclaration> getConstructors();
-
- /**
- * {@inheritDoc}
- */
- Collection<MethodDeclaration> getMethods();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ConstructorDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ConstructorDeclaration.java
deleted file mode 100644
index 61f5b9fcb4..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ConstructorDeclaration.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * @(#)ConstructorDeclaration.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-/**
- * Represents a constructor of a class or interface.
- *
- * @author Joe Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- * @since 1.5
- */
-
-public interface ConstructorDeclaration extends ExecutableDeclaration {
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/Declaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/Declaration.java
deleted file mode 100644
index 1fd3da3174..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/Declaration.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * @(#)Declaration.java 1.6 04/07/16
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-import java.lang.annotation.Annotation;
-import java.util.Collection;
-
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-/**
- * Represents the declaration of a program element such as a package,
- * class, or method. Each declaration represents a static, language-level
- * construct (and not, for example, a runtime construct of the virtual
- * machine), and typically corresponds one-to-one with a particular
- * fragment of source code.
- *
- * <p> Declarations should be compared using the {@link #equals(Object)}
- * method. There is no guarantee that any particular declaration will
- * always be represented by the same object.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.6 04/07/16
- *
- * @see Declarations
- * @see TypeMirror
- * @since 1.5
- */
-
-public interface Declaration {
-
- /**
- * Tests whether an object represents the same declaration as this.
- *
- * @param obj the object to be compared with this declaration
- * @return <tt>true</tt> if the specified object represents the same
- * declaration as this
- */
- boolean equals(Object obj);
-
- /**
- * Returns the text of the documentation ("javadoc") comment of
- * this declaration.
- *
- * @return the documentation comment of this declaration, or <tt>null</tt>
- * if there is none
- */
- String getDocComment();
-
- /**
- * Returns the annotations that are directly present on this declaration.
- *
- * @return the annotations directly present on this declaration;
- * an empty collection if there are none
- */
- Collection<AnnotationMirror> getAnnotationMirrors();
-
- /**
- * Returns the annotation of this declaration having the specified
- * type. The annotation may be either inherited or directly
- * present on this declaration.
- *
- * <p> The annotation returned by this method could contain an element
- * whose value is of type <tt>Class</tt>.
- * This value cannot be returned directly: information necessary to
- * locate and load a class (such as the class loader to use) is
- * not available, and the class might not be loadable at all.
- * Attempting to read a <tt>Class</tt> object by invoking the relevant
- * method on the returned annotation
- * will result in a {@link MirroredTypeException},
- * from which the corresponding {@link TypeMirror} may be extracted.
- * Similarly, attempting to read a <tt>Class[]</tt>-valued element
- * will result in a {@link MirroredTypesException}.
- *
- * <blockquote>
- * <i>Note:</i> This method is unlike
- * others in this and related interfaces. It operates on run-time
- * reflective information -- representations of annotation types
- * currently loaded into the VM -- rather than on the mirrored
- * representations defined by and used throughout these
- * interfaces. It is intended for callers that are written to
- * operate on a known, fixed set of annotation types.
- * </blockquote>
- *
- * @param <A> the annotation type
- * @param annotationType the <tt>Class</tt> object corresponding to
- * the annotation type
- * @return the annotation of this declaration having the specified type
- *
- * @see #getAnnotationMirrors()
- */
- <A extends Annotation> A getAnnotation(Class<A> annotationType);
-
- /**
- * Returns the modifiers of this declaration, excluding annotations.
- * Implicit modifiers, such as the <tt>public</tt> and <tt>static</tt>
- * modifiers of interface members, are included.
- *
- * @return the modifiers of this declaration in undefined order;
- * an empty collection if there are none
- */
- Collection<Modifier> getModifiers();
-
- /**
- * Returns the simple (unqualified) name of this declaration.
- * The name of a generic type does not include any reference
- * to its formal type parameters.
- * For example, the simple name of the interface declaration
- * {@code java.util.Set<E>} is <tt>"Set"</tt>.
- * If this declaration represents the empty package, an empty
- * string is returned.
- * If it represents a constructor, the simple name of its
- * declaring class is returned.
- *
- * @return the simple name of this declaration
- */
- String getSimpleName();
-
- /**
- * Returns the source position of the beginning of this declaration.
- * Returns <tt>null</tt> if the position is unknown or not applicable.
- *
- * <p> This source position is intended for use in providing
- * diagnostics, and indicates only approximately where a declaration
- * begins.
- *
- * @return the source position of the beginning of this declaration,
- * or null if the position is unknown or not applicable
- */
- SourcePosition getPosition();
-
- /**
- * Applies a visitor to this declaration.
- *
- * @param v the visitor operating on this declaration
- */
- void accept(DeclarationVisitor v);
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/EnumConstantDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/EnumConstantDeclaration.java
deleted file mode 100644
index 11dfe81b9a..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/EnumConstantDeclaration.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * @(#)EnumConstantDeclaration.java 1.2 04/03/09
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-/**
- * Represents an enum constant declaration.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.2 04/03/09
- * @since 1.5
- */
-
-public interface EnumConstantDeclaration extends FieldDeclaration {
- /**
- * {@inheritDoc}
- */
- EnumDeclaration getDeclaringType();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/EnumDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/EnumDeclaration.java
deleted file mode 100644
index 8cd4530f8c..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/EnumDeclaration.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * @(#)EnumDeclaration.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-import java.util.Collection;
-
-
-/**
- * Represents the declaration of an enum type.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- * @since 1.5
- */
-
-public interface EnumDeclaration extends ClassDeclaration {
-
- /**
- * Returns the enum constants defined for this enum.
- *
- * @return the enum constants defined for this enum,
- * or an empty collection if there are none
- */
- Collection<EnumConstantDeclaration> getEnumConstants();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ExecutableDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ExecutableDeclaration.java
deleted file mode 100644
index 02e3de863f..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ExecutableDeclaration.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * @(#)ExecutableDeclaration.java 1.2 04/03/08
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.type.ReferenceType;
-
-
-/**
- * Represents a method or constructor of a class or interface.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.2 04/03/08
- * @since 1.5
- */
-
-public interface ExecutableDeclaration extends MemberDeclaration {
-
- /**
- * Returns <tt>true</tt> if this method or constructor accepts a variable
- * number of arguments.
- *
- * @return <tt>true</tt> if this method or constructor accepts a variable
- * number of arguments
- */
- boolean isVarArgs();
-
- /**
- * Returns the formal type parameters of this method or constructor.
- * They are returned in declaration order.
- *
- * @return the formal type parameters of this method or constructor,
- * or an empty collection if there are none
- */
- Collection<TypeParameterDeclaration> getFormalTypeParameters();
-
- /**
- * Returns the formal parameters of this method or constructor.
- * They are returned in declaration order.
- *
- * @return the formal parameters of this method or constructor,
- * or an empty collection if there are none
- */
- Collection<ParameterDeclaration> getParameters();
-
- /**
- * Returns the exceptions and other throwables listed in this
- * method or constructor's <tt>throws</tt> clause.
- *
- * @return the exceptions and other throwables listed in the
- * <tt>throws</tt> clause, or an empty collection if there are none
- */
- Collection<ReferenceType> getThrownTypes();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/FieldDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/FieldDeclaration.java
deleted file mode 100644
index 1c248ad6f8..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/FieldDeclaration.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * @(#)FieldDeclaration.java 1.2 04/04/20
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-import com.sun.mirror.type.TypeMirror;
-
-
-/**
- * Represents a field of a type declaration.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.2 04/04/20
- * @since 1.5
- */
-
-public interface FieldDeclaration extends MemberDeclaration {
-
- /**
- * Returns the type of this field.
- *
- * @return the type of this field
- */
- TypeMirror getType();
-
- /**
- * Returns the value of this field if this field is a compile-time
- * constant. Returns <tt>null</tt> otherwise.
- * The value will be of a primitive type or <tt>String</tt>.
- * If the value is of a primitive type, it is wrapped in the
- * appropriate wrapper class (such as {@link Integer}).
- *
- * @return the value of this field if this field is a compile-time
- * constant, or <tt>null</tt> otherwise
- */
- Object getConstantValue();
-
- /**
- * Returns the text of a <i>constant expression</i> representing the
- * value of this field if this field is a compile-time constant.
- * Returns <tt>null</tt> otherwise.
- * The value will be of a primitive type or <tt>String</tt>.
- * The text returned is in a form suitable for representing the value
- * in source code.
- *
- * @return the text of a constant expression if this field is a
- * compile-time constant, or <tt>null</tt> otherwise
- */
- String getConstantExpression();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/InterfaceDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/InterfaceDeclaration.java
deleted file mode 100644
index c20b374d8d..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/InterfaceDeclaration.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * @(#)InterfaceDeclaration.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-import com.sun.mirror.type.InterfaceType;
-
-
-/**
- * Represents the declaration of an interface.
- * Provides access to information about the interface and its members.
- * Note that an {@linkplain AnnotationTypeDeclaration annotation type} is
- * a kind of interface.
- *
- * <p> While an <tt>InterfaceDeclaration</tt> represents the
- * <i>declaration</i> of an interface, an {@link InterfaceType}
- * represents an interface <i>type</i>.
- * See {@link TypeDeclaration} for more on this distinction.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- *
- * @see InterfaceType
- * @since 1.5
- */
-
-public interface InterfaceDeclaration extends TypeDeclaration {
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/MemberDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/MemberDeclaration.java
deleted file mode 100644
index 315a2da4d2..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/MemberDeclaration.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * @(#)MemberDeclaration.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-/**
- * Represents a declaration that may be a member or constructor of a declared
- * type. This includes fields, constructors, methods, and (since they
- * may be nested) declared types themselves.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- * @since 1.5
- */
-
-public interface MemberDeclaration extends Declaration {
-
- /**
- * Returns the type declaration within which this member or constructor
- * is declared.
- * If this is the declaration of a top-level type (a non-nested class
- * or interface), returns null.
- *
- * @return the type declaration within which this member or constructor
- * is declared, or null if there is none
- */
- TypeDeclaration getDeclaringType();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/MethodDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/MethodDeclaration.java
deleted file mode 100644
index 3303494f5e..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/MethodDeclaration.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * @(#)MethodDeclaration.java 1.2 04/04/20
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.type.VoidType;
-
-
-/**
- * Represents a method of a class or interface.
- * Note that an
- * {@linkplain AnnotationTypeElementDeclaration annotation type element}
- * is a kind of method.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.2 04/04/20
- * @since 1.5
- */
-
-public interface MethodDeclaration extends ExecutableDeclaration {
-
- /**
- * Returns the formal return type of this method.
- * Returns {@link VoidType} if this method does not return a value.
- *
- * @return the formal return type of this method
- */
- TypeMirror getReturnType();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/Modifier.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/Modifier.java
deleted file mode 100644
index 424e444ec4..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/Modifier.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * @(#)Modifier.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-/**
- * Represents a modifier on the declaration of a program element such
- * as a class, method, or field.
- *
- * <p> Not all modifiers are applicable to all kinds of declarations.
- * When two or more modifiers appear in the source code of a declaration,
- * then it is customary, though not required, that they appear in the same
- * order as the constants listed in the detail section below.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/25
- * @since 1.5
- */
-
-public enum Modifier {
-
- // See JLS2 sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1.
- // java.lang.reflect.Modifier includes INTERFACE, but that's a VMism.
-
- /** The modifier <tt>public</tt> */ PUBLIC,
- /** The modifier <tt>protected</tt> */ PROTECTED,
- /** The modifier <tt>private</tt> */ PRIVATE,
- /** The modifier <tt>abstract</tt> */ ABSTRACT,
- /** The modifier <tt>static</tt> */ STATIC,
- /** The modifier <tt>final</tt> */ FINAL,
- /** The modifier <tt>transient</tt> */ TRANSIENT,
- /** The modifier <tt>volatile</tt> */ VOLATILE,
- /** The modifier <tt>synchronized</tt> */ SYNCHRONIZED,
- /** The modifier <tt>native</tt> */ NATIVE,
- /** The modifier <tt>strictfp</tt> */ STRICTFP;
-
-
- private String lowercase = null; // modifier name in lowercase
-
- /**
- * Returns this modifier's name in lowercase.
- */
- public String toString() {
- if (lowercase == null) {
- lowercase = name().toLowerCase(java.util.Locale.US);
- }
- return lowercase;
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/PackageDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/PackageDeclaration.java
deleted file mode 100644
index 67460b34da..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/PackageDeclaration.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * @(#)PackageDeclaration.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-import java.util.Collection;
-
-
-/**
- * Represents the declaration of a package. Provides access to information
- * about the package and its members.
- *
- * <p> {@link com.sun.mirror.util.DeclarationFilter}
- * provides a simple way to select just the items of interest
- * when a method returns a collection of declarations.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- * @since 1.5
- */
-
-public interface PackageDeclaration extends Declaration {
-
- /**
- * Returns the fully qualified name of this package.
- * This is also known as the package's <i>canonical</i> name.
- *
- * @return the fully qualified name of this package, or the
- * empty string if this is the unnamed package
- */
- String getQualifiedName();
-
- /**
- * Returns the declarations of the top-level classes in this package.
- * Interfaces are not included, but enum types are.
- *
- * @return the declarations of the top-level classes in this package
- *
- * @see com.sun.mirror.util.DeclarationFilter
- */
- Collection<ClassDeclaration> getClasses();
-
- /**
- * Returns the declarations of the top-level enum types in this package.
- *
- * @return the declarations of the top-level enum types in this package
- *
- * @see com.sun.mirror.util.DeclarationFilter
- */
- Collection<EnumDeclaration> getEnums();
-
- /**
- * Returns the declarations of the top-level interfaces in this package.
- * Annotation types are included.
- *
- * @return the declarations of the top-level interfaces in this package
- *
- * @see com.sun.mirror.util.DeclarationFilter
- */
- Collection<InterfaceDeclaration> getInterfaces();
-
- /**
- * Returns the declarations of the top-level annotation types in this
- * package.
- *
- * @return the declarations of the top-level annotation types in this
- * package
- *
- * @see com.sun.mirror.util.DeclarationFilter
- */
- Collection<AnnotationTypeDeclaration> getAnnotationTypes();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ParameterDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ParameterDeclaration.java
deleted file mode 100644
index 56d84be9d8..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/ParameterDeclaration.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * @(#)ParameterDeclaration.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-import com.sun.mirror.type.TypeMirror;
-
-
-/**
- * Represents a formal parameter of a method or constructor.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- * @since 1.5
- */
-
-public interface ParameterDeclaration extends Declaration {
-
- /**
- * Returns the type of this parameter.
- *
- * @return the type of this parameter
- */
- TypeMirror getType();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/TypeDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/TypeDeclaration.java
deleted file mode 100644
index 24db97e939..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/TypeDeclaration.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * @(#)TypeDeclaration.java 1.4 04/04/30
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.type.*;
-
-
-/**
- * Represents the declaration of a class or interface.
- * Provides access to information about the type and its members.
- * Note that an {@linkplain EnumDeclaration enum} is a kind of class,
- * and an {@linkplain AnnotationTypeDeclaration annotation type} is
- * a kind of interface.
- *
- * <p> <a name="DECL_VS_TYPE"></a>
- * While a <tt>TypeDeclaration</tt> represents the <i>declaration</i>
- * of a class or interface, a {@link DeclaredType} represents a class
- * or interface <i>type</i>, the latter being a use
- * (or <i>invocation</i>) of the former.
- * The distinction is most apparent with generic types,
- * for which a single declaration can define a whole
- * family of types. For example, the declaration of
- * {@code java.util.Set} corresponds to the parameterized types
- * {@code java.util.Set<String>} and {@code java.util.Set<Number>}
- * (and many others), and to the raw type {@code java.util.Set}.
- *
- * <p> {@link com.sun.mirror.util.DeclarationFilter}
- * provides a simple way to select just the items of interest
- * when a method returns a collection of declarations.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.4 04/04/30
- *
- * @see DeclaredType
- * @since 1.5
- */
-
-public interface TypeDeclaration extends MemberDeclaration {
-
- /**
- * Returns the package within which this type is declared.
- *
- * @return the package within which this type is declared
- */
- PackageDeclaration getPackage();
-
- /**
- * Returns the fully qualified name of this class or interface
- * declaration. More precisely, it returns the <i>canonical</i>
- * name.
- * The name of a generic type does not include any reference
- * to its formal type parameters.
- * For example, the the fully qualified name of the interface declaration
- * {@code java.util.Set<E>} is <tt>"java.util.Set"</tt>.
- *
- * @return the fully qualified name of this class or interface declaration
- */
- String getQualifiedName();
-
- /**
- * Returns the formal type parameters of this class or interface.
- *
- * @return the formal type parameters, or an empty collection
- * if there are none
- */
- Collection<TypeParameterDeclaration> getFormalTypeParameters();
-
- /**
- * Returns the interface types directly implemented by this class
- * or extended by this interface.
- *
- * @return the interface types directly implemented by this class
- * or extended by this interface, or an empty collection if there are none
- *
- * @see com.sun.mirror.util.DeclarationFilter
- */
- Collection<InterfaceType> getSuperinterfaces();
-
- /**
- * Returns the fields that are directly declared by this class or
- * interface. Includes enum constants.
- *
- * @return the fields that are directly declared,
- * or an empty collection if there are none
- *
- * @see com.sun.mirror.util.DeclarationFilter
- */
- Collection<FieldDeclaration> getFields();
-
- /**
- * Returns the methods that are directly declared by this class or
- * interface. Includes annotation type elements. Excludes
- * implicitly declared methods of an interface, such as
- * <tt>toString</tt>, that correspond to the methods of
- * <tt>java.lang.Object</tt>.
- *
- * @return the methods that are directly declared,
- * or an empty collection if there are none
- *
- * @see com.sun.mirror.util.DeclarationFilter
- */
- Collection<? extends MethodDeclaration> getMethods();
-
- /**
- * Returns the declarations of the nested classes and interfaces
- * that are directly declared by this class or interface.
- *
- * @return the declarations of the nested classes and interfaces,
- * or an empty collection if there are none
- *
- * @see com.sun.mirror.util.DeclarationFilter
- */
- Collection<TypeDeclaration> getNestedTypes();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/TypeParameterDeclaration.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/TypeParameterDeclaration.java
deleted file mode 100644
index 9feb0cd216..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/TypeParameterDeclaration.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * @(#)TypeParameterDeclaration.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.declaration;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.type.*;
-
-
-/**
- * Represents a formal type parameter of a generic type, method,
- * or constructor declaration.
- * A type parameter declares a {@link TypeVariable}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- * @since 1.5
- */
-
-public interface TypeParameterDeclaration extends Declaration {
-
- /**
- * Returns the bounds of this type parameter.
- * These are the types given by the <i>extends</i> clause.
- * If there is no explicit <i>extends</i> clause, then
- * <tt>java.lang.Object</tt> is considered to be the sole bound.
- *
- * @return the bounds of this type parameter
- */
- Collection<ReferenceType> getBounds();
-
- /**
- * Returns the type, method, or constructor declaration within which
- * this type parameter is declared.
- *
- * @return the declaration within which this type parameter is declared
- */
- Declaration getOwner();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/package.html b/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/package.html
deleted file mode 100644
index c4950baf33..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/declaration/package.html
+++ /dev/null
@@ -1,49 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<!--
- @(#)package.html 1.3 04/07/26
- Copyright (c) 2004, Sun Microsystems, Inc.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the Sun Microsystems, Inc. nor the names of
- its contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-</head>
-<body bgcolor="white">
-
-Interfaces used to model program element declarations.
-A declaration is represented by the appropriate subinterface of
-{@link com.sun.mirror.declaration.Declaration},
-and an annotation is represented as an
-{@link com.sun.mirror.declaration.AnnotationMirror}.
-
-<p>Note that the <code>apt</code> tool and its associated APIs may be
-changed or superseded in future j2se releases.
-
-@since 1.5
-</body>
-</html>
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/AnnotationType.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/AnnotationType.java
deleted file mode 100644
index c4e2a0ac4b..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/AnnotationType.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * @(#)AnnotationType.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.type;
-
-
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-
-/**
- * Represents an annotation type.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- * @since 1.5
- */
-
-public interface AnnotationType extends InterfaceType {
-
- /**
- * {@inheritDoc}
- */
- AnnotationTypeDeclaration getDeclaration();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/ArrayType.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/ArrayType.java
deleted file mode 100644
index b41a9b0ace..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/ArrayType.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * @(#)ArrayType.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.type;
-
-
-/**
- * Represents an array type.
- * A multidimensional array type is represented as an array type
- * whose component type is also an array type.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- * @since 1.5
- */
-
-public interface ArrayType extends ReferenceType {
-
- /**
- * Returns the component type of this array type.
- *
- * @return the component type of this array type
- */
- TypeMirror getComponentType();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/ClassType.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/ClassType.java
deleted file mode 100644
index 98297c5ef4..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/ClassType.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * @(#)ClassType.java 1.2 04/04/30
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.type;
-
-
-import com.sun.mirror.declaration.*;
-
-
-/**
- * Represents a class type.
- * Interface types are represented separately by {@link InterfaceType}.
- * Note that an {@linkplain EnumType enum} is a kind of class.
- *
- * <p> While a {@link ClassDeclaration} represents the <i>declaration</i>
- * of a class, a <tt>ClassType</tt> represents a class <i>type</i>.
- * See {@link TypeDeclaration} for more on this distinction.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.2 04/04/30
- * @since 1.5
- */
-
-public interface ClassType extends DeclaredType {
-
- /**
- * {@inheritDoc}
- */
- ClassDeclaration getDeclaration();
-
- /**
- * Returns the class type that is a direct supertype of this one.
- * This is the superclass of this type's declaring class, with any
- * type arguments substituted in.
- * The only class with no superclass is <tt>java.lang.Object</tt>,
- * for which this method returns <tt>null</tt>.
- *
- * <p> For example, the class type extended by
- * {@code java.util.TreeSet<String>} is
- * {@code java.util.AbstractSet<String>}.
- *
- * @return the class type that is a direct supertype of this one,
- * or <tt>null</tt> if there is none
- */
- ClassType getSuperclass();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/DeclaredType.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/DeclaredType.java
deleted file mode 100644
index 7ebff111b6..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/DeclaredType.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * @(#)DeclaredType.java 1.6 04/06/07
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.type;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.declaration.TypeDeclaration;
-
-
-/**
- * Represents a declared type, either a class type or an interface type.
- * This includes parameterized types such as {@code java.util.Set<String>}
- * as well as raw types.
- *
- * <p> While a <tt>TypeDeclaration</tt> represents the <i>declaration</i>
- * of a class or interface, a <tt>DeclaredType</tt> represents a class
- * or interface <i>type</i>, the latter being a use of the former.
- * See {@link TypeDeclaration} for more on this distinction.
- *
- * <p> A <tt>DeclaredType</tt> may represent a type
- * for which details (declaration, supertypes, <i>etc.</i>) are unknown.
- * This may be the result of a processing error, such as a missing class file,
- * and is indicated by {@link #getDeclaration()} returning <tt>null</tt>.
- * Other method invocations on such an unknown type will not, in general,
- * return meaningful results.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.6 04/06/07
- * @since 1.5
- */
-
-public interface DeclaredType extends ReferenceType {
-
- /**
- * Returns the declaration of this type.
- *
- * <p> Returns null if this type's declaration is unknown. This may
- * be the result of a processing error, such as a missing class file.
- *
- * @return the declaration of this type, or null if unknown
- */
- TypeDeclaration getDeclaration();
-
- /**
- * Returns the type that contains this type as a member.
- * Returns <tt>null</tt> if this is a top-level type.
- *
- * <p> For example, the containing type of {@code O.I<S>}
- * is the type {@code O}, and the containing type of
- * {@code O<T>.I<S>} is the type {@code O<T>}.
- *
- * @return the type that contains this type,
- * or <tt>null</tt> if this is a top-level type
- */
- DeclaredType getContainingType();
-
- /**
- * Returns (in order) the actual type arguments of this type.
- * For a generic type nested within another generic type
- * (such as {@code Outer<String>.Inner<Number>}), only the type
- * arguments of the innermost type are included.
- *
- * @return the actual type arguments of this type, or an empty collection
- * if there are none
- */
- Collection<TypeMirror> getActualTypeArguments();
-
- /**
- * Returns the interface types that are direct supertypes of this type.
- * These are the interface types implemented or extended
- * by this type's declaration, with any type arguments
- * substituted in.
- *
- * <p> For example, the interface type extended by
- * {@code java.util.Set<String>} is {@code java.util.Collection<String>}.
- *
- * @return the interface types that are direct supertypes of this type,
- * or an empty collection if there are none
- */
- Collection<InterfaceType> getSuperinterfaces();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/EnumType.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/EnumType.java
deleted file mode 100644
index 86cd28a073..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/EnumType.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * @(#)EnumType.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.type;
-
-
-import com.sun.mirror.declaration.EnumDeclaration;
-
-
-/**
- * Represents an enum type.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- * @since 1.5
- */
-
-public interface EnumType extends ClassType {
-
- /**
- * {@inheritDoc}
- */
- EnumDeclaration getDeclaration();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/InterfaceType.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/InterfaceType.java
deleted file mode 100644
index 671d9f3b53..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/InterfaceType.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * @(#)InterfaceType.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.type;
-
-
-import com.sun.mirror.declaration.*;
-
-
-/**
- * Represents an interface type.
- * Note that an {@linkplain AnnotationType annotation type} is
- * a kind of interface.
- *
- * <p> While an {@link InterfaceDeclaration} represents the
- * <i>declaration</i> of an interface, an <tt>InterfaceType</tt>
- * represents an interface <i>type</i>.
- * See {@link TypeDeclaration} for more on this distinction.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- * @since 1.5
- */
-
-public interface InterfaceType extends DeclaredType {
-
- /**
- * {@inheritDoc}
- */
- InterfaceDeclaration getDeclaration();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/MirroredTypeException.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/MirroredTypeException.java
deleted file mode 100644
index 2c59980671..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/MirroredTypeException.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * @(#)MirroredTypeException.java 1.1 04/04/20
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.type;
-
-
-import com.sun.mirror.declaration.Declaration;
-
-
-/**
- * Thrown when an application attempts to access the {@link Class} object
- * corresponding to a {@link TypeMirror}.
- *
- * @see MirroredTypesException
- * @see Declaration#getAnnotation(Class)
- */
-public class MirroredTypeException extends RuntimeException {
-
- private static final long serialVersionUID = 1;
-
- private transient TypeMirror type; // cannot be serialized
- private String name; // type's qualified "name"
-
- /**
- * Constructs a new MirroredTypeException for the specified type.
- *
- * @param type the type being accessed
- */
- public MirroredTypeException(TypeMirror type) {
- super("Attempt to access Class object for TypeMirror " + type); //$NON-NLS-1$
- this.type = type;
- name = type.toString();
- }
-
- /**
- * Returns the type mirror corresponding to the type being accessed.
- * The type mirror may be unavailable if this exception has been
- * serialized and then read back in.
- *
- * @return the type mirror, or <tt>null</tt> if unavailable
- */
- public TypeMirror getTypeMirror() {
- return type;
- }
-
- /**
- * Returns the fully qualified name of the type being accessed.
- * More precisely, returns the canonical name of a class,
- * interface, array, or primitive, and returns <tt>"void"</tt> for
- * the pseudo-type representing the type of <tt>void</tt>.
- *
- * @return the fully qualified name of the type being accessed
- */
- public String getQualifiedName() {
- return name;
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/MirroredTypesException.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/MirroredTypesException.java
deleted file mode 100644
index 104211a7ba..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/MirroredTypesException.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * @(#)MirroredTypesException.java 1.1 04/04/20
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.type;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-import com.sun.mirror.declaration.Declaration;
-
-
-/**
- * Thrown when an application attempts to access a sequence of {@link Class}
- * objects each corresponding to a {@link TypeMirror}.
- *
- * @see MirroredTypeException
- * @see Declaration#getAnnotation(Class)
- */
-public class MirroredTypesException extends RuntimeException {
-
- private static final long serialVersionUID = 1;
-
- private transient Collection<TypeMirror> types; // cannot be serialized
- private Collection<String> names; // types' qualified "names"
-
- /**
- * Constructs a new MirroredTypesException for the specified types.
- *
- * @param types an ordered collection of the types being accessed
- */
- public MirroredTypesException(Collection<TypeMirror> types) {
- super("Attempt to access Class objects for TypeMirrors " + types); //$NON-NLS-1$
- this.types = types;
- names = new ArrayList<String>();
- for (TypeMirror t : types) {
- names.add(t.toString());
- }
- }
-
- /**
- * Returns the type mirrors corresponding to the types being accessed.
- * The type mirrors may be unavailable if this exception has been
- * serialized and then read back in.
- *
- * @return the type mirrors in order, or <tt>null</tt> if unavailable
- */
- public Collection<TypeMirror> getTypeMirrors() {
- return (types != null)
- ? Collections.unmodifiableCollection(types)
- : null;
- }
-
- /**
- * Returns the fully qualified names of the types being accessed.
- * More precisely, returns the canonical names of each class,
- * interface, array, or primitive, and <tt>"void"</tt> for
- * the pseudo-type representing the type of <tt>void</tt>.
- *
- * @return the fully qualified names, in order, of the types being
- * accessed
- */
- public Collection<String> getQualifiedNames() {
- return Collections.unmodifiableCollection(names);
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/PrimitiveType.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/PrimitiveType.java
deleted file mode 100644
index 645aef3991..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/PrimitiveType.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * @(#)PrimitiveType.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.type;
-
-
-/**
- * Represents a primitive type. These include
- * <tt>boolean</tt>, <tt>byte</tt>, <tt>short</tt>, <tt>int</tt>,
- * <tt>long</tt>, <tt>char</tt>, <tt>float</tt>, and <tt>double</tt>.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- * @since 1.5
- */
-
-public interface PrimitiveType extends TypeMirror {
-
- /**
- * Returns the kind of primitive type that this object represents.
- *
- * @return the kind of primitive type that this object represents
- */
- Kind getKind();
-
- /**
- * An enumeration of the different kinds of primitive types.
- */
- enum Kind {
- /** The primitive type <tt>boolean</tt> */ BOOLEAN,
- /** The primitive type <tt>byte</tt> */ BYTE,
- /** The primitive type <tt>short</tt> */ SHORT,
- /** The primitive type <tt>int</tt> */ INT,
- /** The primitive type <tt>long</tt> */ LONG,
- /** The primitive type <tt>char</tt> */ CHAR,
- /** The primitive type <tt>float</tt> */ FLOAT,
- /** The primitive type <tt>double</tt> */ DOUBLE
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/ReferenceType.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/ReferenceType.java
deleted file mode 100644
index 3dca8c305a..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/ReferenceType.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * @(#)ReferenceType.java 1.2 04/06/07
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.type;
-
-
-/**
- * Represents a reference type.
- * These include class and interface types, array types, and type variables.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.2 04/06/07
- * @since 1.5
- */
-
-public interface ReferenceType extends TypeMirror {
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/TypeMirror.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/TypeMirror.java
deleted file mode 100644
index 1f9b8d6d70..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/TypeMirror.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * @(#)TypeMirror.java 1.3 04/07/16
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.type;
-
-
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.util.Types;
-import com.sun.mirror.util.TypeVisitor;
-
-
-/**
- * Represents a type in the Java programming language.
- * Types include primitive types, class and interface types, array
- * types, and type variables. Wildcard type arguments, and the
- * pseudo-type representing the type of <tt>void</tt>, are represented
- * by type mirrors as well.
- *
- * <p> Types may be compared using the utility methods in
- * {@link Types}.
- * There is no guarantee that any particular type will
- * always be represented by the same object.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.3 04/07/16
- *
- * @see Declaration
- * @see Types
- * @since 1.5
- */
-
-public interface TypeMirror {
-
- /**
- * Returns a string representation of this type.
- * Any names embedded in the expression are qualified.
- *
- * @return a string representation of this type
- */
- String toString();
-
- /**
- * Tests whether two types represent the same type.
- *
- * @param obj the object to be compared with this type
- * @return <tt>true</tt> if the specified object represents the same
- * type as this.
- */
- boolean equals(Object obj);
-
- /**
- * Applies a visitor to this type.
- *
- * @param v the visitor operating on this type
- */
- void accept(TypeVisitor v);
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/TypeVariable.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/TypeVariable.java
deleted file mode 100644
index dd83c2d7a3..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/TypeVariable.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * @(#)TypeVariable.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.type;
-
-
-import com.sun.mirror.declaration.*;
-
-
-/**
- * Represents a type variable.
- * A type variable is declared by a
- * {@linkplain TypeParameterDeclaration type parameter} of a
- * type, method, or constructor.
- *
- * @author Joe Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- * @since 1.5
- */
-
-public interface TypeVariable extends ReferenceType {
-
- /**
- * Returns the type parameter that declared this type variable.
- *
- * @return the type parameter that declared this type variable
- */
- TypeParameterDeclaration getDeclaration();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/VoidType.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/VoidType.java
deleted file mode 100644
index 005ba5f0b7..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/VoidType.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * @(#)VoidType.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.type;
-
-
-import com.sun.mirror.declaration.MethodDeclaration;
-
-
-/**
- * A pseudo-type representing the type of <tt>void</tt>.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- *
- * @see MethodDeclaration#getReturnType()
- * @since 1.5
- */
-
-public interface VoidType extends TypeMirror {
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/WildcardType.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/WildcardType.java
deleted file mode 100644
index 2d47000a92..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/WildcardType.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * @(#)WildcardType.java 1.5 04/06/07
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.type;
-
-
-import java.util.Collection;
-
-
-/**
- * Represents a wildcard type argument.
- * Examples include: <pre><tt>
- * ?
- * ? extends Number
- * ? super T
- * </tt></pre>
- *
- * <p> A wildcard may have its upper bound explicitly set by an
- * <tt>extends</tt> clause, its lower bound explicitly set by a
- * <tt>super</tt> clause, or neither (but not both).
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.5 04/06/07
- * @since 1.5
- */
-
-public interface WildcardType extends TypeMirror {
-
- /**
- * Returns the upper bounds of this wildcard.
- * If no upper bound is explicitly declared, then
- * an empty collection is returned.
- *
- * @return the upper bounds of this wildcard
- */
- Collection<ReferenceType> getUpperBounds();
-
- /**
- * Returns the lower bounds of this wildcard.
- * If no lower bound is explicitly declared, then
- * an empty collection is returned.
- *
- * @return the lower bounds of this wildcard
- */
- Collection<ReferenceType> getLowerBounds();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/package.html b/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/package.html
deleted file mode 100644
index c036862106..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/type/package.html
+++ /dev/null
@@ -1,47 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<!--
- @(#)package.html 1.3 04/07/26
- Copyright (c) 2004, Sun Microsystems, Inc.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the Sun Microsystems, Inc. nor the names of
- its contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-</head>
-<body bgcolor="white">
-
-Interfaces used to model types.
-A type is represented by the appropriate subinterface of
-{@link com.sun.mirror.type.TypeMirror}.
-
-<p>Note that the <code>apt</code> tool and its associated APIs may be
-changed or superseded in future j2se releases.
-
-@since 1.5
-</body>
-</html>
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationFilter.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationFilter.java
deleted file mode 100644
index 1daf7f993b..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationFilter.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * @(#)DeclarationFilter.java 1.2 04/07/19
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.util;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.Modifier;
-
-import static com.sun.mirror.declaration.Modifier.*;
-
-
-/**
- * A filter for selecting just the items of interest
- * from a collection of declarations.
- * The filter is said to <i>select</i> or to <i>match</i> those declarations.
- * Filters can be created in several ways:
- * by the static methods described below,
- * by negating or composing existing filters,
- * or by subclasses that implement arbitrary matching rules.
- *
- * <p> A subclass can create an arbitrary filter simply by implementing
- * the {@link #matches(Declaration)} method.
- *
- * <p> Examples.
- * <p> Selecting the <tt>public</tt> declarations from a collection:
- * <blockquote><pre>
- * result = FILTER_PUBLIC.filter(decls); </pre></blockquote>
- * Selecting class declarations (including enums):
- * <blockquote><pre>
- * classFilter = DeclarationFilter.getFilter(ClassDeclaration.class);
- * result = classFilter.filter(decls); </pre></blockquote>
- * Selecting class declarations but excluding enums:
- * <blockquote><pre>
- * enumFilter = DeclarationFilter.getFilter(EnumDeclaration.class);
- * compoundFilter = classFilter.and(enumFilter.not());
- * result = compoundFilter.filter(decls); </pre></blockquote>
- * Selecting declarations named "Bob":
- * <blockquote><pre>
- * nameFilter = new DeclarationFilter() {
- * public boolean matches(Declaration d) {
- * return d.getSimpleName().equals("Bob");
- * }
- * };
- * result = nameFilter.filter(decls); </pre></blockquote>
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.2 04/07/19
- * @since 1.5
- */
-
-public class DeclarationFilter {
-
- // Predefined filters for convenience.
-
- /**
- * A filter that selects only <tt>public</tt> declarations.
- */
- public static final DeclarationFilter FILTER_PUBLIC =
- new AccessFilter(PUBLIC);
-
- /**
- * A filter that selects only <tt>protected</tt> declarations.
- */
- public static final DeclarationFilter FILTER_PROTECTED =
- new AccessFilter(PROTECTED);
-
- /**
- * A filter that selects only <tt>public</tt> or <tt>protected</tt>
- * declarations.
- */
- public static final DeclarationFilter FILTER_PUBLIC_OR_PROTECTED =
- new AccessFilter(PUBLIC, PROTECTED);
-
- /**
- * A filter that selects only package-private (<i>default</i>)
- * declarations.
- */
- public static final DeclarationFilter FILTER_PACKAGE =
- new AccessFilter();
-
- /**
- * A filter that selects only <tt>private</tt> declarations.
- */
- public static final DeclarationFilter FILTER_PRIVATE =
- new AccessFilter(PRIVATE);
-
-
- /**
- * Constructs an identity filter: one that selects all declarations.
- */
- public DeclarationFilter() {
- }
-
-
-
- // Methods to create a filter.
-
- /**
- * Returns a filter that selects declarations containing all of a
- * collection of modifiers.
- *
- * @param mods the modifiers to match (non-null)
- * @return a filter that matches declarations containing <tt>mods</tt>
- */
- public static DeclarationFilter getFilter(
- final Collection<Modifier> mods) {
- return new DeclarationFilter() {
- public boolean matches(Declaration d) {
- return d.getModifiers().containsAll(mods);
- }
- };
- }
-
- /**
- * Returns a filter that selects declarations of a particular kind.
- * For example, there may be a filter that selects only class
- * declarations, or only fields.
- * The filter will select declarations of the specified kind,
- * and also any subtypes of that kind; for example, a field filter
- * will also select enum constants.
- *
- * @param kind the kind of declarations to select
- * @return a filter that selects declarations of a particular kind
- */
- public static DeclarationFilter getFilter(
- final Class<? extends Declaration> kind) {
- return new DeclarationFilter() {
- public boolean matches(Declaration d) {
- return kind.isInstance(d);
- }
- };
- }
-
- /**
- * Returns a filter that selects those declarations selected
- * by both this filter and another.
- *
- * @param f filter to be composed with this one
- * @return a filter that selects those declarations selected by
- * both this filter and another
- */
- public DeclarationFilter and(DeclarationFilter f) {
- final DeclarationFilter f1 = this;
- final DeclarationFilter f2 = f;
- return new DeclarationFilter() {
- public boolean matches(Declaration d) {
- return f1.matches(d) && f2.matches(d);
- }
- };
- }
-
- /**
- * Returns a filter that selects those declarations selected
- * by either this filter or another.
- *
- * @param f filter to be composed with this one
- * @return a filter that selects those declarations selected by
- * either this filter or another
- */
- public DeclarationFilter or(DeclarationFilter f) {
- final DeclarationFilter f1 = this;
- final DeclarationFilter f2 = f;
- return new DeclarationFilter() {
- public boolean matches(Declaration d) {
- return f1.matches(d) || f2.matches(d);
- }
- };
- }
-
- /**
- * Returns a filter that selects those declarations not selected
- * by this filter.
- *
- * @return a filter that selects those declarations not selected
- * by this filter
- */
- public DeclarationFilter not() {
- return new DeclarationFilter() {
- public boolean matches(Declaration d) {
- return !DeclarationFilter.this.matches(d);
- }
- };
- }
-
-
-
- // Methods to apply a filter.
-
- /**
- * Tests whether this filter matches a given declaration.
- * The default implementation always returns <tt>true</tt>;
- * subclasses should override this.
- *
- * @param decl the declaration to match
- * @return <tt>true</tt> if this filter matches the given declaration
- */
- public boolean matches(Declaration decl) {
- return true;
- }
-
- /**
- * Returns the declarations matched by this filter.
- * The result is a collection of the same type as the argument;
- * the {@linkplain #filter(Collection, Class) two-parameter version}
- * of <tt>filter</tt> offers control over the result type.
- *
- * @param <D> type of the declarations being filtered
- * @param decls declarations being filtered
- * @return the declarations matched by this filter
- */
- public <D extends Declaration> Collection<D> filter(Collection<D> decls) {
- ArrayList<D> res = new ArrayList<D>(decls.size());
- for (D d : decls) {
- if (matches(d)) {
- res.add(d);
- }
- }
- return res;
- }
-
- /**
- * Returns the declarations matched by this filter, with the result
- * being restricted to declarations of a given kind.
- * Similar to the simpler
- * {@linkplain #filter(Collection) single-parameter version}
- * of <tt>filter</tt>, but the result type is specified explicitly.
- *
- * @param <D> type of the declarations being returned
- * @param decls declarations being filtered
- * @param resType type of the declarations being returned --
- * the reflective view of <tt>D</tt>
- * @return the declarations matched by this filter, restricted to those
- * of the specified type
- */
- public <D extends Declaration> Collection<D>
- filter(Collection<? extends Declaration> decls, Class<D> resType) {
- ArrayList<D> res = new ArrayList<D>(decls.size());
- for (Declaration d : decls) {
- if (resType.isInstance(d) && matches(d)) {
- res.add(resType.cast(d));
- }
- }
- return res;
- }
-
-
-
- /*
- * A filter based on access modifiers.
- */
- private static class AccessFilter extends DeclarationFilter {
-
- // The first access modifier to filter on, or null if we're looking
- // for declarations with no access modifiers.
- private Modifier mod1 = null;
-
- // The second access modifier to filter on, or null if none.
- private Modifier mod2 = null;
-
- // Returns a filter that matches declarations with no access
- // modifiers.
- AccessFilter() {
- }
-
- // Returns a filter that matches m.
- AccessFilter(Modifier m) {
- mod1 = m;
- }
-
- // Returns a filter that matches either m1 or m2.
- AccessFilter(Modifier m1, Modifier m2) {
- mod1 = m1;
- mod2 = m2;
- }
-
- public boolean matches(Declaration d) {
- Collection<Modifier> mods = d.getModifiers();
- if (mod1 == null) { // looking for package private
- return !(mods.contains(PUBLIC) ||
- mods.contains(PROTECTED) ||
- mods.contains(PRIVATE));
- }
- return mods.contains(mod1) &&
- (mod2 == null || mods.contains(mod2));
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationScanner.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationScanner.java
deleted file mode 100644
index eee999e25b..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationScanner.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * @(#)DeclarationScanner.java 1.5 04/04/20
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.util;
-
-import com.sun.mirror.declaration.*;
-
-/**
- * A visitor for declarations that scans declarations contained within
- * the given declaration. For example, when visiting a class, the
- * methods, fields, constructors, and nested types of the class are
- * also visited.
- *
- * <p> To control the processing done on a declaration, users of this
- * class pass in their own visitors for pre and post processing. The
- * preprocessing visitor is called before the contained declarations
- * are scanned; the postprocessing visitor is called after the
- * contained declarations are scanned.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.5 04/04/20
- * @since 1.5
- */
-
-class DeclarationScanner implements DeclarationVisitor {
- protected DeclarationVisitor pre;
- protected DeclarationVisitor post;
-
- DeclarationScanner(DeclarationVisitor pre, DeclarationVisitor post) {
- this.pre = pre;
- this.post = post;
- }
-
- /**
- * Visits a declaration.
- *
- * @param d the declaration to visit
- */
- public void visitDeclaration(Declaration d) {
- d.accept(pre);
- d.accept(post);
- }
-
- /**
- * Visits a package declaration.
- *
- * @param d the declaration to visit
- */
- public void visitPackageDeclaration(PackageDeclaration d) {
- d.accept(pre);
-
- for(ClassDeclaration classDecl: d.getClasses()) {
- classDecl.accept(this);
- }
-
- for(InterfaceDeclaration interfaceDecl: d.getInterfaces()) {
- interfaceDecl.accept(this);
- }
-
- d.accept(post);
- }
-
- /**
- * Visits a member or constructor declaration.
- *
- * @param d the declaration to visit
- */
- public void visitMemberDeclaration(MemberDeclaration d) {
- visitDeclaration(d);
- }
-
- /**
- * Visits a type declaration.
- *
- * @param d the declaration to visit
- */
- public void visitTypeDeclaration(TypeDeclaration d) {
- d.accept(pre);
-
- for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
- tpDecl.accept(this);
- }
-
- for(FieldDeclaration fieldDecl: d.getFields()) {
- fieldDecl.accept(this);
- }
-
- for(MethodDeclaration methodDecl: d.getMethods()) {
- methodDecl.accept(this);
- }
-
- for(TypeDeclaration typeDecl: d.getNestedTypes()) {
- typeDecl.accept(this);
- }
-
- d.accept(post);
- }
-
- /**
- * Visits a class declaration.
- *
- * @param d the declaration to visit
- */
- public void visitClassDeclaration(ClassDeclaration d) {
- d.accept(pre);
-
- for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
- tpDecl.accept(this);
- }
-
- for(FieldDeclaration fieldDecl: d.getFields()) {
- fieldDecl.accept(this);
- }
-
- for(MethodDeclaration methodDecl: d.getMethods()) {
- methodDecl.accept(this);
- }
-
- for(TypeDeclaration typeDecl: d.getNestedTypes()) {
- typeDecl.accept(this);
- }
-
- for(ConstructorDeclaration ctorDecl: d.getConstructors()) {
- ctorDecl.accept(this);
- }
-
- d.accept(post);
- }
-
- /**
- * Visits an enum declaration.
- *
- * @param d the declaration to visit
- */
- public void visitEnumDeclaration(EnumDeclaration d) {
- visitClassDeclaration(d);
- }
-
- /**
- * Visits an interface declaration.
- *
- * @param d the declaration to visit
- */
- public void visitInterfaceDeclaration(InterfaceDeclaration d) {
- visitTypeDeclaration(d);
- }
-
- /**
- * Visits an annotation type declaration.
- *
- * @param d the declaration to visit
- */
- public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {
- visitInterfaceDeclaration(d);
- }
-
- /**
- * Visits a field declaration.
- *
- * @param d the declaration to visit
- */
- public void visitFieldDeclaration(FieldDeclaration d) {
- visitMemberDeclaration(d);
- }
-
- /**
- * Visits an enum constant declaration.
- *
- * @param d the declaration to visit
- */
- public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {
- visitFieldDeclaration(d);
- }
-
- /**
- * Visits a method or constructor declaration.
- *
- * @param d the declaration to visit
- */
- public void visitExecutableDeclaration(ExecutableDeclaration d) {
- d.accept(pre);
-
- for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
- tpDecl.accept(this);
- }
-
- for(ParameterDeclaration pDecl: d.getParameters()) {
- pDecl.accept(this);
- }
-
- d.accept(post);
- }
-
- /**
- * Visits a constructor declaration.
- *
- * @param d the declaration to visit
- */
- public void visitConstructorDeclaration(ConstructorDeclaration d) {
- visitExecutableDeclaration(d);
- }
-
- /**
- * Visits a method declaration.
- *
- * @param d the declaration to visit
- */
- public void visitMethodDeclaration(MethodDeclaration d) {
- visitExecutableDeclaration(d);
- }
-
- /**
- * Visits an annotation type element declaration.
- *
- * @param d the declaration to visit
- */
- public void visitAnnotationTypeElementDeclaration(
- AnnotationTypeElementDeclaration d) {
- visitMethodDeclaration(d);
- }
-
- /**
- * Visits a parameter declaration.
- *
- * @param d the declaration to visit
- */
- public void visitParameterDeclaration(ParameterDeclaration d) {
- visitDeclaration(d);
- }
-
- /**
- * Visits a type parameter declaration.
- *
- * @param d the declaration to visit
- */
- public void visitTypeParameterDeclaration(TypeParameterDeclaration d) {
- visitDeclaration(d);
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationVisitor.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationVisitor.java
deleted file mode 100644
index d400edc6fe..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationVisitor.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * @(#)DeclarationVisitor.java 1.3 04/04/20
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.util;
-
-import com.sun.mirror.declaration.*;
-
-
-/**
- * A visitor for declarations, in the style of the standard visitor
- * design pattern. Classes implementing this interface are used to
- * operate on a declaration when the kind of declaration is unknown at
- * compile time. When a visitor is passed to a declaration's {@link
- * Declaration#accept accept} method, the most specific
- * <tt>visit<i>Xxx</i></tt> method applicable to that declaration is
- * invoked.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.3 04/04/20
- * @since 1.5
- */
-
-public interface DeclarationVisitor {
-
- /**
- * Visits a declaration.
- * @param d the declaration to visit
- */
- public void visitDeclaration(Declaration d);
-
- /**
- * Visits a package declaration.
- * @param d the declaration to visit
- */
- public void visitPackageDeclaration(PackageDeclaration d);
-
- /**
- * Visits a member or constructor declaration.
- * @param d the declaration to visit
- */
- public void visitMemberDeclaration(MemberDeclaration d);
-
- /**
- * Visits a type declaration.
- * @param d the declaration to visit
- */
- public void visitTypeDeclaration(TypeDeclaration d);
-
- /**
- * Visits a class declaration.
- * @param d the declaration to visit
- */
- public void visitClassDeclaration(ClassDeclaration d);
-
- /**
- * Visits an enum declaration.
- * @param d the declaration to visit
- */
- public void visitEnumDeclaration(EnumDeclaration d);
-
- /**
- * Visits an interface declaration.
- * @param d the declaration to visit
- */
- public void visitInterfaceDeclaration(InterfaceDeclaration d);
-
- /**
- * Visits an annotation type declaration.
- * @param d the declaration to visit
- */
- public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d);
-
- /**
- * Visits a field declaration.
- * @param d the declaration to visit
- */
- public void visitFieldDeclaration(FieldDeclaration d);
-
- /**
- * Visits an enum constant declaration.
- * @param d the declaration to visit
- */
- public void visitEnumConstantDeclaration(EnumConstantDeclaration d);
-
- /**
- * Visits a method or constructor declaration.
- * @param d the declaration to visit
- */
- public void visitExecutableDeclaration(ExecutableDeclaration d);
-
- /**
- * Visits a constructor declaration.
- * @param d the declaration to visit
- */
- public void visitConstructorDeclaration(ConstructorDeclaration d);
-
- /**
- * Visits a method declaration.
- * @param d the declaration to visit
- */
- public void visitMethodDeclaration(MethodDeclaration d);
-
- /**
- * Visits an annotation type element declaration.
- * @param d the declaration to visit
- */
- public void visitAnnotationTypeElementDeclaration(
- AnnotationTypeElementDeclaration d);
-
- /**
- * Visits a parameter declaration.
- * @param d the declaration to visit
- */
- public void visitParameterDeclaration(ParameterDeclaration d);
-
- /**
- * Visits a type parameter declaration.
- * @param d the declaration to visit
- */
- public void visitTypeParameterDeclaration(TypeParameterDeclaration d);
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationVisitors.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationVisitors.java
deleted file mode 100644
index ca6024f827..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/DeclarationVisitors.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * @(#)DeclarationVisitors.java 1.4 04/07/13
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.util;
-
-/**
- * Utilities to create specialized <tt>DeclarationVisitor</tt> instances.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.4 04/07/13
- * @since 1.5
- */
-public class DeclarationVisitors {
- private DeclarationVisitors(){} // do not instantiate.
-
- /**
- * A visitor that has no side effects and keeps no state.
- */
- public static final DeclarationVisitor NO_OP = new SimpleDeclarationVisitor();
-
- /**
- * Return a <tt>DeclarationVisitor</tt> that will scan the
- * declaration structure, visiting declarations contained in
- * another declaration. For example, when visiting a class, the
- * fields, methods, constructors, etc. of the class are also
- * visited. The order in which the contained declarations are scanned is
- * not specified.
- *
- * <p>The <tt>pre</tt> and <tt>post</tt>
- * <tt>DeclarationVisitor</tt> parameters specify,
- * respectively, the processing the scanner will do before or
- * after visiting the contained declarations. If only one of pre
- * and post processing is needed, use {@link
- * DeclarationVisitors#NO_OP DeclarationVisitors.NO_OP} for the
- * other parameter.
- *
- * @param pre visitor representing processing to do before
- * visiting contained declarations.
- *
- * @param post visitor representing processing to do after
- * visiting contained declarations.
- */
- public static DeclarationVisitor getDeclarationScanner(DeclarationVisitor pre,
- DeclarationVisitor post) {
- return new DeclarationScanner(pre, post);
- }
-
- /**
- * Return a <tt>DeclarationVisitor</tt> that will scan the
- * declaration structure, visiting declarations contained in
- * another declaration in source code order. For example, when
- * visiting a class, the fields, methods, constructors, etc. of
- * the class are also visited. The order in which the contained
- * declarations are visited is as close to source code order as
- * possible; declaration mirrors created from class files instead
- * of source code will not have source position information.
- *
- * <p>The <tt>pre</tt> and <tt>post</tt>
- * <tt>DeclarationVisitor</tt> parameters specify,
- * respectively, the processing the scanner will do before or
- * after visiting the contained declarations. If only one of pre
- * and post processing is needed, use {@link
- * DeclarationVisitors#NO_OP DeclarationVisitors.NO_OP} for the other parameter.
- *
- * @param pre visitor representing processing to do before
- * visiting contained declarations.
- *
- * @param post visitor representing processing to do after
- * visiting contained declarations.
- */
- public static DeclarationVisitor getSourceOrderDeclarationScanner(DeclarationVisitor pre,
- DeclarationVisitor post) {
- return new SourceOrderDeclScanner(pre, post);
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/Declarations.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/Declarations.java
deleted file mode 100644
index 62ff127c02..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/Declarations.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * @(#)Declarations.java 1.1 04/01/26
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.util;
-
-
-import com.sun.mirror.declaration.*;
-
-
-/**
- * Utility methods for operating on declarations.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.1 04/01/26
- * @since 1.5
- */
-
-public interface Declarations {
-
- /**
- * Tests whether one type, method, or field declaration hides another.
- *
- * @param sub the first member
- * @param sup the second member
- * @return <tt>true</tt> if and only if the first member hides
- * the second
- */
- boolean hides(MemberDeclaration sub, MemberDeclaration sup);
-
- /**
- * Tests whether one method overrides another. When a
- * non-abstract method overrides an abstract one, the
- * former is also said to <i>implement</i> the latter.
- *
- * @param sub the first method
- * @param sup the second method
- * @return <tt>true</tt> if and only if the first method overrides
- * the second
- */
- boolean overrides(MethodDeclaration sub, MethodDeclaration sup);
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SimpleDeclarationVisitor.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SimpleDeclarationVisitor.java
deleted file mode 100644
index 1411fc782c..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SimpleDeclarationVisitor.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * @(#)SimpleDeclarationVisitor.java 1.3 04/04/30
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.util;
-
-
-import com.sun.mirror.declaration.*;
-
-
-/**
- * A simple visitor for declarations.
- *
- * <p> The implementations of the methods of this class do nothing but
- * delegate up the declaration hierarchy. A subclass should override the
- * methods that correspond to the kinds of declarations on which it
- * will operate.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.3 04/04/30
- * @since 1.5
- */
-
-public class SimpleDeclarationVisitor implements DeclarationVisitor {
-
- /**
- * Creates a new <tt>SimpleDeclarationVisitor</tt>.
- */
- public SimpleDeclarationVisitor(){}
-
- /**
- * Visits a declaration.
- * The implementation does nothing.
- * @param d the declaration to visit
- */
- public void visitDeclaration(Declaration d) {
- }
-
- /**
- * Visits a package declaration.
- * The implementation simply invokes
- * {@link #visitDeclaration visitDeclaration}.
- * @param d the declaration to visit
- */
- public void visitPackageDeclaration(PackageDeclaration d) {
- visitDeclaration(d);
- }
-
- /**
- * Visits a member or constructor declaration.
- * The implementation simply invokes
- * {@link #visitDeclaration visitDeclaration}.
- * @param d the declaration to visit
- */
- public void visitMemberDeclaration(MemberDeclaration d) {
- visitDeclaration(d);
- }
-
- /**
- * Visits a type declaration.
- * The implementation simply invokes
- * {@link #visitMemberDeclaration visitMemberDeclaration}.
- * @param d the declaration to visit
- */
- public void visitTypeDeclaration(TypeDeclaration d) {
- visitMemberDeclaration(d);
- }
-
- /**
- * Visits a class declaration.
- * The implementation simply invokes
- * {@link #visitTypeDeclaration visitTypeDeclaration}.
- * @param d the declaration to visit
- */
- public void visitClassDeclaration(ClassDeclaration d) {
- visitTypeDeclaration(d);
- }
-
- /**
- * Visits an enum declaration.
- * The implementation simply invokes
- * {@link #visitClassDeclaration visitClassDeclaration}.
- * @param d the declaration to visit
- */
- public void visitEnumDeclaration(EnumDeclaration d) {
- visitClassDeclaration(d);
- }
-
- /**
- * Visits an interface declaration.
- * The implementation simply invokes
- * {@link #visitTypeDeclaration visitTypeDeclaration}.
- * @param d the declaration to visit
- */
- public void visitInterfaceDeclaration(InterfaceDeclaration d) {
- visitTypeDeclaration(d);
- }
-
- /**
- * Visits an annotation type declaration.
- * The implementation simply invokes
- * {@link #visitInterfaceDeclaration visitInterfaceDeclaration}.
- * @param d the declaration to visit
- */
- public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {
- visitInterfaceDeclaration(d);
- }
-
- /**
- * Visits a field declaration.
- * The implementation simply invokes
- * {@link #visitMemberDeclaration visitMemberDeclaration}.
- * @param d the declaration to visit
- */
- public void visitFieldDeclaration(FieldDeclaration d) {
- visitMemberDeclaration(d);
- }
-
- /**
- * Visits an enum constant declaration.
- * The implementation simply invokes
- * {@link #visitFieldDeclaration visitFieldDeclaration}.
- * @param d the declaration to visit
- */
- public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {
- visitFieldDeclaration(d);
- }
-
- /**
- * Visits a method or constructor declaration.
- * The implementation simply invokes
- * {@link #visitMemberDeclaration visitMemberDeclaration}.
- * @param d the declaration to visit
- */
- public void visitExecutableDeclaration(ExecutableDeclaration d) {
- visitMemberDeclaration(d);
- }
-
- /**
- * Visits a constructor declaration.
- * The implementation simply invokes
- * {@link #visitExecutableDeclaration visitExecutableDeclaration}.
- * @param d the declaration to visit
- */
- public void visitConstructorDeclaration(ConstructorDeclaration d) {
- visitExecutableDeclaration(d);
- }
-
- /**
- * Visits a method declaration.
- * The implementation simply invokes
- * {@link #visitExecutableDeclaration visitExecutableDeclaration}.
- * @param d the declaration to visit
- */
- public void visitMethodDeclaration(MethodDeclaration d) {
- visitExecutableDeclaration(d);
- }
-
- /**
- * Visits an annotation type element declaration.
- * The implementation simply invokes
- * {@link #visitMethodDeclaration visitMethodDeclaration}.
- * @param d the declaration to visit
- */
- public void visitAnnotationTypeElementDeclaration(
- AnnotationTypeElementDeclaration d) {
- visitMethodDeclaration(d);
- }
-
- /**
- * Visits a parameter declaration.
- * The implementation simply invokes
- * {@link #visitDeclaration visitDeclaration}.
- * @param d the declaration to visit
- */
- public void visitParameterDeclaration(ParameterDeclaration d) {
- visitDeclaration(d);
- }
-
- /**
- * Visits a type parameter declaration.
- * The implementation simply invokes
- * {@link #visitDeclaration visitDeclaration}.
- * @param d the declaration to visit
- */
- public void visitTypeParameterDeclaration(TypeParameterDeclaration d) {
- visitDeclaration(d);
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SimpleTypeVisitor.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SimpleTypeVisitor.java
deleted file mode 100644
index 92c53692f7..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SimpleTypeVisitor.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * @(#)SimpleTypeVisitor.java 1.4 04/06/07
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.util;
-
-
-import com.sun.mirror.type.*;
-
-
-/**
- * A simple visitor for types.
- *
- * <p> The implementations of the methods of this class do nothing but
- * delegate up the type hierarchy. A subclass should override the
- * methods that correspond to the kinds of types on which it will
- * operate.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.4 04/06/07
- * @since 1.5
- */
-
-public class SimpleTypeVisitor implements TypeVisitor {
-
- /**
- * Creates a new <tt>SimpleTypeVisitor</tt>.
- */
- public SimpleTypeVisitor() {}
-
- /**
- * Visits a type mirror.
- * The implementation does nothing.
- * @param t the type to visit
- */
- public void visitTypeMirror(TypeMirror t) {
- }
-
- /**
- * Visits a primitive type.
- * The implementation simply invokes
- * {@link #visitTypeMirror visitTypeMirror}.
- * @param t the type to visit
- */
- public void visitPrimitiveType(PrimitiveType t) {
- visitTypeMirror(t);
- }
-
- /**
- * Visits a void type.
- * The implementation simply invokes
- * {@link #visitTypeMirror visitTypeMirror}.
- * @param t the type to visit
- */
- public void visitVoidType(VoidType t) {
- visitTypeMirror(t);
- }
-
- /**
- * Visits a reference type.
- * The implementation simply invokes
- * {@link #visitTypeMirror visitTypeMirror}.
- * @param t the type to visit
- */
- public void visitReferenceType(ReferenceType t) {
- visitTypeMirror(t);
- }
-
- /**
- * Visits a declared type.
- * The implementation simply invokes
- * {@link #visitReferenceType visitReferenceType}.
- * @param t the type to visit
- */
- public void visitDeclaredType(DeclaredType t) {
- visitReferenceType(t);
- }
-
- /**
- * Visits a class type.
- * The implementation simply invokes
- * {@link #visitDeclaredType visitDeclaredType}.
- * @param t the type to visit
- */
- public void visitClassType(ClassType t) {
- visitDeclaredType(t);
- }
-
- /**
- * Visits an enum type.
- * The implementation simply invokes
- * {@link #visitClassType visitClassType}.
- * @param t the type to visit
- */
- public void visitEnumType(EnumType t) {
- visitClassType(t);
- }
-
- /**
- * Visits an interface type.
- * The implementation simply invokes
- * {@link #visitDeclaredType visitDeclaredType}.
- * @param t the type to visit
- */
- public void visitInterfaceType(InterfaceType t) {
- visitDeclaredType(t);
- }
-
- /**
- * Visits an annotation type.
- * The implementation simply invokes
- * {@link #visitInterfaceType visitInterfaceType}.
- * @param t the type to visit
- */
- public void visitAnnotationType(AnnotationType t) {
- visitInterfaceType(t);
- }
-
- /**
- * Visits an array type.
- * The implementation simply invokes
- * {@link #visitReferenceType visitReferenceType}.
- * @param t the type to visit
- */
- public void visitArrayType(ArrayType t) {
- visitReferenceType(t);
- }
-
- /**
- * Visits a type variable.
- * The implementation simply invokes
- * {@link #visitReferenceType visitReferenceType}.
- * @param t the type to visit
- */
- public void visitTypeVariable(TypeVariable t) {
- visitReferenceType(t);
- }
-
- /**
- * Visits a wildcard.
- * The implementation simply invokes
- * {@link #visitTypeMirror visitTypeMirror}.
- * @param t the type to visit
- */
- public void visitWildcardType(WildcardType t) {
- visitTypeMirror(t);
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SourceOrderDeclScanner.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SourceOrderDeclScanner.java
deleted file mode 100644
index af3a1c2d54..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SourceOrderDeclScanner.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * @(#)SourceOrderDeclScanner.java 1.5 04/09/16
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.util;
-
-import com.sun.mirror.declaration.*;
-
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-/**
- * A visitor for declarations that scans declarations contained within
- * the given declaration in source code order. For example, when
- * visiting a class, the methods, fields, constructors, and nested
- * types of the class are also visited.
- *
- * To control the processing done on a declaration, users of this
- * class pass in their own visitors for pre and post processing. The
- * preprocessing visitor is called before the contained declarations
- * are scanned; the postprocessing visitor is called after the
- * contained declarations are scanned.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.5 04/09/16
- * @since 1.5
- */
-class SourceOrderDeclScanner extends DeclarationScanner {
- static class SourceOrderComparator implements java.util.Comparator<Declaration> {
- SourceOrderComparator(){}
-
-
- static boolean equals(Declaration d1, Declaration d2) {
- return d1 == d2 || (d1 != null && d1.equals(d2));
- }
-
- private static class DeclPartialOrder extends com.sun.mirror.util.SimpleDeclarationVisitor {
- private int value = 1000;
- private static int staticAdjust(Declaration d) {
- return d.getModifiers().contains(Modifier.STATIC)?0:1;
- }
-
- DeclPartialOrder() {}
-
- public int getValue() { return value; }
-
- @Override
- public void visitTypeParameterDeclaration(TypeParameterDeclaration d) {value = 0;}
-
- @Override
- public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {value = 1;}
-
- @Override
- public void visitClassDeclaration(ClassDeclaration d) {value = 2 + staticAdjust(d);}
-
- @Override
- public void visitInterfaceDeclaration(InterfaceDeclaration d) {value = 4;}
-
- @Override
- public void visitEnumDeclaration(EnumDeclaration d) {value = 6;}
-
- @Override
- public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {value = 8;}
-
- @Override
- public void visitFieldDeclaration(FieldDeclaration d) {value = 10 + staticAdjust(d);}
-
- @Override
- public void visitConstructorDeclaration(ConstructorDeclaration d) {value = 12;}
-
- @Override
- public void visitMethodDeclaration(MethodDeclaration d) {value = 14 + staticAdjust(d);}
- }
-
- private int compareEqualPosition(Declaration d1, Declaration d2) {
- assert d1.getPosition() == d2.getPosition();
-
- DeclPartialOrder dpo1 = new DeclPartialOrder();
- DeclPartialOrder dpo2 = new DeclPartialOrder();
-
- d1.accept(dpo1);
- d2.accept(dpo2);
-
- int difference = dpo1.getValue() - dpo2.getValue();
- if (difference != 0)
- return difference;
- else {
- int result = d1.getSimpleName().compareTo(d2.getSimpleName());
- if (result != 0)
- return result;
- return ( Long.signum((long)System.identityHashCode(d1) -
- (long)System.identityHashCode(d2)));
- }
- }
-
- public int compare(Declaration d1, Declaration d2) {
- if (equals(d1, d2))
- return 0;
-
- SourcePosition p1 = d1.getPosition();
- SourcePosition p2 = d2.getPosition();
-
- if (p1 == null && p2 != null)
- return 1;
- else if (p1 != null && p2 == null)
- return -1;
- else if(p1 == null && p2 == null)
- return compareEqualPosition(d1, d2);
- else {
- assert p1 != null && p2 != null;
- int fileComp = p1.file().compareTo(p2.file()) ;
- if (fileComp == 0) {
- long diff = (long)p1.line() - (long)p2.line();
- if (diff == 0) {
- diff = Long.signum((long)p1.column() - (long)p2.column());
- if (diff != 0)
- return (int)diff;
- else {
- // declarations may be two
- // compiler-generated members with the
- // same source position
- return compareEqualPosition(d1, d2);
- }
- } else
- return (diff<0)? -1:1;
- } else
- return fileComp;
- }
- }
- }
-
- final static java.util.Comparator<Declaration> comparator = new SourceOrderComparator();
-
- SourceOrderDeclScanner(DeclarationVisitor pre, DeclarationVisitor post) {
- super(pre, post);
- }
-
- /**
- * Visits a type declaration.
- *
- * @param d the declaration to visit
- */
- public void visitTypeDeclaration(TypeDeclaration d) {
- d.accept(pre);
-
- SortedSet<Declaration> decls = new
- TreeSet<Declaration>(SourceOrderDeclScanner.comparator) ;
-
- for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
- decls.add(tpDecl);
- }
-
- for(FieldDeclaration fieldDecl: d.getFields()) {
- decls.add(fieldDecl);
- }
-
- for(MethodDeclaration methodDecl: d.getMethods()) {
- decls.add(methodDecl);
- }
-
- for(TypeDeclaration typeDecl: d.getNestedTypes()) {
- decls.add(typeDecl);
- }
-
- for(Declaration decl: decls )
- decl.accept(this);
-
- d.accept(post);
- }
-
- /**
- * Visits a class declaration.
- *
- * @param d the declaration to visit
- */
- public void visitClassDeclaration(ClassDeclaration d) {
- d.accept(pre);
-
- SortedSet<Declaration> decls = new
- TreeSet<Declaration>(SourceOrderDeclScanner.comparator) ;
-
- for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
- decls.add(tpDecl);
- }
-
- for(FieldDeclaration fieldDecl: d.getFields()) {
- decls.add(fieldDecl);
- }
-
- for(MethodDeclaration methodDecl: d.getMethods()) {
- decls.add(methodDecl);
- }
-
- for(TypeDeclaration typeDecl: d.getNestedTypes()) {
- decls.add(typeDecl);
- }
-
- for(ConstructorDeclaration ctorDecl: d.getConstructors()) {
- decls.add(ctorDecl);
- }
-
- for(Declaration decl: decls )
- decl.accept(this);
-
- d.accept(post);
- }
-
- public void visitExecutableDeclaration(ExecutableDeclaration d) {
- d.accept(pre);
-
- SortedSet<Declaration> decls = new
- TreeSet<Declaration>(SourceOrderDeclScanner.comparator) ;
-
- for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters())
- decls.add(tpDecl);
-
- for(ParameterDeclaration pDecl: d.getParameters())
- decls.add(pDecl);
-
- for(Declaration decl: decls )
- decl.accept(this);
-
- d.accept(post);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SourcePosition.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SourcePosition.java
deleted file mode 100644
index e2adfd9f61..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/SourcePosition.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * @(#)SourcePosition.java 1.2 04/07/16
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.util;
-
-
-import java.io.File;
-
-
-/**
- * Represents a position in a source file.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.2 04/07/16
- * @since 1.5
- */
-
-public interface SourcePosition {
-
- /**
- * Returns the source file containing this position.
- *
- * @return the source file containing this position; never null
- */
- File file();
-
- /**
- * Returns the line number of this position. Lines are numbered
- * starting with 1.
- *
- * @return the line number of this position, or 0 if the line
- * number is unknown or not applicable
- */
- int line();
-
- /**
- * Returns the column number of this position. Columns are numbered
- * starting with 1.
- *
- * @return the column number of this position, or 0 if the column
- * number is unknown or not applicable
- */
- int column();
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/TypeVisitor.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/TypeVisitor.java
deleted file mode 100644
index 9ba7670c8f..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/TypeVisitor.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * @(#)TypeVisitor.java 1.4 04/06/07
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.util;
-
-
-import com.sun.mirror.type.*;
-
-
-/**
- * A visitor for types, in the style of the standard visitor design pattern.
- * This is used to operate on a type when the kind
- * of type is unknown at compile time.
- * When a visitor is passed to a type's
- * {@link TypeMirror#accept accept} method,
- * the most specific <tt>visit<i>Xxx</i></tt> method applicable to
- * that type is invoked.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.4 04/06/07
- * @since 1.5
- */
-
-public interface TypeVisitor {
-
- /**
- * Visits a type mirror.
- *
- * @param t the type to visit
- */
- public void visitTypeMirror(TypeMirror t);
-
- /**
- * Visits a primitive type.
-
- * @param t the type to visit
- */
- public void visitPrimitiveType(PrimitiveType t);
-
- /**
- * Visits a void type.
- *
- * @param t the type to visit
- */
- public void visitVoidType(VoidType t);
-
- /**
- * Visits a reference type.
- *
- * @param t the type to visit
- */
- public void visitReferenceType(ReferenceType t);
-
- /**
- * Visits a declared type.
- *
- * @param t the type to visit
- */
- public void visitDeclaredType(DeclaredType t);
-
- /**
- * Visits a class type.
- *
- * @param t the type to visit
- */
- public void visitClassType(ClassType t);
-
- /**
- * Visits an enum type.
- *
- * @param t the type to visit
- */
- public void visitEnumType(EnumType t);
-
- /**
- * Visits an interface type.
- *
- * @param t the type to visit
- */
- public void visitInterfaceType(InterfaceType t);
-
- /**
- * Visits an annotation type.
- *
- * @param t the type to visit
- */
- public void visitAnnotationType(AnnotationType t);
-
- /**
- * Visits an array type.
- *
- * @param t the type to visit
- */
- public void visitArrayType(ArrayType t);
-
- /**
- * Visits a type variable.
- *
- * @param t the type to visit
- */
- public void visitTypeVariable(TypeVariable t);
-
- /**
- * Visits a wildcard.
- *
- * @param t the type to visit
- */
- public void visitWildcardType(WildcardType t);
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/Types.java b/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/Types.java
deleted file mode 100644
index e084c68239..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/Types.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * @(#)Types.java 1.3 04/06/07
- *
- * Copyright (c) 2004, Sun Microsystems, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Sun Microsystems, Inc. nor the names of
- * its contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.sun.mirror.util;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-
-
-/**
- * Utility methods for operating on types.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @version 1.3 04/06/07
- * @since 1.5
- */
-
-public interface Types {
-
- /**
- * Tests whether one type is a subtype of the another.
- * Any type is considered to be a subtype of itself.
- *
- * @param t1 the first type
- * @param t2 the second type
- * @return <tt>true</tt> if and only if the first type is a subtype
- * of the second
- */
- boolean isSubtype(TypeMirror t1, TypeMirror t2);
-
- /**
- * Tests whether one type is assignable to another.
- *
- * @param t1 the first type
- * @param t2 the second type
- * @return <tt>true</tt> if and only if the first type is assignable
- * to the second
- */
- boolean isAssignable(TypeMirror t1, TypeMirror t2);
-
- /**
- * Returns the erasure of a type.
- *
- * @param t the type to be erased
- * @return the erasure of the given type
- */
- TypeMirror getErasure(TypeMirror t);
-
- /**
- * Returns a primitive type.
- *
- * @param kind the kind of primitive type to return
- * @return a primitive type
- */
- PrimitiveType getPrimitiveType(PrimitiveType.Kind kind);
-
- /**
- * Returns the pseudo-type representing the type of <tt>void</tt>.
- *
- * @return the pseudo-type representing the type of <tt>void</tt>
- */
- VoidType getVoidType();
-
- /**
- * Returns an array type with the specified component type.
- *
- * @param componentType the component type
- * @return an array type with the specified component type.
- * @throws IllegalArgumentException if the component type is not valid for
- * an array
- */
- ArrayType getArrayType(TypeMirror componentType);
-
- /**
- * Returns the type variable declared by a type parameter.
- *
- * @param tparam the type parameter
- * @return the type variable declared by the type parameter
- */
- TypeVariable getTypeVariable(TypeParameterDeclaration tparam);
-
- /**
- * Returns a new wildcard.
- * Either the wildcards's upper bounds or lower bounds may be
- * specified, or neither, but not both.
- *
- * @param upperBounds the upper bounds of this wildcard,
- * or an empty collection if none
- * @param lowerBounds the lower bounds of this wildcard,
- * or an empty collection if none
- * @return a new wildcard
- * @throws IllegalArgumentException if bounds are not valid
- */
- WildcardType getWildcardType(Collection<ReferenceType> upperBounds,
- Collection<ReferenceType> lowerBounds);
-
- /**
- * Returns the type corresponding to a type declaration and
- * actual type arguments.
- * Given the declaration for <tt>String</tt>, for example, this
- * method may be used to get the <tt>String</tt> type. It may
- * then be invoked a second time, with the declaration for <tt>Set</tt>,
- * to make the parameterized type {@code Set<String>}.
- *
- * <p> The number of type arguments must either equal the
- * number of the declaration's formal type parameters, or must be
- * zero. If zero, and if the declaration is generic,
- * then the declaration's raw type is returned.
- *
- * <p> If a parameterized type is being returned, its declaration
- * must not be contained within a generic outer class.
- * The parameterized type {@code Outer<String>.Inner<Number>},
- * for example, may be constructed by first using this
- * method to get the type {@code Outer<String>}, and then invoking
- * {@link #getDeclaredType(DeclaredType, TypeDeclaration, TypeMirror...)}.
- *
- * @param decl the type declaration
- * @param typeArgs the actual type arguments
- * @return the type corresponding to the type declaration and
- * actual type arguments
- * @throws IllegalArgumentException if too many or too few
- * type arguments are given, or if an inappropriate type
- * argument or declaration is provided
- */
- DeclaredType getDeclaredType(TypeDeclaration decl,
- TypeMirror... typeArgs);
-
- /**
- * Returns the type corresponding to a type declaration
- * and actual arguments, given a
- * {@linkplain DeclaredType#getContainingType() containing type}
- * of which it is a member.
- * The parameterized type {@code Outer<String>.Inner<Number>},
- * for example, may be constructed by first using
- * {@link #getDeclaredType(TypeDeclaration, TypeMirror...)}
- * to get the type {@code Outer<String>}, and then invoking
- * this method.
- *
- * <p> If the containing type is a parameterized type,
- * the number of type arguments must equal the
- * number of the declaration's formal type parameters.
- * If it is not parameterized or if it is <tt>null</tt>, this method is
- * equivalent to <tt>getDeclaredType(decl, typeArgs)</tt>.
- *
- * @param containing the containing type, or <tt>null</tt> if none
- * @param decl the type declaration
- * @param typeArgs the actual type arguments
- * @return the type corresponding to the type declaration and
- * actual type arguments,
- * contained within the given type
- * @throws IllegalArgumentException if too many or too few
- * type arguments are given, or if an inappropriate type
- * argument, declaration, or containing type is provided
- */
- DeclaredType getDeclaredType(DeclaredType containing,
- TypeDeclaration decl,
- TypeMirror... typeArgs);
-}
diff --git a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/package.html b/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/package.html
deleted file mode 100644
index 13b35ef28f..0000000000
--- a/org.eclipse.jdt.apt.core/src/com/sun/mirror/util/package.html
+++ /dev/null
@@ -1,47 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<!--
- @(#)package.html 1.3 04/07/26
- Copyright (c) 2004, Sun Microsystems, Inc.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the Sun Microsystems, Inc. nor the names of
- its contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-
-</head>
-<body bgcolor="white">
-
-Utilities to assist in the processing of {@linkplain
-com.sun.mirror.declaration declarations} and {@linkplain
-com.sun.mirror.type types}.
-
-<p>Note that the <code>apt</code> tool and its associated APIs may be
-changed or superseded in future j2se releases.
-
-@since 1.5
-</body>
-</html>
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/build/AptBuilder.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/build/AptBuilder.java
deleted file mode 100644
index 7b8491f2d1..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/build/AptBuilder.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.build;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.app.IApplication;
-import org.eclipse.equinox.app.IApplicationContext;
-
-/**
- * Commandline entry point for building a workspace using APT.
- * Currently cleans and then builds the entire workspace.<P>
- *
- * Sample commandline invocation:
- *
- * %ECLIPSE_HOME%/eclipsec -nosplash -application org.eclipse.jdt.apt.core.aptBuild -data %WORKSPACE%
- *
- * This class should not be referenced programmatically by other
- * Java code. This class exists only for the purpose of launching
- * the AptBuilder from the command line. The fields and methods on this
- * class are not API.
- */
-public class AptBuilder implements IApplication {
-
- /**
- * Runs this runnable with the given application context and returns a result.
- * The content of the args is unchecked and should conform to the expectations of
- * the runnable being invoked. Typically this is a <code>String</code> array.
- * Applications can return any object they like. If an <code>Integer</code> is returned
- * it is treated as the program exit code if Eclipse is exiting.
- *
- * @param context the given application context passed to the application
- * @return the return value of the application
- * @exception Exception if there is a problem running this runnable.
- * @see #EXIT_OK
- * @see #EXIT_RESTART
- * @see #EXIT_RELAUNCH
- */
- public Object start(IApplicationContext context) throws Exception {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IProgressMonitor progressMonitor = new SystemOutProgressMonitor();
- workspace.build(IncrementalProjectBuilder.CLEAN_BUILD, progressMonitor);
- workspace.build(IncrementalProjectBuilder.FULL_BUILD, progressMonitor);
-
- return IApplication.EXIT_OK;
- }
-
- public void stop() {
- // nothing to do
- }
-
- /**
- * Sends all progress to StdOut
- */
- private static class SystemOutProgressMonitor extends NullProgressMonitor {
-
- public void beginTask(String name, int totalWork) {
- if (name != null && name.length() > 0)
- System.out.println(name);
- }
-
- public void subTask(String name) {
- if (name != null && name.length() > 0)
- System.out.println(name);
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/build/JdtApt.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/build/JdtApt.java
deleted file mode 100644
index 63bee51c83..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/build/JdtApt.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.build;
-
-import java.io.File;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.taskdefs.Java;
-import org.apache.tools.ant.types.Path;
-import org.eclipse.jdt.apt.core.internal.build.Messages;
-
-/**
- * Ant task for invoking the commandline apt builder
- *
- * Sample build.xml:
- *
- * &lt;project name="test_eclipse" default="build" basedir="."&gt;
- *
- * &lt;taskdef name="apt" classname="org.eclipse.jdt.apt.core.build.JdtApt"/&gt;
- *
- * &lt;target name="build"&gt;
- * &lt;apt workspace="C:\my_workspace" eclipseHome="C:\eclipse"/&gt;
- * &lt;/target&gt;
- * &lt;/project&gt;
- */
-public class JdtApt extends Java {
-
- private static final String APP_CLASSNAME = "org.eclipse.core.launcher.Main"; //$NON-NLS-1$
- private static final String APP_PLUGIN = "org.eclipse.jdt.apt.core.aptBuild"; //$NON-NLS-1$
-
- private File workspace;
- private File startupJar;
-
- public void setWorkspace(File file) {
- if(!file.exists()) {
- throw new BuildException(Messages.JdtApt_noWorkspace + file);
- }
- workspace = file;
- }
-
- public void setEclipseHome(File file) {
- if(!file.exists()) {
- throw new BuildException(Messages.JdtApt_noEclipse + file);
- }
- startupJar = new File(file, "startup.jar"); //$NON-NLS-1$
- if(!startupJar.exists()) {
- throw new BuildException(Messages.JdtApt_noStartupJar + file);
- }
- }
-
- public void execute() throws BuildException {
- if(workspace == null) {
- throw new BuildException("Must set a workspace"); //$NON-NLS-1$
- }
- if(startupJar == null) {
- throw new BuildException("Must set eclipse home"); //$NON-NLS-1$
- }
-
- setFork(true);
- setLogError(true);
- setClasspath(new Path(null, startupJar.getAbsolutePath()));
- setClassname(APP_CLASSNAME);
- createArg().setValue("-noupdate"); //$NON-NLS-1$
- createArg().setValue("-application"); //$NON-NLS-1$
- createArg().setValue(APP_PLUGIN);
- createArg().setValue("-data"); //$NON-NLS-1$
- createArg().setValue(workspace.getAbsolutePath());
- super.execute();
- }
-
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/build/package.html b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/build/package.html
deleted file mode 100644
index c724b2297d..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/build/package.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="BEA Systems Inc.">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-This package contains utilities for annotation processing in command-line builds and ant scripts.
-<h2>
-Package Specification</h2>
-
-<p><br>This package contains utilities for performing Java annotation processing
-in command-line builds and ant scripts.
-</body>
-</html>
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 33afa6c3f0..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EclipseAnnotationProcessorEnvironment.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.IJavaProject;
-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 AST of the file currently being processed.
- * @return the root of the fully flushed out DOM/AST of the file that is currently being processed.
- * This AST will contain binding information.
- * Return <code>null</code> for if called by a batch processor.
- */
- CompilationUnit getAST();
-
- /**
- * @return a messager for registering diagnostics.
- */
- EclipseMessager getMessager();
-
- /**
- * Indicate whether the processor is being called during a build or during editing
- * (that is, during reconcile).
- * <p>
- * Note that processors that behave differently depending on phase may cause
- * inconsistent results, such as problems showing up in the Problems view but not in
- * the editor window. If the goal is to improve edit-time performance by skipping
- * processing during reconcile, it is recommended to use the
- * {@link org.eclipse.jdt.apt.core.util.AptPreferenceConstants#PROCESSING_IN_EDITOR_DISABLED_OPTION
- * PROCESSING_IN_EDITOR_DISABLED} option instead.
- *
- * @return the current processing phase: either {@link Phase#RECONCILE} or
- * {@link Phase#BUILD}
- */
- Phase getPhase();
-
- /**
- * @return the java project associated with the current processing phase
- */
- IJavaProject getJavaProject();
-
- /**
- * 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 2b8d476b72..0000000000
--- 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 f2e7417bf6..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/EnvironmentFactory.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-
-public class EnvironmentFactory {
-
- /**
- * Return a processor environment for use outside of building or reconciling.
- * Note that this environment does <b>NOT</b> support the Filer or Messager API,
- * as it is to be used to perform type system navigation, not building.<p>
- *
- * If either getFiler() or getMessager() are called, this environment
- * will throw an UnsupportedOperationException.
- *
- * @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 )
- {
- CompilationUnit node = BaseProcessorEnv.createAST( javaProject, compilationUnit);
- BaseProcessorEnv env = new BaseProcessorEnv(
- node,
- (IFile)compilationUnit.getResource(),
- javaProject,
- Phase.OTHER
- );
- return env;
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/Phase.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/Phase.java
deleted file mode 100644
index ea1dc10c8a..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/Phase.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.env;
-
-/**
- * Enum for APT related operation phase.
- * @see EclipseAnnotationProcessorEnvironment#getPhase()
- */
-public enum Phase {
-
- /** During Reconcile phase */
- RECONCILE,
- /** During Build phase */
- BUILD,
- /**
- * Neither reconcile nor build. Completion would be an example.
- */
- OTHER
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/package.html b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/package.html
deleted file mode 100644
index cedcfecaf6..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/env/package.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="BEA Systems Inc.">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-This package contains Eclipse extensions to some of the Sun annotation processing APIs.
-<h2>
-Package Specification</h2>
-
-<p><br>This package contains Eclipse extensions of APIs related to
-the <code>com.sun.mirror.apt.AnnotationProcessorEnvironment</code> interface.
-Use these extensions in order to access features available only within
-Eclipse. Avoid these extensions if compatibility with Sun's apt tool
-is required.
-</body>
-</html>
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/APTDispatchRunnable.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/APTDispatchRunnable.java
deleted file mode 100644
index ce75ab9b89..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/APTDispatchRunnable.java
+++ /dev/null
@@ -1,876 +0,0 @@
- /*******************************************************************************
- * Copyright (c) 2005, 2007 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;
-
-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.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.apt.core.env.Phase;
-import org.eclipse.jdt.apt.core.internal.env.AbstractCompilationEnv;
-import org.eclipse.jdt.apt.core.internal.env.BuildEnv;
-import org.eclipse.jdt.apt.core.internal.env.EclipseRoundCompleteEvent;
-import org.eclipse.jdt.apt.core.internal.env.ReconcileEnv;
-import org.eclipse.jdt.apt.core.internal.env.AbstractCompilationEnv.EnvCallback;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedFileManager;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.compiler.BuildContext;
-import org.eclipse.jdt.core.compiler.CategorizedProblem;
-import org.eclipse.jdt.core.compiler.ReconcileContext;
-
-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;
-
-public class APTDispatchRunnable implements IWorkspaceRunnable
-{
- /**
- * This callback method is passed to a ReconcileEnv to be called within
- * an AST pipeline in order to process a type during reconcile.
- * Reconciles involve only one type at a time, but can recurse, so
- * that multiple instances of this class are on the stack at one time.
- */
- private final class ReconcileEnvCallback implements EnvCallback {
- private final ReconcileContext _context;
- private final GeneratedFileManager _gfm;
-
- private ReconcileEnvCallback(ReconcileContext context,
- GeneratedFileManager gfm) {
- _context = context;
- _gfm = gfm;
- }
-
- public void run(AbstractCompilationEnv env) {
- // This is a ReconcileEnvCallback, so we better be dealing with a ReconcileEnv!
- ReconcileEnv reconcileEnv = (ReconcileEnv)env;
-
- // Dispatch the annotation processors. Env will keep track of problems and generated types.
- try {
- dispatchToFileBasedProcessor(reconcileEnv, true, true);
- } catch (Throwable t) {
- AptPlugin.log(t, "Processor failure during reconcile"); //$NON-NLS-1$
- }
-
- // "Remove" any types that were generated in the past but not on this round.
- // Because this is a reconcile, if a file exists on disk we can't really remove
- // it, we can only create a blank WorkingCopy that hides it; thus, we can only
- // remove Java source files, not arbitrary files.
- ICompilationUnit parentWC = _context.getWorkingCopy();
- Set<IFile> newlyGeneratedFiles = reconcileEnv.getAllGeneratedFiles();
- _gfm.deleteObsoleteTypesAfterReconcile(parentWC, newlyGeneratedFiles);
-
- // Report problems to the ReconcileContext.
- final List<? extends CategorizedProblem> problemList = reconcileEnv.getProblems();
- final int numProblems = problemList.size();
- if (numProblems > 0) {
- final CategorizedProblem[] aptCatProblems = new CategorizedProblem[numProblems];
- _context.putProblems(
- AptPlugin.APT_COMPILATION_PROBLEM_MARKER, problemList
- .toArray(aptCatProblems));
- }
-
- // Tell the Env that the round is complete.
- // This also calls resetAST() on the context.
- reconcileEnv.close();
- }
- }
-
- private static final BuildContext[] NO_FILES_TO_PROCESS = new BuildContext[0];
- private /*final*/ BuildContext[] _filesWithAnnotation = null;
- private /*final*/ BuildContext[] _filesWithoutAnnotation = null;
- private /*final*/ Map<IFile, CategorizedProblem[]> _problemRecorder = null;
- private final AptProject _aptProject;
- private final Map<AnnotationProcessorFactory, FactoryPath.Attributes> _factories;
- /** Batch processor dispatched in the previous rounds */
- private final Set<AnnotationProcessorFactory> _dispatchedBatchFactories;
- /** Batch processor dispatched in the current round */
- private Set<AnnotationProcessorFactory> _currentDispatchBatchFactories = Collections.emptySet();
- private final boolean _isFullBuild;
-
-
- public static Set<AnnotationProcessorFactory> runAPTDuringBuild(
- BuildContext[] filesWithAnnotations,
- BuildContext[] filesWithoutAnnotations,
- Map<IFile, CategorizedProblem[]> problemRecorder,
- AptProject aptProject,
- Map<AnnotationProcessorFactory, FactoryPath.Attributes> factories,
- Set<AnnotationProcessorFactory> dispatchedBatchFactories,
- boolean isFullBuild){
-
- if( filesWithAnnotations == null ){
- filesWithAnnotations = NO_FILES_TO_PROCESS;
- }
- // If we're building, types can be generated, so we
- // want to run this as an atomic workspace operation
- APTDispatchRunnable runnable =
- new APTDispatchRunnable(
- filesWithAnnotations,
- filesWithoutAnnotations,
- problemRecorder,
- aptProject, factories,
- dispatchedBatchFactories, isFullBuild );
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- try {
- workspace.run(runnable, aptProject.getJavaProject().getResource(), IWorkspace.AVOID_UPDATE, null);
- }
- catch (CoreException ce) {
- AptPlugin.log(ce, "Could not run APT"); //$NON-NLS-1$
- }
- return runnable._currentDispatchBatchFactories;
- }
-
- public static void runAPTDuringReconcile(
- ReconcileContext reconcileContext,
- AptProject aptProject,
- Map<AnnotationProcessorFactory, FactoryPath.Attributes> factories)
- {
- // Reconciling, so we do not want to run this as an atomic workspace
- // operation. If we do, it is easy to have locking issues when someone
- // calls a reconcile from within a workspace lock
- APTDispatchRunnable runnable = new APTDispatchRunnable( aptProject, factories );
- runnable.reconcile(reconcileContext, aptProject.getJavaProject());
- }
-
- /** create a runnable used during build */
- private APTDispatchRunnable(
- BuildContext[] filesWithAnnotation,
- BuildContext[] filesWithoutAnnotation,
- Map<IFile, CategorizedProblem[]> problemRecorder,
- AptProject aptProject,
- Map<AnnotationProcessorFactory, FactoryPath.Attributes> factories,
- Set<AnnotationProcessorFactory> dispatchedBatchFactories,
- boolean isFullBuild)
- {
- assert filesWithAnnotation != null : "missing files"; //$NON-NLS-1$
- _filesWithAnnotation = filesWithAnnotation;
- _filesWithoutAnnotation = filesWithoutAnnotation;
- _problemRecorder = problemRecorder;
- _aptProject = aptProject;
- _factories = factories;
- _dispatchedBatchFactories = dispatchedBatchFactories;
- _isFullBuild = isFullBuild;
- }
- /** create a runnable used during reconcile */
- private APTDispatchRunnable(
- AptProject aptProject,
- Map<AnnotationProcessorFactory, FactoryPath.Attributes> factories)
- {
- _aptProject = aptProject;
- _factories = factories;
- _isFullBuild = false;
- // does not apply in reconcile case. we don't generate file during
- // reconcile and no apt rounding ever occur as a result.
- _dispatchedBatchFactories = Collections.emptySet();
- }
-
- private void reconcile(final ReconcileContext reconcileContext,
- IJavaProject javaProject)
- {
- if (_factories.size() == 0) {
- if (AptPlugin.DEBUG)
- trace("apt leaving project " + javaProject.getProject() + //$NON-NLS-1$
- " early because there are no factories", //$NON-NLS-1$
- null);
- //TODO: clean up generated working copies here? I think not necessary. - WSH 10/06
- return;
- }
-
- // Construct a reconcile time environment. This will invoke
- // dispatch from inside the callback.
- GeneratedFileManager gfm = _aptProject.getGeneratedFileManager();
- gfm.reconcileStarted();
- EnvCallback callback = new ReconcileEnvCallback(reconcileContext, gfm);
- AbstractCompilationEnv.newReconcileEnv(reconcileContext, callback);
-
- }
-
- public void run(IProgressMonitor monitor)
- {
- build();
- }
-
- /**
- * Determine whether there are files to be processed.
- * @return <code>true</code> iff APT processing should occur, return <code>false</code>
- * otherwise.
- *
- * APT should should run one of the following is true
- * 1) There are files with annotations
- * 2) There are factories dispatched in an earlier round
- */
- private boolean shouldBuild()
- {
- if( (_factories == null || _factories.size() == 0) && _dispatchedBatchFactories.isEmpty() )
- return false;
-
- int totalFiles = _filesWithAnnotation == null ? 0 : _filesWithAnnotation.length;
- // We are required to dispatch even though there are no files with annotations.
- // This is a documented behavior in the mirror spec.
- return totalFiles > 0 || !_dispatchedBatchFactories.isEmpty();
- }
-
- private void build(){
-
- if ( !shouldBuild() )
- {
- // tracing
- if ( AptPlugin.DEBUG )
- {
- String msg;
- if ( (_factories == null || _factories.size() == 0) && _dispatchedBatchFactories.isEmpty() )
- msg = "no AnnotationProcessoryFactory instances registered."; //$NON-NLS-1$
- else
- msg = "no files to dispatch to."; //$NON-NLS-1$
- trace( "run(): leaving project " + _aptProject.getJavaProject().getProject() + //$NON-NLS-1$
- " early because there are " + msg, //$NON-NLS-1$
- null);
- }
- cleanupAllGeneratedFiles();
- }
- else
- {
- assert _filesWithAnnotation != null :
- "should never be invoked unless we are in build mode!"; //$NON-NLS-1$
-
- EnvCallback buildCallback = new EnvCallback() {
- public void run(AbstractCompilationEnv env) {
- build((BuildEnv)env);
- }
- };
-
- // Construct build environment, this invokes the build inside a callback
- // in order to keep open the DOM AST pipeline
- BuildEnv.newBuildEnv(
- _filesWithAnnotation,
- _filesWithoutAnnotation,
- _aptProject.getJavaProject(),
- buildCallback);
- }
-
- // We need to save the file dependency state regardless of whether any Java 5 processing
- // was performed, because it may also contain Java 6 information.
- _aptProject.getGeneratedFileManager().writeState();
- }
-
- /**
- * @param factories
- * @return <code>true</code> iff there are factories that can only be run in batch mode.
- */
- private boolean hasBatchFactory()
- {
- for( FactoryPath.Attributes attr : _factories.values() ){
- if( attr.runInBatchMode() )
- return true;
- }
- return false;
-
- }
-
- /**
- * Batch processor should only be invoked during a clean build.
- * @param factories
- * @param processorEnv
- * @return <code>true</code> iff batch processors should be dispatched.
- * Return <code>false</code> otherwise. Return <code>false</code> if
- * there are no batch processors.
- */
- private boolean shouldDispatchToBatchProcessor(final AbstractCompilationEnv processorEnv )
- {
- return ( _isFullBuild && processorEnv.getPhase() == Phase.BUILD && hasBatchFactory() );
- }
-
- private void runAPTInFileBasedMode(final BuildEnv processorEnv)
- {
- final BuildContext[] cpResults = processorEnv.getFilesWithAnnotation();
- final GeneratedFileManager gfm = _aptProject.getGeneratedFileManager();
- boolean projectEnablesReconcile = AptConfig.shouldProcessDuringReconcile(_aptProject.getJavaProject());
- for (BuildContext curResult : cpResults ) {
- processorEnv.beginFileProcessing(curResult);
- dispatchToFileBasedProcessor(processorEnv, projectEnablesReconcile, false);
- reportResult(
- curResult,
- processorEnv.getAllGeneratedFiles(),
- processorEnv.getModifiedGeneratedFiles(),
- processorEnv.getProblems(),
- processorEnv.getTypeDependencies(),
- gfm,
- processorEnv);
- processorEnv.completedFileProcessing();
- }
- }
-
- /**
- * @param curResult
- * @param lastGeneratedFiles files generated from previous apt run.
- * @param generatedFiles all files generated from current apt run.
- * @param modifiedGeneratedFiles new generated files or files differs from those from
- * previous run.
- * @param problems problems from current apt run.
- * @param deps
- * @param gfm
- * @param processorEnv
- */
- private void reportResult(
- BuildContext curResult,
- Set<IFile> java5GeneratedFiles,
- Set<IFile> modifiedGeneratedFiles,
- List<? extends CategorizedProblem> problems,
- Set<String> deps,
- GeneratedFileManager gfm,
- BuildEnv processorEnv)
- {
- // Combine files generated by Java 5 and Java 6 processing phases
- Set<IFile> allGeneratedFiles = null;
- Set<IFile> java6GeneratedFiles = AptCompilationParticipant.getInstance().getJava6GeneratedFiles();
- if (java5GeneratedFiles == null || java5GeneratedFiles.isEmpty()) {
- if (java6GeneratedFiles.isEmpty()) {
- allGeneratedFiles = Collections.emptySet();
- }
- else {
- allGeneratedFiles = java6GeneratedFiles;
- }
- }
- else {
- if (java6GeneratedFiles.isEmpty()) {
- allGeneratedFiles = java5GeneratedFiles;
- }
- else {
- allGeneratedFiles = new HashSet<IFile>(java6GeneratedFiles);
- allGeneratedFiles.addAll(java5GeneratedFiles);
- }
- }
-
- // figure out exactly what got deleted
- final List<IFile> deletedFiles = new ArrayList<IFile>();
- IFile parentFile = curResult.getFile();
- cleanupNoLongerGeneratedFiles(
- parentFile,
- allGeneratedFiles,
- gfm,
- processorEnv,
- deletedFiles);
- // report newly created or modified generated files
- int numNewFiles = modifiedGeneratedFiles.size();
- if( numNewFiles > 0 ){
- final IFile[] newFilesArray = new IFile[numNewFiles];
- curResult.recordAddedGeneratedFiles(modifiedGeneratedFiles.toArray(newFilesArray));
- }
-
- // report deleted file.
- int numDeletedFiles = deletedFiles.size();
- if(numDeletedFiles > 0){
- final IFile[] deletedFilesArray = new IFile[numDeletedFiles];
- curResult.recordDeletedGeneratedFiles(deletedFiles.toArray(deletedFilesArray));
- }
-
- // report problems
- final int numProblems = problems.size();
- if( numProblems > 0 ){
- final CategorizedProblem[] catProblemsArray = new CategorizedProblem[numProblems];
- curResult.recordNewProblems(problems.toArray(catProblemsArray));
- // Tell compilation participant about the problems, so it can report them
- // again without reprocessing if a file is resubmitted.
- _problemRecorder.put(curResult.getFile(), catProblemsArray);
- }
-
- // report dependency
- final int numDeps = deps.size();
- if( numDeps > 0 ){
- final String[] depsArray = new String[numDeps];
- curResult.recordDependencies(deps.toArray(depsArray));
- }
- }
-
-
- /**
- * mixed mode - allow batch processor to be run as well as filed based ones.
- * @param processorEnv
- * @param currentRoundDispatchedBatchFactories output parameter. At return contains the
- * set of batch factories that has been dispatched.
- */
- private void runAPTInMixedMode(final BuildEnv processorEnv)
- {
- final BuildContext[] cpResults = processorEnv.getFilesWithAnnotation();
- final Map<BuildContext, Set<AnnotationTypeDeclaration>> file2AnnotationDecls =
- new HashMap<BuildContext, Set<AnnotationTypeDeclaration>>(cpResults.length * 4/3 + 1);
- final Map<String, AnnotationTypeDeclaration> annotationDecls =
- processorEnv.getAllAnnotationTypes(file2AnnotationDecls);
-
- if (annotationDecls.isEmpty() && _dispatchedBatchFactories.isEmpty() )
- {
- if ( AptPlugin.DEBUG )
- trace( "runAPT: leaving early because annotationDecls is empty", //$NON-NLS-1$
- processorEnv);
- return;
- }
-
- if( AptPlugin.DEBUG )
- trace( "annotations found " + annotationDecls.keySet(), processorEnv); //$NON-NLS-1$
-
- // file based processing factory to the set of annotations that it 'claims'
- final Map<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>> fileFactory2Annos =
- new HashMap<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>>( _factories.size() * 4/3 + 1 );
-
- // batch processing factory to the set of annotations that it 'claims'
- final Map<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>> batchFactory2Annos =
- new HashMap<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>>( _factories.size() * 4/3 + 1 );
-
- for( Map.Entry<AnnotationProcessorFactory, FactoryPath.Attributes> entry : _factories.entrySet() ){
- AnnotationProcessorFactory factory = entry.getKey();
- Set<AnnotationTypeDeclaration> annotationTypes = getFactorySupportedAnnotations(factory, annotationDecls);
- if( annotationTypes != null ){
-
- boolean batch = entry.getValue().runInBatchMode();
- Map<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration> > factory2Annos =
- batch ? batchFactory2Annos : fileFactory2Annos;
- if( annotationTypes.size() == 0 ){
- // this factory is claiming all (remaining) annotations.
- annotationTypes = new HashSet<AnnotationTypeDeclaration>(annotationDecls.values());
- factory2Annos.put(factory, annotationTypes);
- annotationDecls.clear();
- break;
- }
- else{
- factory2Annos.put(factory, annotationTypes);
- }
- }
- if( annotationDecls.isEmpty() )
- break;
- }
-
- if( ! annotationDecls.isEmpty() ){
- // TODO: (theodora) log unclaimed annotations?
- }
-
- // Dispatch to the batch process factories first.
- // Batch processors only get executed on a full/clean build
- if( !batchFactory2Annos.isEmpty() ||
- (_dispatchedBatchFactories != null && !_dispatchedBatchFactories.isEmpty()) ){
-
- processorEnv.beginBatchProcessing();
- if( !batchFactory2Annos.isEmpty()){
- // Once we figure out which factory claims what annotation,
- // the order of the factory doesn't matter.
- // But in order to make things consists between runs, will
- // dispatch base on factory order.
- _currentDispatchBatchFactories = new LinkedHashSet<AnnotationProcessorFactory>();
- for(AnnotationProcessorFactory factory : _factories.keySet() ){
- final Set<AnnotationTypeDeclaration> annotationTypes = batchFactory2Annos.get(factory);
- if( annotationTypes == null ) continue;
- final AnnotationProcessor processor =
- factory.getProcessorFor(annotationTypes, processorEnv);
- if( processor != null ){
- if ( AptPlugin.DEBUG )
- trace( "runAPT: invoking batch processor " + processor.getClass().getName(), //$NON-NLS-1$
- processorEnv);
- _currentDispatchBatchFactories.add(factory);
- processorEnv.setCurrentProcessorFactory(factory, false);
- processor.process();
- processorEnv.setCurrentProcessorFactory(null, false);
- }
- }
- }
- // We have to dispatch to factories even though we may not have discovered any annotations.
- // This is a documented APT behavior that we have to observe.
- for( AnnotationProcessorFactory prevRoundFactory : _dispatchedBatchFactories ){
- if(_currentDispatchBatchFactories.contains(prevRoundFactory))
- continue;
- final AnnotationProcessor processor =
- prevRoundFactory.getProcessorFor(Collections.<AnnotationTypeDeclaration>emptySet(), processorEnv);
- if( processor != null ){
- if ( AptPlugin.DEBUG )
- trace( "runAPT: invoking batch processor " + processor.getClass().getName(), //$NON-NLS-1$
- processorEnv);
- processorEnv.setCurrentProcessorFactory(prevRoundFactory, false);
- processor.process();
- processorEnv.setCurrentProcessorFactory(null, false);
- }
- }
-
- // Currently, we are putting everything in the first file annotations.
- // TODO: Is this correct?
- // Why is it ok (today):
- // 1) Problems are reported as IMarkers and not IProblem thru the
- // BuildContext API.
- // 2) jdt is currently not doing anything about the parent->generated file relation
- // so it doesn't matter which BuildContext we attach the
- // creation/modification/deletion of generated files. -theodora
- BuildContext firstResult = null;
- if( cpResults.length > 0 )
- firstResult = cpResults[0];
- else{
- final BuildContext[] others = processorEnv.getFilesWithoutAnnotation();
- if(others != null && others.length > 0 )
- firstResult = others[0];
- }
-
- // If there are no files to be built, apt will not be involved.
- assert firstResult != null : "don't know where to report results"; //$NON-NLS-1$
- if(firstResult != null ){
- final GeneratedFileManager gfm = _aptProject.getGeneratedFileManager();
- reportResult(
- firstResult, // just put it all in
- processorEnv.getAllGeneratedFiles(),
- processorEnv.getModifiedGeneratedFiles(),
- processorEnv.getProblems(), // this is empty in batch mode.
- processorEnv.getTypeDependencies(), // this is empty in batch mode.
- gfm,
- processorEnv);
- }
- processorEnv.completedBatchProcessing();
- }
-
- // Now, do the file based dispatch
- if( !fileFactory2Annos.isEmpty() ){
- boolean projectEnablesReconcile = AptConfig.shouldProcessDuringReconcile(_aptProject.getJavaProject());
- for(BuildContext curResult : cpResults ){
- final Set<AnnotationTypeDeclaration> annotationTypesInFile = file2AnnotationDecls.get(curResult);
- if( annotationTypesInFile == null || annotationTypesInFile.isEmpty() )
- continue;
- for(AnnotationProcessorFactory factory : _factories.keySet() ){
- final Set<AnnotationTypeDeclaration> annotationTypesForFactory = fileFactory2Annos.get(factory);
- if( annotationTypesForFactory == null || annotationTypesForFactory.isEmpty() )
- continue;
- final Set<AnnotationTypeDeclaration> intersect = setIntersect(annotationTypesInFile, annotationTypesForFactory);
- if( intersect != null && !intersect.isEmpty() ){
- processorEnv.beginFileProcessing(curResult);
- final AnnotationProcessor processor =
- factory.getProcessorFor(intersect, processorEnv);
- if( processor != null ){
- if ( AptPlugin.DEBUG )
- trace( "runAPT: invoking file-based processor " + processor.getClass().getName(), //$NON-NLS-1$
- processorEnv );
- //TODO in 3.4: also consider factory path attributes
- boolean willReconcile = projectEnablesReconcile && AbstractCompilationEnv.doesFactorySupportReconcile(factory);
- processorEnv.setCurrentProcessorFactory(factory, willReconcile);
- processor.process();
- processorEnv.setCurrentProcessorFactory(null, false);
- }
- }
- }
-
- final GeneratedFileManager gfm = _aptProject.getGeneratedFileManager();
- reportResult(
- curResult,
- processorEnv.getAllGeneratedFiles(),
- processorEnv.getModifiedGeneratedFiles(),
- processorEnv.getProblems(),
- processorEnv.getTypeDependencies(),
- gfm,
- processorEnv);
- processorEnv.completedFileProcessing();
- }
- }
- }
-
- /**
- * @param projectEnablesReconcile true if reconcile-time processing is enabled in the current project
- * @param isReconcile true if this call is during reconcile, e.g., processorEnv is a ReconcileEnv
- */
- private void dispatchToFileBasedProcessor(
- final AbstractCompilationEnv processorEnv,
- boolean projectEnablesReconcile, boolean isReconcile){
-
- Map<String, AnnotationTypeDeclaration> annotationDecls = processorEnv.getAnnotationTypes();
- for( Map.Entry<AnnotationProcessorFactory, FactoryPath.Attributes> entry : _factories.entrySet() ){
- if( entry.getValue().runInBatchMode() ) continue;
- AnnotationProcessorFactory factory = entry.getKey();
- //TODO in 3.4: also consider factory path attributes
- boolean reconcileSupported = projectEnablesReconcile &&
- AbstractCompilationEnv.doesFactorySupportReconcile(factory);
- if (isReconcile && !reconcileSupported)
- continue;
- Set<AnnotationTypeDeclaration> factoryDecls = getFactorySupportedAnnotations(factory, annotationDecls);
- if( factoryDecls != null ){
- if(factoryDecls.size() == 0 ){
- factoryDecls = new HashSet<AnnotationTypeDeclaration>(annotationDecls.values());
- annotationDecls.clear();
- }
- }
- if (factoryDecls != null && factoryDecls.size() > 0) {
- final AnnotationProcessor processor = factory
- .getProcessorFor(factoryDecls, processorEnv);
- if (processor != null)
- {
- if ( AptPlugin.DEBUG ) {
- trace( "runAPT: invoking file-based processor " + processor.getClass().getName() + " on " + processorEnv.getFile(), //$NON-NLS-1$ //$NON-NLS-2$
- processorEnv);
- }
- processorEnv.setCurrentProcessorFactory(factory, reconcileSupported);
- processor.process();
- processorEnv.setCurrentProcessorFactory(null, false);
- }
- }
-
- if (annotationDecls.isEmpty())
- break;
- }
- if( ! annotationDecls.isEmpty() ){
- // TODO: (theodora) log unclaimed annotations.
- }
- }
-
- /**
- * @param processorEnv
- * @param filesWithMissingType
- * @param internalRound
- * @param result output parameter
- */
- private Set<AnnotationProcessorFactory> build(final BuildEnv processorEnv)
- {
- try {
- boolean mixedModeDispatch = shouldDispatchToBatchProcessor(processorEnv);
- if( mixedModeDispatch ){
- runAPTInMixedMode(processorEnv);
- }
- else{
- runAPTInFileBasedMode(processorEnv);
- }
-
- // notify the processor listeners
- final Set<AnnotationProcessorListener> listeners = processorEnv
- .getProcessorListeners();
- EclipseRoundCompleteEvent event = null;
- for (AnnotationProcessorListener listener : listeners) {
- if (listener instanceof RoundCompleteListener) {
- if (event == null)
- event = new EclipseRoundCompleteEvent(processorEnv);
- final RoundCompleteListener rcListener = (RoundCompleteListener) listener;
- rcListener.roundComplete(event);
- }
- }
- if( _filesWithoutAnnotation != null ){
- cleanupAllGeneratedFilesFrom(_filesWithoutAnnotation);
- }
-
-
- // log unclaimed annotations.
- }
- catch (Error t) {
- // Don't catch junit exceptions. This prevents one from unit
- // testing a processor
- if (t.getClass().getName().startsWith("junit.framework")) //$NON-NLS-1$
- throw t;
- AptPlugin.logWarning(t, "Unexpected failure running APT on the file(s): " + getFileNamesForPrinting(processorEnv)); //$NON-NLS-1$
- }
- catch (Throwable t) {
- AptPlugin.logWarning(t, "Unexpected failure running APT on the file(s): " + getFileNamesForPrinting(processorEnv)); //$NON-NLS-1$
- }
- finally {
- processorEnv.close();
- }
-
- return Collections.emptySet();
- }
-
- /**
- * @param one
- * @param two
- * @return the set intersect of the two given sets
- */
- private Set<AnnotationTypeDeclaration> setIntersect(Set<AnnotationTypeDeclaration> one, Set<AnnotationTypeDeclaration> two ){
- Set<AnnotationTypeDeclaration> intersect = null;
- for( AnnotationTypeDeclaration obj : one ){
- if( two.contains(obj) ){
- if( intersect == null )
- intersect = new HashSet<AnnotationTypeDeclaration>();
- intersect.add(obj);
- }
- }
- return intersect;
- }
-
- private void cleanupAllGeneratedFiles(){
- cleanupAllGeneratedFilesFrom(_filesWithAnnotation);
- cleanupAllGeneratedFilesFrom(_filesWithoutAnnotation);
- }
-
- private void cleanupAllGeneratedFilesFrom(BuildContext[] cpResults){
- if (cpResults == null) {
- return;
- }
- final Set<IFile> deleted = new HashSet<IFile>();
- GeneratedFileManager gfm = _aptProject.getGeneratedFileManager();
- Set<IFile> java6GeneratedFiles = AptCompilationParticipant.getInstance().getJava6GeneratedFiles();
- for( BuildContext cpResult : cpResults){
- final IFile parentFile = cpResult.getFile();
- cleanupNoLongerGeneratedFiles(
- parentFile,
- java6GeneratedFiles,
- gfm,
- null,
- deleted);
-
- if( deleted.size() > 0 ){
- final IFile[] deletedFilesArray = new IFile[deleted.size()];
- cpResult.recordDeletedGeneratedFiles(deleted.toArray(deletedFilesArray));
- }
- }
- }
-
- /**
- * Remove all the files that were previously generated
- * from a particular parent file, but that were not generated
- * in the most recent build pass.
- * <p>
- * Must be called during build phase, not reconcile
- *
- * @param parent the BuildContext associated with a single
- * compiled parent file
- * @param lastGeneratedFiles the files generated from parent
- * on the previous build; typically obtained from the GFM just
- * prior to beginning the current build.
- * @param newGeneratedFiles the files generated from parent
- * on the current build; typically stored in the BuildEnv, but
- * an empty set can be passed in to remove all generated files
- * of this parent.
- * @param gfm
- * @param processorEnv
- * @param deleted
- */
- private void cleanupNoLongerGeneratedFiles(
- IFile parentFile,
- Set<IFile> newGeneratedFiles,
- GeneratedFileManager gfm,
- BuildEnv processorEnv,
- Collection<IFile> deleted)
- {
- deleted.addAll(gfm.deleteObsoleteFilesAfterBuild(parentFile, newGeneratedFiles));
- }
-
- /**
- * @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> getFactorySupportedAnnotations(
- 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("*")) { //$NON-NLS-1$
- fDecls.addAll(declarations.values());
- declarations.clear();
-
- // Warn that * was claimed, which is non-optimal
- AptPlugin.logWarning(null, "Processor Factory " + factory + //$NON-NLS-1$
- " claimed all annotations (*), which prevents any following factories from being dispatched."); //$NON-NLS-1$
-
- } else if (typeName.endsWith("*")) { //$NON-NLS-1$
- 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(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;
- }
-
- private static void trace( String s, AbstractCompilationEnv processorEnv )
- {
- if (AptPlugin.DEBUG)
- {
- if (processorEnv != null) {
- s = "[ phase = " + processorEnv.getPhase() + ", file = " + getFileNamesForPrinting(processorEnv) +" ] " + s; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- AptPlugin.trace( s );
- }
- }
-
- private static String getFileNamesForPrinting(final AbstractCompilationEnv env){
- if( env instanceof ReconcileEnv ){
- return env.getFile().getName();
- }
- else{
- return getFileNamesForPrinting((BuildEnv)env);
- }
- }
-
- /**
- * For debugging statements only!!
- * @return the names of the files that we are currently processing.
- */
- private static String getFileNamesForPrinting(final BuildEnv processorEnv){
- final IFile file = processorEnv.getFile();
- if( file != null )
- return file.getName();
- final BuildContext[] results = processorEnv.getFilesWithAnnotation();
- final int len = results.length;
- switch( len )
- {
- case 0:
- return "no file(s)"; //$NON-NLS-1$
- case 1:
- return results[0].getFile().getName();
- default:
- StringBuilder sb = new StringBuilder();
- boolean firstItem = true;
- for (BuildContext curResult : results) {
- if (firstItem) {
- firstItem = false;
- }
- else {
- sb.append(", "); //$NON-NLS-1$
- }
- sb.append(curResult.getFile().getName());
- }
- return sb.toString();
- }
- }
-}
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 4d5666ee9f..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AnnotationProcessorFactoryLoader.java
+++ /dev/null
@@ -1,811 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import org.eclipse.core.resources.IMarker;
-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.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPathUtil;
-import org.eclipse.jdt.apt.core.internal.util.FactoryContainer.FactoryType;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath.Attributes;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-
-/**
- * Stores annotation processor factories, and handles mapping from projects
- * to them. This is a singleton object, created by the first call to getLoader().
- * <p>
- * Factories contained in plugins are loaded at APT initialization time.
- * Factories contained in jar files are loaded for a given project the first time
- * getFactoriesForProject() is called, and cached thereafter. Factories are loaded
- * from one of two custom classloaders depending on whether the factory container
- * is to be run in batch processing mode or normal (iterative) mode; the batch
- * classloader for a project is parented by the iterative classloader for that
- * project.
- * <p>
- * <strong>Processor Factories</strong>
- * <p>
- * This class is compilable against a Java 1.5 runtime. However, it includes
- * support for discovering and loading both Java 5 and Java 6 annotation
- * processors. Java 5 annotation processors include a factory object, the
- * AnnotationProcessorFactory, so for Java 5 we simply cache the factory; the
- * client code uses the factory to produce an actual AnnotationProcessor.
- * Java 6 processors do not have a separate factory, so we cache the Class
- * object of the processor implementation and use it to produce new instances.
- * This is wrapped within an IServiceFactory interface, for flexibility in
- * loading from various sources. The actual Processor class does not exist
- * in the Java 1.5 runtime, so all access to it must be done via reflection.
- * <p>
- * <strong>Caches</strong>
- * <p>
- * Factory classes and iterative-mode classloaders are cached for each project,
- * the first time that the classes are needed (e.g., during a build or reconcile).
- * The cache is cleared when the project's factory path changes, when a resource
- * listed on the factory path is changed, or when the project is deleted.
- * If a project contains batch-mode processors, the cache is also cleared at
- * the beginning of every full build (batch-mode processors do not run at all
- * during reconcile).
- * <p>
- * If a project's factory path includes containers which cannot be located on
- * disk, problem markers will be added to the project. This validation process
- * occurs when the cache for a project is first loaded, and whenever the cache
- * is invalidated. We do not validate the workspace-level factory path as such;
- * it is only used to construct a project-specific factory path for projects
- * that do not have their own factory path.
- * <p>
- * In order to efficiently perform re-validation when resources change, we keep
- * track of which projects' factory paths mention which containers. This is
- * stored as a map from canonicalized resource path to project. Entries are
- * created and updated during factory path validation, and removed upon project
- * deletion.
- * <p>
- * Resource changes are presented as delta trees which may contain more than
- * one change. When a change arrives, we build up a list of all potentially
- * affected projects, and then perform re-validation after the list is complete.
- * That way we avoid redundant validations if a project is affected by more
- * than one change.
- * <p>
- * Note that markers and factory classes have different lifetimes: they are
- * discarded at the same time (when something changes), but markers are recreated
- * immediately (as a result of validation) while factory classes are not reloaded
- * until the next time a build or reconcile occurs.
- * <p>
- * <strong>Synchronization</strong>
- * <p>
- * The loader is often accessed on multiple threads, e.g., a build thread, a
- * reconcile thread, and a change notification thread all at once. It is
- * important to maintain consistency across the various cache objects.
- */
-public class AnnotationProcessorFactoryLoader {
-
- /** Loader instance -- holds all workspace and project data */
- private static AnnotationProcessorFactoryLoader LOADER;
-
- private static final String JAR_EXTENSION = "jar"; //$NON-NLS-1$
-
- // Caches the factory classes associated with each project.
- // See class comments for lifecycle of items in this cache.
- private final Map<IJavaProject, Map<AnnotationProcessorFactory, FactoryPath.Attributes>> _project2Java5Factories =
- new HashMap<IJavaProject, Map<AnnotationProcessorFactory, FactoryPath.Attributes>>();
-
- private final Map<IJavaProject, Map<IServiceFactory, FactoryPath.Attributes>> _project2Java6Factories =
- new HashMap<IJavaProject, Map<IServiceFactory, FactoryPath.Attributes>>();
-
- // Caches the iterative classloaders so that iterative processors
- // are not reloaded on every batch build, unlike batch processors
- // which are.
- // See class comments for lifecycle of items in this cache.
- private final Map<IJavaProject, ClassLoader> _iterativeLoaders =
- new HashMap<IJavaProject, ClassLoader>();
-
- private final Map<IJavaProject,ClassLoader> _batchLoaders =
- new HashMap<IJavaProject,ClassLoader>();
-
- // Caches information about which resources affect which projects'
- // factory paths.
- // See class comments for lifecycle of items in this cache.
- private final Map<String, Set<IJavaProject>> _container2Project =
- new HashMap<String, Set<IJavaProject>>();
-
-
- /**
- * Listen for changes that would affect the factory caches or
- * build markers.
- */
- private class ResourceListener implements IResourceChangeListener {
-
- public void resourceChanged(IResourceChangeEvent event) {
- Map<IJavaProject, LoadFailureHandler> failureHandlers = new HashMap<IJavaProject, LoadFailureHandler>();
- synchronized (AnnotationProcessorFactoryLoader.this) {
- switch (event.getType()) {
-
- // Project deletion
- case (IResourceChangeEvent.PRE_DELETE) :
- IResource project = event.getResource();
- if (project != null && project instanceof IProject) {
- IJavaProject jproj = JavaCore.create((IProject)project);
- if (jproj != null) {
- uncacheProject(jproj);
- }
- }
- break;
-
- // Changes to jar files or .factorypath files
- case (IResourceChangeEvent.PRE_BUILD) :
- IResourceDelta rootDelta = event.getDelta();
- FactoryPathDeltaVisitor visitor = new FactoryPathDeltaVisitor();
- try {
- rootDelta.accept(visitor);
- } catch (CoreException e) {
- AptPlugin.log(e, "Unable to determine whether resource change affects annotation processor factory path"); //$NON-NLS-1$
- }
- Set<IJavaProject> affected = visitor.getAffectedProjects();
- if (affected != null) {
- processChanges(affected, failureHandlers);
- }
- break;
-
- }
- }
- for (LoadFailureHandler handler : failureHandlers.values()) {
- handler.reportFailureMarkers();
- }
- }
-
- }
-
- /**
- * Walk the delta tree to see if there have been changes to
- * a factory path or the containers it references. If so,
- * re-validate the affected projects' factory paths.
- */
- private class FactoryPathDeltaVisitor implements IResourceDeltaVisitor {
-
- // List of projects affected by this change.
- // Lazy construction because we assume most changes won't affect any projects.
- private Set<IJavaProject> _affected = null;
-
- private void addAffected(Set<IJavaProject> projects) {
- if (_affected == null) {
- _affected = new HashSet<IJavaProject>(5);
- }
- _affected.addAll(projects);
- }
-
- /**
- * Get the list of IJavaProject affected by the delta we visited.
- * Not valid until done visiting.
- * @return null if there were no affected projects, or a non-empty
- * set of IJavaProject otherwise.
- */
- public Set<IJavaProject> getAffectedProjects() {
- return _affected;
- }
-
- /**
- * @return true to visit children
- */
- public boolean visit(IResourceDelta delta) {
- switch (delta.getKind()) {
- default:
- return true;
- case IResourceDelta.ADDED :
- case IResourceDelta.REMOVED :
- case IResourceDelta.CHANGED :
- break;
- }
- // If the resource is a factory path file, then the project it
- // belongs to is affected.
- IResource res = delta.getResource();
- if (res == null) {
- return true;
- }
- IProject proj = res.getProject();
- if (FactoryPathUtil.isFactoryPathFile(res)) {
- addAffected(Collections.singleton(JavaCore.create(proj)));
- return true;
- }
- // If the resource is a jar file named in at least one factory
- // path, then the projects owning those factorypaths are affected.
- if (res.getType() != IResource.FILE) {
- return true;
- }
- IPath relativePath = res.getFullPath();
- String ext = relativePath.getFileExtension();
- try {
- if (JAR_EXTENSION.equals(ext)) {
- IPath absolutePath = res.getLocation();
- if (absolutePath == null) {
- // Jar file within a deleted project. In this case getLocation()
- // returns null, so we can't get a canonical path. Bounce every
- // factory path that contains anything resembling this jar.
- for (Entry<String, Set<IJavaProject>> entry : _container2Project.entrySet()) {
- IPath jarPath = new Path(entry.getKey());
- if (relativePath.lastSegment().equals(jarPath.lastSegment())) {
- addAffected(entry.getValue());
- }
- }
- }
- else {
- // Lookup key is the canonical path of the resource
- String key = null;
- key = absolutePath.toFile().getCanonicalPath();
- Set<IJavaProject> projects = _container2Project.get(key);
- if (projects != null) {
- addAffected(projects);
- }
- }
- }
- } catch (Exception e) {
- AptPlugin.log(e,
- "Couldn't determine whether any factory paths were affected by change to resource " + res.getName()); //$NON-NLS-1$
- }
- return true;
- }
-
- }
-
- /**
- * Singleton
- */
- public static synchronized AnnotationProcessorFactoryLoader getLoader() {
- if ( LOADER == null ) {
- LOADER = new AnnotationProcessorFactoryLoader();
- LOADER.registerListener();
- }
- return LOADER;
- }
-
- private void registerListener() {
- ResourcesPlugin.getWorkspace().addResourceChangeListener(
- new ResourceListener(),
- IResourceChangeEvent.PRE_DELETE
- | IResourceChangeEvent.PRE_BUILD);
- }
-
- /**
- * Called when workspace preferences change. Resource changes, including
- * changes to project-specific factory paths, are picked up through the
- * ResourceChangedListener mechanism instead.
- */
- public synchronized void resetAll() {
- removeAptBuildProblemMarkers( null );
- _project2Java5Factories.clear();
- _project2Java6Factories.clear();
- // Need to close the iterative classloaders
- for (ClassLoader cl : _iterativeLoaders.values()) {
- if (cl instanceof JarClassLoader)
- ((JarClassLoader)cl).close();
- }
- _iterativeLoaders.clear();
- _container2Project.clear();
-
- for (ClassLoader cl : _batchLoaders.values()) {
- if (cl instanceof JarClassLoader)
- ((JarClassLoader)cl).close();
- }
- _batchLoaders.clear();
-
- // Validate all projects
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- for (IProject proj : root.getProjects()) {
- verifyFactoryPath(JavaCore.create(proj));
- }
- }
-
- /**
- * Called when doing a clean build -- resets
- * the classloaders for the batch processors
- */
- public synchronized void resetBatchProcessors(IJavaProject javaProj) {
- Iterable<Attributes> attrs = null;
- Map<AnnotationProcessorFactory, Attributes> factories = _project2Java5Factories.get(javaProj);
- if (factories != null) {
- attrs = factories.values();
- }
- else {
- Map<IServiceFactory, Attributes> java6factories = _project2Java6Factories.get(javaProj);
- if (java6factories != null) {
- attrs = java6factories.values();
- }
- else {
- // This project's factories have already been cleared.
- return;
- }
- }
- boolean batchProcsFound = false;
- for (Attributes attr : attrs) {
- if (attr.runInBatchMode()) {
- batchProcsFound = true;
- break;
- }
- }
- if (batchProcsFound) {
- _project2Java5Factories.remove(javaProj);
- _project2Java6Factories.remove(javaProj);
- }
-
- ClassLoader c = _batchLoaders.remove(javaProj);
- if (c instanceof JarClassLoader) ((JarClassLoader)c).close();
- }
-
- /**
- * @param jproj must not be null
- * @return order preserving map of annotation processor factories to their attributes.
- * The order of the annotation processor factories respects the order of factory
- * containers in <code>jproj</code>. The map is unmodifiable, and may be empty but
- * will not be null.
- */
- public Map<AnnotationProcessorFactory, FactoryPath.Attributes>
- getJava5FactoriesAndAttributesForProject(IJavaProject jproj){
-
- // We can't create problem markers inside synchronization -- see https://bugs.eclipse.org/bugs/show_bug.cgi?id=184923
- LoadFailureHandler failureHandler = new LoadFailureHandler(jproj);
-
- synchronized (this) {
- Map<AnnotationProcessorFactory, FactoryPath.Attributes> factories = _project2Java5Factories.get(jproj);
- if( factories != null )
- return Collections.unmodifiableMap(factories);
-
- // Load the project
- FactoryPath fp = FactoryPathUtil.getFactoryPath(jproj);
- Map<FactoryContainer, FactoryPath.Attributes> containers = fp.getEnabledContainers();
- loadFactories(containers, jproj, failureHandler);
- }
-
- failureHandler.reportFailureMarkers();
- return Collections.unmodifiableMap(_project2Java5Factories.get(jproj));
-
- }
-
- /**
- * @param jproj must not be null
- * @return order preserving map of annotation processor factories to their attributes.
- * The order of the annotation processor factories respects the order of factory
- * containers in <code>jproj</code>. The map is unmodifiable, and may be empty but
- * will not be null.
- */
- public Map<IServiceFactory, FactoryPath.Attributes>
- getJava6FactoriesAndAttributesForProject(IJavaProject jproj){
-
- // We can't create problem markers inside synchronization -- see https://bugs.eclipse.org/bugs/show_bug.cgi?id=184923
- LoadFailureHandler failureHandler = new LoadFailureHandler(jproj);
-
- synchronized (this) {
-
- Map<IServiceFactory, FactoryPath.Attributes> factories = _project2Java6Factories.get(jproj);
- if( factories != null )
- return Collections.unmodifiableMap(factories);
-
- // Load the project
- FactoryPath fp = FactoryPathUtil.getFactoryPath(jproj);
- Map<FactoryContainer, FactoryPath.Attributes> containers = fp.getEnabledContainers();
- loadFactories(containers, jproj, failureHandler);
- }
-
- failureHandler.reportFailureMarkers();
- return Collections.unmodifiableMap(_project2Java6Factories.get(jproj));
-
- }
-
-/**
- * Convenience method: get the key set of the map returned by
- * @see #getJava5FactoriesAndAttributesForProject(IJavaProject) as a List.
- */
- public synchronized List<AnnotationProcessorFactory> getJava5FactoriesForProject( IJavaProject jproj ) {
-
- Map<AnnotationProcessorFactory, FactoryPath.Attributes> factoriesAndAttrs =
- getJava5FactoriesAndAttributesForProject(jproj);
- final List<AnnotationProcessorFactory> factories =
- new ArrayList<AnnotationProcessorFactory>(factoriesAndAttrs.keySet());
- return Collections.unmodifiableList(factories);
- }
-
- /**
- * Add the resource/project pair 'key' -> 'jproj' to the
- * _container2Project map.
- * @param key the canonicalized pathname of the resource
- * @param jproj must not be null
- */
- private void addToResourcesMap(String key, IJavaProject jproj) {
- Set<IJavaProject> s = _container2Project.get(key);
- if (s == null) {
- s = new HashSet<IJavaProject>();
- _container2Project.put(key, s);
- }
- s.add(jproj);
- }
-
- /**
- * Wrapper around ClassLoader.loadClass().newInstance() to handle reporting of errors.
- */
- private Object loadInstance( String factoryName, ClassLoader cl, IJavaProject jproj, LoadFailureHandler failureHandler )
- {
- Object f = null;
- try
- {
- Class<?> c = cl.loadClass( factoryName );
- f = c.newInstance();
- }
- catch( Exception e )
- {
- AptPlugin.trace("Failed to load factory " + factoryName, e); //$NON-NLS-1$
- failureHandler.addFailedFactory(factoryName);
- }
- catch ( NoClassDefFoundError ncdfe )
- {
- AptPlugin.trace("Failed to load " + factoryName, ncdfe); //$NON-NLS-1$
- failureHandler.addFailedFactory(factoryName);
- }
- return f;
- }
-
- /**
- * Load all Java 5 and Java 6 processors on the factory path. This also resets the
- * APT-related build problem markers. Results are saved in the factory caches.
- * @param containers an ordered map.
- */
- private void loadFactories(
- Map<FactoryContainer, FactoryPath.Attributes> containers,
- IJavaProject project,
- LoadFailureHandler failureHandler)
- {
- Map<AnnotationProcessorFactory, FactoryPath.Attributes> java5Factories =
- new LinkedHashMap<AnnotationProcessorFactory, FactoryPath.Attributes>();
- Map<IServiceFactory, FactoryPath.Attributes> java6Factories =
- new LinkedHashMap<IServiceFactory, FactoryPath.Attributes>();
-
- removeAptBuildProblemMarkers(project);
- Set<FactoryContainer> badContainers = verifyFactoryPath(project);
- if (badContainers != null) {
- for (FactoryContainer badFC : badContainers) {
- failureHandler.addFailedFactory(badFC.getId());
- containers.remove(badFC);
- }
- }
-
- // Need to use the cached classloader if we have one
- ClassLoader iterativeClassLoader = _iterativeLoaders.get(project);
- if (iterativeClassLoader == null) {
- iterativeClassLoader = _createIterativeClassLoader(containers);
- _iterativeLoaders.put(project, iterativeClassLoader);
- }
-
- _createBatchClassLoader(containers, project);
- ClassLoader batchClassLoader = _batchLoaders.get(project);
-
- for ( Map.Entry<FactoryContainer, FactoryPath.Attributes> entry : containers.entrySet() )
- {
- try {
- final FactoryContainer fc = entry.getKey();
- final FactoryPath.Attributes attr = entry.getValue();
- assert !attr.runInBatchMode() || (batchClassLoader != null);
- ClassLoader cl = attr.runInBatchMode() ? batchClassLoader : iterativeClassLoader;
-
- // First the Java 5 factories in this container...
- List<AnnotationProcessorFactory> java5FactoriesInContainer;
- java5FactoriesInContainer = loadJava5FactoryClasses(fc, cl, project, failureHandler);
- for ( AnnotationProcessorFactory apf : java5FactoriesInContainer ) {
- java5Factories.put( apf, entry.getValue() );
- }
-
- if (AptPlugin.canRunJava6Processors()) {
- // Now the Java 6 factories. Use the same classloader for the sake of sanity.
- List<IServiceFactory> java6FactoriesInContainer;
- java6FactoriesInContainer = loadJava6FactoryClasses(fc, cl, project, failureHandler);
- for ( IServiceFactory isf : java6FactoriesInContainer ) {
- java6Factories.put( isf, entry.getValue() );
- }
- }
- }
- catch (FileNotFoundException fnfe) {
- // it would be bizarre to get this, given that we already checked for file existence up above.
- AptPlugin.log(fnfe, Messages.AnnotationProcessorFactoryLoader_jarNotFound + fnfe.getLocalizedMessage());
- }
- catch (IOException ioe) {
- AptPlugin.log(ioe, Messages.AnnotationProcessorFactoryLoader_ioError + ioe.getLocalizedMessage());
- }
- }
- _project2Java5Factories.put(project, java5Factories);
- _project2Java6Factories.put(project, java6Factories);
- }
-
- private List<AnnotationProcessorFactory> loadJava5FactoryClasses(
- FactoryContainer fc, ClassLoader classLoader, IJavaProject jproj, LoadFailureHandler failureHandler )
- throws IOException
- {
- Map<String, String> factoryNames = fc.getFactoryNames();
- List<AnnotationProcessorFactory> factories = new ArrayList<AnnotationProcessorFactory>();
- for ( Entry<String, String> entry : factoryNames.entrySet() )
- {
- if (AptPlugin.JAVA5_FACTORY_NAME.equals(entry.getValue())) {
- String factoryName = entry.getKey();
- AnnotationProcessorFactory factory;
- if ( fc.getType() == FactoryType.PLUGIN )
- factory = FactoryPluginManager.getJava5FactoryFromPlugin( factoryName );
- else
- factory = (AnnotationProcessorFactory)loadInstance( factoryName, classLoader, jproj, failureHandler );
-
- if ( factory != null )
- factories.add( factory );
- }
- }
- return factories;
- }
-
- private List<IServiceFactory> loadJava6FactoryClasses(
- FactoryContainer fc, ClassLoader classLoader, IJavaProject jproj, LoadFailureHandler failureHandler )
- throws IOException
- {
- Map<String, String> factoryNames = fc.getFactoryNames();
- List<IServiceFactory> factories = new ArrayList<IServiceFactory>();
- for ( Entry<String, String> entry : factoryNames.entrySet() )
- {
- if (AptPlugin.JAVA6_FACTORY_NAME.equals(entry.getValue())) {
- String factoryName = entry.getKey();
- IServiceFactory factory = null;
- if ( fc.getType() == FactoryType.PLUGIN ) {
- factory = FactoryPluginManager.getJava6FactoryFromPlugin( factoryName );
- }
- else {
- Class<?> clazz;
- try {
- clazz = classLoader.loadClass(factoryName);
- factory = new ClassServiceFactory(clazz);
- } catch (ClassNotFoundException e) {
- AptPlugin.trace("Unable to load annotation processor " + factoryName, e); //$NON-NLS-1$
- failureHandler.addFailedFactory(factoryName);
- }
- }
-
- if ( factory != null )
- factories.add( factory );
- }
- }
- return factories;
- }
-
- /**
- * Re-validate projects whose factory paths may have been affected
- * by a resource change (e.g., adding a previously absent jar file).
- * This will cause build problem markers to be removed and regenerated,
- * and factory class caches to be cleared.
- */
- private void processChanges(Set<IJavaProject> affected, Map<IJavaProject,LoadFailureHandler> handlers) {
- for (IJavaProject jproj : affected) {
- removeAptBuildProblemMarkers(jproj);
- uncacheProject(jproj);
- }
- // We will do another clear and re-verify when loadFactories()
- // is called. But we have to do it then, because things might
- // have changed in the interim; and if we don't do it here, then
- // we'll have an empty _resources2Project cache, so we'll ignore
- // all resource changes until the next build. Is that a problem?
- for (IJavaProject jproj : affected) {
- if (jproj.exists()) {
- Set<FactoryContainer> badContainers = verifyFactoryPath(jproj);
- if (badContainers != null) {
- LoadFailureHandler handler = handlers.get(jproj);
- if (handler == null) {
- handler = new LoadFailureHandler(jproj);
- handlers.put(jproj, handler);
- }
- for (FactoryContainer container : badContainers) {
- handler.addMissingLibrary(container.getId());
- }
- }
- }
- }
-
- // TODO: flag the affected projects for rebuild.
- }
-
- /**
- * When a project is deleted, remove its factory path information from the loader.
- * @param jproj
- */
- private void uncacheProject(IJavaProject jproj) {
- _project2Java5Factories.remove(jproj);
- _project2Java6Factories.remove(jproj);
- ClassLoader c = _iterativeLoaders.remove(jproj);
- if (c instanceof JarClassLoader)
- ((JarClassLoader)c).close();
-
- ClassLoader cl = _batchLoaders.remove(jproj);
- if (cl instanceof JarClassLoader) ((JarClassLoader)cl).close();
-
- removeProjectFromResourceMap(jproj);
- }
-
- /**
- * Remove APT build problem markers, e.g., "missing factory jar".
- * @param jproj if null, remove markers from all projects that have
- * factory paths associated with them.
- */
- private void removeAptBuildProblemMarkers( IJavaProject jproj ) {
- // note that _project2Java6Factories.keySet() should be same as that for Java5.
- Set<IJavaProject> jprojects = (jproj == null) ? _project2Java5Factories.keySet() : Collections.singleton(jproj);
- try {
- for (IJavaProject jp : jprojects) {
- if (jp.exists()) {
- IProject p = jp.getProject();
- IMarker[] markers = p.findMarkers(AptPlugin.APT_LOADER_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
- if( markers != null ){
- for( IMarker marker : markers )
- marker.delete();
- }
- }
- }
- }
- catch(CoreException e){
- AptPlugin.log(e, "Unable to delete APT build problem marker"); //$NON-NLS-1$
- }
- }
-
- /**
- * Remove references to the project from _container2Project. This is done
- * when a project is deleted, or before re-verifying the project's
- * factory path.
- */
- private void removeProjectFromResourceMap(IJavaProject jproj) {
- Iterator<Entry<String, Set<IJavaProject>>> i = _container2Project.entrySet().iterator();
- while (i.hasNext()) {
- Entry<String, Set<IJavaProject>> e = i.next();
- Set<IJavaProject> s = e.getValue();
- s.remove(jproj);
- // Remove any resulting orphaned resources.
- if (s.isEmpty()) {
- i.remove();
- }
- }
- }
-
- /**
- * Check the factory path for a project and ensure that all the
- * containers it lists are available. Adds jar factory container
- * resources to the _container2Project cache, whether or not the
- * resource can actually be found.
- *
- * @param jproj the project, or null to check all projects that
- * are in the cache.
- * @return a Set of all invalid containers, or null if all containers
- * on the path were valid.
- */
- private Set<FactoryContainer> verifyFactoryPath(IJavaProject jproj) {
- Set<FactoryContainer> badContainers = null;
- FactoryPath fp = FactoryPathUtil.getFactoryPath(jproj);
- Map<FactoryContainer, FactoryPath.Attributes> containers = fp.getEnabledContainers();
- for (FactoryContainer fc : containers.keySet()) {
- if (fc instanceof JarFactoryContainer) {
- try {
- final File jarFile = ((JarFactoryContainer)fc).getJarFile();
- // if null, will add to bad container set below.
- if( jarFile != null ){
- String key = jarFile.getCanonicalPath();
- addToResourcesMap(key, jproj);
- }
- } catch (IOException e) {
- // If there's something this malformed on the factory path,
- // don't bother putting it on the resources map; we'll never
- // get notified about a change to it anyway. It should get
- // reported either as a bad container (below) or as a failure
- // to load (later on).
- }
- }
- if ( !fc.exists() ) {
- if (badContainers == null) {
- badContainers = new HashSet<FactoryContainer>();
- }
- badContainers.add(fc);
- }
- }
- return badContainers;
- }
-
- /**
- * @param containers an ordered map.
- */
- private ClassLoader _createIterativeClassLoader( Map<FactoryContainer, FactoryPath.Attributes> containers )
- {
- ArrayList<File> fileList = new ArrayList<File>( containers.size() );
- for (Map.Entry<FactoryContainer, FactoryPath.Attributes> entry : containers.entrySet()) {
- FactoryPath.Attributes attr = entry.getValue();
- FactoryContainer fc = entry.getKey();
- if (!attr.runInBatchMode() && fc instanceof JarFactoryContainer) {
- JarFactoryContainer jfc = (JarFactoryContainer)fc;
- fileList.add( jfc.getJarFile() );
- }
- }
-
- ClassLoader cl;
- if ( fileList.size() > 0 ) {
- cl = createClassLoader( fileList, AnnotationProcessorFactoryLoader.class.getClassLoader() );
- }
- else {
- cl = AnnotationProcessorFactoryLoader.class.getClassLoader();
- }
- return cl;
- }
-
- private void _createBatchClassLoader(Map<FactoryContainer, FactoryPath.Attributes> containers,
- IJavaProject p)
- {
-
- ArrayList<File> fileList = new ArrayList<File>( containers.size() );
- for (Map.Entry<FactoryContainer, FactoryPath.Attributes> entry : containers.entrySet()) {
- FactoryPath.Attributes attr = entry.getValue();
- FactoryContainer fc = entry.getKey();
- if (attr.runInBatchMode() && fc instanceof JarFactoryContainer) {
-
- JarFactoryContainer jfc = (JarFactoryContainer)fc;
- File f = jfc.getJarFile();
- fileList.add( f );
-
- }
- }
-
- // Try to use the iterative CL as parent, so we can resolve classes within it
- ClassLoader parentCL = _iterativeLoaders.get(p);
- if (parentCL == null) {
- parentCL = AnnotationProcessorFactoryLoader.class.getClassLoader();
- }
-
- if ( fileList.size() > 0 ) {
- _batchLoaders.put(p,createClassLoader( fileList, parentCL));
- }
- }
-
- private static ClassLoader createClassLoader(List<File> files, ClassLoader parentCL) {
- //return new JarClassLoader(files, parentCL);
- List<URL> urls = new ArrayList<URL>(files.size());
- for (int i=0;i<files.size();i++) {
- try {
- urls.add(files.get(i).toURI().toURL());
- }
- catch (MalformedURLException mue) {
- // ignore
- }
- }
- URL[] urlArray = urls.toArray(new URL[urls.size()]);
- return new URLClassLoader(urlArray, parentCL);
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptCompilationParticipant.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptCompilationParticipant.java
deleted file mode 100644
index 433c2a80d7..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptCompilationParticipant.java
+++ /dev/null
@@ -1,291 +0,0 @@
- /*******************************************************************************
- * Copyright (c) 2005, 2007 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;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-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.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.compiler.BuildContext;
-import org.eclipse.jdt.core.compiler.CategorizedProblem;
-import org.eclipse.jdt.core.compiler.CompilationParticipant;
-import org.eclipse.jdt.core.compiler.ReconcileContext;
-
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-
-/**
- * A singleton object, created by callback through the
- * org.eclipse.jdt.core.compilationParticipants extension point.
- */
-public class AptCompilationParticipant extends CompilationParticipant
-{
- /**
- * Batch factories that claimed some annotation in a previous round of APT processing.
- * This currently only apply to the build case since are only generating types during build
- * and hence cause APT rounding.
- * The set is an order preserving. The order is determined by their first invocation.
- */
- private Set<AnnotationProcessorFactory> _previousRoundsBatchFactories = new LinkedHashSet<AnnotationProcessorFactory>();
- private int _buildRound = 0;
- private boolean _isBatch = false;
- private static AptCompilationParticipant INSTANCE;
- /**
- * Files that has been processed by apt during the current build.
- * Files that has been compiled may need re-compilation (from jdt's perspective)
- * because of newly generated types. APT only process each file once during a build and
- * this set will prevent unnecessary/incorrect compilation of already processed files.
- */
- private Map<IFile, CategorizedProblem[]> _processedFiles = null;
-
- /**
- * Files generated by Java 6 annotation processing during the current build.
- * These must be stored here in order to communicate between the Java 6 annotation
- * processing phase, which runs during Java compilation, and the Java 5 phase,
- * which runs afterwards. This member is reinitialized during aboutToBuild()
- * and cleared in buildComplete().
- *
- * Doing it this way implies that files can only be generated by Java 6 processing
- * during a build. That is true as of 8/07. If that changes, then this may need
- * to be stored as a thread local, or elsewhere entirely.
- */
- private HashSet<IFile> _java6GeneratedFiles = null;
-
- public static AptCompilationParticipant getInstance() {
- return INSTANCE;
- }
-
- /**
- * This class is constructed indirectly, by registering an extension to the
- * org.eclipse.jdt.core.compilationParticipants extension point. Other
- * clients should NOT construct this object.
- */
- public AptCompilationParticipant()
- {
- INSTANCE = this;
-
- // Bug 180107: there is no CompilationParticipant.buildComplete() method,
- // so we have to use a resource change listener instead.
- IResourceChangeListener listener = new IResourceChangeListener() {
- public void resourceChanged(IResourceChangeEvent event) {
- buildComplete();
- }
- };
- ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_BUILD);
- }
-
- public boolean isAnnotationProcessor(){
- return true;
- }
-
- public void buildStarting(BuildContext[] files, boolean isBatch){
- // this gets called multiple times during a build.
- // This gets called:
- // 1) after "aboutToBuild" is called.
- // 2) everytime an incremental build occur because of newly generated files
- // this gets called.
- if( _buildRound == 0 )
- _isBatch = isBatch;
- }
-
- public void processAnnotations(BuildContext[] allfiles) {
- // This should not happen. There should always be file that that needs
- // building when
- final int total = allfiles == null ? 0 : allfiles.length;
- if( total == 0 )
- return;
-
- final IProject project = allfiles[0].getFile().getProject();
- final IJavaProject javaProject = JavaCore.create(project);
- // Don't dispatch on pre-1.5 project. They cannot legally have annotations
- String javaVersion = javaProject.getOption("org.eclipse.jdt.core.compiler.source", true); //$NON-NLS-1$
- // Check for 1.3 or 1.4, as we don't want this to break in the future when 1.6
- // is a possibility
- if ("1.3".equals(javaVersion) || "1.4".equals(javaVersion)) { //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
-
- if ( _isBatch && _buildRound == 0 ) {
- AnnotationProcessorFactoryLoader.getLoader().resetBatchProcessors(javaProject);
- _previousRoundsBatchFactories.clear();
- }
-
- try {
-
- // split up the list of files with annotations from those that don't
- // also exclude files that has already been processed.
- int annoFileCount = 0;
- int noAnnoFileCount = 0;
- for( int i=0; i<total; i++ ){
- BuildContext bc = allfiles[i];
- if( _buildRound > 0 && _processedFiles.containsKey( bc.getFile() )){
- // We've already processed this file; we'll skip reprocessing it, on
- // the assumption that nothing would change, but we need to re-report
- // any problems we reported earlier because JDT will have cleared them.
- CategorizedProblem[] problems = _processedFiles.get(bc.getFile());
- if (null != problems && problems.length > 0) {
- bc.recordNewProblems(problems);
- }
- continue;
- }
- if( bc.hasAnnotations() )
- annoFileCount ++;
- else
- noAnnoFileCount ++;
- }
- // apt has already processed all files
- // files that are reported at this point is triggered by
- // dependencies introduced by type creation.
- if( annoFileCount == 0 && noAnnoFileCount == 0 )
- return;
-
- BuildContext[] withAnnotation = null;
- BuildContext[] withoutAnnotation = null;
-
- if( annoFileCount != 0 )
- withAnnotation = new BuildContext[annoFileCount];
- if(noAnnoFileCount != 0 )
- withoutAnnotation = new BuildContext[noAnnoFileCount];
- int wIndex = 0; // index for 'withAnnotation' array
- int woIndex = 0; // index of 'withoutAnnotation' array
- for( int i=0; i<total; i++ ){
- if( _processedFiles.containsKey( allfiles[i].getFile() ) )
- continue;
- if( allfiles[i].hasAnnotations() )
- withAnnotation[wIndex ++] = allfiles[i];
- else
- withoutAnnotation[woIndex ++] = allfiles[i];
- }
-
- for( BuildContext file : allfiles )
- _processedFiles.put(file.getFile(), null);
-
- Map<AnnotationProcessorFactory, FactoryPath.Attributes> factories =
- AnnotationProcessorFactoryLoader.getLoader().getJava5FactoriesAndAttributesForProject(javaProject);
-
- AptProject aptProject = AptPlugin.getAptProject(javaProject);
- Set<AnnotationProcessorFactory> dispatchedBatchFactories =
- APTDispatchRunnable.runAPTDuringBuild(
- withAnnotation,
- withoutAnnotation,
- _processedFiles,
- aptProject,
- factories,
- _previousRoundsBatchFactories,
- _isBatch);
- _previousRoundsBatchFactories.addAll(dispatchedBatchFactories);
- }
- finally {
- _buildRound ++;
- }
- }
-
- public void reconcile(ReconcileContext context){
- final ICompilationUnit workingCopy = context.getWorkingCopy();
- if( workingCopy == null )
- return;
- IJavaProject javaProject = workingCopy.getJavaProject();
- if( javaProject == null )
- return;
- if (!AptConfig.shouldProcessDuringReconcile(javaProject)) {
- AptPlugin.trace("Reconcile-time processing is disabled for project: " + javaProject.getElementName()); //$NON-NLS-1$
- return;
- }
- AptProject aptProject = AptPlugin.getAptProject(javaProject);
-
- Map<AnnotationProcessorFactory, FactoryPath.Attributes> factories =
- AnnotationProcessorFactoryLoader.getLoader().getJava5FactoriesAndAttributesForProject( javaProject );
- APTDispatchRunnable.runAPTDuringReconcile(context, aptProject, factories);
- }
-
- public void cleanStarting(IJavaProject javaProject){
- IProject p = javaProject.getProject();
-
- AptPlugin.getAptProject(javaProject).projectClean( true );
- try{
- // clear out all markers during a clean.
- IMarker[] markers = p.findMarkers(AptPlugin.APT_BATCH_PROCESSOR_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
- if( markers != null ){
- for( IMarker marker : markers )
- marker.delete();
- }
- }
- catch(CoreException e){
- AptPlugin.log(e, "Unable to delete batch annotation processor markers"); //$NON-NLS-1$
- }
- }
-
- /**
- * Does APT have anything to do for this project?
- * Even if there are no processors on the factory path, apt may still
- * be involved during a clean.
- */
- public boolean isActive(IJavaProject project){
- return AptConfig.isEnabled(project);
- }
-
- public int aboutToBuild(IJavaProject project) {
- if (AptConfig.isEnabled(project)) {
- // setup the classpath and make sure the generated source folder is on disk.
- AptPlugin.getAptProject(project).compilationStarted();
- }
- _buildRound = 0; // reset
- // Note that for each project build, we blow away the last project's processed files.
- _processedFiles = new HashMap<IFile, CategorizedProblem[]>();
- _java6GeneratedFiles = new HashSet<IFile>();
- // TODO: (wharley) if the factory path is different we need a full build
- return CompilationParticipant.READY_FOR_BUILD;
- }
-
- /**
- * Called during Java 6 annotation processing phase to register newly-generated files.
- * This information is then used in the Java 5 (post-compilation) phase when
- * determining no-longer-generated files to delete. The list of files is discarded
- * at the end of each build.
- */
- public void addJava6GeneratedFile(IFile file) {
- _java6GeneratedFiles.add(file);
- }
-
- /**
- * Get the files generated during this build by Java 6 processors.
- * This is only meaningful in the context of a build, not a reconcile.
- * @return an unmodifiable, non-null but possibly empty, set of IFiles.
- */
- public Set<IFile> getJava6GeneratedFiles() {
- if (null == _java6GeneratedFiles) {
- return Collections.emptySet();
- }
- return Collections.unmodifiableSet(_java6GeneratedFiles);
- }
-
- private void buildComplete() {
- _processedFiles = null;
- _java6GeneratedFiles = null;
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptPlugin.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptPlugin.java
deleted file mode 100644
index 749ef903ae..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptPlugin.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedResourceChangeListener;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.osgi.framework.BundleContext;
-
-public class AptPlugin extends Plugin {
- public static final String PLUGIN_ID = "org.eclipse.jdt.apt.core"; //$NON-NLS-1$
-
- // Tracing options
- public static boolean DEBUG = false;
- public final static String APT_DEBUG_OPTION = AptPlugin.PLUGIN_ID + "/debug"; //$NON-NLS-1$
- public static boolean DEBUG_GFM = false;
- public final static String APT_DEBUG_GFM_OPTION = AptPlugin.APT_DEBUG_OPTION + "/generatedFiles"; //$NON-NLS-1$
- public static boolean DEBUG_GFM_MAPS = false;
- public final static String APT_DEBUG_GFM_MAPS_OPTION = AptPlugin.APT_DEBUG_OPTION + "/generatedFileMaps"; //$NON-NLS-1$
- public static boolean DEBUG_COMPILATION_ENV = false;
- public final static String APT_COMPILATION_ENV_OPTION = AptPlugin.APT_DEBUG_OPTION + "/compilationEnv"; //$NON-NLS-1$
-
- /**
- * Status IDs for system log entries. Must be unique per plugin.
- */
- public static final int STATUS_EXCEPTION = 1;
- public static final int STATUS_NOTOOLSJAR = 2;
- public static final int STATUS_CANTLOADPLUGINFACTORY = 3;
-
- public static final String APT_BATCH_PROCESSOR_PROBLEM_MARKER = PLUGIN_ID + ".marker"; //$NON-NLS-1$
- /** Marker ID used for build problem, e.g., missing factory jar */
- public static final String APT_LOADER_PROBLEM_MARKER = PLUGIN_ID + ".buildproblem"; //$NON-NLS-1$
- /** Marker ID used for configuration problem, e.g generated source folder not on classpath */
- public static final String APT_CONFIG_PROBLEM_MARKER = PLUGIN_ID + ".configproblem"; //$NON-NLS-1$
- /** Marker ID used for posting problems during reconcile/build */
- public static final String APT_COMPILATION_PROBLEM_MARKER = PLUGIN_ID + ".compile.problem"; //$NON-NLS-1$
- /** Marker ID used for posting problems during build by processors that don't run in reconcile */
- public static final String APT_NONRECONCILE_COMPILATION_PROBLEM_MARKER = PLUGIN_ID + ".nonreconcile.compile.problem"; //$NON-NLS-1$
-
- private static final SimpleDateFormat TRACE_DATE_FORMAT = new SimpleDateFormat("HH:mm:ss.SSS"); //$NON-NLS-1$
-
- private static AptPlugin thePlugin = null; // singleton object
-
- /**
- * The javax.annotation.processing.Processor class, which is only available on Java 6 and higher.
- */
- private static Class<?> _java6ProcessorClass;
-
- // Entries are added lazily in getAptProject(), and removed upon
- // project deletion in deleteAptProject().
- private static final Map<IJavaProject,AptProject> PROJECT_MAP =
- new HashMap<IJavaProject,AptProject>();
-
- // Qualified names of services for which these containers may provide implementations
- public static final String JAVA5_FACTORY_NAME = "com.sun.mirror.apt.AnnotationProcessorFactory"; //$NON-NLS-1$
- public static final String JAVA6_FACTORY_NAME = "javax.annotation.processing.Processor"; //$NON-NLS-1$
-
- public void start(BundleContext context) throws Exception {
- thePlugin = this;
- super.start(context);
- initDebugTracing();
- // Do we have access to
-
- try {
- _java6ProcessorClass = Class.forName(JAVA6_FACTORY_NAME);
- } catch (Throwable e) {
- // ignore
- }
-
- AptConfig.initialize();
- // DO NOT load extensions from the start() method. This can cause cycles in class loading
- // Not to mention it is bad form to load stuff early.
- // AnnotationProcessorFactoryLoader.getLoader();
- // register resource-changed listener
- // TODO: can move this into AptProject.
- int mask =
- IResourceChangeEvent.PRE_BUILD |
- IResourceChangeEvent.PRE_CLOSE |
- IResourceChangeEvent.PRE_DELETE |
- IResourceChangeEvent.POST_CHANGE;
- JavaCore.addPreProcessingResourceChangedListener( new GeneratedResourceChangeListener(), mask );
-
- if( DEBUG )
- trace("registered resource change listener"); //$NON-NLS-1$
- }
-
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- }
-
- public static AptPlugin getPlugin() {
- return thePlugin;
- }
-
- /**
- * Log a status message to the platform log. Use this for reporting exceptions.
- * @param status
- */
- public static void log(IStatus status) {
- thePlugin.getLog().log(status);
- }
-
- /**
- * Convenience wrapper around log(IStatus), to log an exception
- * with severity of ERROR.
- */
- public static void log(Throwable e, String message) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, STATUS_EXCEPTION, message, e));
- }
-
- /**
- * Convenience wrapper around log(IStatus), to log an exception
- * with severity of WARNING.
- */
- public static void logWarning(Throwable e, String message) {
- log(createWarningStatus(e, message));
- }
-
- /**
- * Convenience wrapper for rethrowing exceptions as CoreExceptions,
- * with severity of ERROR.
- */
- public static Status createStatus(Throwable e, String message) {
- return new Status(IStatus.ERROR, PLUGIN_ID, STATUS_EXCEPTION, message, e);
- }
-
- /**
- * Convenience wrapper for rethrowing exceptions as CoreExceptions,
- * with severity of WARNING.
- */
- public static Status createWarningStatus(Throwable e, String message) {
- return new Status(IStatus.WARNING, PLUGIN_ID, STATUS_EXCEPTION, message, e);
- }
-
- /**
- * Convenience wrapper for rethrowing exceptions as CoreExceptions,
- * with severity of INFO.
- */
- public static Status createInfoStatus(Throwable e, String message) {
- return new Status(IStatus.INFO, PLUGIN_ID, STATUS_EXCEPTION, message, e);
- }
-
- private void initDebugTracing() {
- String option = Platform.getDebugOption(APT_DEBUG_OPTION);
- if(option != null) DEBUG = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
- option = Platform.getDebugOption(APT_DEBUG_GFM_OPTION);
- if(option != null) DEBUG_GFM = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
- option = Platform.getDebugOption(APT_DEBUG_GFM_MAPS_OPTION);
- if(option != null) DEBUG_GFM_MAPS = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
- }
-
- public static void trace(final String msg){
- if (DEBUG) {
- StringBuffer sb = new StringBuffer();
- sb.append('[');
- // SimpleDateFormat is not thread-safe, according to javadoc
- synchronized(TRACE_DATE_FORMAT) {
- sb.append(TRACE_DATE_FORMAT.format(new Date()));
- }
- sb.append('-');
- // Some threads have qualified type names; too long.
- String threadName = Thread.currentThread().getName();
- int dot = threadName.lastIndexOf('.');
- if (dot < 0) {
- sb.append(threadName);
- }
- else {
- sb.append(threadName.substring(dot+1));
- }
- sb.append(']');
- sb.append(msg);
- System.out.println(sb);
- }
- }
-
- /**
- * Convenience method to report an exception in debug trace mode.
- */
- public static void trace(String msg, Throwable t) {
- trace(msg);
- if (DEBUG) {
- t.printStackTrace(System.out);
- }
- }
-
- private static AptProject getAptProject(IJavaProject javaProject, boolean create){
- synchronized(PROJECT_MAP){
- AptProject aptProject = PROJECT_MAP.get(javaProject);
- if (aptProject != null) {
- return aptProject;
- }
- else{
- if( create ){
- aptProject = new AptProject(javaProject);
- PROJECT_MAP.put(javaProject, aptProject);
- return aptProject;
- }
- else
- return null;
- }
- }
- }
-
- public static AptProject getAptProject(IJavaProject javaProject) {
- return getAptProject(javaProject, true);
- }
-
- public static void deleteAptProject(IJavaProject javaProject) {
- synchronized (PROJECT_MAP) {
- PROJECT_MAP.remove(javaProject);
- }
- }
-
- /**
- * True if we are running on a platform that supports Java 6 annotation processing,
- * that is, if we are running on Java 6 or higher and the org.eclipse.jdt.compiler.apt
- * plug-in is also present.
- */
- public static boolean canRunJava6Processors() {
- if (_java6ProcessorClass == null)
- return false;
- return Platform.getBundle("org.eclipse.jdt.compiler.apt") != null; //$NON-NLS-1$
- }
-
- /**
- * The javax.annotation.processing.Processor class. This is only available on the
- * Java 6 or higher platform, so it is loaded via reflection in {@link #start}.
- */
- public static Class<?> getJava6ProcessorClass() {
- return _java6ProcessorClass;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptProject.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptProject.java
deleted file mode 100644
index 8b28ab7d56..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptProject.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.internal;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedFileManager;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager;
-import org.eclipse.jdt.apt.core.internal.util.FileSystemUtil;
-import org.eclipse.jdt.apt.core.util.AptPreferenceConstants;
-import org.eclipse.jdt.core.IJavaProject;
-
-/**
- * Stores project-specific data for APT. Analagous to JavaProject
- * @author jgarms
- *
- */
-public class AptProject {
-
- private final IJavaProject _javaProject;
-
- private final GeneratedFileManager _gfm;
-
- private final GeneratedSourceFolderManager _gsfm;
-
- public AptProject(final IJavaProject javaProject) {
- _javaProject = javaProject;
- _gsfm = new GeneratedSourceFolderManager(this);
- _gfm = new GeneratedFileManager(this, _gsfm);
- }
-
- public IJavaProject getJavaProject() {
- return _javaProject;
- }
-
- public GeneratedFileManager getGeneratedFileManager() {
- return _gfm;
- }
-
- public GeneratedSourceFolderManager getGeneratedSourceFolderManager() {
- return _gsfm;
- }
-
- /**
- * This method should be called whenever compilation begins, to perform
- * initialization and verify configuration.
- */
- public void compilationStarted() {
- _gfm.compilationStarted();
- }
-
- /**
- * This method should be called whenever project preferences are
- * changed by the user. This may cause the classpath and generated
- * source folder to change, so this should <em>not</em> be called
- * from a context where resources may be locked, e.g., within
- * certain resource change listeners.
- * @param key a preference key such as @see AptPreferenceConstants#APT_ENABLED
- */
- public void preferenceChanged(String key) {
- if (AptPreferenceConstants.APT_GENSRCDIR.equals(key)) {
- _gsfm.folderNamePreferenceChanged();
- }
- else if(AptPreferenceConstants.APT_ENABLED.equals(key) ){
- _gsfm.enabledPreferenceChanged();
- }
- }
-
- /**
- * Invoked whenever a project is cleaned. This will remove any state kept about
- * generated files for the given project. If the deleteFiles flag is specified,
- * then the contents of the generated source folder will be deleted.
- *
- * @param deleteFiles true if the contents of the generated source folder are to be
- * deleted, false otherwise.
- */
-
- public void projectClean( boolean deleteFiles )
- {
- _gfm.projectCleaned();
-
- // 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.
- if ( deleteFiles )
- {
- IFolder f = _gsfm.getFolder();
- if ( f != null && f.exists() )
- {
- try
- {
- IResource[] members = f.members();
- for ( int i = 0; i<members.length; i++ ){
- FileSystemUtil.deleteDerivedResources(members[i]);
- }
- }
- catch ( CoreException ce )
- {
- AptPlugin.log(ce, "Could not delete generated files"); //$NON-NLS-1$
- }
- }
- }
- }
-
- /**
- * Invoked when a project is closed.
- */
- public void projectClosed()
- {
- _gfm.projectClosed();
- }
-
- /**
- * Invoked when a project has been deleted, to clean up
- * state associated with the project.
- * This will not delete any of the project's generated files
- * from disk, nor will it delete this object (which in turn
- * owns the GeneratedFileManager for this project).
- */
- public void projectDeleted()
- {
- if (AptPlugin.DEBUG)
- AptPlugin.trace("AptProject.projectDeleted cleaning state for project " + _javaProject.getElementName()); //$NON-NLS-1$
- _gfm.projectDeleted();
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/ClassServiceFactory.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/ClassServiceFactory.java
deleted file mode 100644
index 78e3d53843..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/ClassServiceFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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 org.eclipse.core.runtime.CoreException;
-
-class ClassServiceFactory implements IServiceFactory {
- private final Class<?> _clazz;
-
- public ClassServiceFactory(Class<?> clazz) {
- _clazz = clazz;
- }
-
- public Object newInstance() throws CoreException {
- try {
- return _clazz.newInstance();
- } catch (InstantiationException e) {
- throw new CoreException(AptPlugin.createWarningStatus(e,
- "Unable to create instance of annotation processor " + _clazz.getName())); //$NON-NLS-1$
- } catch (IllegalAccessException e) {
- throw new CoreException(AptPlugin.createWarningStatus(e,
- "Unable to create instance of annotation processor " + _clazz.getName())); //$NON-NLS-1$
- }
- }
-
- public String toString() {
- if (_clazz == null) {
- return "unknown (null)"; //$NON-NLS-1$
- }
- else {
- return _clazz.getName();
- }
- }
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/ExtJarFactoryContainer.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/ExtJarFactoryContainer.java
deleted file mode 100644
index a8b301189e..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/ExtJarFactoryContainer.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.File;
-
-/**
- * Annotation processor factory container based on a jar file
- * outside the workspace, referenced by absolute path.
- */
-public class ExtJarFactoryContainer extends JarFactoryContainer {
- private String _id;
- private File _jarFile;
-
- /**
- * @param jar must not be null
- */
- public ExtJarFactoryContainer(File jar) {
- _jarFile = jar.getAbsoluteFile();
- _id = _jarFile.getPath(); // id of ExtJar is the absolute path
- }
-
- @Override
- public FactoryType getType() {
- return FactoryType.EXTJAR;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.internal.JarFactoryContainer#getJarFile()
- */
- @Override
- public File getJarFile() {
- return _jarFile;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.FactoryContainer#getId()
- */
- @Override
- public String getId() {
- return _id;
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/FactoryPluginManager.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/FactoryPluginManager.java
deleted file mode 100644
index ed7485ceb4..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/FactoryPluginManager.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.TreeMap;
-
-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.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
-
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-
-/**
- * Manages caches of plugins which provide annotation processors.
- *
- * @since 3.3
- */
-public class FactoryPluginManager {
- /**
- * Map of factory names -> factories. A single plugin factory container may
- * contain multiple annotation processor factories, each with a unique name.
- * To support lazy initialization, this should only be accessed by calling
- * @see #getJava5PluginFactoryMap() .
- */
- private static final HashMap<String, AnnotationProcessorFactory> PLUGIN_JAVA5_FACTORY_MAP = new HashMap<String, AnnotationProcessorFactory>();
-
- /**
- * Map of factory names -> factories. A single plugin factory container may
- * contain multiple annotation processor factories, each with a unique name.
- * To support lazy initialization, this should only be accessed by calling
- * @see #getJava5PluginFactoryMap() .
- */
- private static final HashMap<String, IServiceFactory> PLUGIN_JAVA6_FACTORY_MAP = new HashMap<String, IServiceFactory>();
-
- /**
- * Map of plugin names -> plugin factory containers, sorted by plugin name.
- * A plugin that contains annotation processor factories (and extends the
- * corresponding extension point) is a "plugin factory container".
- * To support lazy initialization, this should only be accessed by calling
- * @see #getPluginFactoryContainerMap() .
- */
- private static final TreeMap<String, PluginFactoryContainer> PLUGIN_CONTAINER_MAP = new TreeMap<String, PluginFactoryContainer>();
-
- /**
- * true if PLUGIN_FACTORY_MAP and PLUGIN_CONTAINER_MAP have been initialized,
- * by calling @see #loadPluginFactories() .
- */
- private static boolean mapsInitialized = false;
-
- /**
- * Returns an ordered list of all the plugin factory containers that have
- * been registered as plugins. Note that this may include plugins that have
- * been disabled by the user's configuration. The 'enabled' attribute in the
- * returned map reflects the 'enableDefault' attribute in the plugin
- * manifest, rather than the user configuration.
- * Ordering is alphabetic by plugin id.
- */
- public static synchronized Map<FactoryContainer, FactoryPath.Attributes> getAllPluginFactoryContainers()
- {
- Map<FactoryContainer, FactoryPath.Attributes> map =
- new LinkedHashMap<FactoryContainer, FactoryPath.Attributes>(getPluginContainerMap().size());
- for (PluginFactoryContainer pfc : getPluginContainerMap().values()) {
- FactoryPath.Attributes a = new FactoryPath.Attributes(pfc.getEnableDefault(), false);
- map.put(pfc, a);
- }
- return map;
- }
-
- public static synchronized AnnotationProcessorFactory getJava5FactoryFromPlugin( String factoryName )
- {
- AnnotationProcessorFactory apf = getJava5PluginFactoryMap().get( factoryName );
- if ( apf == null )
- {
- String s = "could not find AnnotationProcessorFactory " + //$NON-NLS-1$
- factoryName + " from available factories defined by plugins"; //$NON-NLS-1$
- AptPlugin.log(new Status(IStatus.WARNING, AptPlugin.PLUGIN_ID, AptPlugin.STATUS_NOTOOLSJAR, s, null));
- }
- return apf;
- }
-
- public static synchronized IServiceFactory getJava6FactoryFromPlugin( String factoryName )
- {
- IServiceFactory isf = getJava6PluginFactoryMap().get( factoryName );
- if ( isf == null )
- {
- String s = "could not find annotation processor " + //$NON-NLS-1$
- factoryName + " from available factories defined by plugins"; //$NON-NLS-1$
- AptPlugin.log(new Status(IStatus.WARNING, AptPlugin.PLUGIN_ID, AptPlugin.STATUS_NOTOOLSJAR, s, null));
- }
- return isf;
- }
-
- /**
- * Return the factory container corresponding to the specified plugin id.
- * All plugin factories are loaded at startup time.
- * @param pluginId the id of a plugin that extends annotationProcessorFactory.
- * @return a PluginFactoryContainer, or null if the plugin id does not
- * identify an annotation processor plugin.
- */
- public static synchronized FactoryContainer getPluginFactoryContainer(String pluginId) {
- return getPluginContainerMap().get(pluginId);
- }
-
- /**
- * Get the alphabetically sorted map of plugin names to plugin factory containers.
- * Load plugins if the map has not yet been initialized.
- */
- private static TreeMap<String, PluginFactoryContainer> getPluginContainerMap() {
- loadFactoryPlugins();
- return PLUGIN_CONTAINER_MAP;
- }
-
- /**
- * Get the map of plugin factory names to plugin factories.
- * Load plugins if the map has not yet been initialized.
- */
- private static HashMap<String, AnnotationProcessorFactory> getJava5PluginFactoryMap() {
- loadFactoryPlugins();
- return PLUGIN_JAVA5_FACTORY_MAP;
- }
-
- /**
- * Get the map of plugin factory names to plugin factories.
- * Load plugins if the map has not yet been initialized.
- */
- private static HashMap<String, IServiceFactory> getJava6PluginFactoryMap() {
- loadFactoryPlugins();
- return PLUGIN_JAVA6_FACTORY_MAP;
- }
-
- /**
- * Discover and instantiate annotation processor factories by searching for plugins
- * which contribute to org.eclipse.jdt.apt.core.annotationProcessorFactory.
- * The first time this method is called, it will load all the plugin factories.
- * Subsequent calls will be ignored.
- */
- private static synchronized void loadFactoryPlugins() {
- if (mapsInitialized) {
- return;
- }
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(
- AptPlugin.PLUGIN_ID, // name of plugin that exposes this extension point
- "annotationProcessorFactory"); //$NON-NLS-1$ - extension id
-
- // Iterate over all declared extensions of this extension point.
- // A single plugin may extend the extension point more than once, although it's not recommended.
- for (IExtension extension : extensionPoint.getExtensions())
- {
- // Iterate over the children of the extension to find one named "factories".
- for(IConfigurationElement factories : extension.getConfigurationElements())
- {
- if ("factories".equals(factories.getName())) { //$NON-NLS-1$ - name of configElement
- loadJava5Factories(extension, factories);
- }
- else if ("java6processors".equals(factories.getName())) { //$NON-NLS-1$ - name of configElement
- loadJava6Factories(extension, factories);
- }
-
- }
- }
- mapsInitialized = true;
- }
-
- private static void loadJava6Factories(IExtension extension, IConfigurationElement factories) {
- if (!AptPlugin.canRunJava6Processors()) {
- return;
- }
-
- // Get enableDefault. If the attribute is missing, default to true.
- String enableDefaultStr = factories.getAttribute("enableDefault"); //$NON-NLS-1$
- boolean enableDefault = true;
- if ("false".equals(enableDefaultStr)) { //$NON-NLS-1$
- enableDefault = false;
- }
-
- // Create and cache a PluginFactoryContainer for this plugin.
- String pluginId = extension.getNamespaceIdentifier();
- //TODO: level problem. In the extension point, enableDefault is associated with element, not ext point.
- PluginFactoryContainer pfc = new PluginFactoryContainer(pluginId, enableDefault);
- PLUGIN_CONTAINER_MAP.put(pluginId, pfc);
-
- // Iterate over the children of the "java6processors" element to find all the ones named "java6processor".
- for (IConfigurationElement factory : factories.getChildren()) {
- if (!"java6processor".equals(factory.getName())) { //$NON-NLS-1$
- continue;
- }
- String factoryName = null;
- try {
- factoryName = factory.getAttribute("class"); //$NON-NLS-1$
- Object execExt = factory.createExecutableExtension("class"); //$NON-NLS-1$ - attribute name
- Class<?> clazz = execExt.getClass();
- if (AptPlugin.getJava6ProcessorClass().isInstance(execExt)){
- assert(clazz.getName().equals(factoryName));
- IServiceFactory isf = new ClassServiceFactory(clazz);
- PLUGIN_JAVA6_FACTORY_MAP.put( factoryName, isf );
- pfc.addFactoryName(factoryName, AptPlugin.JAVA6_FACTORY_NAME);
- }
- else {
- reportFailureToLoadProcessor(null, factoryName, extension.getNamespaceIdentifier());
- }
- } catch(CoreException e) {
- reportFailureToLoadProcessor(e, factoryName, extension.getNamespaceIdentifier());
- }
- }
- }
-
- private static void loadJava5Factories(IExtension extension, IConfigurationElement factories) {
- // Get enableDefault. If the attribute is missing, default to true.
- String enableDefaultStr = factories.getAttribute("enableDefault"); //$NON-NLS-1$
- boolean enableDefault = true;
- if ("false".equals(enableDefaultStr)) { //$NON-NLS-1$
- enableDefault = false;
- }
-
- // Create and cache a PluginFactoryContainer for this plugin.
- String pluginId = extension.getNamespaceIdentifier();
- PluginFactoryContainer pfc = new PluginFactoryContainer(pluginId, enableDefault);
- PLUGIN_CONTAINER_MAP.put(pluginId, pfc);
-
- // Iterate over the children of the "factories" element to find all the ones named "factory".
- for (IConfigurationElement factory : factories.getChildren()) {
- if (!"factory".equals(factory.getName())) { //$NON-NLS-1$
- continue;
- }
- String factoryName = null;
- try {
- factoryName = factory.getAttribute("class"); //$NON-NLS-1$
- Object execExt = factory.createExecutableExtension("class"); //$NON-NLS-1$ - attribute name
- if (execExt instanceof AnnotationProcessorFactory){
- assert(execExt.getClass().getName().equals(factoryName));
- PLUGIN_JAVA5_FACTORY_MAP.put( factoryName, (AnnotationProcessorFactory)execExt );
- pfc.addFactoryName(factoryName, AptPlugin.JAVA5_FACTORY_NAME);
- }
- else {
- reportFailureToLoadProcessor(null, factory.getName(), extension.getNamespaceIdentifier());
- }
- } catch(CoreException e) {
- reportFailureToLoadProcessor(e, factory.getName(), extension.getNamespaceIdentifier());
- }
- }
- }
-
- private static void reportFailureToLoadProcessor(Exception e, String factoryName, String pluginId) {
- AptPlugin.log(e, "Unable to load annotation processor "+ factoryName + //$NON-NLS-1$
- " from plug-in " + pluginId); //$NON-NLS-1$
- }
-
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/IServiceFactory.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/IServiceFactory.java
deleted file mode 100644
index 0c925d0555..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/IServiceFactory.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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 org.eclipse.core.runtime.CoreException;
-
-/**
- * An abstract factory for services such as annotation processors.
- * This abstraction exists because the way a service is instantiated
- * may depend on where it was loaded from as well as what kind of
- * service it is (e.g., Java 6 annotation processors use their class
- * object as a factory; Java 5 processors have an explicit factory
- * object.)
- * @since 3.3
- * @see AnnotationProcessorFactoryLoader
- */
-public interface IServiceFactory {
-
- Object newInstance() throws CoreException;
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/JarClassLoader.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/JarClassLoader.java
deleted file mode 100644
index 90e878e753..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/JarClassLoader.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.internal;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-import java.util.zip.ZipEntry;
-
-
-
-/**
- * This classloader allows us to close out underlying jars,
- * so that projects can be deleted even if they contain
- * factory jars that are in use.<P>
- *
- * This classloader caches open jars while it is in use,
- * and once closed it will close those jars. It can still be used
- * after that point, but it will open and close on each classloader
- * operation.
- */
-public class JarClassLoader extends ClassLoader {
-
- // This is nulled out when the classloader is closed
- private List<JarFile> _jars;
- private final LinkedHashSet<File> _files;
- private List<JarCLInputStream> _openStreams = new LinkedList<JarCLInputStream>();
- private boolean _open = true;
-
- public JarClassLoader(List<File> jarFiles, final ClassLoader parent) {
- super(parent);
- // Handle manifest classpath entries
- _files = new LinkedHashSet<File>(jarFiles);
- for (File f : jarFiles) {
- _recursiveGetManifestJars(f, _files);
- }
- open();
- }
-
- private void open() {
- // Create all jar files
- _jars = new ArrayList<JarFile>(_files.size());
- for (File f : _files) {
- try {
- JarFile jar = new JarFile(f);
- _jars.add(jar);
- }
- catch (IOException ioe) {
- AptPlugin.log(ioe, "Unable to create JarFile for file: " + f); //$NON-NLS-1$
- }
- }
- }
-
- public synchronized void close() {
- if (! _open) return;
- _open = false;
-
- for (JarCLInputStream st : _openStreams) {
- try {
- st.close();
- }
- catch (IOException ioe) {
- AptPlugin.log(ioe, "Failed to close stream"); //$NON-NLS-1$
- }
- }
- _openStreams = null;
-
- for (JarFile jar : _jars) {
- try {
- jar.close();
- }
- catch (IOException ioe) {
- AptPlugin.log(ioe, "Failed to close jar: " + jar); //$NON-NLS-1$
- }
- }
- _jars = null;
- }
-
- private InputStream openInputStream(InputStream in) {
- JarCLInputStream result = new JarCLInputStream(in);
- _openStreams.add(result);
- return in;
- }
-
- private synchronized void closeInputStream(JarCLInputStream in) {
- if (_open)
- _openStreams.remove(in);
- }
-
- @Override
- protected synchronized Class<?> findClass(String name) throws ClassNotFoundException {
- if (!_open)
- throw new ClassNotFoundException("Classloader closed: " + name); //$NON-NLS-1$
-
- byte[] b = loadClassData(name);
- if (b == null) {
- throw new ClassNotFoundException("Could not find class " + name); //$NON-NLS-1$
- }
- Class<?> clazz = defineClass(name, b, 0, b.length);
- // Define the package if necessary
- String pkgName = getPackageName(name);
- if (pkgName != null) {
- Package pkg = getPackage(pkgName);
- if (pkg == null) {
- definePackage(pkgName, null, null, null, null, null, null, null);
- }
- }
- return clazz;
- }
-
- private String getPackageName(String fullyQualifiedName) {
- int index = fullyQualifiedName.lastIndexOf('.');
- if (index != -1) {
- return fullyQualifiedName.substring(0, index);
- }
- return null;
- }
-
- // returns null if no class found
- private byte[] loadClassData(String name) {
- name = name.replace('.','/');
- InputStream input = getResourceAsStream(name + ".class"); //$NON-NLS-1$
- if (input == null)
- return null;
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte[] buf = new byte[1024];
- int len;
- while ((len = input.read(buf)) > 0) {
- baos.write(buf, 0, len);
- }
- baos.close();
- return baos.toByteArray();
- }
- catch (IOException ioe) {
- return null;
- }
- finally {
- try {input.close();} catch (IOException ioe) {}
- }
- }
-
- @Override
- public synchronized InputStream getResourceAsStream(String name) {
- InputStream input = getParent().getResourceAsStream(name);
- if (input != null)
- return input;
-
- if (!_open)
- return null;
-
- for (JarFile j : _jars) {
- try {
- ZipEntry entry = j.getEntry(name);
- if (entry != null) {
- InputStream zipInput = j.getInputStream(entry);
- return openInputStream(zipInput);
- }
- }
- catch (IOException ioe) {
- AptPlugin.log(ioe, "Unable to get entry from jar: " + j); //$NON-NLS-1$
- }
- }
- return null;
- }
-
- /**
- * This is difficult to implement and close out resources underneath.
- * Delaying until someone actually requests this.
- *
- * If we actually contain the entry throw UnsupportedOperationException,
- * else return null in case another classloader can handle this.
- */
- @Override
- public URL getResource(String name) {
- for (JarFile j : _jars) {
- ZipEntry entry = j.getEntry(name);
- if (entry != null) {
- throw new UnsupportedOperationException("getResource() not implemented: " + name); //$NON-NLS-1$
- }
- }
- return null;
- }
-
- /**
- * This is difficult to implement and close out resources underneath.
- * Delaying until someone actually requests this.
- */
- @Override
- public Enumeration<URL> getResources(String name) throws IOException {
- throw new UnsupportedOperationException("getResources() not implemented"); //$NON-NLS-1$
- }
-
- private class JarCLInputStream extends InputStream {
-
- private boolean _closed = false;
-
- private final InputStream _input;
-
- public JarCLInputStream(InputStream origInput) {
- _input = origInput;
- }
-
- @Override
- public void close() throws IOException {
- if (_closed) {
- // NOOP
- return;
- }
- try {
- super.close();
- _input.close();
- _closed = true;
- }
- finally {
- closeInputStream(this);
- }
- }
-
- @Override
- public int read() throws IOException {
- return _input.read();
- }
-
- @Override
- public int available() throws IOException {
- return _input.available();
- }
-
- @Override
- public synchronized void mark(int readlimit) {
- _input.mark(readlimit);
- }
-
- @Override
- public boolean markSupported() {
- return _input.markSupported();
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws IOException {
- return _input.read(b, off, len);
- }
-
- @Override
- public int read(byte[] b) throws IOException {
- return _input.read(b);
- }
-
- @Override
- public synchronized void reset() throws IOException {
- _input.reset();
- }
-
- @Override
- public long skip(long n) throws IOException {
- return _input.skip(n);
- }
- }
-
- /**
- * Scan manifest classpath entries of a jar, adding all found jar files
- * to the set of manifest jars.
- */
- private static void _recursiveGetManifestJars(File jarFile, Set<File> manifestJars) {
- if (!jarFile.exists())
- return;
-
- JarFile jar = null;
- try {
- jar = new JarFile(jarFile);
- Manifest mf = jar.getManifest();
- if (mf == null)
- return;
- String classpath = mf.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
- if (classpath == null)
- return;
-
- // We've got some entries
- File parent = jarFile.getParentFile();
-
- String[] rgPaths = classpath.split(" "); //$NON-NLS-1$
- for (String path : rgPaths)
- {
- if (path.length() == 0)
- continue;
- File file = new File(parent, path);
- // If we haven't seen this, we need to get its manifest jars as well
- if (!manifestJars.contains(file) && file.exists()) {
- manifestJars.add(file);
- _recursiveGetManifestJars(file, manifestJars);
- }
- }
- }
- catch (IOException ioe) {
- }
- finally {
- if (jar != null) {
- try {jar.close();} catch (IOException ioe) {}
- }
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/JarFactoryContainer.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/JarFactoryContainer.java
deleted file mode 100644
index dcf70a5e7f..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/JarFactoryContainer.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
-
-/**
- * Represents a jar file that contains annotation processor factories.
- * The factories are listed in the jar's META-INF/services folder, in
- * a file named com.sun.mirror.apt.AnnotationProcessorFactory.
- */
-public abstract class JarFactoryContainer extends FactoryContainer
-{
-
- /**
- * @return a java.io.File. The file is not guaranteed to exist.
- */
- public abstract File getJarFile();
-
- @Override
- public boolean exists() {
- try {
- final File jarFile = getJarFile();
- if(jarFile == null)
- return false;
- return getJarFile().exists();
- } catch (SecurityException e) {
- return false;
- }
- }
-
- @Override
- protected Map<String, String> loadFactoryNames() throws IOException {
- return getServiceClassnamesFromJar( getJarFile() );
- }
-
- /**
- * 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.
- */
- protected static Map<String, String> getServiceClassnamesFromJar(File jar) throws IOException
- {
- Map<String, String> classNames = new LinkedHashMap<String, String>();
- JarFile jarFile = null;
- try {
- jarFile = new JarFile(jar);
-
- for (String serviceName : AUTOLOAD_SERVICES) {
- String providerName = "META-INF/services/" + serviceName; //$NON-NLS-1$
- // Get the service provider def file out of the jar.
- JarEntry provider = jarFile.getJarEntry(providerName);
- if (provider == null) {
- continue;
- }
- // Extract classnames from the service provider def file.
- InputStream is = jarFile.getInputStream(provider);
- readServiceProvider(is, serviceName, classNames);
- }
- }
- finally {
- try {if (jarFile != null) jarFile.close();} catch (IOException ioe) {}
- }
- return classNames;
- }
-
- /**
- * Read service classnames from a service provider definition.
- * @param is an input stream corresponding to a Sun-style service provider
- * definition file, e.g., one of the files named in AUTOLOAD_SERVICES.
- * @param classNames a list to which the classes named in is will be added.
- */
- protected static void readServiceProvider(InputStream is, String serviceName, Map<String, String> classNames) throws IOException {
- BufferedReader rd = null;
- try {
- rd = new BufferedReader(new InputStreamReader(is, "UTF-8")); //$NON-NLS-1$
- 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); //$NON-NLS-1$
- if (tokens[0].length() > 0) {
- classNames.put(tokens[0], serviceName);
- }
- }
- rd.close();
- }
- finally {
- if (rd != null) try {rd.close();} catch (IOException ioe) {}
- }
- }
-
- /** List of jar file entries within META-INF/services that specify autoloadable service providers */
- private static final String[] AUTOLOAD_SERVICES = {
- AptPlugin.JAVA5_FACTORY_NAME,
- AptPlugin.JAVA6_FACTORY_NAME
- };
-
-}
-
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/LoadFailureHandler.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/LoadFailureHandler.java
deleted file mode 100644
index c2507f6255..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/LoadFailureHandler.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jdt.core.IJavaProject;
-
-/**
- * Stores factories or libraries that were inaccessible when
- * attempting to load annotation processors, and then handles
- * reporting those errors to the user as markers in the problems pane.
- * <p>
- * This class is necessary due to deadlock possibilities in
- * {@link AnnotationProcessorFactoryLoader}. We need to gather up
- * the errors while holding a lock in that class,
- * and then later report them outside the lock, via the
- * reportFailureMarkers() method.
- */
-public class LoadFailureHandler {
-
- private final IProject _project;
- private final List<String> _missingLibraries = new ArrayList<String>();
- private final List<String> _failedFactories = new ArrayList<String>();
-
- public LoadFailureHandler(IJavaProject proj) {
- _project = proj.getProject();
- }
-
- public void addMissingLibrary(String lib) {
- _missingLibraries.add(lib);
- }
-
- public void addFailedFactory(String factory) {
- _failedFactories.add(factory);
- }
-
- public void reportFailureMarkers() {
- reportFailureToLoadFactories();
- reportMissingLibraries();
- }
-
- /**
- * Enter problem markers for factory containers that could not be found on
- * disk. This routine does not check whether markers already exist.
- * See {@link AnnotationProcessorFactoryLoader} for information about
- * the lifecycle of these markers.
- */
- private void reportMissingLibraries() {
- for (String fc : _missingLibraries) {
- try {
- String message = Messages.bind(
- Messages.AnnotationProcessorFactoryLoader_factorypath_missingLibrary,
- new String[] {fc, _project.getName()});
- IMarker marker = _project.createMarker(AptPlugin.APT_LOADER_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {
- IMarker.MESSAGE,
- IMarker.SEVERITY,
- IMarker.LOCATION
- },
- new Object[] {
- message,
- IMarker.SEVERITY_ERROR,
- Messages.AnnotationProcessorFactoryLoader_factorypath
- }
- );
- } catch (CoreException e) {
- AptPlugin.log(e, "Unable to create APT build problem marker on project " + _project.getName()); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Enter a marker for a factory class that could not be loaded.
- * Note that if a jar is missing, we won't be able to load its factory
- * names, and thus we won't even try loading its factory classes; but
- * we can still fail to load a factory class if, for instance, the
- * jar is corrupted or the factory constructor throws an exception.
- * See {@link AnnotationProcessorFactoryLoader} for information about
- * the lifecycle of these markers.
- */
- private void reportFailureToLoadFactories() {
- for (String factoryName : _failedFactories) {
- try {
- String message = Messages.bind(
- Messages.AnnotationProcessorFactoryLoader_unableToLoadFactoryClass,
- new String[] {factoryName, _project.getName()});
- IMarker marker = _project.createMarker(AptPlugin.APT_LOADER_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {
- IMarker.MESSAGE,
- IMarker.SEVERITY,
- IMarker.LOCATION
- },
- new Object[] {
- message,
- IStatus.ERROR,
- Messages.AnnotationProcessorFactoryLoader_factorypath
- }
- );
- } catch (CoreException e) {
- AptPlugin.log(e, "Unable to create build problem marker"); //$NON-NLS-1$
- }
- }
- }
-
- @Override
- public int hashCode() {
- return _project.hashCode();
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof LoadFailureHandler)) return false;
- LoadFailureHandler otherHandler = (LoadFailureHandler)o;
- return _project.equals(otherHandler._project);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/Messages.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/Messages.java
deleted file mode 100644
index 6c97fa13e8..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/Messages.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:
- * jgarms@bea.com - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.jdt.apt.core.internal;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.jdt.apt.core.internal.messages"; //$NON-NLS-1$
-
- private Messages() {
- }
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- public static String AnnotationProcessorFactoryLoader_jarNotFound;
-
- public static String AnnotationProcessorFactoryLoader_ioError;
-
- public static String AnnotationProcessorFactoryLoader_factorypath_missingLibrary;
-
- public static String AnnotationProcessorFactoryLoader_factorypath;
-
- public static String AnnotationProcessorFactoryLoader_unableToLoadFactoryClass;
-
- public static String GeneratedFileManager_missing_classpath_entry;
-}
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 5497e0be56..0000000000
--- 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/PluginFactoryContainer.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/PluginFactoryContainer.java
deleted file mode 100644
index 0b515c60d1..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/PluginFactoryContainer.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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;
-
-import java.io.IOException;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
-
-public class PluginFactoryContainer extends FactoryContainer
-{
- /** The label of the plug that owns this factory container. */
- private final String id;
-
- /** Whether the plugin's factories are enabled by default */
- private final boolean enableDefault;
-
- /**
- * In general clients should not construct this object. This c'tor should
- * only be called from @see FactoryPathUtil#loadPluginFactories().
- * @param pluginId
- * @param enableDefault
- */
- public PluginFactoryContainer(final String pluginId, boolean enableDefault) {
- this.id = pluginId;
- this.enableDefault = enableDefault;
- }
-
- public void addFactoryName( String factoryName, String serviceName ) {
- try {
- getFactoryNames().put( factoryName, serviceName );
- }
- catch (IOException ioe) {
- AptPlugin.log(ioe, "IOException reading a plugin"); //$NON-NLS-1$
- }
- }
-
- @Override
- public boolean exists() {
- // This object is created only in the process of loading factory plugins.
- return true;
- }
-
- protected Map<String, String> loadFactoryNames() {
- // The list is populated when factory plugins are loaded.
- return new LinkedHashMap<String, String>();
- }
-
- public String getId() {
- return id;
- }
-
- public boolean getEnableDefault() {
- return enableDefault;
- }
-
- @Override
- public FactoryType getType() {
- return FactoryType.PLUGIN;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/VarJarFactoryContainer.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/VarJarFactoryContainer.java
deleted file mode 100644
index b93ef332eb..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/VarJarFactoryContainer.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.File;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jdt.core.JavaCore;
-
-/**
- * Annotation processor factory container based on a jar file
- * outside of the workspace, referenced by a classpath variable.
- */
-public class VarJarFactoryContainer extends JarFactoryContainer {
-
- private final String _id;
- private final File _jarFile;
-
- /**
- * @param jarPath
- */
- public VarJarFactoryContainer(IPath jarPath) {
- _id = jarPath.toString();
- IPath resolved = JavaCore.getResolvedVariablePath(jarPath);
- if (null != resolved) {
- _jarFile = resolved.toFile();
- }
- else {
- _jarFile = null;
- IStatus s = AptPlugin.createWarningStatus(
- null, "The factorypath entry " + _id + " could not be resolved"); //$NON-NLS-1$ //$NON-NLS-2$
- AptPlugin.log(s);
- }
- }
-
- @Override
- public FactoryType getType() {
- return FactoryType.VARJAR;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.internal.JarFactoryContainer#getJarFile()
- */
- @Override
- public File getJarFile() {
- return _jarFile;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.FactoryContainer#getId()
- */
- @Override
- public String getId() {
- return _id;
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/WkspJarFactoryContainer.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/WkspJarFactoryContainer.java
deleted file mode 100644
index 6ca7512c48..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/WkspJarFactoryContainer.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.File;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * Annotation processor factory container based on a jar file
- * within the workspace.
- */
-public class WkspJarFactoryContainer extends JarFactoryContainer {
-
- private final String _id;
- private final File _jarFile; // A java.io.File, not guaranteed to exist.
-
- /**
- * Construct a workspace-jar container from an IPath representing
- * the jar file's location in the workspace. We will construct
- * the container even if the file does not exist.
- * @param jar an IPath representing a jar file in the workspace;
- * the path is relative to the workspace root.
- */
- public WkspJarFactoryContainer(IPath jar) {
- _id = jar.toString();
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IResource res = root.findMember(_id);
- if (null == res) {
- // The file evidently doesn't exist on disk. Do our best to
- // construct a java.io.File for it anyway.
- _jarFile = root.getLocation().append(jar).toFile();
-
- }
- else if (res.getType() == IResource.FILE) {
- _jarFile = res.getLocation().toFile();
- }
- else {
- _jarFile = null;
- IStatus s = AptPlugin.createWarningStatus(
- null, "The factorypath entry " + _id + " does not refer to a jar file"); //$NON-NLS-1$ //$NON-NLS-2$
- AptPlugin.log(s);
- }
- }
-
- @Override
- public FactoryType getType() {
- return FactoryType.WKSPJAR;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.internal.JarFactoryContainer#getJarFile()
- */
- @Override
- public File getJarFile() {
- return _jarFile;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.FactoryContainer#getId()
- */
- @Override
- public String getId() {
- return _id;
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/build/Messages.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/build/Messages.java
deleted file mode 100644
index 460fd14fe7..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/build/Messages.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.internal.build;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.jdt.apt.core.build.messages"; //$NON-NLS-1$
-
- private Messages() {
- }
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- public static String JdtApt_noWorkspace;
-
- public static String JdtApt_noEclipse;
-
- public static String JdtApt_noStartupJar;
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/build/messages.properties b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/build/messages.properties
deleted file mode 100644
index 8faea219b8..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/build/messages.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 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
-###############################################################################
-JdtApt_noWorkspace=Workspace does not exist:
-JdtApt_noEclipse=Eclipse not found in eclipse home:
-JdtApt_noStartupJar=Could not find startup.jar in the eclipse directory:
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedAnnotationElementDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedAnnotationElementDeclarationImpl.java
deleted file mode 100644
index bdd77f3b71..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedAnnotationElementDeclarationImpl.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-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.Expression;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.SimpleName;
-import org.eclipse.jdt.core.dom.Type;
-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.type.TypeMirror;
-import com.sun.mirror.util.DeclarationVisitor;
-
-public class ASTBasedAnnotationElementDeclarationImpl
- extends ASTBasedMethodDeclarationImpl implements AnnotationTypeElementDeclaration{
-
- public ASTBasedAnnotationElementDeclarationImpl(
- final AnnotationTypeMemberDeclaration astNode,
- final IFile file,
- final BaseProcessorEnv env)
- {
- super(astNode, file, env);
- }
-
- public void accept(DeclarationVisitor 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 AnnotationTypeMemberDeclaration decl = getMemberAstNode();
- if (decl != null){
- final Expression defaultExpr = decl.getDefault();
- if( defaultExpr != null )
- return Factory.createDefaultValue(defaultExpr.resolveConstantExpressionValue(), this, _env);
- }
-
- return null;
- }
-
- public ASTNode getAstNodeForDefault() {
- final AnnotationTypeMemberDeclaration decl = (AnnotationTypeMemberDeclaration) getAstNode();
- if (decl != null)
- return decl.getDefault();
-
- return null;
- }
-
- public boolean isVarArgs(){ return false; }
-
- public String getSimpleName()
- {
- final AnnotationTypeMemberDeclaration memberAstNode = getMemberAstNode();
- final SimpleName nameNode = memberAstNode.getName();
- return nameNode == null ? EMPTY_STRING : nameNode.getIdentifier();
- }
-
- public TypeMirror getReturnType()
- {
- final AnnotationTypeMemberDeclaration memberAstNode = getMemberAstNode();
- final Type retType = memberAstNode.getType();
- // some funny error case where the return type is missing but it's not a constructor.
- if( retType == null )
- return Factory.createErrorClassType(EMPTY_STRING);
- final ITypeBinding typeBinding = retType.resolveBinding();
- // This is most likely the reason that we end up with an ast based implementation.
- if( typeBinding == null ){
- return Factory.createErrorClassType(retType.toString());
- }
- else{
- final TypeMirror type = Factory.createTypeMirror(typeBinding, _env);
- if(type == null )
- return Factory.createErrorClassType(retType.toString());
- return type;
- }
- }
-
- public String toString()
- {
- final StringBuilder buffer = new StringBuilder();
- final AnnotationTypeMemberDeclaration memberAstNode = (AnnotationTypeMemberDeclaration) getAstNode();
-
- if( memberAstNode.getType() != null )
- buffer.append(memberAstNode.getType());
- buffer.append(' ');
- buffer.append(memberAstNode.getName());
- buffer.append("()"); //$NON-NLS-1$
-
- return buffer.toString();
- }
-
- public Collection<ParameterDeclaration> getParameters() {
- return Collections.emptyList();
- }
-
- public MirrorKind kind() {
- return MirrorKind.ANNOTATION_ELEMENT;
- }
-
- private AnnotationTypeMemberDeclaration getMemberAstNode(){
- return (AnnotationTypeMemberDeclaration)_astNode;
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedConstructorDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedConstructorDeclarationImpl.java
deleted file mode 100644
index 00a5c47364..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedConstructorDeclarationImpl.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import com.sun.mirror.declaration.ConstructorDeclaration;
-
-import com.sun.mirror.util.DeclarationVisitor;
-
-public class ASTBasedConstructorDeclarationImpl
- extends ASTBasedExecutableDeclarationImpl
- implements ConstructorDeclaration{
-
- public ASTBasedConstructorDeclarationImpl(
- final org.eclipse.jdt.core.dom.BodyDeclaration astNode,
- final IFile file,
- final BaseProcessorEnv env)
- {
- super(astNode, file, env);
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- visitor.visitConstructorDeclaration(this);
- }
-
- public MirrorKind kind(){ return MirrorKind.CONSTRUCTOR; }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedDeclarationImpl.java
deleted file mode 100644
index 908f8e0ce7..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedDeclarationImpl.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.apt.core.internal.util.SourcePositionImpl;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IExtendedModifier;
-import org.eclipse.jdt.core.dom.IAnnotationBinding;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.VariableDeclaration;
-import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
-
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.Modifier;
-import com.sun.mirror.util.SourcePosition;
-
-/**
- * Most mirror implementation are based on bindings but in some cases because of
- * incomplete information no bindings will be created at all. This implementation
- * is to allow clients to get to the partial information that's available on certain
- * declarations.
- *
- * The prefered implementation of the API is to rely on the binding since it is a more
- * complete and versatile representation of a declaration.
- */
-public abstract class ASTBasedDeclarationImpl extends EclipseDeclarationImpl {
-
- static final String EMPTY_STRING = ""; //$NON-NLS-1$
- /** either a <code>BodyDeclaration</code> or a <code>VariableDeclaration</code> */
- protected final ASTNode _astNode;
- /** the file which this ast node came from */
- protected final IFile _file;
- public ASTBasedDeclarationImpl(
- ASTNode astNode,
- IFile file,
- BaseProcessorEnv env)
- {
- super(env);
- assert astNode != null : "ast node cannot be missing"; //$NON-NLS-1$
- assert file != null : "file cannot be missing";//$NON-NLS-1$
-
- assert astNode instanceof BodyDeclaration ||
- astNode instanceof VariableDeclaration :
- "ast node must be either a body declaration or a variable declaration"; //$NON-NLS-1$
-
- _astNode = astNode;
- _file = file;
- }
-
- public Collection<Modifier> getModifiers()
- {
- int modBits = 0;
- if( _astNode instanceof BodyDeclaration )
- modBits = ((BodyDeclaration)_astNode).getModifiers();
- else if( _astNode instanceof SingleVariableDeclaration )
- modBits = ((SingleVariableDeclaration)_astNode).getModifiers();
- else{
- ASTNode parent = ((VariableDeclarationFragment)_astNode).getParent();
- if( _astNode instanceof BodyDeclaration )
- modBits = ((BodyDeclaration)parent).getModifiers();
- }
-
- return getModifiers(modBits);
- }
-
- private Collection<Modifier> getModifiers(int modBits)
- {
- 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;
-
- }
-
- public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
- {
- final IAnnotationBinding[] instances = getAnnotationInstancesFromAST();
- return _getAnnotation(annotationClass, instances);
- }
-
- public Collection<AnnotationMirror> getAnnotationMirrors()
- {
- final IAnnotationBinding[] instances = getAnnotationInstancesFromAST();
- return _getAnnotationMirrors(instances);
- }
-
- @SuppressWarnings("unchecked") // DOM AST API returns raw collections
- private IAnnotationBinding[] getAnnotationInstancesFromAST()
- {
- IAnnotationBinding[] instances = null;
- List extendsMods = null;
- switch( _astNode.getNodeType() )
- {
- case ASTNode.TYPE_DECLARATION:
- case ASTNode.ANNOTATION_TYPE_DECLARATION:
- case ASTNode.ENUM_DECLARATION:
- case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION:
- case ASTNode.METHOD_DECLARATION:
- case ASTNode.FIELD_DECLARATION:
- case ASTNode.ENUM_CONSTANT_DECLARATION:
- extendsMods = ((BodyDeclaration)_astNode).modifiers();
- break;
-
- case ASTNode.SINGLE_VARIABLE_DECLARATION:
- extendsMods = ((SingleVariableDeclaration)_astNode).modifiers();
- break;
- case ASTNode.VARIABLE_DECLARATION_FRAGMENT:
- final ASTNode parent = ((VariableDeclarationFragment)_astNode).getParent();
- if( parent instanceof BodyDeclaration )
- extendsMods = ((BodyDeclaration)parent).modifiers();
- break;
-
- default:
- throw new IllegalStateException();
- }
- if( extendsMods != null ){
- int count = 0;
- for( Object obj : extendsMods ){
- final IExtendedModifier extMod = (IExtendedModifier)obj;
- if( extMod.isAnnotation() )
- count ++;
- }
- instances = new IAnnotationBinding[count];
- int index = 0;
- for( Object obj : extendsMods ){
- final IExtendedModifier extMod = (IExtendedModifier)obj;
- if( extMod.isAnnotation() )
- instances[index ++] =
- ((org.eclipse.jdt.core.dom.Annotation)extMod).resolveAnnotationBinding();
- }
- }
- return instances;
- }
-
- public boolean isFromSource(){ return true; }
-
- ASTNode getAstNode(){
- return _astNode;
- }
-
- CompilationUnit getCompilationUnit(){
- return (CompilationUnit)_astNode.getRoot();
- }
-
- public IFile getResource(){
- return _file;
- }
-
- public SourcePosition getPosition()
- {
- 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.getLineNumber(start),
- unit.getColumnNumber(start),
- this);
-
- }
-
- public boolean isBindingBased(){ return false; }
-
- public boolean equals(Object obj)
- {
- if(obj instanceof ASTBasedDeclarationImpl)
- return _astNode == ((ASTBasedDeclarationImpl)obj)._astNode;
-
- return false;
- }
-
- public int hashCode(){
- return _astNode.hashCode();
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedExecutableDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedExecutableDeclarationImpl.java
deleted file mode 100644
index 3ad3dbe27e..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedExecutableDeclarationImpl.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.core.dom.SimpleName;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.TypeParameter;
-
-import com.sun.mirror.declaration.ExecutableDeclaration;
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.declaration.TypeParameterDeclaration;
-import com.sun.mirror.type.ReferenceType;
-import com.sun.mirror.util.DeclarationVisitor;
-
-public abstract class ASTBasedExecutableDeclarationImpl
- extends ASTBasedMemberDeclarationImpl
- implements ExecutableDeclaration{
-
- public ASTBasedExecutableDeclarationImpl(
- final org.eclipse.jdt.core.dom.BodyDeclaration astNode,
- final IFile file,
- final BaseProcessorEnv env)
- {
- super(astNode, file, env);
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- visitor.visitExecutableDeclaration(this);
- }
-
- public Collection<TypeParameterDeclaration> getFormalTypeParameters()
- {
- return ExecutableUtil.getFormalTypeParameters(this, _env);
- }
-
- public Collection<ParameterDeclaration> getParameters()
- {
- return ExecutableUtil.getParameters(this, _env);
- }
-
- public Collection<ReferenceType> getThrownTypes()
- {
- return ExecutableUtil.getThrownTypes(this, _env);
- }
-
- public boolean isVarArgs()
- {
- return getMethodAstNode().isVarargs();
- }
-
- public String getSimpleName()
- {
- final org.eclipse.jdt.core.dom.MethodDeclaration methodAstNode = getMethodAstNode();
- final SimpleName nameNode = methodAstNode.getName();
- return nameNode == null ? EMPTY_STRING : nameNode.getIdentifier();
- }
-
- org.eclipse.jdt.core.dom.MethodDeclaration getMethodAstNode(){
- return (org.eclipse.jdt.core.dom.MethodDeclaration)_astNode;
- }
-
- public String toString()
- {
- final StringBuilder buffer = new StringBuilder();
- final org.eclipse.jdt.core.dom.MethodDeclaration methodAstNode = getMethodAstNode();
- @SuppressWarnings("unchecked")
- final List<TypeParameter> typeParams = methodAstNode.typeParameters();
- if( typeParams != null && typeParams.size() > 0 ){
- buffer.append('<');
- for(int i=0, size=typeParams.size(); i<size; i++ ){
- if( i != 0 )
- buffer.append(", "); //$NON-NLS-1$
- buffer.append(typeParams.get(i).toString());
- }
- buffer.append('>');
- }
-
- if( methodAstNode.getReturnType2() != null )
- buffer.append(methodAstNode.getReturnType2());
- buffer.append(' ');
- buffer.append(methodAstNode.getName());
- buffer.append('(');
- int i=0;
- @SuppressWarnings("unchecked")
- final List<SingleVariableDeclaration> params = methodAstNode.parameters();
- for( SingleVariableDeclaration param : params ){
- if( i++ != 0 )
- buffer.append(", "); //$NON-NLS-1$
- buffer.append(param.getName());
- }
- buffer.append(')');
-
- return buffer.toString();
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedFieldDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedFieldDeclarationImpl.java
deleted file mode 100644
index ad7c2901a7..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedFieldDeclarationImpl.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.SimpleName;
-import org.eclipse.jdt.core.dom.Type;
-import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
-
-import com.sun.mirror.declaration.FieldDeclaration;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.util.DeclarationVisitor;
-
-/**
- * This field declaration implementation is based on the variable declaration
- * fragment ast node in the parse tree.
- * The most common scenario where such implementation is required is when
- * the type of the field cannot be resolved. In this case, the jdt will not
- * create the field binding. Information such as the declaring type as well
- * as the name of the field will still be captured and make available to clients.
- */
-public class ASTBasedFieldDeclarationImpl
- extends ASTBasedMemberDeclarationImpl
- implements FieldDeclaration {
-
- public ASTBasedFieldDeclarationImpl(
- final VariableDeclarationFragment astNode,
- final IFile file,
- final BaseProcessorEnv env)
- {
- super(astNode, file, env);
- assert astNode.getParent() != null &&
- astNode.getParent().getNodeType() == ASTNode.FIELD_DECLARATION :
- "parent isn't a field declaration"; //$NON-NLS-1$
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- visitor.visitFieldDeclaration(this);
- }
-
- public String getConstantExpression()
- {
- final Object constant = getConstantValue();
- if( constant == null ) return null;
- return constant.toString();
- }
-
- public Object getConstantValue()
- {
- final VariableDeclarationFragment fragment = getAstNode();
- final Expression initializer = fragment.getInitializer();
- if( initializer == null ) return null;
- return initializer.resolveConstantExpressionValue();
- }
-
- public String getSimpleName() {
- final VariableDeclarationFragment fragment = getAstNode();
- final SimpleName nameNode = fragment.getName();
- return nameNode == null ? EMPTY_STRING : nameNode.getIdentifier();
- }
-
- public TypeMirror getType()
- {
- final org.eclipse.jdt.core.dom.FieldDeclaration fieldASTNode = getFieldDeclarationAstNode();
- final Type type = fieldASTNode.getType();
- if( type == null )
- return null;
- final ITypeBinding typeBinding = type.resolveBinding();
- // This is probably why we end up with an ast based implementation.
- if( typeBinding == null )
- return Factory.createErrorClassType(type.toString());
- else{
- TypeMirror typeMirror = Factory.createTypeMirror( typeBinding, _env );
- if( typeMirror == null )
- typeMirror = Factory.createErrorClassType(typeBinding);
- return typeMirror;
- }
- }
-
- public String toString()
- {
- /*
- final org.eclipse.jdt.core.dom.FieldDeclaration fieldASTNode = getFieldDeclarationAstNode();
- StringBuilder buffer = new StringBuilder();
- final Type type = fieldASTNode.getType();
- if( type != null ){
- buffer.append(type);
- buffer.append(' ');
- }
- buffer.append( getSimpleName() );
-
- return buffer.toString();
- */
- return getSimpleName();
- }
-
- public MirrorKind kind(){ return MirrorKind.FIELD; }
-
- VariableDeclarationFragment getAstNode()
- {
- return (VariableDeclarationFragment)_astNode;
- }
-
- org.eclipse.jdt.core.dom.FieldDeclaration getFieldDeclarationAstNode()
- {
- return (org.eclipse.jdt.core.dom.FieldDeclaration)_astNode.getParent();
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedMemberDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedMemberDeclarationImpl.java
deleted file mode 100644
index dce039fdc5..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedMemberDeclarationImpl.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import com.sun.mirror.declaration.MemberDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.util.DeclarationVisitor;
-
-public abstract class ASTBasedMemberDeclarationImpl
- extends ASTBasedDeclarationImpl implements MemberDeclaration{
-
- public ASTBasedMemberDeclarationImpl(
- ASTNode astNode,
- IFile file,
- BaseProcessorEnv env)
- {
- super(astNode, file, env);
- }
-
- public void accept(DeclarationVisitor visitor) {
- visitor.visitMemberDeclaration(this);
- }
-
- public TypeDeclaration getDeclaringType()
- {
- final AbstractTypeDeclaration parentType = getContainingTypeAstNode();
- // most likely a mal-formed text.
- if( parentType == null )
- return null;
-
- final ITypeBinding parentTypeBinding = parentType.resolveBinding();
- if( parentTypeBinding == null )
- throw new UnsupportedOperationException("Type declaration that doesn't have binding"); //$NON-NLS-1$
- return Factory.createReferenceType(parentTypeBinding, _env);
- }
-
- public String getDocComment()
- {
- final ASTNode node = getAstNode();
-
- if( node instanceof BodyDeclaration )
- return getDocComment((BodyDeclaration)node);
-
- else if( node.getNodeType() == ASTNode.VARIABLE_DECLARATION_FRAGMENT ){
- final ASTNode parent = node.getParent();
- // a field declaration
- if( parent instanceof BodyDeclaration )
- return getDocComment((BodyDeclaration)parent);
-
- }
- return EMPTY_STRING;
- }
-
- /**
- * @return the closest ancestor to the ast node in this instance that
- * is a type declaration node or <code>null</code> if none is found.
- */
- protected AbstractTypeDeclaration getContainingTypeAstNode()
- {
- ASTNode cur = _astNode;
- while(cur != null){
- switch(cur.getNodeType()){
- case ASTNode.ANNOTATION_TYPE_DECLARATION:
- case ASTNode.ENUM_DECLARATION:
- case ASTNode.TYPE_DECLARATION:
- return (AbstractTypeDeclaration)cur;
- }
- cur = cur.getParent();
- }
- return null;
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedMethodDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedMethodDeclarationImpl.java
deleted file mode 100644
index 3221af5883..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedMethodDeclarationImpl.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.Type;
-
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.util.DeclarationVisitor;
-
-public class ASTBasedMethodDeclarationImpl
- extends ASTBasedExecutableDeclarationImpl
- implements MethodDeclaration{
-
- public ASTBasedMethodDeclarationImpl(
- final org.eclipse.jdt.core.dom.BodyDeclaration astNode,
- final IFile file,
- final BaseProcessorEnv env)
- {
- super(astNode, file, env);
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- visitor.visitMethodDeclaration(this);
- }
-
- public TypeMirror getReturnType()
- {
- final org.eclipse.jdt.core.dom.MethodDeclaration methodAstNode = getMethodAstNode();
- final Type retType = methodAstNode.getReturnType2();
- // some funny error case where the return type is missing but it's not a constructor.
- if( retType == null )
- return Factory.createErrorClassType(EMPTY_STRING);
- final ITypeBinding typeBinding = retType.resolveBinding();
- // This is most likely the reason that we end up with an ast based implementation.
- if( typeBinding == null ){
- return Factory.createErrorClassType(retType.toString());
- }
- else{
- final TypeMirror type = Factory.createTypeMirror(typeBinding, _env);
- if(type == null )
- return Factory.createErrorClassType(retType.toString());
- return type;
- }
- }
-
- public MirrorKind kind(){ return MirrorKind.METHOD; }
-
-}
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 5a025fe55b..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationDeclarationImpl.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.BaseProcessorEnv;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-public class AnnotationDeclarationImpl extends InterfaceDeclarationImpl implements AnnotationTypeDeclaration, AnnotationType
-{
- public AnnotationDeclarationImpl(final ITypeBinding binding, final BaseProcessorEnv env)
- {
- super(binding, env);
- assert binding.isAnnotation() : "binding does not represent a annotation "; //$NON-NLS-1$
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- visitor.visitAnnotationTypeDeclaration(this);
- }
-
- @SuppressWarnings("unchecked") // _getMethods() return type is too broadly specified
- public Collection<AnnotationTypeElementDeclaration> getMethods()
- {
- return (Collection<AnnotationTypeElementDeclaration>)_getMethods();
- }
-
- // start of implementation of AnnotationType API
- public void accept(TypeVisitor 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 cc95c2f54f..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationElementDeclarationImpl.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.BaseProcessorEnv;
-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 BaseProcessorEnv env)
- {
- super(binding, env);
- }
-
- public void accept(DeclarationVisitor 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 ee6fcae59b..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationMirrorImpl.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-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.Annotation;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.IAnnotationBinding;
-import org.eclipse.jdt.core.dom.IMemberValuePairBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.Name;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-
-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, EclipseMirrorObject
-{
- /**The ast node that correspond to the annotation.*/
- private final IAnnotationBinding _domAnnotation;
- private final BaseProcessorEnv _env;
- /** the declaration that is annotated by this annotation or the annotation element declaration
- * if this is (part of) a default value*/
- private final EclipseDeclarationImpl _annotated;
-
- public AnnotationMirrorImpl(IAnnotationBinding annotationAstNode, EclipseDeclarationImpl decl, BaseProcessorEnv env)
- {
- _domAnnotation = annotationAstNode;
- _env = env;
- _annotated = decl;
- assert _domAnnotation != null : "annotation node missing."; //$NON-NLS-1$
- assert _annotated != null : "missing the declaration that is annotated with this annotation."; //$NON-NLS-1$
- }
-
- public AnnotationType getAnnotationType()
- {
- final ITypeBinding binding = _domAnnotation.getAnnotationType();
- if( binding == null ){
- final ASTNode node = _annotated.getCompilationUnit().findDeclaringNode(_domAnnotation);
- String name = ""; //$NON-NLS-1$
- if( node != null && node instanceof Annotation ){
- final Name typeNameNode = ((Annotation)node).getTypeName();
- if( typeNameNode != null )
- name = typeNameNode.toString();
- }
- return Factory.createErrorAnnotationType(name);
- }
- else
- return (AnnotationType)Factory.createReferenceType(binding, _env);
- }
-
- public Map<AnnotationTypeElementDeclaration, AnnotationValue> getElementValues()
- {
- final IMemberValuePairBinding[] 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( IMemberValuePairBinding pair : pairs ){
- final String name = pair.getName();
- if( name == null ) continue;
- IMethodBinding elementMethod = pair.getMethodBinding();
- if( elementMethod != null ){
- final EclipseDeclarationImpl mirrorDecl = Factory.createDeclaration(elementMethod, _env);
- if( mirrorDecl != null && mirrorDecl.kind() == EclipseMirrorObject.MirrorKind.ANNOTATION_ELEMENT )
- {
- final AnnotationTypeElementDeclaration elementDecl =
- (AnnotationTypeElementDeclaration)mirrorDecl;
- final AnnotationValue annoValue =
- Factory.createAnnotationMemberValue(pair.getValue(), name, this, _env, elementDecl.getReturnType());
- if( annoValue != null )
- result.put( elementDecl, 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;
-
- final int offset = astNode.getStartPosition();
- return new SourcePositionImpl(astNode.getStartPosition(),
- astNode.getLength(),
- unit.getLineNumber(offset),
- unit.getColumnNumber(offset),
- _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 IMemberValuePairBinding[] declaredPairs = _domAnnotation.getDeclaredMemberValuePairs();
- for( IMemberValuePairBinding pair : declaredPairs ){
- if( membername.equals(pair.getName()) ){
- final Object value = pair.getValue();
- return getValueTypeBinding(value, pair.getMethodBinding().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 ); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
-
- /**
- * @param memberName the name of the member
- * @return the value of the given member
- */
- public Object getValue(final String memberName)
- {
- if( memberName == null ) return null;
- final IMemberValuePairBinding[] declaredPairs = _domAnnotation.getDeclaredMemberValuePairs();
- for( IMemberValuePairBinding 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 IAnnotationBinding getResolvedAnnotaion(){return _domAnnotation; }
-
-
-
- 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;
- }
-
- @SuppressWarnings("unchecked")
- 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) ) //$NON-NLS-1$
- 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 BaseProcessorEnv getEnvironment(){ return _env; }
-
- public IFile getResource()
- { return _annotated.getResource(); }
-
- public EclipseDeclarationImpl 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 515b608edc..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/AnnotationValueImpl.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.declaration.AnnotationValue;
-import com.sun.mirror.util.SourcePosition;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-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 EclipseMirrorObject, AnnotationValue
-{
- /**
- * Either the annotation that directly contains this annotation value
- * or an annotation method, which indicates that this is its default value.
- */
- private EclipseMirrorObject _parent;
- private final BaseProcessorEnv _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 BaseProcessorEnv env)
- {
-
- _value = value;
- _env = env;
- _parent = element;
- _name = null;
- _index = index;
- assert _env != null : "missing environment"; //$NON-NLS-1$
- assert _parent != null : "missing element"; //$NON-NLS-1$
- }
-
- /**
- *
- * @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 BaseProcessorEnv env)
- {
- assert value != null : "value is null"; //$NON-NLS-1$
- _value = value;
- _env = env;
- _parent = annotation;
- _name = name;
- _index = index;
- assert _env != null : "missing environment"; //$NON-NLS-1$
- assert _parent != null : "missing element"; //$NON-NLS-1$
- }
-
- @SuppressWarnings("unchecked") // DOM AST API returns raw collections
- 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;
- final int offset = astNode.getStartPosition();
- return new SourcePositionImpl(astNode.getStartPosition(),
- astNode.getLength(),
- unit.getLineNumber(offset),
- unit.getColumnNumber(offset),
- this);
- }
-
- CompilationUnit getCompilationUnit()
- {
- final MirrorKind kind = _parent.kind();
- switch(kind)
- {
- case ANNOTATION_MIRROR:
- return ((AnnotationMirrorImpl)_parent).getCompilationUnit();
- case ANNOTATION_ELEMENT:
- if( ((EclipseDeclarationImpl)_parent).isBindingBased() )
- return ((AnnotationElementDeclarationImpl)_parent).getCompilationUnit();
- else
- return ((ASTBasedAnnotationElementDeclarationImpl)_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:
- if( ((EclipseDeclarationImpl)_parent).isBindingBased() )
- return ((AnnotationElementDeclarationImpl)_parent).isFromSource();
- else
- return ((ASTBasedAnnotationElementDeclarationImpl)_parent).isFromSource();
- default:
- throw new IllegalStateException(); // should never reach this point.
- }
- }
-
- public IFile getResource()
- {
- final MirrorKind kind = _parent.kind();
- switch(kind)
- {
- case ANNOTATION_MIRROR:
- return ((AnnotationMirrorImpl)_parent).getResource();
- case ANNOTATION_ELEMENT:
- if( ((EclipseDeclarationImpl)_parent).isBindingBased() )
- return ((AnnotationElementDeclarationImpl)_parent).getResource();
- else
- return ((ASTBasedAnnotationElementDeclarationImpl)_parent).getResource();
- default:
- throw new IllegalStateException(); // should never reach this point.
- }
- }
-
- public Object getValue(){ return _value; }
-
- public MirrorKind kind(){ return MirrorKind.ANNOTATION_VALUE; }
-
- public BaseProcessorEnv getEnvironment(){
- return _env;
- }
-
- public String toString(){ return _value == null ? "" : _value.toString(); } //$NON-NLS-1$
-}
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 0ac7ce3973..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/BinaryParameterDeclarationImpl.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.Modifier;
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.mirror.util.SourcePosition;
-
-import java.lang.annotation.Annotation;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.IAnnotationBinding;
-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 that came from binary.
- */
-public class BinaryParameterDeclarationImpl extends DeclarationImpl implements ParameterDeclaration
-{
- static final String ARG = "arg"; //$NON-NLS-1$
- private final ITypeBinding _type;
- private final ExecutableDeclarationImpl _executable;
- private final int _paramIndex;
- /**
- * Parameter declaration from binary
- */
- public BinaryParameterDeclarationImpl(ExecutableDeclarationImpl executable,
- ITypeBinding typeBinding,
- int index,
- BaseProcessorEnv env)
- {
- super(typeBinding, env);
- assert( typeBinding != null ) : "missing type binding"; //$NON-NLS-1$
- assert( index >= 0 ) : "invalid index " + index; //$NON-NLS-1$
- assert executable != null : "missing executable"; //$NON-NLS-1$
- _type = typeBinding;
- _paramIndex = index;
- _executable = executable;
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- visitor.visitParameterDeclaration(this);
- }
-
- public Collection<Modifier> getModifiers()
- {
- // TODO
- // we don't store this information. so simply return nothing for now.
- return Collections.emptyList();
- }
-
- 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 SourcePosition getPosition()
- {
- return null;
- }
-
- 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 IAnnotationBinding[] paramAnnos = methodBinding.getParameterAnnotations(_paramIndex);
- return _getAnnotation(annotationClass, paramAnnos);
- }
-
- public Collection<AnnotationMirror> getAnnotationMirrors()
- {
- final IMethodBinding methodBinding = _executable.getDeclarationBinding();
- final IAnnotationBinding[] paramAnnos = methodBinding.getParameterAnnotations(_paramIndex);
- return _getAnnotationMirrors(paramAnnos);
- }
-
- public boolean isBindingBased(){ return true; }
-
- public boolean isFromSource(){ return false; }
-
- ASTNode getAstNode(){ return null; }
-
- public IFile getResource(){ return null; }
-
- private ITypeBinding getTypeBinding(){ return _type; }
-
- public MirrorKind kind(){ return MirrorKind.FORMAL_PARAMETER; }
-
- public IBinding getDeclarationBinding(){
- throw new UnsupportedOperationException("should never be invoked on a BinaryParameterDeclaration"); //$NON-NLS-1$
- }
-
- 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;
- }
-
- public int hashCode(){
- final String methodKey = _executable.getDeclarationBinding().getKey();
- int hashcode = 0;
- if( methodKey != null )
- hashcode = methodKey.hashCode();
- return hashcode + _paramIndex;
- }
-
- public String toString(){
- final StringBuilder builder = new StringBuilder();
- builder.append(getTypeBinding().getName());
- builder.append(' ');
- builder.append(getSimpleName());
- return builder.toString();
- }
-}
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 02e9c0ea70..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ClassDeclarationImpl.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
-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 BaseProcessorEnv env)
- {
- super(binding, env);
- // Enum types return false for isClass().
- assert !binding.isInterface();
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- visitor.visitClassDeclaration(this);
- }
-
- @SuppressWarnings("unchecked")
- private void getASTConstructor(
- final AbstractTypeDeclaration typeDecl,
- final List<ConstructorDeclaration> results){
-
- final List bodyDecls = typeDecl.bodyDeclarations();
- IFile file = null;
- for( int i=0, len=bodyDecls.size(); i<len; i++ ){
- final BodyDeclaration bodyDecl = (BodyDeclaration)bodyDecls.get(i);
- if( bodyDecl.getNodeType() == ASTNode.METHOD_DECLARATION ){
- final org.eclipse.jdt.core.dom.MethodDeclaration methodDecl =
- (org.eclipse.jdt.core.dom.MethodDeclaration)bodyDecl;
-
- if( methodDecl.isConstructor() ){
- final IMethodBinding methodBinding = methodDecl.resolveBinding();
- // built an ast based representation.
- if( methodBinding == null ){
- if( file == null )
- file = getResource();
- ConstructorDeclaration mirrorDecl =
- (ConstructorDeclaration)Factory.createDeclaration(methodDecl, file, _env);
- if( mirrorDecl != null )
- results.add(mirrorDecl);
- }
- }
- }
- }
- }
-
- public Collection<ConstructorDeclaration> getConstructors()
- {
- final List<ConstructorDeclaration> results = new ArrayList<ConstructorDeclaration>();
- if( isFromSource() ){
- // need to consult the ast since methods with broken signature
- // do not appear in bindings.
- final ITypeBinding typeBinding = getDeclarationBinding();
- final ASTNode node =
- _env.getASTNodeForBinding(typeBinding);
- if( node != null ){
- switch( node.getNodeType() )
- {
- case ASTNode.TYPE_DECLARATION:
- case ASTNode.ANNOTATION_TYPE_DECLARATION:
- case ASTNode.ENUM_DECLARATION:
- AbstractTypeDeclaration typeDecl =
- (AbstractTypeDeclaration)node;
- // built the ast based methods first.
- getASTConstructor(typeDecl, results);
- break;
- default:
- // the ast node for a type binding should be a AbstractTypeDeclaration.
- throw new IllegalStateException("expecting a AbstractTypeDeclaration but got " //$NON-NLS-1$
- + node.getClass().getName() );
- }
- }
- }
- // build methods for binding type or
- // build the binding based method for source type.
-
- final IMethodBinding[] methods = getDeclarationBinding().getDeclaredMethods();
- 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;
-
- }
-
- @SuppressWarnings("unchecked")
- public Collection<MethodDeclaration> getMethods()
- {
- return (Collection<MethodDeclaration>)_getMethods();
- }
-
- // Start of implementation of ClassType API
- public void accept(TypeVisitor visitor)
- {
- visitor.visitClassType(this);
- }
-
- public ClassType getSuperclass()
- {
- final ITypeBinding superClass = getDeclarationBinding().getSuperclass();
- if ( superClass == null )
- return null;
- else 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 53f180b7b7..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ConstructorDeclarationImpl.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.BaseProcessorEnv;
-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, BaseProcessorEnv env)
- {
- super(binding, env);
- assert binding.isConstructor() : "binding does not represent a constructor"; //$NON-NLS-1$
- }
-
- public void accept(DeclarationVisitor 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(", "); //$NON-NLS-1$
- 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 0df837edae..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/DeclarationImpl.java
+++ /dev/null
@@ -1,107 +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.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IBinding;
-
-import com.sun.mirror.declaration.Modifier;
-
-public abstract class DeclarationImpl extends EclipseDeclarationImpl {
-
- /** the type binding corresponding to this declaration */
- protected final IBinding _binding;
- DeclarationImpl(final IBinding binding, final BaseProcessorEnv env )
- {
- super(env);
- assert binding != null : "binding cannot be null"; //$NON-NLS-1$
- _binding = binding;
- }
-
- public boolean equals(Object obj)
- {
- if(obj instanceof DeclarationImpl)
- return _binding.isEqualTo( ((DeclarationImpl)obj)._binding );
-
- return false;
- }
-
- public int hashCode(){
- final String key = getDeclarationBinding().getKey();
- return key == null ? 0 : key.hashCode();
- }
-
- /**
- * @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;
- }
-
- public boolean isBindingBased(){ return true; }
-
- ASTNode getAstNode(){
- if( !isFromSource() ) return null;
- return _env.getASTNodeForBinding(getDeclarationBinding());
- }
-
- CompilationUnit getCompilationUnit(){
- if( !isFromSource() ) return null;
- return _env.getCompilationUnitForBinding(getDeclarationBinding());
- }
-
- public IFile getResource(){
- if( isFromSource() ){
- final IBinding binding = getDeclarationBinding();
- return _env.getDeclaringFileForBinding(binding);
- }
- return null;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EclipseDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EclipseDeclarationImpl.java
deleted file mode 100644
index dd286d2d70..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EclipseDeclarationImpl.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.IFile;
-import org.eclipse.jdt.apt.core.internal.env.AnnotationInvocationHandler;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
-import org.eclipse.jdt.core.dom.FieldDeclaration;
-import org.eclipse.jdt.core.dom.IAnnotationBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.Javadoc;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.SimpleName;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
-
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.util.DeclarationVisitor;
-
-public abstract class EclipseDeclarationImpl implements Declaration, EclipseMirrorObject
-{
- final BaseProcessorEnv _env;
-
- EclipseDeclarationImpl(final BaseProcessorEnv env)
- {
- assert env != null : "missing environment"; //$NON-NLS-1$
- _env = env;
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- visitor.visitDeclaration(this);
- }
-
- @SuppressWarnings("unchecked")
- <A extends Annotation> A _getAnnotation(Class<A> annotationClass,
- IAnnotationBinding[] annoInstances)
- {
- if( annoInstances == null || annoInstances.length == 0 || annotationClass == null )
- return null;
-
- String annoTypeName = annotationClass.getName();
- if( annoTypeName == null ) return null;
- annoTypeName = annoTypeName.replace('$', '.');
- for( IAnnotationBinding annoInstance : annoInstances){
- if (annoInstance == null)
- continue;
- final ITypeBinding binding = annoInstance.getAnnotationType();
- if( binding != null && 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, annotationClass);
- return (A)Proxy.newProxyInstance(annotationClass.getClassLoader(),
- new Class[]{ annotationClass }, handler );
- }
- }
- }
- return null;
- }
-
- Collection<AnnotationMirror> _getAnnotationMirrors(IAnnotationBinding[] annoInstances)
- {
- if( annoInstances == null || annoInstances.length == 0 )
- return Collections.emptyList();
- final List<AnnotationMirror> result = new ArrayList<AnnotationMirror>(annoInstances.length);
- for(IAnnotationBinding annoInstance : annoInstances){
- if (annoInstance != null) {
- 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){
- if (annoInstance != null) {
- final AnnotationMirrorImpl annoMirror =
- (AnnotationMirrorImpl)Factory.createAnnotationMirror(annoInstance.resolveAnnotationBinding(), this, _env);
- result.add(annoMirror);
- }
- }
- return result;
- }
-
- /**
- * @return the ast node that corresponding to this declaration,
- * or null if this declaration came from binary.
- * @see #isFromSource()
- */
- abstract ASTNode getAstNode();
-
- /**
- * @return the compilation unit that the ast node of this declaration came from
- * Return null if this declaration came from binary.
- * @see #isFromSource()
- */
- abstract CompilationUnit getCompilationUnit();
-
- /**
- * @return the resource of this declaration if the declaration is from source.
- */
- abstract public IFile getResource();
-
- /**
- * @return true iff this declaration came from a source file.
- * Return false otherwise.
- */
- public abstract boolean isFromSource();
-
- public abstract boolean isBindingBased();
-
- public BaseProcessorEnv getEnvironment(){ return _env; }
-
- /**
- * @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.
- */
- protected 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;
- }
-
- protected String getDocComment(final BodyDeclaration decl)
- {
- final Javadoc javaDoc = decl.getJavadoc();
- if( javaDoc == null ) return ""; //$NON-NLS-1$
- return javaDoc.toString();
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EclipseMirrorObject.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EclipseMirrorObject.java
deleted file mode 100644
index 1202ac3174..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EclipseMirrorObject.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.BaseProcessorEnv;
-
-/**
- * The base of all eclipse type system object
- * @author tyeung
- *
- */
-public interface EclipseMirrorObject {
-
- public enum MirrorKind
- {
- CONSTRUCTOR,
- METHOD,
- ANNOTATION_ELEMENT,
- FIELD,
- ENUM_CONSTANT,
- ANNOTATION_VALUE,
- ANNOTATION_MIRROR,
- TYPE_ANNOTATION,
- TYPE_INTERFACE,
- TYPE_CLASS,
- TYPE_ENUM,
- TYPE_ARRAY,
- TYPE_WILDCARD,
- TYPE_VOID,
- TYPE_PRIMITIVE,
- TYPE_PARAMETER_VARIABLE,
- TYPE_ERROR,
- FORMAL_PARAMETER,
- PACKAGE
- }
-
- public MirrorKind kind();
-
- /**
- * @return the processor environment associated with the object.
- * return null for primitive, void and error type.
- */
- public BaseProcessorEnv getEnvironment();
-
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EclipseMirrorType.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EclipseMirrorType.java
deleted file mode 100644
index 35295777e4..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EclipseMirrorType.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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:
- * thanson@bea.com - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.apt.core.internal.declaration;
-
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-import com.sun.mirror.type.TypeMirror;
-
-/**
- * The base type for all Mirror type objects
- * @author thanson
- *
- */
-public interface EclipseMirrorType extends EclipseMirrorObject, TypeMirror {
- public boolean isAssignmentCompatible(EclipseMirrorType left);
- public boolean isSubTypeCompatible(EclipseMirrorType type);
-
- public ITypeBinding getTypeBinding();
-}
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 fe77269cae..0000000000
--- 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, 2007 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.BaseProcessorEnv;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-
-public class EnumConstantDeclarationImpl extends FieldDeclarationImpl implements EnumConstantDeclaration
-{
- public EnumConstantDeclarationImpl(IVariableBinding binding, BaseProcessorEnv env)
- {
- super(binding, env);
- assert binding.isEnumConstant() : "binding does not represent an enum constant"; //$NON-NLS-1$
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- visitor.visitEnumConstantDeclaration(this);
- }
-
- 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 67d7a20103..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/EnumDeclarationImpl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.BaseProcessorEnv;
-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 BaseProcessorEnv env)
- {
- super(binding, env);
- assert binding.isEnum() : "binding is not an enum."; //$NON-NLS-1$
- }
-
- public void accept(DeclarationVisitor 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)
- {
- visitor.visitEnumType(this);
- }
-
- public EnumDeclaration getDeclaration()
- {
- return (EnumDeclaration)super.getDeclaration();
- }
-
- public MirrorKind kind(){ return MirrorKind.TYPE_ENUM; }
-}
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 46facd0983..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ExecutableDeclarationImpl.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-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 BaseProcessorEnv env)
- {
- super(binding, env);
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- visitor.visitExecutableDeclaration(this);
- }
-
- public TypeDeclaration getDeclaringType()
- {
- final IMethodBinding methodBinding = getDeclarationBinding();
- return Factory.createReferenceType(methodBinding.getDeclaringClass(), _env);
- }
-
- public Collection<TypeParameterDeclaration> getFormalTypeParameters()
- {
- return ExecutableUtil.getFormalTypeParameters(this, _env);
- }
- public Collection<ParameterDeclaration> getParameters()
- {
- return ExecutableUtil.getParameters(this, _env);
- }
-
- public Collection<ReferenceType> getThrownTypes()
- {
- return ExecutableUtil.getThrownTypes(this, _env);
- }
-
- public boolean isVarArgs()
- {
- return getDeclarationBinding().isVarargs();
- }
-
- public String getSimpleName()
- {
- return getDeclarationBinding().getName();
- }
-
- public IMethodBinding getDeclarationBinding()
- {
- return (IMethodBinding)_binding;
- }
-
- public 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/ExecutableUtil.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ExecutableUtil.java
deleted file mode 100644
index b894ce15f5..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ExecutableUtil.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.declaration.EclipseMirrorObject.MirrorKind;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-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.Name;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.TypeParameter;
-
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.declaration.TypeParameterDeclaration;
-import com.sun.mirror.type.ReferenceType;
-
-class ExecutableUtil {
-
- /**
- * @param executable must be a constructor, method or annotation element.
- * @return the formal type parameters of the executable.
- */
- static Collection<TypeParameterDeclaration> getFormalTypeParameters(
- EclipseDeclarationImpl executable,
- BaseProcessorEnv env)
- {
- // the dom ast does not provide type parameter list for annotation element
- // that incorrectly includes them in the text
- if(executable == null || executable.kind() == MirrorKind.ANNOTATION_ELEMENT)
- return Collections.emptyList();
- if( executable.kind() != MirrorKind.METHOD && executable.kind() != MirrorKind.CONSTRUCTOR)
- throw new IllegalArgumentException("Executable is not a method " + //$NON-NLS-1$
- executable.getClass().getName());
-
- if( executable.isFromSource() ){
- final org.eclipse.jdt.core.dom.MethodDeclaration methodAstNode =
- (org.eclipse.jdt.core.dom.MethodDeclaration)executable.getAstNode();
-
- // Synthetic methods will have no ast node
- if (methodAstNode == null)
- return Collections.emptyList();
- @SuppressWarnings("unchecked")
- final List<TypeParameter> typeParams = methodAstNode.typeParameters();
- final List<TypeParameterDeclaration> result = new ArrayList<TypeParameterDeclaration>();
- for(TypeParameter typeParam : typeParams){
- final ITypeBinding typeBinding = typeParam.resolveBinding();
- if( typeBinding == null ){
- throw new UnsupportedOperationException("cannot create a type parameter declaration without a binding"); //$NON-NLS-1$
- }
- else{
- final TypeParameterDeclaration typeParamDecl =
- (TypeParameterDeclaration)Factory.createDeclaration(typeBinding, env);
- if( typeParamDecl != null )
- result.add(typeParamDecl);
- }
- }
- return result;
- }
- else{ // binary
- if( !executable.isBindingBased() )
- throw new IllegalStateException("binary executable without binding."); //$NON-NLS-1$
- final IMethodBinding methodBinding = ((ExecutableDeclarationImpl)executable).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;
-
- }
- }
-
- /**
- * @param executable must be a constructor, method or annotation element.
- * @return the list formal parameters of the executable.
- */
- static Collection<ParameterDeclaration> getParameters(
- final EclipseDeclarationImpl executable,
- final BaseProcessorEnv env)
- {
- // the dom ast does not provide parameter list for annotation element
- // that incorrectly includes them in the text
- if(executable == null || executable.kind() == MirrorKind.ANNOTATION_ELEMENT)
- return Collections.emptyList();
- if( executable.kind() != MirrorKind.METHOD && executable.kind() != MirrorKind.CONSTRUCTOR)
- throw new IllegalArgumentException("Executable is not a method " + //$NON-NLS-1$
- executable.getClass().getName());
-
- if( executable.isFromSource() ){
- // We always need to look into the ast to make sure the complete list of
- // parameters are returned since parameters with unresolved type will not
- // show up in the method binding
- final org.eclipse.jdt.core.dom.MethodDeclaration methodAstNode =
- (org.eclipse.jdt.core.dom.MethodDeclaration)executable.getAstNode();
-
- // Synthetic methods will have no ast node
- if (methodAstNode == null)
- return Collections.emptyList();
-
- @SuppressWarnings("unchecked")
- final List<SingleVariableDeclaration> params = methodAstNode.parameters();
- if( params == null || params.size() == 0 )
- return Collections.emptyList();
- final List<ParameterDeclaration> result = new ArrayList<ParameterDeclaration>(params.size());
- for( int i=0, size=params.size(); i<size; i++ ){
- final SingleVariableDeclaration varDecl = params.get(i);
- final ParameterDeclaration param =
- Factory.createParameterDeclaration(varDecl, executable.getResource(), env);
- result.add(param);
- }
- return result;
- }
- else{
- if( !executable.isBindingBased() )
- throw new IllegalStateException("binary executable without binding."); //$NON-NLS-1$
- // it is binary, since we don't support the class file format, will rely on the
- // binding and hope that it's complete.
- final ExecutableDeclarationImpl impl = (ExecutableDeclarationImpl)executable;
- final IMethodBinding methodBinding = impl.getDeclarationBinding();
- final ITypeBinding[] paramTypes = methodBinding.getParameterTypes();
- if( paramTypes == null || paramTypes.length == 0 )
- return Collections.emptyList();
- final List<ParameterDeclaration> result = new ArrayList<ParameterDeclaration>(paramTypes.length);
-
- for( int i=0; i<paramTypes.length; i++ ){
- final ITypeBinding type = paramTypes[i];
- final ParameterDeclaration param = Factory.createParameterDeclaration(impl, i, type, env);
- result.add(param);
- }
-
- return result;
-
- }
- }
-
- /**
- * @param executable must be a constructor, method or annotation element.
- * @return the list thrown types of the executable.
- */
- static Collection<ReferenceType> getThrownTypes(
- final EclipseDeclarationImpl executable,
- final BaseProcessorEnv env)
- {
- if(executable == null || executable.kind() == MirrorKind.ANNOTATION_ELEMENT)
- return Collections.emptyList();
- if( executable.kind() != MirrorKind.METHOD && executable.kind() != MirrorKind.CONSTRUCTOR)
- throw new IllegalArgumentException("Executable is not a method " + //$NON-NLS-1$
- executable.getClass().getName());
- if( executable.isFromSource()){
- // We always need to look into the ast to make sure the complete list of
- // parameters are returned since parameters with unresolved type will not
- // show up in the method binding
- final org.eclipse.jdt.core.dom.MethodDeclaration methodAstNode =
- (org.eclipse.jdt.core.dom.MethodDeclaration)executable.getAstNode();
-
- // If this method is synthetic, there will be no AST node
- if (methodAstNode == null)
- return Collections.emptyList();
-
- @SuppressWarnings("unchecked")
- final List<Name> exceptions = methodAstNode.thrownExceptions();
- if(exceptions == null || exceptions.size() == 0 )
- return Collections.emptyList();
- final List<ReferenceType> results = new ArrayList<ReferenceType>(4);
- for(Name exception : exceptions ){
- final ITypeBinding eType = exception.resolveTypeBinding();
- final ReferenceType refType;
- if( eType == null )
- refType = Factory.createErrorClassType(exception.toString());
- else
- refType = Factory.createReferenceType(eType, env);
- results.add(refType);
- }
-
- return results;
- }
- else{
- if( !executable.isBindingBased() )
- throw new IllegalStateException("binary executable without binding."); //$NON-NLS-1$
- final ExecutableDeclarationImpl impl = (ExecutableDeclarationImpl)executable;
- final IMethodBinding methodBinding = impl.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;
- }
- }
-}
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 4485b5b807..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/FieldDeclarationImpl.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.BaseProcessorEnv;
-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 BaseProcessorEnv env)
- {
- super(binding, env);
- assert binding.isField() : "binding doesn't represent a field"; //$NON-NLS-1$
- }
-
- public void accept(DeclarationVisitor 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; //$NON-NLS-1$
- }
-
- 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()
- {
- /*
- final StringBuilder buffer = new StringBuilder();
- final IVariableBinding field = getDeclarationBinding();
- if( field.getType() != null ){
- buffer.append( field.getType() );
- buffer.append(' ');
- }
- buffer.append(field.getName());
- return buffer.toString();
- */
- return getSimpleName();
- }
-
- public MirrorKind kind(){ return MirrorKind.FIELD; }
-
- public 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/InterfaceDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/InterfaceDeclarationImpl.java
deleted file mode 100644
index 26337928d2..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/InterfaceDeclarationImpl.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.BaseProcessorEnv;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-public class InterfaceDeclarationImpl extends TypeDeclarationImpl implements InterfaceDeclaration, InterfaceType
-{
- public InterfaceDeclarationImpl(final ITypeBinding binding, final BaseProcessorEnv env)
- {
- super(binding, env);
- assert binding.isInterface() : "binding does not represents an interface."; //$NON-NLS-1$
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- visitor.visitInterfaceDeclaration(this);
- }
-
- public Collection<? extends MethodDeclaration> getMethods()
- {
- return _getMethods();
- }
-
- // start of implementation of InterfaceType API
- public void accept(TypeVisitor 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 b019f5b0d8..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MemberDeclarationImpl.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-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, EclipseMirrorObject
-{
- MemberDeclarationImpl(final IBinding binding, BaseProcessorEnv env)
- {
- super(binding, env);
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- visitor.visitMemberDeclaration(this);
- }
-
- public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
- {
- final IAnnotationBinding[] instances = getAnnotationInstances();
- return _getAnnotation(annotationClass, instances);
- }
-
- public Collection<AnnotationMirror> getAnnotationMirrors()
- {
- final IAnnotationBinding[] instances = getAnnotationInstances();
- return _getAnnotationMirrors(instances);
- }
-
- private IAnnotationBinding[] getAnnotationInstances()
- {
- final IBinding binding = getDeclarationBinding();
- final IAnnotationBinding[] 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 ASTNode node = getAstNode();
- if(node != null){
- if( node instanceof BodyDeclaration )
-
- return getDocComment((BodyDeclaration)node);
-
- else if( node.getNodeType() == ASTNode.VARIABLE_DECLARATION_FRAGMENT ){
- final ASTNode parent = node.getParent();
- // a field declaration
- if( parent instanceof BodyDeclaration )
- return getDocComment((BodyDeclaration)parent);
-
- }
- return ""; //$NON-NLS-1$
- }
- }
- return null;
- }
-
- /**
- * @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.getLineNumber(start),
- unit.getColumnNumber(start),
- this);
- }
- return null;
- }
-}
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 30713238a8..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MethodDeclarationImpl.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.BaseProcessorEnv;
-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 BaseProcessorEnv env)
- {
- super(binding, env);
- assert !binding.isConstructor() : "binding does not represent a method."; //$NON-NLS-1$
- }
-
- public TypeMirror getReturnType()
- {
- final IMethodBinding methodBinding = getDeclarationBinding();
- final ITypeBinding retType = methodBinding.getReturnType();
- final TypeMirror type = Factory.createTypeMirror(retType, _env);
- if(type == null )
- return Factory.createErrorClassType(retType);
- return type;
- }
-
- public void accept(DeclarationVisitor 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(", "); //$NON-NLS-1$
- 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(", "); //$NON-NLS-1$
- 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 399e355014..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/PackageDeclarationImpl.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.env.BaseProcessorEnv;
-import org.eclipse.jdt.apt.core.internal.util.PackageUtil;
-import org.eclipse.jdt.apt.core.internal.util.SourcePositionImpl;
-import org.eclipse.jdt.core.IClassFile;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-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.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.declaration.TypeDeclaration;
-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;
-
- // Lazily initialized unless specified in constructor.
- private IPackageFragment[] _pkgFragments = null;
-
- public PackageDeclarationImpl(
- final IPackageBinding binding,
- final TypeDeclarationImpl typeDecl,
- final BaseProcessorEnv env,
- final boolean hideSourcePosition)
- {
- this(binding,
- typeDecl,
- env,
- hideSourcePosition,
- null);
- }
-
- public PackageDeclarationImpl(
- final IPackageBinding binding,
- final TypeDeclarationImpl typeDecl,
- final BaseProcessorEnv env,
- final boolean hideSourcePosition,
- final IPackageFragment[] pkgFragments)
- {
- super(binding, env);
- _typeDecl = typeDecl;
- _hideSourcePosition = hideSourcePosition;
- _pkgFragments = pkgFragments;
- }
-
- public IPackageBinding getPackageBinding(){ return (IPackageBinding)_binding; }
-
- public void accept(DeclarationVisitor 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() {
- initFragments();
- List<IType> types = getTypesInPackage(_pkgFragments);
- List<ClassDeclaration> classes = new ArrayList<ClassDeclaration>();
- for (IType type : types) {
- try {
- // isClass() will return true if TypeDeclaration is an InterfaceDeclaration
- if (type.isClass()) {
- TypeDeclaration td = _env.getTypeDeclaration( type );
- if ( td instanceof ClassDeclaration ) {
- classes.add((ClassDeclaration)td);
- }
- }
- }
- catch (JavaModelException ex) {} // No longer exists, don't return it
- }
-
- return classes;
- }
-
- public Collection<EnumDeclaration> getEnums() {
- initFragments();
- List<IType> types = getTypesInPackage(_pkgFragments);
- 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 Collection<InterfaceDeclaration> getInterfaces() {
- initFragments();
- List<IType> types = getTypesInPackage(_pkgFragments);
- 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;
- }
-
- 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 (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.getLineNumber(start),
- unit.getColumnNumber(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 ""; //$NON-NLS-1$
- return components[components.length - 1];
- }
-
- public MirrorKind kind(){ return MirrorKind.PACKAGE; }
-
- public String toString(){ return getQualifiedName(); }
-
- public IPackageBinding getDeclarationBinding(){ return (IPackageBinding)_binding; }
-
- public boolean isFromSource(){ return _typeDecl != null && _typeDecl.isFromSource(); }
-
- /**
- * Make sure to call this before attempting to access _pkgFragments.
- * We initialize this field lazily, because it is very expensive to compute and
- * there are some common questions such as getQualifiedName() that can be
- * answered without initializing it at all.
- */
- private void initFragments() {
- if (null == _pkgFragments) {
- _pkgFragments = PackageUtil.getPackageFragments(_binding.getName(), _env);
- }
- }
-
- private static List<IType> getTypesInPackage(final IPackageFragment[] fragments) {
- List<IType> types = new ArrayList<IType>();
- try {
- // Get all top-level classes -- ignore local, member, and anonymous classes
- for (IPackageFragment fragment : fragments) {
- for (IClassFile classFile : fragment.getClassFiles()) {
- IType type = classFile.getType();
- if (! (type.isLocal() || type.isMember() || type.isAnonymous()) ) {
- types.add(type);
- }
- }
- for (ICompilationUnit compUnit : fragment.getCompilationUnits()) {
- for (IType type : compUnit.getTypes()) {
- if (! (type.isLocal() || type.isMember() || type.isAnonymous()) ) {
- types.add(type);
- }
- }
- }
- }
- }
- catch (JavaModelException jme) {
- // Ignore -- project is in a bad state. This will get recalled if necessary
- }
- return types;
- }
-
-}
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 8b91c4c96a..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/PackageDeclarationImplNoBinding.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.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;
-
- public PackageDeclarationImplNoBinding(final IPackageFragment[] fragments) {
- this.fragments = fragments;
- }
-
- 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 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("."); //$NON-NLS-1$
- 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/SourceParameterDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/SourceParameterDeclarationImpl.java
deleted file mode 100644
index 7f0e5abd2b..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/SourceParameterDeclarationImpl.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jdt.core.dom.Name;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.Type;
-
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.util.DeclarationVisitor;
-
-/**
- * Represents a formal parameter that came from source
- */
-public class SourceParameterDeclarationImpl
- extends ASTBasedDeclarationImpl implements ParameterDeclaration{
-
- /**
- * Parameter declaration from source files
- * @param astNode the ast node that defines this parameter
- * @param file the file where the ast node originates
- * @param env
- */
- public SourceParameterDeclarationImpl(SingleVariableDeclaration astNode,
- IFile file,
- BaseProcessorEnv env)
- {
- super( astNode, file, env);
- }
-
- public void accept(DeclarationVisitor visitor)
- {
- visitor.visitParameterDeclaration(this);
- }
-
- public TypeMirror getType()
- {
- final SingleVariableDeclaration astNode = getAstNode();
- final Type type = astNode.getType();
- if( type == null )
- return Factory.createErrorClassType(EMPTY_STRING);
- final IVariableBinding varBinding = astNode.resolveBinding();
- if( varBinding == null ){
- String typeName = type.toString();
- if( astNode.isVarargs() )
- return Factory.createErrorArrayType(typeName, 1);
- else
- return Factory.createErrorClassType(typeName);
- }
- else{
- final ITypeBinding typeBinding = varBinding.getType();
- if( typeBinding == null ){
- String typeName = type.toString();
- if( astNode.isVarargs() )
- return Factory.createErrorArrayType(typeName, 1);
- else
- return Factory.createErrorClassType(typeName);
- }
- else{
- final TypeMirror mirrorType = Factory.createTypeMirror(typeBinding, _env);
- if(mirrorType == null )
- return Factory.createErrorClassType(type.toString());
- return mirrorType;
- }
- }
- }
-
- public String getSimpleName()
- {
- final Name nameNode = getAstNode().getName();
- return nameNode == null ? EMPTY_STRING : nameNode.toString();
- }
-
- public String getDocComment()
- {
- return EMPTY_STRING;
- }
-
- SingleVariableDeclaration getAstNode()
- {
- return (SingleVariableDeclaration)_astNode;
- }
-
- public MirrorKind kind(){ return MirrorKind.FORMAL_PARAMETER; }
-
- public String toString(){
- return _astNode.toString();
- }
-
- public boolean equals(Object obj){
- if( obj instanceof SourceParameterDeclarationImpl ){
- final SourceParameterDeclarationImpl otherParam = (SourceParameterDeclarationImpl)obj;
- return _astNode == otherParam._astNode;
- }
- return false;
- }
-
- public int hashCode(){
- return _astNode.hashCode();
- }
-}
-
-
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 8bf4e35fa6..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/TypeDeclarationImpl.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
-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;
-import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
-
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.FieldDeclaration;
-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.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;
-
-public abstract class TypeDeclarationImpl extends MemberDeclarationImpl
- implements TypeDeclaration, DeclaredType, ReferenceType, EclipseMirrorType
-{
- // jdt core compiler add a field to a type with the following name when there is a hierachy problem with the type.
- private static final String HAS_INCONSISTENT_TYPE_HIERACHY = "has inconsistent hierarchy"; //$NON-NLS-1$
- public TypeDeclarationImpl(final ITypeBinding binding,
- final BaseProcessorEnv 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)
- {
- visitor.visitTypeDeclaration(this);
- }
-
- public ITypeBinding getTypeBinding(){ return (ITypeBinding)_binding; }
-
- @SuppressWarnings("unchecked")
- private void getASTFields(
- final AbstractTypeDeclaration typeDecl,
- final List<FieldDeclaration> results){
- final List bodyDecls = typeDecl.bodyDeclarations();
- for( int i=0, len=bodyDecls.size(); i<len; i++ ){
- final BodyDeclaration bodyDecl = (BodyDeclaration)bodyDecls.get(i);
- IFile file = null;
- if( bodyDecl.getNodeType() == ASTNode.FIELD_DECLARATION ){
- final List<VariableDeclarationFragment> fragments =
- ((org.eclipse.jdt.core.dom.FieldDeclaration)bodyDecl).fragments();
- for( VariableDeclarationFragment frag : fragments ){
- final IBinding fieldBinding = frag.resolveBinding();
- if( fieldBinding == null ){
- if( file == null )
- file = getResource();
- final EclipseDeclarationImpl decl = Factory.createDeclaration(frag, file, _env);
- if( decl != null )
- results.add((FieldDeclaration)decl);
- }
- }
- }
- }
- }
-
- public Collection<FieldDeclaration> getFields()
- {
- final List<FieldDeclaration> results = new ArrayList<FieldDeclaration>();
- final ITypeBinding typeBinding = getDeclarationBinding();
- if( isFromSource() ){
- final ASTNode node =
- _env.getASTNodeForBinding(typeBinding);
- if( node != null ){
- switch( node.getNodeType() )
- {
- case ASTNode.TYPE_DECLARATION:
- case ASTNode.ANNOTATION_TYPE_DECLARATION:
- case ASTNode.ENUM_DECLARATION:
- AbstractTypeDeclaration typeDecl =
- (AbstractTypeDeclaration)node;
- // built the ast based methods first.
- getASTFields(typeDecl, results);
- break;
- default:
- // the ast node for a type binding should be a AbstractTypeDeclaration.
- throw new IllegalStateException("expecting a AbstractTypeDeclaration but got " //$NON-NLS-1$
- + node.getClass().getName() );
- }
- }
- }
- // either type is binary or
- // constructing the binding based fields for source type.
- final IVariableBinding[] fields = typeBinding.getDeclaredFields();
- for( IVariableBinding field : fields ){
- // note that the name HAS_INCONSISTENT_TYPE_HIERACHY is not a legal java identifier
- // so there is no chance that we are filtering out actual declared fields.
- if( field.isSynthetic() || HAS_INCONSISTENT_TYPE_HIERACHY.equals(field.getName()))
- 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 (mirror == null)
- result.add(Factory.createErrorClassType(arg));
- else
- result.add(mirror);
- }
-
- return result;
- }
-
- public DeclaredType getContainingType()
- {
- final ITypeBinding outer = getTypeBinding().getDeclaringClass();
- return Factory.createReferenceType(outer, _env);
- }
-
- public TypeDeclaration getDeclaration()
- {
- final ITypeBinding declBinding = getDeclarationBinding();
- if( declBinding == _binding ) return this;
- else return 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;
- }
-
-
- // End of implementation of DeclaredType API
-
- public ITypeBinding getDeclarationBinding()
- {
- final ITypeBinding type = getTypeBinding();
- return type.getTypeDeclaration();
- }
-
- /**
- * create mirror methods that does not have a binding represention.
- */
- @SuppressWarnings("unchecked")
- protected void getASTMethods(
- final AbstractTypeDeclaration typeDecl,
- final List<MethodDeclaration> results){
- final List bodyDecls = typeDecl.bodyDeclarations();
- IFile file = null;
- for( int i=0, len=bodyDecls.size(); i<len; i++ ){
- final BodyDeclaration bodyDecl = (BodyDeclaration)bodyDecls.get(i);
- switch(bodyDecl.getNodeType()){
- case ASTNode.METHOD_DECLARATION:
- final org.eclipse.jdt.core.dom.MethodDeclaration methodDecl =
- (org.eclipse.jdt.core.dom.MethodDeclaration)bodyDecl;
-
- if( !methodDecl.isConstructor() ){
- final IMethodBinding methodBinding = methodDecl.resolveBinding();
- // built an ast based representation.
- if( methodBinding == null ){
- if( file == null )
- file = getResource();
- MethodDeclaration mirrorDecl =
- (MethodDeclaration)Factory.createDeclaration(methodDecl, file, _env);
- if( mirrorDecl != null )
- results.add(mirrorDecl);
- }
- }
- break;
- case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION:
- final AnnotationTypeMemberDeclaration memberDecl =
- (AnnotationTypeMemberDeclaration)bodyDecl;
- final IMethodBinding methodBinding = memberDecl.resolveBinding();
- // built an ast based representation.
- if( methodBinding == null ){
- if( file == null )
- file = getResource();
- MethodDeclaration mirrorDecl =
- (MethodDeclaration)Factory.createDeclaration(memberDecl, file, _env);
- if( mirrorDecl != null )
- results.add(mirrorDecl);
- }
- break;
- }
- }
- }
-
- protected List<? extends MethodDeclaration> _getMethods()
- {
- final List<MethodDeclaration> results = new ArrayList<MethodDeclaration>();
- if( isFromSource() ){
- // need to consult the ast since methods with broken signature
- // do not appear in bindings.
- final ITypeBinding typeBinding = getDeclarationBinding();
- final ASTNode node =
- _env.getASTNodeForBinding(typeBinding);
- if( node != null ){
- switch( node.getNodeType() )
- {
- case ASTNode.TYPE_DECLARATION:
- case ASTNode.ANNOTATION_TYPE_DECLARATION:
- case ASTNode.ENUM_DECLARATION:
- AbstractTypeDeclaration typeDecl =
- (AbstractTypeDeclaration)node;
- // built the ast based methods first.
- getASTMethods(typeDecl, results);
- break;
- default:
- // the ast node for a type binding should be a AbstractTypeDeclaration.
- throw new IllegalStateException("expecting a AbstractTypeDeclaration but got " //$NON-NLS-1$
- + node.getClass().getName() );
- }
- }
- }
- // build methods for binding type or
- // build the binding based method for source type.
- final IMethodBinding[] methods = getDeclarationBinding().getDeclaredMethods();
- 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()
- {
- return getQualifiedName();
- }
-
- public boolean isFromSource(){ return getDeclarationBinding().isFromSource(); }
-
- public boolean isAssignmentCompatible(EclipseMirrorType left) {
- return isSubTypeCompatible(left);
- }
-
- public boolean isSubTypeCompatible(EclipseMirrorType type) {
- // Operate on erasures - ignore generics for now
- // Also ignore boxing for now
- ITypeBinding thisErased = getTypeBinding().getErasure();
- ITypeBinding typeErased = type.getTypeBinding().getErasure();
-
- if (kind() == MirrorKind.TYPE_CLASS) {
- if (type.kind() == MirrorKind.TYPE_CLASS)
- return isSubClassOf(thisErased, typeErased);
- if (type.kind() == MirrorKind.TYPE_INTERFACE)
- return isImplementorOf(thisErased, typeErased);
- return false;
- }
- else { //kind() == MirrorKind.TYPE_INTERFACE
- if (type.kind() == MirrorKind.TYPE_INTERFACE)
- return isImplementorOf(thisErased, typeErased);
- if (type.kind() == MirrorKind.TYPE_CLASS)
- return "java.lang.Object".equals(getQualifiedName()); //$NON-NLS-1$
- return false;
- }
- }
-
- private static boolean isImplementorOf(ITypeBinding t1, ITypeBinding t2) {
- if (eq(t1,t2)) return true;
- ITypeBinding[] intfs = t1.getInterfaces();
-
- for (ITypeBinding intf : intfs) {
- if (isImplementorOf(intf.getErasure(), t2))
- return true;
- }
- ITypeBinding superClass = t1.getSuperclass();
- if (superClass != null) {
- if (isImplementorOf(superClass, t2)) {
- return true;
- }
- }
- return false;
- }
-
- private static boolean isSubClassOf(ITypeBinding t1, ITypeBinding t2) {
- while(t1 != null) {
- if (eq(t1, t2)) return true;
- t1 = t1.getSuperclass();
- }
- return false;
- }
-
- private static boolean eq(ITypeBinding t1, ITypeBinding t2) {
- return t1.getQualifiedName().equals(t2.getQualifiedName());
- }
-}
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 711e097d05..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/TypeParameterDeclarationImpl.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.BaseProcessorEnv;
-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.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.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, EclipseMirrorType
-{
- public TypeParameterDeclarationImpl(final ITypeBinding binding,
- final BaseProcessorEnv env)
- {
- super(binding, env);
- assert binding.isTypeVariable();
- }
-
- public void accept(DeclarationVisitor 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 = 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()
- {
- return Factory.createDeclaration(getOwnerBinding(), _env);
- }
-
- private IBinding getOwnerBinding() {
- final ITypeBinding binding = getDeclarationBinding();
- // declared on a class
- IBinding owner = binding.getDeclaringClass();
- if( owner == null )
- // declared on the method
- owner = binding.getDeclaringMethod();
- return owner;
- }
-
- 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.getLineNumber(offset),
- unit.getColumnNumber(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.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; }
- public ITypeBinding getTypeBinding() { return (ITypeBinding)_binding;}
-
- public boolean isFromSource(){ return getDeclarationBinding().isFromSource(); }
-
- public boolean isAssignmentCompatible(EclipseMirrorType left) {
- return isSubTypeCompatible(left);
- }
-
- public boolean isSubTypeCompatible(EclipseMirrorType type) {
- if (type.kind() == MirrorKind.TYPE_PARAMETER_VARIABLE) {
- TypeParameterDeclarationImpl other = (TypeParameterDeclarationImpl) type;
- return getOwnerBinding() == other.getOwnerBinding() &&
- getSimpleName().equals(other.getSimpleName());
- }
-
- for (ReferenceType bound : getBounds()) {
- if (((EclipseMirrorType)bound).isSubTypeCompatible(type))
- return true;
- }
-
- return false;
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/APTProblem.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/APTProblem.java
deleted file mode 100644
index 5fea082ef2..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/APTProblem.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.env.MessagerImpl.Severity;
-import org.eclipse.jdt.apt.core.util.EclipseMessager;
-import org.eclipse.jdt.core.compiler.CategorizedProblem;
-import org.eclipse.jdt.core.compiler.IProblem;
-
-class APTProblem extends CategorizedProblem implements IProblem
-{
- private static final String[] NO_ARGS = new String[0];
- private final Severity _severity;
- private int _startingOffset;
- private int _endingOffset;
- private int _line;
- private IFile _resource;
- private final String _message;
- private final String _markerType;
-
- // May be null
- private final String[] _arguments;
-
- APTProblem(final String msg,
- final Severity severity,
- final IFile file,
- final int startingOffset,
- final int endingOffset,
- final int line,
- final String[] arguments,
- boolean isNonReconcile){
- _message = msg;
- _severity = severity;
- _startingOffset = startingOffset;
- _endingOffset = endingOffset;
- _line = line;
- _resource = file;
- _arguments = arguments;
- _markerType = isNonReconcile ? AptPlugin.APT_NONRECONCILE_COMPILATION_PROBLEM_MARKER : AptPlugin.APT_COMPILATION_PROBLEM_MARKER;
- }
-
- public int getID() {
- // If we have arguments, then we're quick-fixable
- if (_arguments != null) {
- return EclipseMessager.APT_QUICK_FIX_PROBLEM_ID;
- }
- else {
- return EclipseMessager.APT_PROBLEM_ID;
- }
- }
-
- public String[] getArguments() {
- return _arguments == null ? NO_ARGS : (String[])_arguments.clone();
- }
-
- public String getMessage() {
- return _message;
- }
-
- public char[] getOriginatingFileName() {
- return _resource.getName().toCharArray();
- }
-
- public int getSourceStart() {
- return _startingOffset;
- }
-
- public int getSourceEnd() {
- return _endingOffset;
- }
-
- public int getSourceLineNumber() {
- return _line;
- }
-
- public void setSourceStart(int sourceStart) {
- _startingOffset = sourceStart;
- }
-
- public void setSourceEnd(int sourceEnd) {
- _endingOffset = sourceEnd;
- }
-
- public void setSourceLineNumber(int lineNumber) {
- _line = lineNumber;
- }
-
- public boolean isError() {
- return _severity == Severity.ERROR;
- }
-
- public boolean isWarning() {
- return _severity == Severity.WARNING;
- }
-
- public String toString()
- {
- return _message == null ? "<null message>" : _message ; //$NON-NLS-1$
- }
-
- @Override
- public int getCategoryID() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public String getMarkerType() {
- return _markerType;
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/AbstractCompilationEnv.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/AbstractCompilationEnv.java
deleted file mode 100644
index b1bc62f668..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/AbstractCompilationEnv.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.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.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jdt.apt.core.env.EclipseAnnotationProcessorEnvironment;
-import org.eclipse.jdt.apt.core.env.Phase;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.declaration.EclipseMirrorObject;
-import org.eclipse.jdt.apt.core.internal.declaration.TypeDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.env.MessagerImpl.Severity;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.apt.core.internal.util.Visitors.AnnotationVisitor;
-import org.eclipse.jdt.apt.core.util.AptPreferenceConstants;
-import org.eclipse.jdt.apt.core.util.EclipseMessager;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaConventions;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.compiler.BuildContext;
-import org.eclipse.jdt.core.compiler.CategorizedProblem;
-import org.eclipse.jdt.core.compiler.ReconcileContext;
-import org.eclipse.jdt.core.dom.ASTRequestor;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.apt.AnnotationProcessorListener;
-import com.sun.mirror.apt.Filer;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-/** Base environment to be used during reconcile or build */
-public abstract class AbstractCompilationEnv
- extends BaseProcessorEnv
- implements EclipseAnnotationProcessorEnvironment {
-
- // Bugzilla 188185: accept "-AenableTypeGenerationInEditor" as well as "enableTypeGenerationInEditor".
- private final static String RTTG_ENABLED_DASH_A_OPTION = "-A" + AptPreferenceConstants.RTTG_ENABLED_OPTION; //$NON-NLS-1$
- private final static String PROCESSING_IN_EDITOR_DISABLED_DASH_A_OPTION = "-A" + AptPreferenceConstants.PROCESSING_IN_EDITOR_DISABLED_OPTION; //$NON-NLS-1$
-
- private Set<AnnotationProcessorListener> _listeners = null;
-
- protected List<APTProblem> _problems = new ArrayList<APTProblem>();
- private boolean _isClosed = false;
-
- EnvCallback _callback;
-
- private Set<IFile> _allGeneratedSourceFiles = new HashSet<IFile>();
- private Set<IFile> _modifiedGeneratedSourceFiles = new HashSet<IFile>();
-
- /**
- * Currently open dom pipeline, used to request type bindings.
- */
- protected ASTRequestor _requestor;
-
- /**
- * The processor that is currently being executed, or null if processing is not underway.
- */
- private AnnotationProcessorFactory _currentProcessorFactory = null;
-
- /**
- * True if the currently active processor will be called during reconcile as well as build.
- * Takes into account project settings, factory path, and processor options.
- */
- private boolean _currentProcessorFactoryWillReconcile;
-
- public static interface EnvCallback {
- public void run(AbstractCompilationEnv env);
- }
-
- public static void newReconcileEnv(ReconcileContext reconcileContext, EnvCallback callback)
- {
- assert reconcileContext != null : "reconcile context is null"; //$NON-NLS-1$
- ReconcileEnv env = ReconcileEnv.newEnv(reconcileContext);
- env._callback = callback;
- env.openPipeline();
- }
-
- public static void newBuildEnv(
- BuildContext[] filesWithAnnotations,
- final BuildContext[] additionalFiles,
- IJavaProject javaProj,
- EnvCallback callback)
- {
- assert filesWithAnnotations != null : "missing files"; //$NON-NLS-1$
-
- // note, we are not reading any files.
- BuildEnv env = new BuildEnv(filesWithAnnotations, additionalFiles, javaProj);
- env._callback = callback;
- env.createASTs(filesWithAnnotations);
- }
-
- /**
- * Determine whether a processor wants to be called during reconcile. By default
- * processors are called during both build and reconcile, but a processor can choose
- * not to be called during reconcile by reporting
- * {@link AptPreferenceConstants#PROCESSING_IN_EDITOR_DISABLED_OPTION}
- * in its supportedOptions() method.
- * @return false if the processor reports PROCESSING_IN_EDITOR_DISABLED_OPTION.
- * This does not consider project or factory path settings.
- */
- public static boolean doesFactorySupportReconcile(AnnotationProcessorFactory factory) {
- Collection<String> options = factory.supportedOptions();
- return options == null ||
- (!options.contains(AptPreferenceConstants.PROCESSING_IN_EDITOR_DISABLED_OPTION) &&
- !options.contains(PROCESSING_IN_EDITOR_DISABLED_DASH_A_OPTION));
- }
-
- AbstractCompilationEnv(
- CompilationUnit compilationUnit,
- IFile file,
- IJavaProject javaProj,
- Phase phase)
- {
- super(compilationUnit, file, javaProj, phase);
- }
-
- @Override
- protected IBinding getBindingFromKey(String key, ICompilationUnit unit) {
- return _requestor.createBindings(new String[] {key})[0];
- }
-
- 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 a copy, to avoid ConcurrentModificationException if a listener
- // removes itself in response to the callback.
- return new HashSet<AnnotationProcessorListener>(_listeners);
- }
-
- public Map<String, String> getOptions()
- {
- final HashMap<String, String> options = new HashMap<String, String>(_options);
- options.put("phase", getPhase().toString()); //$NON-NLS-1$
- return options;
- }
-
- abstract public CompilationUnit getASTFrom(final IFile file);
-
- public CompilationUnit getAST(){
- return _astRoot;
- }
-
- public EclipseMessager getMessager()
- {
- checkValid();
- return new MessagerImpl(this);
- }
-
- abstract void addMessage(
- IFile resource,
- int start,
- int end,
- Severity severity,
- String msg,
- int line,
- String[] arguments);
-
- public List<? extends CategorizedProblem> getProblems(){
- checkValid();
- if( !_problems.isEmpty() )
- EnvUtil.updateProblemLength(_problems, getAstCompilationUnit());
- return _problems;
- }
-
- APTProblem createProblem(
- IFile resource,
- int start,
- int end,
- Severity severity,
- String msg,
- int line,
- String[] arguments)
- {
- // end-1 since IProblem ending offsets are inclusive but DOM layer
- // ending offsets are exclusive.
- final APTProblem newProblem =
- new APTProblem(msg, severity, resource, start, end-1, line, arguments, !_currentProcessorFactoryWillReconcile);
- return newProblem;
- }
-
- public abstract Filer getFiler();
-
- public void addGeneratedSourceFile( IFile f, boolean contentsChanged ) {
- if (!f.toString().endsWith(".java")) { //$NON-NLS-1$
- throw new IllegalArgumentException("Source files must be java source files, and end with .java"); //$NON-NLS-1$
- }
-
- boolean addedToAll = _allGeneratedSourceFiles.add(f);
- boolean addedToMod = false;
- if (contentsChanged)
- addedToMod = _modifiedGeneratedSourceFiles.add(f);
- if (AptPlugin.DEBUG_COMPILATION_ENV) {
- AptPlugin.trace("add generated file " + f + " to env " + this + //$NON-NLS-1$ //$NON-NLS-2$
- "; addToAll = " + addedToAll + "; addToMod = " + addedToMod + //$NON-NLS-1$ //$NON-NLS-2$
- "; contentsChanged = " + contentsChanged); //$NON-NLS-1$
- }
- }
-
- public void addGeneratedNonSourceFile(final IFile file) {
- _allGeneratedSourceFiles.add(file);
- }
-
- public Set<IFile> getAllGeneratedFiles() {
- return _allGeneratedSourceFiles;
- }
-
- public Set<IFile> getModifiedGeneratedFiles() {
- return _modifiedGeneratedSourceFiles;
- }
-
- /**
- * @return true iff source files has been generated.
- * Always return false when this environment is closed.
- */
- public boolean hasGeneratedSourceFiles(){ return !_allGeneratedSourceFiles.isEmpty(); }
-
-
- /**
- * @return all annotation types in the current compilation unit.
- */
- public Map<String, AnnotationTypeDeclaration> getAnnotationTypes()
- {
- checkValid();
- final List<Annotation> instances = new ArrayList<Annotation>();
- final Map<String, AnnotationTypeDeclaration> decls =
- new HashMap<String, AnnotationTypeDeclaration>();
- final AnnotationVisitor visitor = new AnnotationVisitor(instances);
- _astRoot.accept(visitor);
-
- for (int instanceIndex=0, size = instances.size(); instanceIndex < size; instanceIndex++) {
- final Annotation instance = instances.get(instanceIndex);
- final ITypeBinding annoType = instance.resolveTypeBinding();
- if (annoType == null)
- continue;
- final TypeDeclarationImpl decl =
- Factory.createReferenceType(annoType, this);
- if (decl.kind() == EclipseMirrorObject.MirrorKind.TYPE_ANNOTATION){
- final AnnotationTypeDeclaration annoDecl = (AnnotationTypeDeclaration)decl;
- decls.put(annoDecl.getQualifiedName(), annoDecl);
- }
- }
-
- return decls;
- }
-
- /* package */ void checkValid()
- {
- if( _isClosed )
- throw new IllegalStateException("Environment has expired"); //$NON-NLS-1$
- }
-
- // Call this after each file; cf. BuildEnv#beginFileProcessing()
- protected void completedProcessing() {
- _modifiedGeneratedSourceFiles.clear();
- }
-
- public void close(){
- if (isClosed())
- return;
- if(_listeners != null)
- _listeners.clear();
- _problems = null;
- _typeCache.clear();
- _packageRootsCache = null;
- _isClosed = true;
- _callback = null;
- _requestor = null;
- _allGeneratedSourceFiles = null;
- _modifiedGeneratedSourceFiles = null;
- if (AptPlugin.DEBUG_COMPILATION_ENV) AptPlugin.trace(
- "closed env " + this); //$NON-NLS-1$
- }
-
- boolean isClosed(){ return _isClosed; }
-
- /**
- * Check typeName to ensure it doesn't contain any bogus characters.
- * @param typeName
- * @throws CoreException
- */
- @SuppressWarnings("unchecked")
- public void validateTypeName(String typeName) throws CoreException
- {
- Map<String, String> options = getJavaProject().getOptions(true);
- String sourceLevel = options.get(JavaCore.COMPILER_SOURCE);
- String complianceLevel = options.get(JavaCore.COMPILER_COMPLIANCE);
- IStatus status = JavaConventions.validateJavaTypeName(typeName, sourceLevel, complianceLevel);
- if (status.matches(IStatus.ERROR)) {
- throw new CoreException(status);
- }
- }
-
- public AnnotationProcessorFactory getCurrentProcessorFactory() {
- return _currentProcessorFactory;
- }
-
- /**
- * @param factory a processor factory, or null to indicate processing is over.
- * @param willReconcile true if the processor will be called during reconcile as well as during build,
- * taking into account project settings, factory path, and processor options.
- */
- public void setCurrentProcessorFactory(AnnotationProcessorFactory factory, boolean willReconcile)
- {
- _currentProcessorFactory = factory;
- _currentProcessorFactoryWillReconcile = willReconcile;
- }
-
- public boolean currentProcessorSupportsRTTG()
- {
- AnnotationProcessorFactory factory = getCurrentProcessorFactory();
- if (null == factory) {
- return false;
- }
- Collection<String> options = factory.supportedOptions();
- if (null == options) {
- return false;
- }
- return options.contains(AptPreferenceConstants.RTTG_ENABLED_OPTION) ||
- options.contains(RTTG_ENABLED_DASH_A_OPTION);
- }
-
-}
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 dff9c000a5..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/AnnotationInvocationHandler.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-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.IAnnotationBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-
-public class AnnotationInvocationHandler implements InvocationHandler
-{
- private static final String JAVA_LANG_CLASS = "java.lang.Class"; //$NON-NLS-1$
- private final AnnotationMirrorImpl _instance;
- private final Class<?> _clazz;
-
- public AnnotationInvocationHandler(final AnnotationMirrorImpl annotation,
- final Class<?> clazz)
- {
- _instance = annotation;
- _clazz = clazz;
- }
-
- 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") ) //$NON-NLS-1$
- return new Integer( _instance.hashCode() );
- if( methodName.equals("toString") ) //$NON-NLS-1$
- return _instance.toString();
- if( methodName.equals("annotationType")) //$NON-NLS-1$
- return _clazz;
- }
- else if( args.length == 1 && methodName.equals("equals") ) //$NON-NLS-1$
- {
- return new Boolean( _instance.equals( args[0] ) );
- }
- if( args != null && args.length != 0 )
- throw new NoSuchMethodException("method " + method.getName() + formatArgs(args) + " does not exists"); //$NON-NLS-1$ //$NON-NLS-2$
- 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"); //$NON-NLS-1$ //$NON-NLS-2$
-
- final ITypeBinding retType = methodBinding.getReturnType();
- if( retType == null ) return null;
-
- final String qName = retType.getTypeDeclaration().getQualifiedName();
- // type of annotation member is java.lang.Class
- if( retType.isClass() && JAVA_LANG_CLASS.equals(qName) ){
- // 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();
- final String leafQName = leafType.getTypeDeclaration().getQualifiedName();
- // type of annotation member is java.lang.Class[]
- if( leafType.isClass() && JAVA_LANG_CLASS.equals(leafQName) ){
- 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.createErrorClassType(type));
- else
- mirrorTypes.add(mirror);
- }
- }
-
- throw new MirroredTypesException(mirrorTypes);
- }
- }
- final Object sourceValue = _instance.getValue(c_methodName);
- return getReflectionValueWithTypeConversion(sourceValue, method.getReturnType());
- }
-
- private Object getReflectionValueWithTypeConversion(
- final Object domValue,
- final Class<?> expectedType )
- {
-
- final Object actualValue = _getReflectionValue(domValue, expectedType);
- return performNecessaryTypeConversion(expectedType, actualValue);
- }
-
- private Object _getReflectionValue(final Object domValue, final Class<?> expectedType)
- {
- if( expectedType == null || domValue == null )
- return null;
-
- if( domValue instanceof IVariableBinding )
- {
- final IVariableBinding varBinding = (IVariableBinding)domValue;
- final ITypeBinding declaringClass = varBinding.getDeclaringClass();
- if( declaringClass != null ){
- try {
- final Field returnedField = expectedType.getField( varBinding.getName() );
- return returnedField == null ? null : returnedField.get(null);
- }
- catch (NoSuchFieldException nsfe) {
- return null;
- }
- catch (IllegalAccessException iae) {
- return null;
- }
- }
- return null;
- }
- else if (domValue instanceof Object[])
- {
- final Object[] elements = (Object[])domValue;
- if(!expectedType.isArray())
- return null; // bad user source
- final Class<?> componentType = expectedType.getComponentType();
- final int length = elements.length;
- final Object array = Array.newInstance(componentType, length);
-
- for( int i=0; i<length; i++ ){
- final Object returnObj =
- getReflectionValueWithTypeConversion( 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 ); //$NON-NLS-1$
- }
- }
- else{
- Array.set( array, i, returnObj );
- }
- }
- return array;
- }
- // caller should have caught this case.
- else if( domValue instanceof ITypeBinding )
- throw new IllegalStateException("sourceValue is a type binding."); //$NON-NLS-1$
-
- else if( domValue instanceof IAnnotationBinding )
- {
- // We cannot convert an annotation into anything else
- if (!expectedType.isAnnotation()) {
- return null;
- }
-
- final AnnotationMirrorImpl annoMirror =
- (AnnotationMirrorImpl)Factory.createAnnotationMirror(
- (IAnnotationBinding)domValue,
- _instance.getAnnotatedDeclaration(),
- _instance.getEnvironment());
- final AnnotationInvocationHandler handler = new AnnotationInvocationHandler(annoMirror, expectedType);
- return Proxy.newProxyInstance(expectedType.getClassLoader(),
- new Class[]{ expectedType }, handler );
- }
- // primitive wrapper or String.
- else
- return domValue;
- }
-
- private Object performNecessaryTypeConversion(Class<?> expectedType, Object actualValue){
- if( actualValue == null )
- return Factory.getMatchingDummyValue(expectedType);
- else if( expectedType.isPrimitive() )
- return Factory.performNecessaryPrimitiveTypeConversion( expectedType, actualValue, true);
- else if( expectedType.isAssignableFrom(actualValue.getClass()))
- return actualValue;
- else if( expectedType.isArray() ){
- // the above assignableFrom test failed which leave up with
- // the array-ificiation problem.
- // arrays are always type corrected.
- actualValue = performNecessaryTypeConversion(expectedType.getComponentType(), actualValue);
- return arrayify(expectedType, actualValue);
- }
- // type conversion cannot be performed and expected type is not a primitive
- // Returning null so that we don't get a ClassCastException.
- else return null;
- }
-
- private Object arrayify(final Class<?> expectedType, Object actualValue){
- assert expectedType.isArray() : "expected type must be an array"; //$NON-NLS-1$
- assert ( !(actualValue instanceof Object[]) ) :
- "actual value cannot be of type Object[]"; //$NON-NLS-1$
- final Class<?> componentType = expectedType.getComponentType();
- final Object array = Array.newInstance(componentType, 1);
-
- if( componentType.isPrimitive() ){
- if( componentType == boolean.class ){
- final Boolean bool = (Boolean)actualValue;
- Array.setBoolean( array, 0, bool.booleanValue());
- }
- else if( componentType == byte.class ){
- final Byte b = (Byte)actualValue;
- Array.setByte( array, 0, b.byteValue() );
- }
- else if( componentType == char.class ){
- final Character c = (Character)actualValue;
- Array.setChar( array, 0, c.charValue() );
- }
- else if( componentType == double.class ){
- final Double d = (Double)actualValue;
- Array.setDouble( array, 0, d.doubleValue() );
- }
- else if( componentType == float.class ){
- final Float f = (Float)actualValue;
- Array.setFloat( array, 0, f.floatValue() );
- }
- else if( componentType == int.class ){
- final Integer integer = (Integer)actualValue;
- Array.setInt( array, 0, integer.intValue() );
- }
- else if( componentType == long.class ){
- final Long l = (Long)actualValue;
- Array.setLong( array, 0, l.longValue() );
- }
- else if( componentType == short.class ){
- final Short s = (Short)actualValue;
- Array.setShort( array, 0, s.shortValue() );
- }
- else {
- throw new IllegalStateException("unrecognized primitive type: " + componentType ); //$NON-NLS-1$
- }
- }
- else{
- Array.set( array, 0, actualValue );
- }
- return array;
- }
-
- 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(", "); //$NON-NLS-1$
- 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/BaseProcessorEnv.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BaseProcessorEnv.java
deleted file mode 100644
index 6e23757b7d..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BaseProcessorEnv.java
+++ /dev/null
@@ -1,989 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.apt.core.env.Phase;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.AptProject;
-import org.eclipse.jdt.apt.core.internal.declaration.EclipseDeclarationImpl;
-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.internal.util.Visitors.AnnotatedNodeVisitor;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-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.IPackageFragmentRoot;
-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.AbstractTypeDeclaration;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-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.VariableDeclarationFragment;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.AnnotationProcessorListener;
-import com.sun.mirror.apt.Filer;
-import com.sun.mirror.apt.Messager;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.PackageDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.util.Declarations;
-import com.sun.mirror.util.Types;
-
-/**
- * Base annotation processor environment that supports type system navigation.
- * No support for problem registration as well as type generation.
- *
- * @author tyeung
- */
-public class BaseProcessorEnv implements AnnotationProcessorEnvironment
-{
- static{
- final AST ast = AST.newAST(AST.JLS3);
- EMPTY_AST_UNIT = ast.newCompilationUnit();
- }
- public static final CompilationUnit EMPTY_AST_UNIT;
- public static final ICompilationUnit[] NO_UNIT = new ICompilationUnit[0];
- public static final CompilationUnit[] NO_AST_UNITs = new CompilationUnit[0];
- public static final String[] NO_KEYS = new String[0];
-
- private static final int BOOLEAN_INDEX = 0;
- private static final int BYTE_INDEX = 1;
- private static final int CHAR_INDEX = 2;
- private static final int DOUBLE_INDEX = 3;
- private static final int FLOAT_INDEX = 4;
- private static final int INT_INDEX = 5;
- private static final int LONG_INDEX = 6;
- private static final int SHORT_INDEX = 7;
-
- private static final String DOT_JAVA = ".java"; //$NON-NLS-1$
-
- protected CompilationUnit _astRoot;
- protected final Phase _phase;
- protected IFile _file;
- protected final IJavaProject _javaProject;
- protected final AptProject _aptProject;
-
- /**
- * Unmodifiable map of processor options, including -A options.
- * Set in ctor and then not changed.
- */
- protected final Map<String, String> _options;
-
- /**
- * 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.
- */
- protected final Map<ICompilationUnit, CompilationUnit> _modelCompUnit2astCompUnit;
- /**
- * Mapping (source) top-level type binding to the compilation unit that defines it.
- */
- protected final Map<ITypeBinding, ICompilationUnit> _typeBinding2ModelCompUnit;
- // void type and the primitive types will be null if the '_file'
- // is outside of the workspace.
- private VoidTypeImpl _voidType;
- private PrimitiveTypeImpl[] _primitives;
-
- // This type cache exists for the duration of a single round.
- // We store positive as well as negative hits. Negative hits are
- // stored with a value of null
- protected final Map<String,TypeDeclaration> _typeCache = new HashMap<String,TypeDeclaration>();
-
- protected IPackageFragmentRoot[] _packageRootsCache;
-
- public BaseProcessorEnv(CompilationUnit astCompilationUnit,
- IFile file,
- IJavaProject javaProj,
- Phase phase )
- {
- _astRoot = astCompilationUnit;
- _file = file;
- _javaProject = javaProj;
- _phase = phase;
- _options = initOptions(javaProj);
- _modelCompUnit2astCompUnit = new HashMap<ICompilationUnit, CompilationUnit>();
- _typeBinding2ModelCompUnit = new HashMap<ITypeBinding, ICompilationUnit>();
- _aptProject = AptPlugin.getAptProject(javaProj);
- }
-
- /**
- * Set the _options map based on the current project/workspace settings.
- * There is a bug in Sun's apt implementation: it parses the command line
- * incorrectly, such that -Akey=value gets added to the options map as
- * key "-Akey=value" and value "". In order to support processors written
- * to run on Sun's apt as well as processors written without this bug
- * in mind, we populate the map with two copies of every option, one the
- * expected way ("key" / "value") and the other the Sun way
- * ("-Akey=value" / ""). We make exceptions for the non-dash-A options
- * that we set automatically, such as -classpath, -target, and so forth;
- * since these wouldn't have come from a -A option we don't construct a
- * -Akey=value variant.
- *
- * Called from constructor. A new Env is constructed for each build pass,
- * so this will always be up to date with the latest settings.
- */
- private Map<String, String> initOptions(IJavaProject jproj) {
- Map<String, String> procOptions = AptConfig.getProcessorOptions(jproj);
- // options is large enough to include the translated -A options
- Map<String, String> options = new HashMap<String, String>(procOptions.size() * 2);
-
- // Add configured options
- for (Map.Entry<String, String> entry : procOptions.entrySet()) {
- String value = entry.getValue();
- String key = entry.getKey();
- options.put(key, value);
- if (!AptConfig.isAutomaticProcessorOption(key)) {
- String sunStyle;
- if (value != null) {
- sunStyle = "-A" + entry.getKey() + "=" + value; //$NON-NLS-1$ //$NON-NLS-2$
- }
- else {
- sunStyle = "-A" + entry.getKey(); //$NON-NLS-1$
- }
- options.put(sunStyle, ""); //$NON-NLS-1$
- }
- }
- return Collections.unmodifiableMap(options);
- }
-
- public Types getTypeUtils()
- {
- return new TypesUtil(this);
- }
-
- public Declarations getDeclarationUtils()
- {
- return new DeclarationsUtil();
- }
-
- public void addListener(AnnotationProcessorListener listener) {
- throw new UnsupportedOperationException("Not supported!"); //$NON-NLS-1$
- }
-
- public void removeListener(AnnotationProcessorListener listener) {
- throw new UnsupportedOperationException("Not supported!"); //$NON-NLS-1$
- }
-
- /**
- * @return the list of all named type declarations in the compilation units associated with
- * this environment - usually just one compilation unit, except in batch mode
- * where it will be all compilation units in the build.
- * This implementation is different from the API specification in that it does not return
- * all included source 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;
- }
-
- @SuppressWarnings("unchecked")
- protected List<AbstractTypeDeclaration> searchLocallyForTypeDeclarations()
- {
- return _astRoot.types();
- }
-
- private List<ITypeBinding> getTypeBindings()
- {
- final List<AbstractTypeDeclaration> declTypes = searchLocallyForTypeDeclarations();
- 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.
- */
- protected void getTypeBindings(final ITypeBinding type, final List<ITypeBinding> typeBindings)
- {
- if( type == null ) return;
- typeBindings.add(type);
- for( ITypeBinding nestedType : type.getDeclaredTypes() ) {
- //typeBindings.add(nestedType);
- getTypeBindings(nestedType, typeBindings);
- }
- }
-
- public Collection<TypeDeclaration> getSpecifiedTypeDeclarations()
- {
- return getTypeDeclarations();
- }
-
- public Collection<Declaration> getDeclarationsAnnotatedWith(AnnotationTypeDeclaration a)
- {
- final ITypeBinding annotationType = TypesUtil.getTypeBinding(a);
- if( annotationType == null || !annotationType.isAnnotation()) return Collections.emptyList();
- return getDeclarationsAnnotatedWith(annotationType);
- }
-
- /**
- * Go through the current compilation unit and look for ast nodes that has annotations.
- * @return the map between ast node and
- */
- protected Map<ASTNode, List<Annotation>> getASTNodesWithAnnotations()
- {
- final Map<ASTNode, List<Annotation>> astNode2Anno = new HashMap<ASTNode, List<Annotation>>();
- final AnnotatedNodeVisitor visitor = new AnnotatedNodeVisitor(astNode2Anno);
- _astRoot.accept(visitor);
- return astNode2Anno;
- }
-
- private List<Declaration> getDeclarationsAnnotatedWith(final ITypeBinding annotationType)
- {
- final Map<ASTNode, List<Annotation>> astNode2Anno = getASTNodesWithAnnotations();
- if( astNode2Anno.isEmpty() )
- return Collections.emptyList();
- final List<Declaration> decls = new ArrayList<Declaration>();
- 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) )
- getDeclarations(node, decls);
- }
- }
- return decls;
-
- }
-
- protected IFile getFileForNode(final ASTNode node)
- {
- if( node.getRoot() == _astRoot )
- return _file;
-
- throw new IllegalStateException(); // should never get here.
- }
-
- /**
- * @param node the ast node in question
- * @param decls the list to be populated.
- * adding the declaration(s) corresponding to the ast node to this list.
- */
- @SuppressWarnings("unchecked")
- protected void getDeclarations(ASTNode node, List<Declaration>decls)
- {
- 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();
- final EclipseDeclarationImpl decl;
- if( fieldBinding != null )
- decl = Factory.createDeclaration(fieldBinding, this);
- else{
- decl = Factory.createDeclaration(frag, getFileForNode(frag), this);
- }
- if( decl != null )
- decls.add(decl);
- }
- 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();
- break;
- 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:
- // Need to create the declaration with the ast node, not the binding
- break;
- case ASTNode.PACKAGE_DECLARATION:
- binding = ((org.eclipse.jdt.core.dom.PackageDeclaration)node).resolveBinding();
- break;
- default:
- throw new UnsupportedOperationException("unknown node type: " + node.getNodeType()); //$NON-NLS-1$
- }
-
- final EclipseDeclarationImpl decl;
- if( binding != null )
- decl = Factory.createDeclaration(binding, this);
- else{
- decl = Factory.createDeclaration(node, getFileForNode(node), this);
- }
- if( decl != null )
- decls.add( decl );
-
- return;
- }
-
-
-
- /**
- * @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());
- }
-
- public Map<String, String> getOptions(){ return _options; }
-
- // does not generate dependencies
- public TypeDeclaration getTypeDeclaration(String name)
- {
- if( name == null || name.length() == 0 ) return null;
-
- // get rid of the generics parts.
- final int index = name.indexOf('<');
- if( index != -1 )
- name = name.substring(0, index);
-
- ITypeBinding typeBinding = null;
- try {
- typeBinding = getTypeDefinitionBindingFromName(name);
- }
- catch (ArrayIndexOutOfBoundsException e) {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=133947
- // if the name is invalid, JDT can throw an ArrayIndexOutOfBoundsException
- // We'll ignore this and return null to the user
- AptPlugin.log(e, "Unable to get type definition binding for: " + name); //$NON-NLS-1$
- }
-
- return Factory.createReferenceType(typeBinding, this);
- }
-
- /**
- * @param fullyQualifiedName the fully qualified name of a type.
- * The name cannot contain type argument or array signature.
- * The name *must* also be correct wrt $ for inner-class separators.
- * e.g. java.util.Map$Entry, NOT java.util.Map.Entry
- * @return the type binding corresponding to the parameter.
- */
- protected ITypeBinding getTypeDefinitionBindingFromCorrectName(
- final String fullyQualifiedName ){
- final int dollarIndex = fullyQualifiedName.indexOf('$');
- final String toplevelTypeName;
- if( dollarIndex < 0 )
- toplevelTypeName = fullyQualifiedName;
- else
- toplevelTypeName = fullyQualifiedName.substring(0, dollarIndex);
-
- // locate the compilation unit for the type of interest.
- // we need this information so that when we request the binding for 'fullyQualifiedName'
- // we can get the dom pipeline to return back to us the ast compilation unit
- // which we will need to correctly compute the number of methods, fields and constructors.
- // see CR259011 -theodora
- ICompilationUnit unit = getICompilationUnitForTopLevelType(toplevelTypeName);
- final String key = BindingKey.createTypeBindingKey(fullyQualifiedName);
- return (ITypeBinding)getBindingFromKey(key, unit);
- }
-
- private ITypeBinding getTypeDefinitionBindingFromName(String fullyQualifiedName) {
- // We don't know for sure that the name we have represents a top-level type,
- // so we need to loop backwards until we find one, in case we have something
- // like "java.util.Map.Entry", converting it to "java.util.Map$Entry". --jgarms
- ITypeBinding binding = getTypeDefinitionBindingFromCorrectName(fullyQualifiedName);
- while (binding == null) {
- int dotIndex = fullyQualifiedName.lastIndexOf('.');
- if (dotIndex == -1) {
- break;
- }
- fullyQualifiedName = fullyQualifiedName.substring(0, dotIndex) +
- "$" + //$NON-NLS-1$
- fullyQualifiedName.substring(dotIndex + 1);
- binding = getTypeDefinitionBindingFromCorrectName(fullyQualifiedName);
- }
- return binding;
- }
-
- /**
- * @param key
- * @param unit the unit that contains the definition of type whose type key is <code>key</code>
- * if <code>key</code> is a wild card, primitive, array type or parameterized type, this should be null.
- * @return return the type binding for the given key or null if none is found.
- */
- protected IBinding getBindingFromKey(final String key, final ICompilationUnit unit){
-
- class BindingRequestor extends ASTRequestor
- {
- private IBinding _result = null;
- private int _kind;
-
- public void acceptAST(ICompilationUnit source, CompilationUnit ast) {
- if( source == unit ){
- _modelCompUnit2astCompUnit.put(source, ast);
- }
- }
- public void acceptBinding(String bindingKey, IBinding binding)
- {
- if( binding != null )
- _result = binding;
- _kind = binding.getKind();
- }
- }
-
- final BindingRequestor requestor = new BindingRequestor();
- final ASTParser parser = ASTParser.newParser(AST.JLS3);
- parser.setResolveBindings(true);
- parser.setProject(_javaProject);
- ICompilationUnit[] units = unit == null ? NO_UNIT : new ICompilationUnit[]{unit};
- parser.createASTs(units, new String[]{key}, requestor, null);
- final IBinding result = requestor._result;
- if(result != null && unit != null){
- final CompilationUnit astUnit = _modelCompUnit2astCompUnit.get(unit);
- // make sure everything is lining up properly. Only cache real types, not package-infos.
- if( requestor._kind == IBinding.TYPE && astUnit.findDeclaringNode(result) != null ){
- ITypeBinding declaringClass = getDeclaringClass(result);
- _typeBinding2ModelCompUnit.put(declaringClass, unit);
- }
- }
- return result;
- }
-
- /**
- * @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 getTypeBindingFromKey(final String key)
- {
- return (ITypeBinding)getBindingFromKey(key, null);
-
- }
-
- public TypeDeclaration getTypeDeclaration(final IType type) {
- if (type == null) return null;
- String name = type.getFullyQualifiedName();
- return getTypeDeclaration(name);
- }
-
- public PackageDeclaration getPackage(String name)
- {
- if (name == null)
- throw new IllegalArgumentException("name cannot be null"); //$NON-NLS-1$
- IPackageFragment[] pkgFrags = PackageUtil.getPackageFragments(name, this);
-
- // No packages found, null expected
- if (pkgFrags.length == 0)
- return null;
-
- try {
- // 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) {
- if (pkg.containsJavaResources()) {
- containsNoJavaResources = false;
- break;
- }
- }
- if (containsNoJavaResources)
- return new PackageDeclarationImplNoBinding(pkgFrags);
-
- // We should be able to create a class or
- // source file from one of the packages.
- // If we find package-info, don't use it, but set
- // it aside in case it's all we can find.
- ICompilationUnit compUnit = null;
- IClassFile classFile = null;
- ICompilationUnit pkgInfoUnit = null;
- IClassFile pkgInfoClassFile = null;
- OUTER:
- for (IPackageFragment frag : pkgFrags) {
- if (frag.getKind() == IPackageFragmentRoot.K_SOURCE) {
- for (ICompilationUnit unit : frag.getCompilationUnits()) {
- if ("package-info.java".equals(unit.getElementName())) { //$NON-NLS-1$
- pkgInfoUnit = unit;
- }
- else {
- compUnit = unit;
- break OUTER;
- }
- }
- }
- else { // K_BINARY
- for (IClassFile file : frag.getClassFiles()) {
- String cfName = file.getElementName();
- if ("package-info.class".equals(cfName)) { //$NON-NLS-1$
- pkgInfoClassFile = file;
- }
- else if (file.getElementName().indexOf("$") < 0) { //$NON-NLS-1$
- classFile = file;
- break OUTER;
- }
- }
- }
- }
-
- IType type = null;
- if (compUnit != null) {
- try {
- IType[] types = compUnit.getAllTypes();
- if (types.length > 0) {
- type = types[0];
- }
- }
- catch (JavaModelException e) {}
- }
- if (type == null && classFile != null) {
- type = classFile.getType();
- }
-
- // 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, pkgFrags);
- }
-
- // No classes or source files found. Do we have a package-info we can use?
- if (pkgInfoUnit != null || pkgInfoClassFile != null) {
- String key = getPackageBindingKey(name);
- IPackageBinding packageBinding = (IPackageBinding)getBindingFromKey(key, compUnit);
- if (null != packageBinding) {
- return new PackageDeclarationImpl(packageBinding, null, this, true, pkgFrags);
- }
- }
- }
- catch (JavaModelException e) {
- // Probably bad code; treat as if no types were found
- }
-
- // This package is empty: no types and no package-info.
- return new PackageDeclarationImplNoBinding(pkgFrags);
- }
-
- // There doesn't seem to be a public inverse of
- // org.eclipse.jdt.internal.compiler.lookup.PackageBinding.computeUniqueKey().
- private String getPackageBindingKey(String packageName) {
- return packageName.replace('.', '/');
- }
-
- protected CompilationUnit searchLocallyForBinding(final IBinding binding)
- {
- if (_astRoot == null) {
- throw new IllegalStateException("_astRoot is null. Check that types or environments are not being cached between builds or reconciles by user code"); //$NON-NLS-1$
- }
-
- final ASTNode node = _astRoot.findDeclaringNode(binding);
- if( node != null )
- return _astRoot;
- return null;
- }
-
- /**
- * Retrieve the <code>ICompilationUnit</code> whose top-level type has
- * <code>topTypeQName</code> as its fully qualified name.
- * @param topTypeQName
- * @return the <code>ICompilationUnit</code> matching <code>topTypeQName</code> or
- * <code>null</code> if one doesn't exist.
- */
- private ICompilationUnit getICompilationUnitForTopLevelType(final String topTypeQName ){
- final String pathname = topTypeQName.replace('.', File.separatorChar) + DOT_JAVA;
- final IPath path = Path.fromOSString(pathname);
- try{
- final IJavaElement element = _javaProject.findElement(path);
- if( element instanceof ICompilationUnit )
- return (ICompilationUnit)element;
- else // dropping class files.
- return null;
- }
- catch(JavaModelException e){
- return null;
- }
- }
-
- /**
- * @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 ;
- CompilationUnit domUnit = searchLocallyForBinding(binding);
- if( domUnit != null )
- return domUnit;
- else{
- final IMember member = (IMember)binding.getJavaElement();
- final ICompilationUnit unit;
- if( member != null ){
- unit = member.getCompilationUnit();
- }
- else{
- final ITypeBinding typeBinding = getDeclaringClass(binding);
- // binary type don't have compilation unit.
- if( !typeBinding.isFromSource() )
- return null;
- if( _typeBinding2ModelCompUnit.get(typeBinding) != null )
- unit = _typeBinding2ModelCompUnit.get(typeBinding);
- else{
- final String qname = typeBinding.getQualifiedName();
- unit = getICompilationUnitForTopLevelType(qname);
- }
- }
- 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;
- }
- }
- }
-
- public Filer getFiler(){
- throw new UnsupportedOperationException("Not supported: the EnvironmentFactory API is for type system navigation only"); //$NON-NLS-1$
- }
-
- public Messager getMessager(){
- throw new UnsupportedOperationException("Not supported: the EnvironmentFactory API is for type system navigation only"); //$NON-NLS-1$
- }
-
- /**
- * @param binding a type, method or field binding.
- * @return the top-level type binding that declares <code>binding</code>
- * or itself if it is already one.
- */
- protected static ITypeBinding getDeclaringClass(final IBinding binding)
- {
- assert binding != null : "binding cannot be null"; //$NON-NLS-1$
- 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()); //$NON-NLS-1$
- }
- if(aTypeBinding == null ) return null;
- while( !aTypeBinding.isTopLevel() ){
- aTypeBinding = aTypeBinding.getDeclaringClass();
- }
- return aTypeBinding;
- }
-
- /**
- * The environment caches the package fragment roots, as
- * they are expensive to compute
- */
- public IPackageFragmentRoot[] getAllPackageFragmentRoots() throws JavaModelException {
- if (_packageRootsCache == null) {
- _packageRootsCache = getJavaProject().getAllPackageFragmentRoots();
- }
- return _packageRootsCache;
- }
-
- protected IFile searchLocallyForIFile(final IBinding binding)
- {
- if (_astRoot == null) {
- return null;
- }
-
- ASTNode node = _astRoot.findDeclaringNode(binding);
- if( node != null )
- return _file;
- return null;
- }
-
- /**
- * @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.
- IFile file = searchLocallyForIFile(binding);
- if( file != null )
- return file;
-
- 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"; //$NON-NLS-1$
- ICompilationUnit unit = _typeBinding2ModelCompUnit.get(type);
- if( unit != null )
- return (IFile)unit.getResource();
- final String qname = type.getQualifiedName();
- unit = getICompilationUnitForTopLevelType(qname);
- if( unit == null )
- return null;
- return (IFile)unit.getResource();
- }
- }
-
- static class BaseRequestor extends ASTRequestor
- {
- ICompilationUnit[] parseUnits;
- CompilationUnit[] asts;
- BaseRequestor(ICompilationUnit[] parseUnits)
- {
- asts = new CompilationUnit[parseUnits.length];
- // Init all units to empty to prevent any NPEs
- Arrays.fill(asts, EMPTY_AST_UNIT);
- this.parseUnits = parseUnits;
- }
-
- public void acceptAST(ICompilationUnit source, CompilationUnit ast) {
- for( int i=0, len = asts.length; i<len; i++ ){
- if( source == parseUnits[i] ){
- asts[i] = ast;
- break;
- }
- }
- }
-
- }
-
- /**
- * Parse and fully resolve all files.
- * @param javaProject
- * @param parseUnits the files to be parsed and resolved.
- */
- static void createASTs(
- final IJavaProject javaProject,
- final ICompilationUnit[] parseUnits,
- ASTRequestor requestor)
- {
- // Construct exactly 1 binding key. When acceptBinding is called we know that
- // All ASTs have been returned. This also means that a pipeline is opened when
- // there are no asts. This is needed by the batch processors.
- String bogusKey = BindingKey.createTypeBindingKey("java.lang.Object"); //$NON-NLS-1$
- String[] keys = new String[] {bogusKey};
-
- ASTParser p = ASTParser.newParser( AST.JLS3 );
- p.setResolveBindings( true );
- p.setProject( javaProject );
- p.setKind( ASTParser.K_COMPILATION_UNIT );
- p.createASTs( parseUnits, keys, requestor, null);
- }
-
- /**
- * This should create an AST without imports or method-body statements
- */
- public static CompilationUnit createAST(
- IJavaProject javaProject,
- final ICompilationUnit compilationUnit)
- {
- if(compilationUnit == null)
- return null;
-
- class CompilationUnitRequestor extends ASTRequestor
- {
- CompilationUnit domUnit = EMPTY_AST_UNIT;
- public void acceptAST(ICompilationUnit source, CompilationUnit ast) {
- if( source == compilationUnit )
- domUnit = ast;
- }
- }
-
- CompilationUnitRequestor requestor = new CompilationUnitRequestor();
- ASTParser p = ASTParser.newParser( AST.JLS3 );
- p.setResolveBindings( true );
- p.setProject( javaProject );
- p.setKind( ASTParser.K_COMPILATION_UNIT );
- p.createASTs( new ICompilationUnit[]{compilationUnit}, NO_KEYS, requestor, null);
- if( AptPlugin.DEBUG ){
- AptPlugin.trace("created DOM AST for " + compilationUnit.getElementName() ); //$NON-NLS-1$
- }
- return requestor.domUnit;
- }
-
- /**
- * @return the ast current being processed
- */
- protected AST getCurrentDietAST(){
- return _astRoot.getAST();
- }
-
- private void initPrimitives()
- {
- if(_primitives != null ) return;
- AST ast = getCurrentDietAST();
-
- _primitives = new PrimitiveTypeImpl[8];
- // boolean
- ITypeBinding binding = ast.resolveWellKnownType(ITypeConstants.BOOLEAN);
- if( binding == null )
- throw new IllegalStateException("fail to locate " + ITypeConstants.BOOLEAN); //$NON-NLS-1$
- _primitives[BOOLEAN_INDEX] = new PrimitiveTypeImpl(binding);
- // byte
- binding = ast.resolveWellKnownType(ITypeConstants.BYTE);
- if( binding == null )
- throw new IllegalStateException("fail to locate " + ITypeConstants.BYTE); //$NON-NLS-1$
- _primitives[BYTE_INDEX] = new PrimitiveTypeImpl(binding);
- // char
- binding = ast.resolveWellKnownType(ITypeConstants.CHAR);
- if( binding == null )
- throw new IllegalStateException("fail to locate " + ITypeConstants.BYTE); //$NON-NLS-1$
- _primitives[CHAR_INDEX] = new PrimitiveTypeImpl(binding);
- // double
- binding = ast.resolveWellKnownType(ITypeConstants.DOUBLE);
- if( binding == null )
- throw new IllegalStateException("fail to locate " + ITypeConstants.BYTE); //$NON-NLS-1$
- _primitives[DOUBLE_INDEX] = new PrimitiveTypeImpl(binding);
- // float
- binding = ast.resolveWellKnownType(ITypeConstants.FLOAT);
- if( binding == null )
- throw new IllegalStateException("fail to locate " + ITypeConstants.BYTE); //$NON-NLS-1$
- _primitives[FLOAT_INDEX] = new PrimitiveTypeImpl(binding);
- // int
- binding = ast.resolveWellKnownType(ITypeConstants.INT);
- if( binding == null )
- throw new IllegalStateException("fail to locate " + ITypeConstants.BYTE); //$NON-NLS-1$
- _primitives[INT_INDEX] = new PrimitiveTypeImpl(binding);
- // long
- binding = ast.resolveWellKnownType(ITypeConstants.LONG);
- if( binding == null )
- throw new IllegalStateException("fail to locate " + ITypeConstants.BYTE); //$NON-NLS-1$
- _primitives[LONG_INDEX] = new PrimitiveTypeImpl(binding);
- // short
- binding = ast.resolveWellKnownType(ITypeConstants.SHORT);
- if( binding == null )
- throw new IllegalStateException("fail to locate " + ITypeConstants.BYTE); //$NON-NLS-1$
- _primitives[SHORT_INDEX] = new PrimitiveTypeImpl(binding);
- // void
- binding = ast.resolveWellKnownType(ITypeConstants.VOID);
- if( binding == null )
- throw new IllegalStateException("fail to locate " + ITypeConstants.BYTE); //$NON-NLS-1$
- _voidType = new VoidTypeImpl(binding);
- }
-
- public PrimitiveTypeImpl getBooleanType(){
- initPrimitives();
- return _primitives[BOOLEAN_INDEX];
- }
- public PrimitiveTypeImpl getByteType(){
- initPrimitives();
- return _primitives[BYTE_INDEX];
- }
- public PrimitiveTypeImpl getCharType(){
- initPrimitives();
- return _primitives[CHAR_INDEX];
- }
- public PrimitiveTypeImpl getDoubleType(){
- initPrimitives();
- return _primitives[DOUBLE_INDEX];
- }
- public PrimitiveTypeImpl getFloatType(){
- initPrimitives();
- return _primitives[FLOAT_INDEX];
- }
- public PrimitiveTypeImpl getIntType(){
- initPrimitives();
- return _primitives[INT_INDEX];
- }
- public PrimitiveTypeImpl getLongType(){
- initPrimitives();
- return _primitives[LONG_INDEX];
- }
- public PrimitiveTypeImpl getShortType(){
- initPrimitives();
- return _primitives[SHORT_INDEX];
- }
- public VoidTypeImpl getVoidType(){
- initPrimitives();
- return _voidType;
- }
-
- public CompilationUnit getAstCompilationUnit(){ return _astRoot; }
- public IFile getFile() { return _file; }
- public Phase getPhase(){ return _phase; }
- public IProject getProject(){ return _javaProject.getProject(); }
- public IJavaProject getJavaProject(){ return _javaProject; }
- public AptProject getAptProject(){ return _aptProject; }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BinaryFileOutputStream.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BinaryFileOutputStream.java
deleted file mode 100644
index 1e44b2f461..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BinaryFileOutputStream.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.internal.env;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.util.FileSystemUtil;
-
-/**
- * Wrap output operations, caching them in memory,
- * then writing them out at the end if the content
- * is different than what is on disk
- */
-public class BinaryFileOutputStream extends ByteArrayOutputStream {
-
- protected final IFile _file;
- private final BuildEnv _env;
-
- public BinaryFileOutputStream(IFile file, BuildEnv env) {
- _file = file;
- _env = env;
- }
-
- @Override
- public void close() throws IOException {
- super.close();
-
- InputStream contents = new ByteArrayInputStream(toByteArray());
- try {
-
- boolean contentsChanged = true;
- if (!_file.exists()) {
- saveToDisk(contents, true);
- }
- else {
- InputStream in = null;
- InputStream oldData = null;
- try {
- // Only write the contents if the data is different
- in = new ByteArrayInputStream(toByteArray());
- oldData = new BufferedInputStream(_file.getContents());
- if (FileSystemUtil.compareStreams(in, oldData)) {
- contentsChanged = false;
- }
- }
- catch (CoreException ce) {
- // Ignore -- couldn't read the old data, so assume it's different
- contentsChanged = true;
- }
- finally {
- closeInputStream(in);
- closeInputStream(oldData);
- }
- if (contentsChanged) {
- contents.reset();
- saveToDisk(contents, false);
- }
- }
- }
- finally {
- closeInputStream(contents);
- }
-
- IFile parentFile = _env.getFile();
- if (parentFile != null) {
- _env.getAptProject().getGeneratedFileManager().addGeneratedFileDependency(Collections.singleton(parentFile), _file);
- _env.addGeneratedNonSourceFile(_file);
- }
- }
-
- private void closeInputStream(InputStream stream) {
- if (stream != null) {
- try {
- stream.close();
- }
- catch (IOException ioe) {}
- }
- }
-
- private void saveToDisk(InputStream toSave, boolean create) throws IOException{
- try {
- FileSystemUtil.makeDerivedParentFolders(_file.getParent());
- if (create) {
- _file.create(toSave, true, null);
- _file.setDerived(true);
- }
- else {
- _file.setContents(toSave, true, false, null);
- }
- }
- catch (CoreException ce) {
- if (_file.exists()) {
- // Do nothing. This is a case-insensitive file system mismatch,
- // and the underlying platform has saved the contents already.
- }
- else {
- AptPlugin.log(ce, "Could not create generated file"); //$NON-NLS-1$
- throw new IOException(ce.getMessage());
- }
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BuildEnv.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BuildEnv.java
deleted file mode 100644
index 635400ea30..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BuildEnv.java
+++ /dev/null
@@ -1,615 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.*;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jdt.apt.core.env.Phase;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.declaration.EclipseMirrorObject;
-import org.eclipse.jdt.apt.core.internal.declaration.TypeDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.env.MessagerImpl.Severity;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.apt.core.internal.util.Visitors.AnnotatedNodeVisitor;
-import org.eclipse.jdt.apt.core.internal.util.Visitors.AnnotationVisitor;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.compiler.CategorizedProblem;
-import org.eclipse.jdt.core.compiler.BuildContext;
-import org.eclipse.jdt.core.dom.*;
-import com.sun.mirror.apt.Filer;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.PackageDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-
-public class BuildEnv extends AbstractCompilationEnv
-{
- private boolean _hasRaisedErrors = false;
-
- private final BuildFilerImpl _filer;
-
- /**
- * 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>();
-
- /**
- * Indicates whether we are in batch mode or not. This gets flipped only
- * during build and could be flipped back and forth.
- */
- private boolean _batchMode = false; // off by default.
-
- /**
- * Holds all the files that contains annotation that are to be processed during build.
- * If we are not in batch mode, <code>super._file</code> holds the file
- * being processed at the time.
- */
- private BuildContext[] _filesWithAnnotation = null;
-
- /**
- * These are files that are part of a build but does not have annotations on it.
- * During batch mode processing, these files still also need to be included.
- */
- private BuildContext[] _additionFiles = null;
- /**
- * This is intialized when <code>_batchMode</code> is set to be <code>true</code> or
- * when batch processing is expected. <p>
- * It is also set in build mode for perf reason rather than parsing and resolving
- * each file individually.
- * @see #getAllAnnotationTypes(Map)
- */
- private CompilationUnit[] _astRoots = null;
- private List<MarkerInfo> _markerInfos = null;
-
- /**
- * Constructor for creating a processor environment used during build.
- * @param filesWithAnnotations
- * @param additionalFiles
- * @param units
- * @param javaProj
- * @param phase
- */
- BuildEnv(
- final BuildContext[] filesWithAnnotations,
- final BuildContext[] additionalFiles,
- final IJavaProject javaProj) {
-
- super(null, null, javaProj, Phase.BUILD);
- _filer = new BuildFilerImpl(this);
- _filesWithAnnotation = filesWithAnnotations;
- _additionFiles = additionalFiles;
- _problems = new ArrayList<APTProblem>();
- _markerInfos = new ArrayList<MarkerInfo>();
-
- if (AptPlugin.DEBUG_COMPILATION_ENV) AptPlugin.trace(
- "constructed " + this + " for " + _filesWithAnnotation.length + " files"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public Filer getFiler()
- {
- checkValid();
- return _filer;
- }
- public PackageDeclaration getPackage(String name)
- {
- checkValid();
- return super.getPackage(name);
- }
-
- public TypeDeclaration getTypeDeclaration(String name)
- {
- checkValid();
- TypeDeclaration decl = super.getTypeDeclaration(name);
-
- if (!_batchMode)
- addTypeDependency(name);
-
- return decl;
- }
-
- /**
- * @return true iff errors (MessagerImpl.Severity.Error) has been posted
- * Always return false when this environment is closed.
- */
- public boolean hasRaisedErrors(){
- return _hasRaisedErrors;
- }
-
- public static InputStreamReader getFileReader( final IFile file ) throws IOException, CoreException {
- return new InputStreamReader(getInputStream(file), file.getCharset());
- }
-
- public static InputStream getInputStream( final IFile file ) throws IOException, CoreException {
- return new BufferedInputStream(file.getContents());
- }
-
- /**
- * @return true iff class files has been generated.
- * Always return false when this environment is closed.
- */
- public boolean hasGeneratedClassFiles(){ return _filer.hasGeneratedClassFile(); }
-
- /* (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(){
- if( isClosed() )
- return;
- _markerInfos = null;
- _astRoot = null;
- _file = null;
- _astRoots = null;
- _filesWithAnnotation = null;
- _problems = null;
- _modelCompUnit2astCompUnit.clear();
- _hasRaisedErrors = false;
- super.close();
- }
-
- /**
- *
- * @param resource null to indicate current resource
- * @param start the starting offset of the marker
- * @param end -1 to indicate unknow ending offset.
- * @param severity the severity of the marker
- * @param msg the message on the marker
- * @param line the line number of where the marker should be
- */
- void addMessage(IFile resource,
- int start,
- int end,
- Severity severity,
- String msg,
- int line,
- String[] arguments)
- {
- checkValid();
-
- if( resource == null )
- resource = getFile();
-
- _hasRaisedErrors |= severity == MessagerImpl.Severity.ERROR;
-
- // Eclipse doesn't support INFO-level IProblems, so we send them to the log instead.
- if ( severity == Severity.INFO) {
- StringBuilder sb = new StringBuilder();
- sb.append("Informational message reported by annotation processor:\n"); //$NON-NLS-1$
- sb.append(msg);
- sb.append("\n"); //$NON-NLS-1$
- if (resource != null) {
- sb.append("Resource="); //$NON-NLS-1$
- sb.append(resource.getName());
- sb.append("; "); //$NON-NLS-1$
- }
- sb.append("starting offset="); //$NON-NLS-1$
- sb.append(start);
- sb.append("; ending offset="); //$NON-NLS-1$
- sb.append(end);
- sb.append("; line="); //$NON-NLS-1$
- sb.append(line);
- if (arguments != null) {
- sb.append("; arguments:"); //$NON-NLS-1$
- for (String s : arguments) {
- sb.append("\n"); //$NON-NLS-1$
- sb.append(s);
- }
- }
- else {
- sb.append("\n"); //$NON-NLS-1$
- }
- IStatus status = AptPlugin.createInfoStatus(null, sb.toString());
- AptPlugin.log(status);
- return;
- }
-
- if( resource == null ){
- assert _batchMode : "not in batch mode but don't know about current resource"; //$NON-NLS-1$
- addMarker(start, end, severity, msg, line, arguments);
- }
- else
- addProblem(resource, start, end, severity, msg, line, arguments);
- }
-
- private void addProblem(
- IFile resource,
- int start,
- int end,
- Severity severity,
- String msg,
- int line,
- String[] arguments)
- {
-
- APTProblem problem = createProblem(resource, start, end, severity, msg, line, arguments);
- _problems.add(problem);
- }
-
- private void addMarker(
- int start,
- int end,
- Severity severity,
- String msg,
- int line,
- String[] arguments)
- {
-
- // Note that the arguments are ignored -- no quick-fix for markers.
- _markerInfos.add(new MarkerInfo(start, end, severity, msg, line));
- }
-
- public Map<String, AnnotationTypeDeclaration> getAnnotationTypes()
- {
- checkValid();
- assert _astRoot != null && _file != null && !_batchMode :
- "operation not available under batch mode."; //$NON-NLS-1$
- return super.getAnnotationTypes();
- }
-
- /**
- * Return all annotations at declaration level within all compilation unit(s)
- * associated with this environment. All the files associated with this environment will
- * be parsed and resolved for all declaration level elements at the return of this call.
- *
- * @param file2Annotations populated by this method to map files to the annotation types
- * if contains. May be null.
- * @return the map containing all annotation types found within this environment.
- */
- public Map<String, AnnotationTypeDeclaration> getAllAnnotationTypes(
- final Map<BuildContext, Set<AnnotationTypeDeclaration>> file2Annotations) {
-
- checkValid();
- if( _filesWithAnnotation == null )
- return getAnnotationTypes();
-
- final List<Annotation> instances = new ArrayList<Annotation>();
- final Map<String, AnnotationTypeDeclaration> decls =
- new HashMap<String, AnnotationTypeDeclaration>();
- final AnnotationVisitor visitor = new AnnotationVisitor(instances);
- for( int astIndex=0, len=_astRoots.length; astIndex<len; astIndex++ ){
- if( _astRoots == null || _astRoots[astIndex] == null )
- System.err.println();
- _astRoots[astIndex].accept(visitor);
- final Set<AnnotationTypeDeclaration> perFileAnnos = new HashSet<AnnotationTypeDeclaration>();
-
- for (int instanceIndex=0, size = instances.size(); instanceIndex < size; instanceIndex++) {
- final Annotation instance = instances.get(instanceIndex);
- final ITypeBinding annoType = instance.resolveTypeBinding();
- if (annoType == null)
- continue;
- final TypeDeclarationImpl decl =
- Factory.createReferenceType(annoType, this);
- if (decl.kind() == EclipseMirrorObject.MirrorKind.TYPE_ANNOTATION){
- final AnnotationTypeDeclaration annoDecl = (AnnotationTypeDeclaration)decl;
- decls.put(annoDecl.getQualifiedName(), annoDecl);
- perFileAnnos.add(annoDecl);
- }
- }
- if( file2Annotations != null && !perFileAnnos.isEmpty() )
- file2Annotations.put(_filesWithAnnotation[astIndex], perFileAnnos);
- visitor.reset();
- }
-
- return decls;
- }
-
- /**
- * @return - the extra type dependencies for the files under compilation
- */
- public Set<String> getTypeDependencies() { return _typeDependencies; }
-
- /**
- * Switch to batch processing mode.
- * Note: Call to this method will cause all files associated with this environment to be
- * read and parsed.
- */
- public void beginBatchProcessing(){
- if( _phase != Phase.BUILD )
- throw new IllegalStateException("No batch processing outside build."); //$NON-NLS-1$
-
- if( _batchMode ) return;
- checkValid();
-
- _batchMode = true;
- _file = null;
- _astRoot = null;
- }
-
- public void completedBatchProcessing(){
- postMarkers();
- completedProcessing();
- }
-
- void createASTs(BuildContext[] cpResults){
- final int len = cpResults.length;
- final ICompilationUnit[] units = new ICompilationUnit[len];
- for( int i=0; i<len; i++ ){
- // may return null if creation failed. this may occur if
- // the file does not exists.
- units[i] = JavaCore.createCompilationUnitFrom(cpResults[i].getFile());
- }
- createASTs(_javaProject, units, _requestor = new CallbackRequestor(units));
- }
-
- public void beginFileProcessing(BuildContext result){
- if( result == null )
- throw new IllegalStateException("missing compilation result"); //$NON-NLS-1$
- _batchMode = false;
- final IFile file = result.getFile();
- if( file.equals(_file) ) // this is a no-op
- return;
-
- _astRoot = null;
- _file = null;
-
- // need to match up the file with the ast.
- if( _filesWithAnnotation != null ){
- for( int i=0, len=_filesWithAnnotation.length; i<len; i++ ){
- if( file.equals(_filesWithAnnotation[i].getFile()) ){
- _file = file;
- _astRoot = _astRoots[i];
- }
- }
- }
-
- if( _file == null || _astRoot == null)
- throw new IllegalStateException(
- "file " + //$NON-NLS-1$
- file.getName() +
- " is not in the list to be processed."); //$NON-NLS-1$
- }
-
- public void completedFileProcessing(){
- completedProcessing();
- }
-
- @Override
- protected void completedProcessing(){
- _problems.clear();
- _typeDependencies.clear();
- super.completedProcessing();
- }
-
- public List<? extends CategorizedProblem> getProblems(){
- if( !_problems.isEmpty() )
- EnvUtil.updateProblemLength(_problems, getAstCompilationUnit());
- return _problems;
- }
-
- // Implementation for EclipseAnnotationProcessorEnvironment
- public CompilationUnit getAST()
- {
- if( _batchMode )
- return null;
- return _astRoot;
- }
-
- public void addTypeDependency(final String fullyQualifiedTypeName )
- {
- if(!_batchMode){
- _typeDependencies.add( fullyQualifiedTypeName );
- }
- }
- // End of implementation for EclipseAnnotationProcessorEnvironment
-
- /**
- * Include all the types from all files, files with and without annotations on it
- * if we are in batch mode. Otherwise, just the types from the file that's currently
- * being processed.
- */
- @SuppressWarnings("unchecked")
- protected List<AbstractTypeDeclaration> searchLocallyForTypeDeclarations()
- {
- if( !_batchMode )
- return super.searchLocallyForTypeDeclarations();
- final List<AbstractTypeDeclaration> typeDecls = new ArrayList<AbstractTypeDeclaration>();
- for( int i=0, len=_astRoots.length; i<len; i++ )
- typeDecls.addAll( _astRoots[i].types() );
-
- getTypeDeclarationsFromAdditionFiles(typeDecls);
-
- return typeDecls;
- }
-
- @SuppressWarnings("unchecked")
- private void getTypeDeclarationsFromAdditionFiles(List<AbstractTypeDeclaration> typeDecls){
- if( _additionFiles == null || _additionFiles.length == 0 ) return;
-
- final int len = _additionFiles.length;
- final ICompilationUnit[] units = new ICompilationUnit[len];
- for( int i=0; i<len; i++ ){
- // may return null if creation failed. this may occur if
- // the file does not exists.
- units[i] = JavaCore.createCompilationUnitFrom(_additionFiles[i].getFile());
- }
- BaseRequestor r = new BaseRequestor(units);
- createASTs(_javaProject, units, r);
-
- CompilationUnit[] asts = r.asts;
- for( CompilationUnit ast : asts ){
- if( ast != null ){
- typeDecls.addAll( ast.types() );
- }
- }
- }
-
- protected Map<ASTNode, List<Annotation>> getASTNodesWithAnnotations()
- {
- if( !_batchMode )
- return super.getASTNodesWithAnnotations();
- final Map<ASTNode, List<Annotation>> astNode2Anno = new HashMap<ASTNode, List<Annotation>>();
- final AnnotatedNodeVisitor visitor = new AnnotatedNodeVisitor(astNode2Anno);
- for( int i=0, len=_astRoots.length; i<len; i++ )
- _astRoots[i].accept( visitor );
- return astNode2Anno;
- }
-
- protected IFile getFileForNode(final ASTNode node)
- {
- if( !_batchMode )
- return super.getFileForNode(node);
- final CompilationUnit curAST = (CompilationUnit)node.getRoot();
- for( int i=0, len=_astRoots.length; i<len; i++ ){
- if( _astRoots[i] == curAST )
- return _filesWithAnnotation[i].getFile();
- }
- throw new IllegalStateException();
- }
-
- /**
- * Go through the list of compilation unit in this environment and looking for
- * the declaration node of the given binding.
- * @param binding
- * @return the compilation unit that defines the given binding or null if no
- * match is found.
- */
- protected CompilationUnit searchLocallyForBinding(final IBinding binding)
- {
- if( !_batchMode )
- return super.searchLocallyForBinding(binding);
-
- for( int i=0, len=_astRoots.length; i<len; i++ ){
- ASTNode node = _astRoots[i].findDeclaringNode(binding);
- if( node != null)
- return _astRoots[i];
- }
- return null;
- }
-
- /**
- * Go through the list of compilation unit in this environment and looking for
- * the declaration node of the given binding.
- * @param binding
- * @return the compilation unit that defines the given binding or null if no
- * match is found.
- */
- protected IFile searchLocallyForIFile(final IBinding binding)
- {
- if( !_batchMode )
- return super.searchLocallyForIFile(binding);
-
- for( int i=0, len=_astRoots.length; i<len; i++ ){
- ASTNode node = _astRoots[i].findDeclaringNode(binding);
- if( node != null)
- return _filesWithAnnotation[i].getFile();
- }
- return null;
- }
-
- /**
- * @param file
- * @return the compilation unit associated with the given file.
- * If the file is not one of those that this environment is currently processing,
- * return null;
- */
- public CompilationUnit getASTFrom(final IFile file)
- {
- if( file == null )
- return null;
- else if( file.equals(_file) )
- return _astRoot;
- else if( _astRoots != null ){
- for( int i=0, len=_filesWithAnnotation.length; i<len; i++ ){
- if( file.equals(_filesWithAnnotation[i].getFile()) )
- return _astRoots[i];
- }
- }
- return null;
- }
-
- /**
- * @return the current ast being processed if in per-file mode.
- * If in batch mode, one of the asts being processed (no guarantee which
- * one will be returned.
- */
- protected AST getCurrentDietAST(){
-
- if( _astRoot != null )
- return _astRoot.getAST();
- else{
- if( _astRoots == null )
- throw new IllegalStateException("no AST is available"); //$NON-NLS-1$
- return _astRoots[0].getAST();
- }
- }
-
- void postMarkers()
- {
- if( _markerInfos == null || _markerInfos.size() == 0 )
- return;
- // Posting all the markers to the workspace. Doing this in a batch process
- // to minimize the amount of notification.
- try{
- final IWorkspaceRunnable runnable = new IWorkspaceRunnable(){
- public void run(IProgressMonitor monitor)
- {
- for( MarkerInfo markerInfo : _markerInfos ){
- try{
- final IMarker marker = _javaProject.getProject().createMarker(AptPlugin.APT_BATCH_PROCESSOR_PROBLEM_MARKER);
- markerInfo.copyIntoMarker(marker);
- }
- catch(CoreException e){
- AptPlugin.log(e, "Failure posting markers"); //$NON-NLS-1$
- }
- }
- }
- };
- IWorkspace ws = _javaProject.getProject().getWorkspace();
- ws.run(runnable, null);
- }
- catch(CoreException e){
- AptPlugin.log(e, "Failed to post markers"); //$NON-NLS-1$
- }
- finally{
- _markerInfos.clear();
- }
- }
-
- public BuildContext[] getFilesWithAnnotation()
- {
- return _filesWithAnnotation;
- }
-
- public BuildContext[] getFilesWithoutAnnotation()
- {
- return _additionFiles;
- }
-
- private class CallbackRequestor extends BaseRequestor {
- CallbackRequestor(ICompilationUnit[] parseUnits) {
- super(parseUnits);
- }
- public void acceptBinding(String bindingKey, IBinding binding) {
- // If we have recieved the last ast we have requested,
- // then assign the asts, then begin dispatch
- _astRoots = asts;
- _callback.run(BuildEnv.this);
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BuildFilerImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BuildFilerImpl.java
deleted file mode 100644
index db3b54da47..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/BuildFilerImpl.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.env;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jdt.apt.core.env.Phase;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager;
-
-import com.sun.mirror.apt.Filer;
-
-/**
- * @author wharley
- *
- */
-public class BuildFilerImpl extends FilerImpl {
-
- private boolean _generatedClassFiles = false;
- private final BuildEnv _env;
-
- public BuildFilerImpl(BuildEnv env) {
- _env = env;
- }
-
- /**
- * 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 typeName - canonical (fully qualified) name of the type being written
- * @return -a stream for writing to the new file
- */
- public OutputStream createClassFile(String typeName) throws IOException
- {
- if (typeName == null)
- throw new IllegalArgumentException("Type name cannot be null"); //$NON-NLS-1$
- if ("".equals(typeName)) //$NON-NLS-1$
- throw new IllegalArgumentException("Type name cannot be empty"); //$NON-NLS-1$
-
- _env.checkValid();
- try {
- _env.validateTypeName(typeName);
- } catch (CoreException e) {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
- _generatedClassFiles = true;
-
- // We do not want to write to disk during reconcile
- if (_env.getPhase() == Phase.RECONCILE) {
- return new NoOpOutputStream();
- }
-
- GeneratedSourceFolderManager gsfm = _env.getAptProject().getGeneratedSourceFolderManager();
- IPath path;
- try
- {
- path = gsfm.getBinaryOutputLocation();
- }
- catch ( Exception e )
- {
- // TODO - stop throwing this exception
- AptPlugin.log(e, "Failure getting the output file"); //$NON-NLS-1$
- throw new IOException();
- }
-
- path = path.append(typeName.replace('.', File.separatorChar) + ".class"); //$NON-NLS-1$
-
- IFile file = getEnv().getProject().getFile(path);
- return new BinaryFileOutputStream(file, _env);
- }
-
- 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
- {
- if (relPath == null)
- throw new IllegalArgumentException("Path cannot be null"); //$NON-NLS-1$
- if ("".equals(relPath.getPath())) //$NON-NLS-1$
- throw new IllegalArgumentException("Path cannot be empty"); //$NON-NLS-1$
-
- _env.checkValid();
-
- // If we're reconciling, we do not want to actually create the text file
- if (_env.getPhase() == Phase.RECONCILE) {
- return new NoOpPrintWriter();
- }
-
-
- IPath path = getOutputFileForLocation( loc, pkg, relPath );
- IFile file = _env.getProject().getFile(path);
- validateFile(file);
- OutputStream binaryOut = new EncodedFileOutputStream(file, _env, charsetName);
-
- if (charsetName == null) {
- return new PrintWriter(binaryOut);
- }
- else {
- OutputStreamWriter outWriter = new OutputStreamWriter(binaryOut, charsetName);
- return new PrintWriter(outWriter);
- }
- }
-
- /**
- * 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
- {
- if (relPath == null)
- throw new IllegalArgumentException("Path cannot be null"); //$NON-NLS-1$
- if ("".equals(relPath.getPath())) //$NON-NLS-1$
- throw new IllegalArgumentException("Path cannot be empty"); //$NON-NLS-1$
-
- _env.checkValid();
-
- // We do not want to write to disk during reconcile
- if (_env.getPhase() == Phase.RECONCILE) {
- return new NoOpOutputStream();
- }
-
- IPath path = getOutputFileForLocation( loc, pkg, relPath );
- IFile file = _env.getProject().getFile(path);
- validateFile(file);
- return new BinaryFileOutputStream(file, _env);
- }
-
- @Override
- protected AbstractCompilationEnv getEnv() {
- return _env;
- }
-
- private void validateFile(IFile file) throws IOException
- {
- IStatus status = file.getWorkspace().validatePath(file.getFullPath().toOSString(), IResource.FILE);
- if (!status.isOK()) {
- CoreException ce = new CoreException(status);
- IOException ioe = new IOException("Invalid file name"); //$NON-NLS-1$
- ioe.initCause(ce);
- throw ioe;
- }
- }
-
-}
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 99bee01181..0000000000
--- 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, 2007 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 BuildEnv env)
- {
- super( env, new State(env) );
- }
-
- private static class State implements RoundState
- {
- private final BuildEnv _env;
- State(BuildEnv 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/EncodedFileOutputStream.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/EncodedFileOutputStream.java
deleted file mode 100644
index 49f01a14e0..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/EncodedFileOutputStream.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 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.core.internal.env;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * Sets the encoding for the IFile on close of the stream
- */
-public class EncodedFileOutputStream extends BinaryFileOutputStream {
-
- private final String _charsetName;
-
- public EncodedFileOutputStream(IFile file, BuildEnv env, String charsetName) {
- super(file, env);
- _charsetName = charsetName;
- }
-
- @Override
- public void close() throws IOException {
- super.close();
- if (_charsetName != null) {
-
- // Need to check for source control on the resources encoding file
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=190268
- IWorkspace ws = ResourcesPlugin.getWorkspace();
-
- // Yuck -- we need to hardcode the location of the prefs file for file encoding
- IFile resourceFile = _file.getProject().getFile(".settings/org.eclipse.core.resources.prefs"); //$NON-NLS-1$
- IStatus result = ws.validateEdit(new IFile[]{resourceFile}, IWorkspace.VALIDATE_PROMPT);
- if (result.getSeverity() == IStatus.CANCEL) {
- // User cancelled the checkout. Don't try to edit the encoding for the file
- return;
- }
- try {
- String defaultCharset = _file.getCharset();
- if (!_charsetName.equalsIgnoreCase(defaultCharset)) {
- _file.setCharset(_charsetName, null);
- }
- }
- catch (CoreException ce) {
- IOException ioe = new IOException("Could not set charset: " + _charsetName); //$NON-NLS-1$
- ioe.initCause(ce);
- throw ioe;
- }
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/EnvUtil.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/EnvUtil.java
deleted file mode 100644
index 80cb9f0949..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/EnvUtil.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.util.Arrays;
-import java.util.List;
-
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ASTVisitor;
-import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.SimpleName;
-
-/*package*/ class EnvUtil {
- /**
- * Handling the following 2 cases
- * 1) For IProblems that does not have a starting and ending offset,
- * place the problem at the class name.
- *
- * 2) For IProblems that does not have an ending offset, place the ending
- * offset at the end of the tightest ast node.
- * We will only walk the ast once to determine the ending
- * offsets of all the problems that do not have the information set.
- */
- static void updateProblemLength(List<APTProblem> problems, CompilationUnit astUnit)
- {
- // for those problems that doesn't have an ending offset, figure it out by
- // traversing the ast.
- // we do it once just before we post the marker so we only have to walk the ast
- // once.
- int count = 0;
- int[] classNameRange = null;
- for(IProblem problem : problems ){
- if( problem.getSourceStart() < 0 ){
- if( classNameRange == null )
- classNameRange = getClassNameRange(astUnit);
- problem.setSourceStart(classNameRange[0]);
- problem.setSourceEnd(classNameRange[1]);
- problem.setSourceLineNumber(classNameRange[2]);
- }
- if( problem.getSourceEnd() < 0 ){
- count ++;
- }
- }
-
- if( count > 0 ){
- if( astUnit != null ){
- final int[] startingOffsets = new int[count];
- int index = 0;
- for( IProblem problem : problems ){
- if( problem.getSourceEnd() < 0 )
- startingOffsets[index++] = problem.getSourceStart();
- }
-
- final EndingOffsetFinder lfinder = new EndingOffsetFinder(startingOffsets);
-
- astUnit.accept( lfinder );
-
- for(IProblem problem : problems ){
- if( problem.getSourceEnd() < 0 ){
- int startingOffset = problem.getSourceStart();
- int endingOffset = lfinder.getEndingOffset(startingOffset);
- if( endingOffset == 0 )
- endingOffset = startingOffset;
- problem.setSourceEnd(endingOffset-1);
- }
- }
- }
- else{
- for(IProblem problem : problems){
- // set the -1 source end to be the same as the source start.
- if( problem.getSourceEnd() < problem.getSourceStart() )
- problem.setSourceEnd(problem.getSourceStart());
- }
- }
- }
- }
-
- /**
- * @param file
- * @return length 3 int array with the following information.
- * at index 0: contains the starting offset, always >= 0
- * at index 1: contains the ending offset, may be a negative number.
- * at index 2: the line number
- *
- */
- private static int[] getClassNameRange(final CompilationUnit astUnit){
- int[] startAndEnd = null;
- if( astUnit != null){
- @SuppressWarnings({"unchecked"})
- final List<AbstractTypeDeclaration> topTypes = astUnit.types();
- if( topTypes != null && topTypes.size() > 0 ){
- final AbstractTypeDeclaration topType = topTypes.get(0);
- startAndEnd = new int[3];
- final SimpleName typename = topType.getName();
- if( typename != null ){
- startAndEnd[0] = typename.getStartPosition();
- // ending offsets need to be exclusive.
- startAndEnd[1] = startAndEnd[0] + typename.getLength() - 1;
- startAndEnd[2] = astUnit.getLineNumber(typename.getStartPosition());
- if( startAndEnd[2] < 1 )
- startAndEnd[2] = 1;
- }
- else{
- startAndEnd[0] = topType.getStartPosition();
- // let case 2 in updateProblemLength() kicks in.
- startAndEnd[1] = -2;
- startAndEnd[2] = astUnit.getLineNumber(topType.getStartPosition());
- if( startAndEnd[2] < 1 )
- startAndEnd[2] = 1;
- }
- }
- }
- if( startAndEnd == null )
- // let case 2 in updateProblemLength() kicks in.
- return new int[]{0, -2, 1};
-
- return startAndEnd;
- }
-
- /**
- * Responsible for finding the ending offset of the ast node that has the tightest match
- * for a given offset. This ast visitor can operator on an array of offsets in one pass.
- * @author tyeung
- */
- private static class EndingOffsetFinder extends ASTVisitor
- {
- private final int[] _sortedStartingOffset;
- /**
- * parallel to <code>_sortedOffsets</code> and contains
- * the ending offset of the ast node that has the tightest match for the
- * corresponding starting offset.
- */
- private final int[] _endingOffsets;
-
- /**
- * @param offsets the array of offsets which will be sorted.
- * @throws IllegalArgumentException if <code>offsets</code> is <code>null</code>.
- */
- private EndingOffsetFinder(int[] offsets)
- {
- if(offsets == null)
- throw new IllegalArgumentException("argument cannot be null."); //$NON-NLS-1$
- // sort the array first
- Arrays.sort(offsets);
-
- // look for duplicates.
- int count = 0;
- for( int i=0, len=offsets.length; i<len; i++){
- if( i > 0 && offsets[i-1] == offsets[i] )
- continue;
- count ++;
- }
-
- if( count != offsets.length ){
- _sortedStartingOffset = new int[count];
-
- int index = 0;
- for( int i=0, len=offsets.length; i<len; i++){
- if( i > 0 && offsets[i-1] == offsets[i] )
- continue;
- _sortedStartingOffset[index++] = offsets[i];
- }
- }
- else{
- _sortedStartingOffset = offsets;
- }
-
- _endingOffsets = new int[count];
- for( int i=0; i<count; i++ )
- _endingOffsets[i] = 0;
- }
-
- public void preVisit(ASTNode node)
- {
- final int startingOffset = node.getStartPosition();
- final int endingOffset = startingOffset + node.getLength();
- // starting offset is inclusive
- int startIndex = Arrays.binarySearch(_sortedStartingOffset, startingOffset);
- // ending offset is exclusive
- int endIndex = Arrays.binarySearch(_sortedStartingOffset, endingOffset);
- if( startIndex < 0 )
- startIndex = - startIndex - 1;
- if( endIndex < 0 )
- endIndex = - endIndex - 1;
- else
- // endIndex needs to be exclusive and we want to
- // include the 'endIndex'th entry in our computation.
- endIndex ++;
- if( startIndex >= _sortedStartingOffset.length )
- return;
-
- for( int i=startIndex; i<endIndex; i++ ){
- if( _endingOffsets[i] == 0 )
- _endingOffsets[i] = endingOffset;
- else if( endingOffset < _endingOffsets[i] )
- _endingOffsets[i] = endingOffset;
- }
- }
-
-
- public int getEndingOffset(final int startingOffset)
- {
- int index = Arrays.binarySearch(_sortedStartingOffset, startingOffset);
- if( index == -1 ) return 0;
- return _endingOffsets[index];
- }
- }
-}
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 9810255723..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/FilerImpl.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.PrintWriter;
-import java.io.StringWriter;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager;
-import org.eclipse.jdt.apt.core.internal.util.FileSystemUtil;
-import org.eclipse.jdt.core.JavaModelException;
-
-import com.sun.mirror.apt.Filer;
-
-
-public abstract class FilerImpl implements Filer {
-
- abstract protected AbstractCompilationEnv getEnv();
-
- /**
- * 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 typeName - canonical (fully qualified) name of the principal type being declared in this file
- */
- public PrintWriter createSourceFile(String typeName) throws IOException
- {
- if (typeName == null)
- throw new IllegalArgumentException("Type name cannot be null"); //$NON-NLS-1$
- if ("".equals(typeName)) //$NON-NLS-1$
- throw new IllegalArgumentException("Type name cannot be empty"); //$NON-NLS-1$
-
- getEnv().checkValid();
-
- PrintWriter pw;
- try {
- pw = new JavaSourceFilePrintWriter( typeName, new StringWriter(), getEnv() );
- } catch (CoreException e) {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
- return pw;
- }
-
-
- /**
- * Return a project-relative path
- */
- protected IPath getOutputFileForLocation( Filer.Location loc, String pkg, File relPath )
- throws IOException
- {
- GeneratedSourceFolderManager gsfm = getEnv().getAptProject().getGeneratedSourceFolderManager();
- IPath path = null;
- if ( loc == Filer.Location.CLASS_TREE )
- {
- try
- {
- path = gsfm.getBinaryOutputLocation();
- }
- catch ( JavaModelException e )
- {
- AptPlugin.log(e, "Failure getting the output file"); //$NON-NLS-1$
- throw new IOException();
- }
- }
- else if ( loc == Filer.Location.SOURCE_TREE ) {
- path = gsfm.getFolder().getProjectRelativePath();
- }
-
- if( pkg != null )
- path = path.append(pkg.replace('.', File.separatorChar) );
-
- path = path.append(relPath.getPath() );
-
- // Create the parent folder (need an absolute path temporarily)
- IPath absolutePath = getEnv().getProject().getLocation().append(path);
- File parentFile = absolutePath.toFile().getParentFile();
- FileSystemUtil.mkdirs( parentFile );
-
- return path;
- }
-
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ITypeConstants.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ITypeConstants.java
deleted file mode 100644
index f066f8bafe..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ITypeConstants.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.env;
-
-public interface ITypeConstants {
- static final String BOOLEAN = "boolean"; //$NON-NLS-1$
- static final String BYTE = "byte"; //$NON-NLS-1$
- static final String CHAR = "char"; //$NON-NLS-1$
- static final String DOUBLE = "double"; //$NON-NLS-1$
- static final String FLOAT = "float"; //$NON-NLS-1$
- static final String INT = "int"; //$NON-NLS-1$
- static final String LONG = "long"; //$NON-NLS-1$
- static final String SHORT = "short"; //$NON-NLS-1$
- static final String VOID = "void"; //$NON-NLS-1$
-}
-
-
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 066c76063a..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/JavaSourceFilePrintWriter.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.util.Collections;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.apt.core.env.Phase;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.generatedfile.FileGenerationResult;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedFileManager;
-import org.eclipse.jdt.core.ICompilationUnit;
-
-public class JavaSourceFilePrintWriter extends PrintWriter {
-
- private final StringWriter _sw;
- private final String _typeName;
- private final AbstractCompilationEnv _env;
-
- /**
- * @throws CoreException if type name is not valid
- */
- public JavaSourceFilePrintWriter( String typeName, StringWriter sw, AbstractCompilationEnv env )
- throws CoreException
- {
- super( sw );
- _sw = sw;
- _typeName = typeName;
- _env = env;
- _env.validateTypeName(typeName);
- }
-
- public void close()
- {
- try {
- String contents = _sw.toString();
- super.close();
- GeneratedFileManager gfm = _env.getAptProject().getGeneratedFileManager();
- Phase phase = _env.getPhase();
-
- FileGenerationResult result = null;
- if ( phase == Phase.RECONCILE && _env.currentProcessorSupportsRTTG() )
- {
- ReconcileEnv reconcileEnv = (ReconcileEnv)_env;
- ICompilationUnit parentCompilationUnit = reconcileEnv.getCompilationUnit();
- result = gfm.generateFileDuringReconcile(
- parentCompilationUnit, _typeName, contents );
- // Need to call ReconcileContext.resetAst() for this to be effective;
- // that will happen in ReconcileEnv.close().
- }
- else if ( phase == Phase.BUILD) {
- result = gfm.generateFileDuringBuild(
- Collections.singletonList(_env.getFile()), _typeName, contents,
- _env.currentProcessorSupportsRTTG(), null /* progress monitor */ );
- }
- if (result != null) {
- _env.addGeneratedSourceFile(result.getFile(), result.isModified());
- }
- }
- catch (CoreException ce) {
- AptPlugin.log(ce, "Unable to generate type when JavaSourceFilePrintWriter was closed"); //$NON-NLS-1$
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/MarkerInfo.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/MarkerInfo.java
deleted file mode 100644
index 88778d75ae..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/MarkerInfo.java
+++ /dev/null
@@ -1,70 +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.core.internal.env;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.apt.core.internal.env.MessagerImpl.Severity;
-
-/**
- * Simple container class for attributes of IMarker
- *
- */
-public class MarkerInfo {
-
- private final int start;
- private final int end;
- private final Severity severity;
- private final String msg;
- private final int line;
-
-
- public MarkerInfo(final int start,
- final int end,
- final Severity severity,
- final String msg,
- final int line)
- {
- this.start = start;
- this.end = end;
- this.severity = severity;
- this.msg = msg;
- this.line = line;
- }
-
- private int getSeverity() {
- switch (severity) {
- case ERROR :
- return IMarker.SEVERITY_ERROR;
- case WARNING :
- return IMarker.SEVERITY_WARNING;
- case INFO :
- return IMarker.SEVERITY_INFO;
- }
- throw new IllegalStateException("Unhandled severity level: " + severity); //$NON-NLS-1$
- }
-
- public boolean isError(){
- return severity == Severity.ERROR;
- }
-
- /**
- * Copy this info into the provided marker
- */
- public void copyIntoMarker(IMarker marker) throws CoreException {
- marker.setAttribute(IMarker.CHAR_START, start);
- marker.setAttribute(IMarker.CHAR_END, end);
- marker.setAttribute(IMarker.SEVERITY, getSeverity());
- marker.setAttribute(IMarker.MESSAGE, msg);
- marker.setAttribute(IMarker.LINE_NUMBER, line);
- }
-}
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 61fa5f109d..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/MessagerImpl.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.util.SourcePositionImpl;
-import org.eclipse.jdt.apt.core.util.EclipseMessager;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-
-
-public class MessagerImpl implements Messager, EclipseMessager
-{
- public static enum Severity {
- ERROR,
- WARNING,
- INFO
- }
- private final AbstractCompilationEnv _env;
-
- MessagerImpl(AbstractCompilationEnv env){
- _env = env;
- }
-
- public void printError(SourcePosition pos, String msg, String[] arguments)
- {
- if( pos == null )
- printError(msg);
- else if( pos instanceof SourcePositionImpl )
- print((SourcePositionImpl)pos, Severity.ERROR, msg, arguments);
- else
- print(pos, Severity.ERROR, msg, arguments);
- }
-
- public void printError(ASTNode node, String msg)
- {
- if( node == null )
- throw new IllegalArgumentException("'node' cannot be null"); //$NON-NLS-1$
- final int start = node.getStartPosition();
- // The only time you get a dom AST node is when you are processing in a per-file mode.
- // _env.getAstCompilationUnit() && _env.getFile() will return an non-null value.
- int line = _env.getAstCompilationUnit().getLineNumber(start);
- if( line < 1 )
- line = 1;
- _env.addMessage(_env.getFile(), start, node.getLength() + start, Severity.ERROR, msg, line, null );
- }
-
- public void printError(String msg)
- {
- print(Severity.ERROR, msg, null);
- }
-
- public void printNotice(SourcePosition pos, String msg, String[] arguments)
- {
- if( pos instanceof SourcePositionImpl )
- print((SourcePositionImpl)pos, Severity.INFO, msg, arguments);
- else if (pos == null )
- printNotice(msg);
- else
- print(pos, Severity.INFO, msg, arguments);
- }
-
- public void printNotice(ASTNode node, String msg)
- {
- if( node == null )
- throw new IllegalArgumentException("'node' cannot be null"); //$NON-NLS-1$
- final int start = node.getStartPosition();
- // The only time you get a dom AST node is when you are processing in a per-file mode.
- // _env.getAstCompilationUnit() && _env.getFile() will return an non-null value.
- int line = _env.getAstCompilationUnit().getLineNumber(start);
- if( line < 1 )
- line = 1;
- _env.addMessage(_env.getFile(), start, node.getLength() + start, Severity.INFO, msg, line, null );
- }
-
- public void printNotice(String msg)
- {
- print(Severity.INFO, msg, null);
- }
-
- public void printWarning(SourcePosition pos, String msg, String[] arguments)
- {
- if( pos instanceof SourcePositionImpl )
- print((SourcePositionImpl)pos, Severity.WARNING, msg, arguments);
- else if (pos == null )
- printWarning(msg);
- else
- print(pos, Severity.WARNING, msg, arguments);
- }
-
- public void printWarning(ASTNode node, String msg)
- {
- if( node == null )
- throw new IllegalArgumentException("'node' cannot be null"); //$NON-NLS-1$
- final int start = node.getStartPosition();
- // The only time you get a dom AST node is when you are processing in a per-file mode.
- // _env.getAstCompilationUnit() && _env.getFile() will return an non-null value.
- int line = _env.getAstCompilationUnit().getLineNumber(start);
- if( line < 1 )
- line = 1;
- _env.addMessage(_env.getFile(), start, node.getLength() + start, Severity.WARNING, msg, line, null);
- }
-
- public void printWarning(String msg)
- {
- print(Severity.WARNING, msg, null);
- }
-
- public void printError(SourcePosition pos, String msg) {
- printError(pos, msg, null);
- }
-
- public void printWarning(SourcePosition pos, String msg) {
- printWarning(pos, msg, null);
- }
-
- public void printNotice(SourcePosition pos, String msg) {
- printNotice(pos, msg, null);
- }
-
- public void printFixableError(SourcePosition pos, String msg, String pluginId, String errorId) {
- if (pluginId == null) {
- throw new IllegalArgumentException("pluginId cannot be null"); //$NON-NLS-1$
- }
- if (errorId == null) {
- throw new IllegalArgumentException("errorId cannot be null"); //$NON-NLS-1$
- }
- printError(pos, msg, new String[] {pluginId, errorId});
- }
-
- public void printFixableWarning(SourcePosition pos, String msg, String pluginId, String errorId) {
- if (pluginId == null) {
- throw new IllegalArgumentException("pluginId cannot be null"); //$NON-NLS-1$
- }
- if (errorId == null) {
- throw new IllegalArgumentException("errorId cannot be null"); //$NON-NLS-1$
- }
- printWarning(pos, msg, new String[] {pluginId, errorId});
- }
-
- public void printFixableNotice(SourcePosition pos, String msg, String pluginId, String errorId) {
- if (pluginId == null) {
- throw new IllegalArgumentException("pluginId cannot be null"); //$NON-NLS-1$
- }
- if (errorId == null) {
- throw new IllegalArgumentException("errorId cannot be null"); //$NON-NLS-1$
- }
- printNotice(pos, msg, new String[] {pluginId, errorId});
- }
-
- public void printFixableError(String msg, String pluginId, String errorId) {
- if (pluginId == null) {
- throw new IllegalArgumentException("pluginId cannot be null"); //$NON-NLS-1$
- }
- if (errorId == null) {
- throw new IllegalArgumentException("errorId cannot be null"); //$NON-NLS-1$
- }
- print(Severity.ERROR, msg, new String[] {pluginId, errorId});
- }
-
- public void printFixableWarning(String msg, String pluginId, String errorId) {
- if (pluginId == null) {
- throw new IllegalArgumentException("pluginId cannot be null"); //$NON-NLS-1$
- }
- if (errorId == null) {
- throw new IllegalArgumentException("errorId cannot be null"); //$NON-NLS-1$
- }
- print(Severity.WARNING, msg, new String[] {pluginId, errorId});
- }
-
- public void printFixableNotice(String msg, String pluginId, String errorId) {
- if (pluginId == null) {
- throw new IllegalArgumentException("pluginId cannot be null"); //$NON-NLS-1$
- }
- if (errorId == null) {
- throw new IllegalArgumentException("errorId cannot be null"); //$NON-NLS-1$
- }
- print(Severity.INFO, msg, new String[] {pluginId, errorId});
- }
-
- private void print(SourcePositionImpl pos,
- Severity severity,
- String msg,
- String[] arguments)
- {
- final IFile resource = pos.getResource();
- if( resource == null ){
- throw new IllegalStateException("missing resource"); //$NON-NLS-1$
- }
- else{
- _env.addMessage(resource, pos.getStartingOffset(), pos.getEndingOffset(),
- severity, msg, pos.line(), arguments);
- }
- }
-
- private void print(SourcePosition pos,
- Severity severity,
- String msg,
- String[] arguments)
- {
- final java.io.File file = pos.file();
- IFile resource = null;
- if( file != null ){
- final String projAbsPath = _env.getProject().getLocation().toOSString();
- final String fileAbsPath = file.getAbsolutePath();
- final String fileRelPath = fileAbsPath.substring(projAbsPath.length());
- resource = _env.getProject().getFile(fileRelPath);
- if( !resource.exists() )
- resource = null;
- }
-
- int offset = -1;
- if( resource != null ){
- final CompilationUnit unit = _env.getASTFrom(resource);
- if( unit != null )
- offset = unit.getPosition( pos.line(), pos.column() );
- }
- _env.addMessage(resource, offset, -1, severity, msg, pos.line(), arguments );
- }
-
- private void print(Severity severity, String msg, String[] arguments)
- {
- _env.addMessage(null, -1, -1, severity, msg, 1, arguments );
-
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/NoOpOutputStream.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/NoOpOutputStream.java
deleted file mode 100644
index b3c80b8900..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/NoOpOutputStream.java
+++ /dev/null
@@ -1,37 +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.core.internal.env;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Dummy output stream for filer operations
- */
-public class NoOpOutputStream extends OutputStream {
-
- public NoOpOutputStream() {
- super();
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException {
- }
-
- @Override
- public void write(byte[] b) throws IOException {
- }
-
- @Override
- public void write(int b) throws IOException {
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/NoOpPrintWriter.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/NoOpPrintWriter.java
deleted file mode 100644
index c1e40fcd10..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/NoOpPrintWriter.java
+++ /dev/null
@@ -1,21 +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.core.internal.env;
-
-import java.io.PrintWriter;
-
-public class NoOpPrintWriter extends PrintWriter {
-
- public NoOpPrintWriter() {
- super(new NoOpOutputStream());
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ReconcileEnv.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ReconcileEnv.java
deleted file mode 100644
index b3b90fbf61..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ReconcileEnv.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.apt.core.env.EclipseAnnotationProcessorEnvironment;
-import org.eclipse.jdt.apt.core.env.Phase;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.env.MessagerImpl.Severity;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.compiler.ReconcileContext;
-import org.eclipse.jdt.core.dom.ASTRequestor;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IBinding;
-
-import com.sun.mirror.apt.Filer;
-
-public class ReconcileEnv extends AbstractCompilationEnv implements EclipseAnnotationProcessorEnvironment{
-
- /** The compilation unit being reconciled */
- private final ICompilationUnit _workingCopy;
-
- private final ReconcileContext _context;
-
- /**
- * Create a reconcile environment from the given context.
- * @param reconcileContext
- * @return the reconcile environment or null if creation failed.
- */
- static ReconcileEnv newEnv(ReconcileContext context)
- {
- final ICompilationUnit workingCopy = context.getWorkingCopy();
- IJavaProject javaProject = workingCopy.getJavaProject();
- final IFile file = (IFile)workingCopy.getResource();
- return new ReconcileEnv(context, workingCopy, file, javaProject);
- }
-
- private ReconcileEnv(
- ReconcileContext context,
- ICompilationUnit workingCopy,
- IFile file,
- IJavaProject javaProj)
- {
- // See bug 133744: calling ReconcileContext.getAST3() here would result in
- // a typesystem whose types are not comparable with the types we get after
- // openPipeline(). Instead, we start the env with an EMPTY_AST_UNIT, and
- // replace it with the real thing inside the openPipeline() ASTRequestor's
- // acceptAST() callback.
- super(EMPTY_AST_UNIT, file, javaProj, Phase.RECONCILE);
- _context = context;
- _workingCopy = workingCopy;
- if (AptPlugin.DEBUG_COMPILATION_ENV) AptPlugin.trace(
- "constructed " + this + " for " + _workingCopy.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- void addMessage(
- IFile resource,
- int start,
- int end,
- Severity severity,
- String msg,
- int line,
- String[] arguments)
- {
- checkValid();
-
- if( resource == null )
- resource = getFile();
-
- assert resource != null : "don't know about the current resource"; //$NON-NLS-1$
-
- // not going to post any markers to resource outside of the one we are currently
- // processing during reconcile phase.
- if( resource != null && !resource.equals( getFile() ) )
- return;
-
- _problems.add(createProblem(resource, start, end, severity, msg, line, arguments));
- }
-
- public CompilationUnit getASTFrom(final IFile file){
- if( _file.equals(file) )
- return _astRoot;
- else
- return null;
- }
-
- public void addTypeDependency(String fullyQualifiedTypeName) {
- // do not store type dependency during reconcile.
- return;
- }
-
- public Filer getFiler(){
- return new ReconcileFilerImpl(this);
- }
-
- void openPipeline() {
- _requestor = new CallbackRequestor();
- createASTs(_javaProject, new ICompilationUnit[]{_workingCopy}, _requestor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.internal.env.AbstractCompilationEnv#close()
- */
- @Override
- public void close() {
- // Notify the compiler that the working copy was modified, so that the editor
- // and any downstream compilationParticipants will get a recomputed AST,
- // taking into account any changes to generated types.
- //TODO: don't call unless generated types were changed - WSH 10/06
- _context.resetAST();
- super.close();
- }
-
- class CallbackRequestor extends ASTRequestor {
- @Override
- public void acceptAST(ICompilationUnit source, CompilationUnit ast) {
- // Use the AST from the pipeline's parser, not the one from ReconcileContext.getAST3().
- _astRoot = ast;
- }
-
- @Override
- public void acceptBinding(String bindingKey, IBinding binding) {
- // This is called when the only binding has been passed, hence it is time
- // to dispatch
- _callback.run(ReconcileEnv.this);
-
- }
- }
-
- /* package scope */
- ICompilationUnit getCompilationUnit() {
- return _workingCopy;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ReconcileFilerImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ReconcileFilerImpl.java
deleted file mode 100644
index 857cc658f1..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/ReconcileFilerImpl.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 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.env;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.Writer;
-
-import com.sun.mirror.apt.Filer;
-
-/**
- * An implementation of com.sun.mirror.apt.Filer for use during reconcile phase.
- * This implementation is able to generate new Java source types (though it
- * does not lay them onto disk), but it silently ignores attempts to generate
- * binary, text, or class files.
- */
-final class ReconcileFilerImpl extends FilerImpl {
-
- private final ReconcileEnv _env;
-
- private static final OutputStream NO_OP_STREAM = new OutputStream(){
- public void write(int b) throws IOException {
- return;
- }
- };
-
- private static final class NoOpWriter extends Writer{
- public void write(char[] cbuf, int off, int len)
- throws IOException {
- return;
- }
- public void flush() throws IOException {
- return;
- }
- public void close() throws IOException {
- return;
- }
- }
-
- public ReconcileFilerImpl(ReconcileEnv env) {
- _env = env;
- }
-
- @Override
- protected AbstractCompilationEnv getEnv() {
- return _env;
- }
-
- private static final PrintWriter NO_OP_WRITER = new PrintWriter(new NoOpWriter());
-
- public OutputStream createBinaryFile(Filer.Location loc, String pkg, File relPath)
- throws IOException {
- return NO_OP_STREAM;
- }
-
- public OutputStream createClassFile(String name) throws IOException {
- return NO_OP_STREAM;
- }
-
- public PrintWriter createTextFile(Filer.Location loc, String pkg, File relPath, String charsetName)
- throws IOException {
- return NO_OP_WRITER;
- }
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/ClasspathUtil.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/ClasspathUtil.java
deleted file mode 100644
index 2a656e7d18..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/ClasspathUtil.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.generatedfile;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-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;
-
-/**
- * Utilities to ensure the generated source folder is (or is not) on the
- * Java build path as appropriate.
- */
-public class ClasspathUtil {
-
- /**
- * Given a java project, this function will determine if the specified
- * folder is a source folder of the java project.
- *
- * @param jp - the java project
- * @param folder - the folder that you want to see if it is a classpath entry for the java project
- * @return the IClasspathEntry corresponding to folder, or null if none was found.
- * @throws JavaModelException
- */
- public static IClasspathEntry findProjectSourcePath( IJavaProject jp, IFolder folder )
- throws JavaModelException
- {
- IClasspathEntry[] cp = jp.getRawClasspath();
- IClasspathEntry searchingFor =
- JavaCore.newSourceEntry(folder.getFullPath());
- IPath searchingForPath = searchingFor.getPath();
- for (int i = 0; i < cp.length; i++)
- {
- if (cp[i].getPath().equals( searchingForPath ))
- return cp[i];
- }
- return null;
- }
-
- /**
- * Does the classpath contain the specified path?
- * @param jp if non-null, get this project's classpath and ignore cp
- * @param cp if non-null, use this classpath and ignore jp
- * @param path the entry to look for on the classpath
- * @param progressMonitor
- * @return true if classpath contains the path specified.
- * @throws JavaModelException
- */
- public static boolean doesClasspathContainEntry(
- IJavaProject jp,
- IClasspathEntry[] cp,
- IPath path,
- IProgressMonitor progressMonitor)
- throws JavaModelException
- {
- if( cp == null )
- cp = jp.getRawClasspath();
- for (int i = 0; i < cp.length; i++)
- {
- if (cp[i].getPath().equals( path ))
- {
- return true;
- }
- }
- return false;
- }
-
- /**
- * removes a classpath entry from the project
- */
- public static void removeFromProjectClasspath( IJavaProject jp, IFolder folder, IProgressMonitor progressMonitor )
- throws JavaModelException
- {
- IClasspathEntry[] cp = jp.getRawClasspath();
- IPath workspaceRelativePath = folder.getFullPath();
- boolean found = doesClasspathContainEntry(jp, cp, workspaceRelativePath, progressMonitor);
-
- if( found ){
- IPath projectRelativePath = folder.getProjectRelativePath().addTrailingSeparator();
-
- // remove entries that are for the specified folder, account for
- // multiple entries, and clean up any exclusion entries to the
- // folder being removed.
- int j = 0;
- for ( int i=0; i<cp.length; i++ )
- {
- if (! cp[i].getPath().equals( workspaceRelativePath ) )
- {
-
- // see if we added the generated source dir as an exclusion pattern to some other entry
- IPath[] oldExclusions = cp[i].getExclusionPatterns();
- int m = 0;
- for ( int k = 0; k < oldExclusions.length; k++ )
- {
- if ( !oldExclusions[k].equals( projectRelativePath ) )
- {
- oldExclusions[m] = oldExclusions[k];
- m++;
- }
- }
-
- if ( oldExclusions.length == m )
- {
- // no exclusions changed, so we do't need to create a new entry
- cp[j] = cp[i];
- }
- else
- {
- // we've removed some exclusion, so create a new entry
- IPath[] newExclusions = new IPath[ m ];
- System.arraycopy( oldExclusions, 0, newExclusions, 0, m );
- cp[j] = JavaCore.newSourceEntry( cp[i].getPath(), cp[i].getInclusionPatterns(), newExclusions, cp[i].getOutputLocation(), cp[i].getExtraAttributes() );
- }
-
- j++;
- }
- }
-
- // now copy updated classpath entries into new array
- IClasspathEntry[] newCp = new IClasspathEntry[ j ];
- System.arraycopy( cp, 0, newCp, 0, j);
- jp.setRawClasspath( newCp, progressMonitor );
-
- if( AptPlugin.DEBUG ){
- AptPlugin.trace("removed " + workspaceRelativePath + " from classpath"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-
- /**
- * returns true if we updated the classpath, false otherwise
- */
- public static boolean updateProjectClasspath( IJavaProject jp, IFolder folder, IProgressMonitor progressMonitor )
- throws JavaModelException
- {
- IClasspathEntry[] cp = jp.getRawClasspath();
- IPath path = folder.getFullPath();
- boolean found = ClasspathUtil.doesClasspathContainEntry(jp, cp, path, progressMonitor);
-
- if (!found)
- {
- // update exclusion patterns
- ArrayList<IPath> exclusions = new ArrayList<IPath>();
- for ( int i = 0; i< cp.length; i++ )
- {
- if ( cp[i].getPath().isPrefixOf( path ) )
- {
- // exclusion patterns must be project-relative paths, and must end with a "/"
- IPath projectRelativePath = folder.getProjectRelativePath().addTrailingSeparator();
-
- // path is contained in an existing source path, so update existing paths's exclusion patterns
- IPath[] oldExclusions = cp[i].getExclusionPatterns();
-
- // don't add if exclusion pattern already contains src dir
- boolean add = true;
- for ( int j = 0; j < oldExclusions.length; j++ )
- if ( oldExclusions[j].equals( projectRelativePath ) )
- add = false;
-
- if ( add )
- {
- IPath[] newExclusions;
- if ( cp[i].getExclusionPatterns() == null )
- newExclusions = new IPath[1];
- else
- {
- newExclusions = new IPath[ oldExclusions.length + 1 ];
- System.arraycopy( oldExclusions, 0, newExclusions, 0, oldExclusions.length );
- }
- newExclusions[ newExclusions.length - 1 ] = projectRelativePath;
- cp[i] = JavaCore.newSourceEntry(cp[i].getPath(), cp[i].getInclusionPatterns(), newExclusions, cp[i].getOutputLocation(), cp[i].getExtraAttributes());
- }
-
- }
- else if ( path.isPrefixOf( cp[i].getPath() ))
- {
- // new source path contains an existing source path, so add an exclusion pattern for it
- exclusions.add( cp[i].getPath().addTrailingSeparator() );
- }
- }
-
- IPath[] exclusionPatterns = exclusions.toArray( new IPath[exclusions.size()] );
- final IClasspathAttribute[] attrs = new IClasspathAttribute[1];
- attrs[0] = JavaCore.newClasspathAttribute(IClasspathAttribute.OPTIONAL, Boolean.toString(true));
- IClasspathEntry generatedSourceClasspathEntry =
- JavaCore.newSourceEntry(folder.getFullPath(), new IPath[] {}, exclusionPatterns, null, attrs );
-
- IClasspathEntry[] newCp = new IClasspathEntry[cp.length + 1];
- System.arraycopy(cp, 0, newCp, 0, cp.length);
- newCp[newCp.length - 1] = generatedSourceClasspathEntry;
-
- jp.setRawClasspath(newCp, progressMonitor );
- }
-
- // return true if we updated the project's classpath entries
- return !found;
- }
-
- /**
- * All methods static. Clients should not instantiate this class.
- */
- private ClasspathUtil() {
- }
-
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/CompilationUnitHelper.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/CompilationUnitHelper.java
deleted file mode 100644
index 6d428d5a3f..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/CompilationUnitHelper.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package org.eclipse.jdt.apt.core.internal.generatedfile;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.WorkingCopyOwner;
-
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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 - refactored, and reinstated reconcile-time type gen
- *******************************************************************************/
-
-/**
- * Helper utilities to create, modify, save, and discard compilation units and their
- * working copies. Basically, calls to ICompilationUnit.
- * These are encapsulated here not so much because the code is complex, but rather to
- * make it very clear what the algorithms are (as opposed to distributing these calls
- * throughout other code). All calls to the Java Model involved in generating types
- * should go through methods here.
- */
-public class CompilationUnitHelper
-{
-
- /**
- * Update the contents of a working copy and commit it to disk.
- * @throws JavaModelException
- */
- public void commitNewContents(ICompilationUnit wc, String contents, IProgressMonitor monitor) throws JavaModelException {
- IBuffer b = wc.getBuffer();
- b.setContents(contents);
- wc.commitWorkingCopy(true, monitor);
- }
-
- /**
- * Get an in-memory working copy. This does not create the type or package on disk.
- * <p>
- * The methods called by this routine are all read-only with respect to the resource
- * tree, so they do not require taking any scheduling locks. Therefore we think
- * it's safe to call this method within a synchronized block.
- * @param typeName the fully qualified type name, e.g., "foo.Bar"
- * @param root the package fragment root within which the type will be created
- * @return a working copy that is ready to be modified. The working copy may not
- * yet be backed by a file on disk.
- */
- public ICompilationUnit getWorkingCopy(String typeName, IPackageFragmentRoot root)
- {
- String[] names = parseTypeName(typeName);
- String pkgName = names[0];
- String fname = names[1];
-
- IPackageFragment pkgFragment;
- ICompilationUnit workingCopy = null;
- try {
- pkgFragment = root.getPackageFragment(pkgName );
- workingCopy = pkgFragment.getCompilationUnit(fname);
- workingCopy.becomeWorkingCopy(null);
- } catch (JavaModelException e) {
- AptPlugin.log(e, "Unable to become working copy: " + typeName); //$NON-NLS-1$
- return null;
- }
- if (AptPlugin.DEBUG_GFM) AptPlugin.trace(
- "Created working copy: root = " + //$NON-NLS-1$
- root + ",\n\tfragment = " + pkgFragment + ",\n\twc = " + workingCopy); //$NON-NLS-1$ //$NON-NLS-2$
- return workingCopy;
- }
-
- /**
- * Discard a working copy, ie, remove it from memory. Each call to
- * {@link #getWorkingCopy(String typeName, IPackageFragmentRoot root)}
- * must be balanced with exactly one call to this method.
- */
- public void discardWorkingCopy(ICompilationUnit wc)
- {
- if (null == wc)
- return;
- if (AptPlugin.DEBUG_GFM) AptPlugin.trace(
- "discarding working copy: " + wc.getElementName()); //$NON-NLS-1$
- try {
- wc.discardWorkingCopy();
- } catch (JavaModelException e) {
- AptPlugin.log(e, "Unable to discard working copy: " + wc.getElementName()); //$NON-NLS-1$
- }
- }
-
- /**
- * Update the contents of an existing working copy.
- *
- * @param contents
- * the new text.
- * @param reconcile
- * true if the changes should be reconciled.
- * @return true if the contents were modified as a result.
- */
- public boolean updateWorkingCopyContents(String contents, ICompilationUnit wc,
- WorkingCopyOwner wcOwner, boolean reconcile)
- {
- boolean modified = true;
- IBuffer b = null;
- try {
- b = wc.getBuffer();
- } catch (JavaModelException e) {
- AptPlugin.log(e, "Unable to get buffer for working copy: " + wc.getElementName()); //$NON-NLS-1$
- return false;
- }
- // We need to do this diff to tell our caller whether this is a modification.
- // It's not obvious to me that the caller actually needs to know, so
- // this might just be a needless performance sink. - WHarley 11/06
- modified = !contents.equals(b.getContents());
-
- b.setContents(contents);
- if (AptPlugin.DEBUG_GFM_MAPS) AptPlugin.trace(
- "updated contents of working copy: " //$NON-NLS-1$
- + wc.getElementName() + " modified = " + modified); //$NON-NLS-1$
- if (reconcile && modified) {
- try {
- wc.reconcile(ICompilationUnit.NO_AST, true, wcOwner, null);
- } catch (JavaModelException e) {
- AptPlugin.log(e, "Unable to reconcile generated type: " + wc.getElementName()); //$NON-NLS-1$
- }
- }
- return modified;
- }
-
- /**
- * Create a package fragment on disk.
- * @param pkgName the name of the package.
- * @param root the package fragment root under which to place the package.
- * @param progressMonitor
- * @return a package fragment, or null if there was an error.
- */
- public IPackageFragment createPackageFragment(String pkgName, IPackageFragmentRoot root, IProgressMonitor progressMonitor) {
- IPackageFragment pkgFrag = null;
- try {
- pkgFrag = root.createPackageFragment(pkgName, true,
- progressMonitor);
- } catch (JavaModelException e) {
- AptPlugin.log(e, "Unable to create package fragment for package " + pkgName); //$NON-NLS-1$
- }
-
- return pkgFrag;
- }
-
- /**
- * Given a fully qualified type name, generate the package name and the local filename
- * including the extension. For instance, type name <code>foo.bar.Baz</code> is
- * turned into package <code>foo.bar</code> and filename <code>Baz.java</code>.
- *
- * @param qualifiedName
- * a fully qualified type name
- * @return a String array containing {package name, filename}
- */
- private String[] parseTypeName(String qualifiedName) {
- String[] names = new String[2];
- String pkgName;
- String fname;
- int idx = qualifiedName.lastIndexOf( '.' );
- if ( idx > 0 )
- {
- pkgName = qualifiedName.substring( 0, idx );
- fname =
- qualifiedName.substring(idx + 1, qualifiedName.length()) + ".java"; //$NON-NLS-1$
- }
- else
- {
- pkgName = ""; //$NON-NLS-1$
- fname = qualifiedName + ".java"; //$NON-NLS-1$
- }
- names[0] = pkgName;
- names[1] = fname;
- return names;
- }
-
-}
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 bd9ebae6fb..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/FileGenerationResult.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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;
-
-/**
- * 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 9bafe5df27..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileManager.java
+++ /dev/null
@@ -1,1531 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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
- * wharley@bea.com - refactored, and reinstated reconcile-time type gen
- *******************************************************************************/
-
-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.util.ArrayList;
-import java.util.Collection;
-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.regex.Pattern;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.AptProject;
-import org.eclipse.jdt.apt.core.internal.Messages;
-import org.eclipse.jdt.apt.core.internal.util.FileSystemUtil;
-import org.eclipse.jdt.apt.core.internal.util.ManyToMany;
-import org.eclipse.jdt.core.ElementChangedEvent;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.WorkingCopyOwner;
-
-/**
- * This class is used for managing generated files; in particular, keeping track of
- * dependencies so that no-longer-generated files can be deleted, and managing the
- * lifecycle of working copies in memory.
- * <p>
- * During build, a generated file may be a "type", in the sense of a generated Java source
- * file, or it may be a generated class file or an arbitrary resource (such as an XML
- * file). During reconcile, it is only possible to generate Java source files. Also,
- * during reconcile, it is not possible to write to disk or delete files from disk; all
- * operations take place in memory only, using "working copies" provided by the Java
- * Model.
- *
- * <h2>DATA STRUCTURES</h2>
- * <code>_buildDeps</code> is a many-to-many map that tracks which parent files
- * are responsible for which generated files. Entries in this map are created when files
- * are created during builds. This map is serialized so that dependencies can be reloaded
- * when a project is opened without having to do a full build.
- * <p>
- * When types are generated during reconcile, they are not actually laid down on disk (ie
- * we do not commit the working copy). However, the file handles are still used as keys
- * into the various maps in this case.
- * <p>
- * <code>_reconcileDeps</code> is the reconcile-time analogue of
- * <code>_buildDeps</code>. This map is not serialized.
- * <p>
- * Given a working copy, it is easy to determine the IFile that it models by calling
- * <code>ICompilationUnit.getResource()</code>. To go the other way, we store maps
- * of IFile to ICompilationUnit. Working copies that represent generated types are
- * stored in <code>_reconcileGenTypes</code>; working copies that represent deleted types
- * are stored in <code>_hiddenBuiltTypes</code>.
- * <p>
- * List invariants: for the many-to-many maps, every forward entry must correspond to a
- * reverse entry; this is managed (and verified) by the ManyToMany map code. Also, every
- * entry in the <code>_reconcileGenTypes</code> list must correspond to an entry in the
- * <code>_reconcileDeps</code> map. There can be no overlap between these
- * entries and the <code>_hiddenBuiltTypes</code> map. Whenever a working copy is placed
- * into this overall collection, it must have <code>becomeWorkingCopy()</code> called on
- * it; whenever it is removed, it must have <code>discardWorkingCopy()</code> called on
- * it.
- *
- * <h2>SYNCHRONIZATION NOTES</h2>
- * Synchronization around the GeneratedFileManager's maps uses the GeneratedFileMap
- * instance's monitor. When acquiring this monitor, DO NOT PERFORM ANY OPERATIONS THAT
- * TAKE ANY OTHER LOCKS (e.g., java model operations, or file system operations like
- * creating or deleting a file or folder). If you do this, then the code is subject to
- * deadlock situations. For example, a resource-changed listener may take a resource lock
- * and then call into the GeneratedFileManager for clean-up, where your code could reverse
- * the order in which the locks are taken. This is bad, so be careful.
- *
- * <h2>RECONCILE vs. BUILD</h2>
- * Reconciles are based on in-memory type information, i.e., working copies. Builds are
- * based on files on disk. At any given moment, a build thread and any number of reconcile
- * threads may be executing. All share the same GeneratedFileManager object, but each
- * thread will have a separate BuildEnvironment. Multiple files are built in a loop, with
- * files generated on one round being compiled (and possibly generating new files) on the
- * next; only one file at a time is reconciled, but when a file is generated during
- * reconcile it will invoke a recursive call to reconcile, with a unique
- * ReconcileBuildEnvironment.
- * <p>
- * What is the relationship between reconcile-time dependency information and build-time
- * dependency information? In general, there is one set of dependency maps for build time
- * information and a separate set for reconcile time information (with the latter being
- * shared by all reconcile threads). Reconciles do not write to build-time information,
- * nor do they write to the disk. Builds, however, may have to interact with
- * reconcile-time info. The tricky bit is that a change to a file "B.java" in the
- * foreground editor window might affect the way that background file "A.java" generates
- * "AGen.java". That is, editing B.java is in effect making A.java dirty; but the Eclipse
- * build system has no way of knowing that, so A will not be reconciled.
- * <p>
- * The nearest Eclipse analogy is to refactoring, where a refactor operation in the
- * foreground editor can modify background files; Eclipse solves this problem by requiring
- * that all files be saved before and after a refactoring operation, but that solution is
- * not practical for the simple case of making edits to a file that might happen to be an
- * annotation processing dependency. The JSR269 API works around this problem by letting
- * processors state these out-of-band dependencies explicitly, but com.sun.mirror.apt has
- * no such mechanism.
- * <p>
- * The approach taken here is that when a build is performed, we discard the working
- * copies of any files that are open in editors but that are not dirty (meaning the file
- * on disk is the same as the version in the editor). This still means that if file A is
- * dirty, AGen will not be updated even when B is edited; thus, making a breaking change
- * to A and then making a change to B that is supposed to fix the break will not work.
- */
-public class GeneratedFileManager
-{
-
- /**
- * Access to the package fragment root for generated types.
- * Encapsulated into this class so that synchronization can be guaranteed.
- */
- private class GeneratedPackageFragmentRoot {
-
- // The name and root are returned as a single object to ensure synchronization.
- final class NameAndRoot {
- final String name;
- final IPackageFragmentRoot root;
- NameAndRoot(String name, IPackageFragmentRoot root) {
- this.name = name;
- this.root = root;
- }
- }
-
- private IPackageFragmentRoot _root = null;
-
- private String _folderName = null;
-
- /**
- * Get the package fragment root and the name of the folder
- * it corresponds to. If the folder is not on the classpath,
- * the root will be null.
- */
- public synchronized NameAndRoot get() {
- return new NameAndRoot(_folderName, _root);
- }
-
- /**
- * Force the package fragment root and folder name to be recalculated.
- * Check whether the new folder is actually on the classpath; if not,
- * set root to be null.
- */
- public synchronized void set() {
- IFolder genFolder = _gsfm.getFolder();
- _root = null;
- if (_jProject.isOnClasspath(genFolder)) {
- _root = _jProject.getPackageFragmentRoot(genFolder);
- }
- _folderName = genFolder.getProjectRelativePath().toString();
- }
- }
-
- /**
- * If true, when buffer contents are updated during a reconcile, reconcile() will
- * be called on the new contents. This is not necessary to update the open editor,
- * but if the generated file is itself a parent file, it will cause recursive
- * type generation.
- */
- private static final boolean RECURSIVE_RECONCILE = true;
-
- /**
- * Disable type generation during reconcile. In the past, reconcile-time type
- * generation caused deadlocks; see (BEA internal) Radar bug #238684. As of
- * Eclipse 3.3 this should work.
- */
- private static final boolean GENERATE_TYPE_DURING_RECONCILE = true;
-
- /**
- * If true, the integrity of internal data structures will be verified after various
- * operations are performed.
- */
- private static final boolean ENABLE_INTEGRITY_CHECKS = true;
-
- /**
- * A singleton instance of CompilationUnitHelper, which encapsulates operations on working copies.
- */
- private static final CompilationUnitHelper _CUHELPER = new CompilationUnitHelper();
-
- /**
- * The regex delimiter used to parse package names.
- */
- private static final Pattern _PACKAGE_DELIMITER = Pattern.compile("\\."); //$NON-NLS-1$
-
- static {
- // register element-changed listener to clean up working copies
- int mask = ElementChangedEvent.POST_CHANGE;
- JavaCore.addElementChangedListener(new WorkingCopyCleanupListener(), mask);
- }
-
- /**
- * Many-to-many map from parent files to files generated during build. These files all
- * exist on disk. This map is used to keep track of dependencies during build, and is
- * read-only during reconcile. This map is serialized.
- */
- private final GeneratedFileMap _buildDeps;
-
- /**
- * Set of files that have been generated during build by processors that
- * support reconcile-time type generation. Files in this set are expected to
- * be generated during reconcile, and therefore will be deleted after a reconcile
- * if they're not generated. This is different from the value set of
- * _reconcileDeps in that the contents of this set are known to have been
- * generated during a build.
- */
- private final Set<IFile> _clearDuringReconcile;
-
- /**
- * Many-to-many map from parent files to files generated during reconcile.
- * Both the keys and the values may correspond to files that exist on disk or only in
- * memory. This map is used to keep track of dependencies created during reconcile,
- * and is not accessed during build. This map is not serialized.
- */
- private final ManyToMany<IFile, IFile> _reconcileDeps;
-
- /**
- * Many-to-many map from parent files to files that are generated in build but not
- * during reconcile. We need this so we can tell parents that were never reconciled
- * (meaning their generated children on disk are valid) from parents that have been
- * edited so that they no longer generate their children (meaning the generated
- * children may need to be removed from the typesystem). This map is not serialized.
- */
- private final ManyToMany<IFile, IFile> _reconcileNonDeps;
-
- /**
- * Map of types that were generated during build but are being hidden (removed from
- * the reconcile-time typesystem) by blank WorkingCopies. These are tracked separately
- * from regular working copies for the sake of clarity. The keys all correspond to
- * files that exist on disk; if they didn't, there would be no reason for an entry.
- * <p>
- * This is a map of file to working copy of that file, <strong>NOT</strong> a map of
- * parents to generated children. The keys in this map are a subset of the values in
- * {@link #_reconcileNonDeps}. This map exists so that given a file, we can find the
- * working copy that represents it.
- * <p>
- * Every working copy exists either in this map or in {@link #_hiddenBuiltTypes}, but
- * not in both. These maps exist to track the lifecycle of a working copy. When a new
- * working copy is created, {@link ICompilationUnit#becomeWorkingCopy()} is called. If
- * an entry is removed from this map without being added to the other,
- * {@link ICompilationUnit#discardWorkingCopy()} must be called.
- *
- * @see #_reconcileGenTypes
- */
- private final Map<IFile, ICompilationUnit> _hiddenBuiltTypes;
-
- /**
- * Cache of working copies (in-memory types created or modified during reconcile).
- * Includes working copies that represent changes to types that were generated during
- * a build and thus exist on disk, as well as working copies for types newly generated
- * during reconcile that thus do not exist on disk.
- * <p>
- * This is a map of file to working copy of that file, <strong>NOT</strong> a map of
- * parents to generated children. There is a 1:1 correspondence between keys in this
- * map and values in {@link #_reconcileDeps}. This map exists so that given a file,
- * we can find the working copy that represents it.
- * <p>
- * Every working copy exists either in this map or in {@link #_hiddenBuiltTypes}, but
- * not in both. These maps exist to track the lifecycle of a working copy. When a new
- * working copy is created, {@link ICompilationUnit#becomeWorkingCopy()} is called. If
- * an entry is removed from this map without being added to the other,
- * {@link ICompilationUnit#discardWorkingCopy()} must be called.
- *
- * @see #_hiddenBuiltTypes
- */
- private final Map<IFile, ICompilationUnit> _reconcileGenTypes;
-
- /**
- * Access to the package fragment root for generated types. Encapsulated into a
- * helper class in order to ensure synchronization.
- */
- private final GeneratedPackageFragmentRoot _generatedPackageFragmentRoot;
-
- private final IJavaProject _jProject;
-
- private final GeneratedSourceFolderManager _gsfm;
-
- /**
- * Initialized when the build starts, and accessed during type generation.
- * This has the same lifecycle as _generatedPackageFragmentRoot.
- * If there is a configuration problem, this may be set to <code>true</code>
- * during generation of the first type to prevent any other types from
- * being generated.
- */
- private boolean _skipTypeGeneration = false;
-
- /**
- * Clients should not instantiate this class; it is created only by {@link AptProject}.
- */
- public GeneratedFileManager(final AptProject aptProject, final GeneratedSourceFolderManager gsfm) {
- _jProject = aptProject.getJavaProject();
- _gsfm = gsfm;
- _buildDeps = new GeneratedFileMap(_jProject.getProject());
- _clearDuringReconcile = new HashSet<IFile>();
- _reconcileDeps = new ManyToMany<IFile, IFile>();
- _reconcileNonDeps = new ManyToMany<IFile, IFile>();
- _hiddenBuiltTypes = new HashMap<IFile, ICompilationUnit>();
- _reconcileGenTypes = new HashMap<IFile, ICompilationUnit>();
- _generatedPackageFragmentRoot = new GeneratedPackageFragmentRoot();
- }
-
- /**
- * Add a non-Java-source entry to the build-time dependency maps. Java source files are added to
- * the maps when they are generated, as by {@link #generateFileDuringBuild}, but files of other
- * types must be added explicitly by the code that creates the file.
- * <p>
- * This method must only be called during build, not reconcile. It is not possible to add
- * non-Java-source files during reconcile.
- */
- public void addGeneratedFileDependency(Collection<IFile> parentFiles, IFile generatedFile)
- {
- addBuiltFileToMaps(parentFiles, generatedFile, false);
- }
-
- /**
- * Called at the start of build in order to cache our package fragment root
- */
- public void compilationStarted()
- {
- try {
- // clear out any generated source folder config markers
- IMarker[] markers = _jProject.getProject().findMarkers(AptPlugin.APT_CONFIG_PROBLEM_MARKER, true,
- IResource.DEPTH_INFINITE);
- if (markers != null) {
- for (IMarker marker : markers)
- marker.delete();
- }
- } catch (CoreException e) {
- AptPlugin.log(e, "Unable to delete configuration marker."); //$NON-NLS-1$
- }
- _skipTypeGeneration = false;
- _gsfm.ensureFolderExists();
- _generatedPackageFragmentRoot.set();
-
- }
-
- /**
- * This method should only be used for testing purposes to ensure that maps contain
- * entries when we expect them to.
- */
- public synchronized boolean containsWorkingCopyMapEntriesForParent(IFile f)
- {
- return _reconcileDeps.containsKey(f);
- }
-
- /**
- * Invoked at the end of a build to delete files that are no longer parented by
- * <code>parentFile</code>. Files that are multiply parented will not actually be
- * deleted, but the association from this parent to the generated file will be
- * removed, so that when the last parent ceases to generate a given file it will be
- * deleted at that time.
- *
- * @param newlyGeneratedFiles
- * the set of files generated by <code>parentFile</code> on the most
- * recent compilation; these files will be spared deletion.
- * @return the set of source files that were actually deleted, or an empty set.
- * The returned set does not include non-source (e.g. text or xml) files.
- */
- public Set<IFile> deleteObsoleteFilesAfterBuild(IFile parentFile, Set<IFile> newlyGeneratedFiles)
- {
- Set<IFile> deleted;
- List<ICompilationUnit> toDiscard = new ArrayList<ICompilationUnit>();
- Set<IFile> toReport = new HashSet<IFile>();
- deleted = computeObsoleteFiles(parentFile, newlyGeneratedFiles, toDiscard, toReport);
-
- for (IFile toDelete : deleted) {
- if (AptPlugin.DEBUG_GFM) AptPlugin.trace(
- "deleted obsolete file during build: " + toDelete); //$NON-NLS-1$
- deletePhysicalFile(toDelete);
- }
-
- // Discard blank WCs *after* we delete the corresponding files:
- // we don't want the type to become briefly visible to a reconcile thread.
- for (ICompilationUnit wcToDiscard : toDiscard) {
- _CUHELPER.discardWorkingCopy(wcToDiscard);
- }
-
- return toReport;
- }
-
- /**
- * Invoked at the end of a reconcile to get rid of any files that are no longer being
- * generated. If the file existed on disk, we can't actually delete it, we can only
- * create a blank WorkingCopy to hide it. Therefore, we can only remove Java source
- * files, not arbitrary files. If the file was generated during reconcile and exists
- * only in memory, we can actually remove it altogether.
- * <p>
- * Only some processors specify (via {@link org.eclipse.jdt.apt.core.util.AptPreferenceConstants#RTTG_ENABLED_OPTION})
- * that they support type generation during reconcile. We need to remove obsolete
- * files generated by those processors, but preserve files generated by
- * other processors.
- *
- * @param parentWC
- * the WorkingCopy being reconciled
- * @param newlyGeneratedFiles
- * the complete list of files generated during the reconcile (including
- * files that exist on disk as well as files that only exist in memory)
- */
- public void deleteObsoleteTypesAfterReconcile(ICompilationUnit parentWC, Set<IFile> newlyGeneratedFiles)
- {
- IFile parentFile = (IFile) parentWC.getResource();
-
- List<ICompilationUnit> toSetBlank = new ArrayList<ICompilationUnit>();
- List<ICompilationUnit> toDiscard = new ArrayList<ICompilationUnit>();
- computeObsoleteReconcileTypes(parentFile, newlyGeneratedFiles, _CUHELPER, toSetBlank, toDiscard);
-
- for (ICompilationUnit wcToDiscard : toDiscard) {
- if (AptPlugin.DEBUG_GFM) AptPlugin.trace(
- "discarded obsolete working copy during reconcile: " + wcToDiscard.getElementName()); //$NON-NLS-1$
- _CUHELPER.discardWorkingCopy(wcToDiscard);
- }
-
- WorkingCopyOwner workingCopyOwner = parentWC.getOwner();
- for (ICompilationUnit wcToSetBlank : toSetBlank) {
- if (AptPlugin.DEBUG_GFM) AptPlugin.trace(
- "hiding file with blank working copy during reconcile: " + wcToSetBlank.getElementName()); //$NON-NLS-1$
- _CUHELPER.updateWorkingCopyContents("", wcToSetBlank, workingCopyOwner, RECURSIVE_RECONCILE); //$NON-NLS-1$
- }
-
- assert checkIntegrity();
- }
-
- /**
- * Called by the resource change listener when a file is deleted (eg by the user).
- * Removes any files parented by this file, and removes the file from dependency maps
- * if it is generated. This does not remove working copies parented by the file; that
- * will happen when the working copy corresponding to the parent file is discarded.
- *
- * @param f
- */
- public void fileDeleted(IFile f)
- {
- List<IFile> toDelete = removeFileFromBuildMaps(f);
-
- for (IFile fileToDelete : toDelete) {
- deletePhysicalFile(fileToDelete);
- }
-
- }
-
- /**
- * Invoked when a file is generated during a build. The generated file and
- * intermediate directories will be created if they don't exist. This method takes
- * file-system locks, and assumes that the calling method has at some point acquired a
- * workspace-level resource lock.
- *
- * @param parentFiles
- * the parent or parents of the type being generated. May be empty, and/or
- * may contain null entries, but must not itself be null.
- * @param typeName
- * the dot-separated java type name of the type being generated
- * @param contents
- * the java code contents of the new type .
- * @param clearDuringReconcile
- * if true, this file should be removed after any reconcile in which it was not
- * regenerated. This typically is used when the file is being generated by a
- * processor that supports {@linkplain org.eclipse.jdt.apt.core.util.AptPreferenceConstants#RTTG_ENABLED_OPTION
- * reconcile-time type generation}.
- * @param progressMonitor
- * a progress monitor. This may be null.
- * @return - the newly created IFile along with whether it was modified
- * @throws CoreException
- */
- public FileGenerationResult generateFileDuringBuild(Collection<IFile> parentFiles, String typeName, String contents,
- boolean clearDuringReconcile, IProgressMonitor progressMonitor) throws CoreException
- {
- if (_skipTypeGeneration)
- return null;
-
- GeneratedPackageFragmentRoot.NameAndRoot gpfr = _generatedPackageFragmentRoot.get();
- IPackageFragmentRoot root = gpfr.root;
- if (root == null) {
- // If the generated package fragment root wasn't set, then our classpath
- // is incorrect. Add a marker and return. We do this here, rather than in
- // the set() method, because if they're not going to generate any types
- // then it doesn't matter that the classpath is wrong.
- String message = Messages.bind(Messages.GeneratedFileManager_missing_classpath_entry,
- new String[] { gpfr.name });
- IMarker marker = _jProject.getProject().createMarker(AptPlugin.APT_CONFIG_PROBLEM_MARKER);
- marker.setAttributes(new String[] { IMarker.MESSAGE, IMarker.SEVERITY }, new Object[] { message,
- IMarker.SEVERITY_ERROR });
- // disable any future type generation
- _skipTypeGeneration = true;
- return null;
- }
-
- // Do the new contents differ from what is already on disk?
- // We need to know so we can tell the caller whether this is a modification.
- IFile file = getIFileForTypeName(typeName);
- boolean contentsDiffer = compareFileContents(contents, file);
-
- try {
- if (contentsDiffer) {
- final String[] names = parseTypeName(typeName);
- final String pkgName = names[0];
- final String cuName = names[1];
-
- // Get a list of the folders that will have to be created for this package to exist
- IFolder genSrcFolder = (IFolder) root.getResource();
- final Set<IFolder> newFolders = computeNewPackageFolders(pkgName, genSrcFolder);
-
- // Create the package fragment in the Java Model. This creates all needed parent folders.
- IPackageFragment pkgFrag = _CUHELPER.createPackageFragment(pkgName, root, progressMonitor);
-
- // Mark all newly created folders (but not pre-existing ones) as derived.
- for (IContainer folder : newFolders) {
- try {
- folder.setDerived(true);
- } catch (CoreException e) {
- AptPlugin.logWarning(e, "Unable to mark generated type folder as derived: " + folder.getName()); //$NON-NLS-1$
- break;
- }
- }
-
- saveCompilationUnit(pkgFrag, cuName, contents, progressMonitor);
- }
-
- // during a batch build, parentFile will be null.
- // Only keep track of ownership in iterative builds
- addBuiltFileToMaps(parentFiles, file, true);
- if (clearDuringReconcile) {
- _clearDuringReconcile.add(file);
- }
-
- // Mark the file as derived. Note that certain user actions may have
- // deleted this file before we get here, so if the file doesn't
- // exist, marking it derived throws a ResourceException.
- if (file.exists()) {
- file.setDerived(true);
- }
- // We used to also make the file read-only. This is a bad idea,
- // as refactorings then fail in the future, which is worse
- // than allowing a user to modify a generated file.
-
- assert checkIntegrity();
-
- return new FileGenerationResult(file, contentsDiffer);
- } catch (CoreException e) {
- AptPlugin.log(e, "Unable to generate type " + typeName); //$NON-NLS-1$
- return null;
- }
- }
-
- /**
- * This function generates a type "in-memory" by creating or updating a working copy
- * with the specified contents. The generated-source folder must be configured
- * correctly for this to work. This method takes no locks, so it is safe to call when
- * holding fine-grained resource locks (e.g., during some reconcile paths). Since this
- * only works on an in-memory working copy of the type, the IFile for the generated
- * type might not exist on disk. Likewise, the corresponding package directories of
- * type-name might not exist on disk.
- *
- * TODO: figure out how to create a working copy with a client-specified character set
- *
- * @param parentCompilationUnit the parent compilation unit.
- * @param typeName the dot-separated java type name for the new type
- * @param contents the contents of the new type
- * @return The FileGenerationResult. This will return null if the generated source
- * folder is not configured, or if there is some other error during type
- * generation.
- *
- */
- public FileGenerationResult generateFileDuringReconcile(ICompilationUnit parentCompilationUnit, String typeName,
- String contents) throws CoreException
- {
- if (!GENERATE_TYPE_DURING_RECONCILE)
- return null;
-
- IFile parentFile = (IFile) parentCompilationUnit.getResource();
-
- ICompilationUnit workingCopy = getWorkingCopyForReconcile(parentFile, typeName, _CUHELPER);
-
- // Update its contents and recursively reconcile
- boolean modified = _CUHELPER.updateWorkingCopyContents(
- contents, workingCopy, parentCompilationUnit.getOwner(), RECURSIVE_RECONCILE);
- if (AptPlugin.DEBUG_GFM) {
- if (modified)
- AptPlugin.trace("working copy modified during reconcile: " + typeName); //$NON-NLS-1$
- else
- AptPlugin.trace("working copy unmodified during reconcile: " + typeName); //$NON-NLS-1$
- }
-
- IFile generatedFile = (IFile) workingCopy.getResource();
- return new FileGenerationResult(generatedFile, modified);
- }
-
- /**
- * @param parent -
- * the parent file that you want to get generated files for
- * @return Set of IFile instances that are the files known to be generated by this
- * parent, or an empty collection if there are none.
- *
- * @see #isParentFile(IFile)
- * @see #isGeneratedFile(IFile)
- */
- public synchronized Set<IFile> getGeneratedFilesForParent(IFile parent)
- {
- return _buildDeps.getValues(parent);
- }
-
- /**
- * returns true if the specified file is a generated file (i.e., it has one or more
- * parent files)
- *
- * @param f
- * the file in question
- * @return true
- */
- public synchronized boolean isGeneratedFile(IFile f)
- {
- return _buildDeps.containsValue(f);
- }
-
-
-
- /**
- * returns true if the specified file is a parent file (i.e., it has one or more
- * generated files)
- *
- * @param f -
- * the file in question
- * @return true if the file is a parent, false otherwise
- *
- * @see #getGeneratedFilesForParent(IFile)
- * @see #isGeneratedFile(IFile)
- */
- public synchronized boolean isParentFile(IFile f)
- {
- return _buildDeps.containsKey(f);
- }
-
- /**
- * Perform the actions necessary to respond to a clean.
- */
- public void projectCleaned() {
- Iterable<ICompilationUnit> toDiscard = computeClean();
- for (ICompilationUnit wc : toDiscard) {
- _CUHELPER.discardWorkingCopy(wc);
- }
- if (AptPlugin.DEBUG_GFM_MAPS) AptPlugin.trace(
- "cleared build file dependencies"); //$NON-NLS-1$
- }
-
- /**
- * Perform the actions necessary to respond to a project being closed.
- * Throw out the reconcile-time information and working copies; throw
- * out the build-time dependency information but leave its serialized
- * version on disk in case the project is re-opened.
- */
- public void projectClosed()
- {
- if (AptPlugin.DEBUG_GFM) AptPlugin.trace("discarding working copy state"); //$NON-NLS-1$
- List<ICompilationUnit> toDiscard;
- toDiscard = computeProjectClosed(false);
- for (ICompilationUnit wc : toDiscard) {
- _CUHELPER.discardWorkingCopy(wc);
- }
- }
-
- /**
- * Perform the actions necessary to respond to a project being deleted.
- * Throw out everything related to the project, including its serialized
- * build dependencies.
- */
- public void projectDeleted()
- {
- if (AptPlugin.DEBUG_GFM) AptPlugin.trace("discarding all state"); //$NON-NLS-1$
- List<ICompilationUnit> toDiscard;
- toDiscard = computeProjectClosed(true);
- for (ICompilationUnit wc : toDiscard) {
- _CUHELPER.discardWorkingCopy(wc);
- }
- }
-
- /**
- * Called at the start of reconcile in order to cache our package fragment root
- */
- public void reconcileStarted()
- {
- _generatedPackageFragmentRoot.set();
- }
-
- /**
- * Invoked when a working copy is released, ie, an editor is closed. This
- * includes IDE shutdown.
- *
- * @param wc
- * must not be null, but does not have to be a parent.
- * @throws CoreException
- */
- public void workingCopyDiscarded(ICompilationUnit wc) throws CoreException
- {
- List<ICompilationUnit> toDiscard = removeFileFromReconcileMaps((IFile)(wc.getResource()));
- if (AptPlugin.DEBUG_GFM) AptPlugin.trace(
- "Working copy discarded: " + wc.getElementName() + //$NON-NLS-1$
- " removing " + toDiscard.size() + " children"); //$NON-NLS-1$//$NON-NLS-2$
- for (ICompilationUnit obsoleteWC : toDiscard) {
- _CUHELPER.discardWorkingCopy(obsoleteWC);
- }
- }
-
- /**
- * Serialize the generated file dependency data for builds, so that when a workspace
- * is reopened, incremental builds will work correctly.
- */
- public void writeState()
- {
- _buildDeps.writeState();
- }
-
- /**
- * Add a file dependency at build time. This updates the build dependency map but does
- * not affect the reconcile-time dependencies.
- * <p>
- * This method only affects maps; it does not touch disk or modify working copies.
- *
- * @param isSource true for source files that will be compiled; false for non-source, e.g., text or xml.
- */
- private synchronized void addBuiltFileToMaps(Collection<IFile> parentFiles, IFile generatedFile, boolean isSource)
- {
- // during a batch build, parentFile will be null.
- // Only keep track of ownership in iterative builds
- for (IFile parentFile : parentFiles) {
- if (parentFile != null) {
- boolean added = _buildDeps.put(parentFile, generatedFile, isSource);
- if (AptPlugin.DEBUG_GFM_MAPS) {
- if (added)
- AptPlugin.trace("build file dependency added: " + parentFile + " -> " + generatedFile); //$NON-NLS-1$//$NON-NLS-2$
- else
- AptPlugin.trace("build file dependency already exists: " + parentFile + " -> " + generatedFile); //$NON-NLS-1$//$NON-NLS-2$
- }
- }
- }
- }
-
- /**
- * Check integrity of data structures.
- * @return true always, so that it can be called within an assert to turn it off at runtime
- */
- private synchronized boolean checkIntegrity() throws IllegalStateException
- {
- if (!ENABLE_INTEGRITY_CHECKS || !AptPlugin.DEBUG_GFM_MAPS) {
- return true;
- }
-
- // There is a 1:1 correspondence between values in _reconcileDeps and
- // keys in _reconcileGenTypes.
- Set<IFile> depChildren = _reconcileDeps.getValueSet(); // copy - safe to modify
- Set<IFile> genTypes = _reconcileGenTypes.keySet(); // not a copy!
- List<IFile> extraFiles = new ArrayList<IFile>();
- for (IFile f : genTypes) {
- if (!depChildren.remove(f)) {
- extraFiles.add(f);
- }
- }
- if (!extraFiles.isEmpty()) {
- logExtraFiles("File(s) in reconcile-generated list but not in reconcile dependency map: ", //$NON-NLS-1$
- extraFiles);
- }
- if (!depChildren.isEmpty()) {
- logExtraFiles("File(s) in reconcile dependency map but not in reconcile-generated list: ", //$NON-NLS-1$
- depChildren);
- }
-
- // Every file in _clearDuringReconcile must be a value in _buildDeps.
- List<IFile> extraClearDuringReconcileFiles = new ArrayList<IFile>();
- for (IFile clearDuringReconcile : _clearDuringReconcile) {
- if (!_buildDeps.containsValue(clearDuringReconcile)) {
- extraClearDuringReconcileFiles.add(clearDuringReconcile);
- }
- }
- if (!extraClearDuringReconcileFiles.isEmpty()) {
- logExtraFiles("File(s) in list to clear during reconcile but not in build dependency map: ", //$NON-NLS-1$
- extraClearDuringReconcileFiles);
- }
-
- // Every key in _hiddenBuiltTypes must be a value in _reconcileNonDeps.
- List<IFile> extraHiddenTypes = new ArrayList<IFile>();
- for (IFile hidden : _hiddenBuiltTypes.keySet()) {
- if (!_reconcileNonDeps.containsValue(hidden)) {
- extraHiddenTypes.add(hidden);
- }
- }
- if (!extraHiddenTypes.isEmpty()) {
- logExtraFiles("File(s) in hidden types list but not in reconcile-obsoleted list: ", //$NON-NLS-1$
- extraHiddenTypes);
- }
-
- // There can be no parent/child pairs that exist in both _reconcileDeps
- // and _reconcileNonDeps.
- Map<IFile, IFile> reconcileOverlaps = new HashMap<IFile, IFile>();
- for (IFile parent : _reconcileNonDeps.getKeySet()) {
- for (IFile child : _reconcileNonDeps.getValues(parent)) {
- if (_reconcileDeps.containsKeyValuePair(parent, child)) {
- reconcileOverlaps.put(parent, child);
- }
- }
- }
- if (!reconcileOverlaps.isEmpty()) {
- logExtraFilePairs("Entries exist in both reconcile map and reconcile-obsoleted maps: ", //$NON-NLS-1$
- reconcileOverlaps);
- }
-
- // Every parent/child pair in _reconcileNonDeps must have a matching
- // parent/child pair in _buildDeps.
- Map<IFile, IFile> extraNonDeps = new HashMap<IFile, IFile>();
- for (IFile parent : _reconcileNonDeps.getKeySet()) {
- for (IFile child : _reconcileNonDeps.getValues(parent)) {
- if (!_buildDeps.containsKeyValuePair(parent, child)) {
- extraNonDeps.put(parent, child);
- }
- }
- }
- if (!extraNonDeps.isEmpty()) {
- logExtraFilePairs("Entries exist in reconcile-obsoleted map but not in build map: ", //$NON-NLS-1$
- extraNonDeps);
- }
-
- // Values in _hiddenBuiltTypes must not be null
- List<IFile> nullHiddenTypes = new ArrayList<IFile>();
- for (Map.Entry<IFile, ICompilationUnit> entry : _hiddenBuiltTypes.entrySet()) {
- if (entry.getValue() == null) {
- nullHiddenTypes.add(entry.getKey());
- }
- }
- if (!nullHiddenTypes.isEmpty()) {
- logExtraFiles("Null entries in hidden type list: ", nullHiddenTypes); //$NON-NLS-1$
- }
-
- // Values in _reconcileGenTypes must not be null
- List<IFile> nullReconcileTypes = new ArrayList<IFile>();
- for (Map.Entry<IFile, ICompilationUnit> entry : _reconcileGenTypes.entrySet()) {
- if (entry.getValue() == null) {
- nullReconcileTypes.add(entry.getKey());
- }
- }
- if (!nullReconcileTypes.isEmpty()) {
- logExtraFiles("Null entries in reconcile type list: ", nullReconcileTypes); //$NON-NLS-1$
- }
-
- return true;
- }
-
- /**
- * Clear the working copy maps, that is, the reconcile-time dependency information.
- * Returns a list of working copies that are no longer referenced and should be
- * discarded. Typically called when a project is being closed or deleted.
- * <p>
- * It's not obvious we actually need this. As long as the IDE discards the parent
- * working copies before the whole GeneratedFileManager is discarded, there'll be
- * nothing left to clear by the time we get here. This is a "just in case."
- * <p>
- * This method affects maps only; it does not touch disk nor create, modify, nor
- * discard any working copies. This method is atomic with respect to data structure
- * integrity.
- *
- * @param deleteState
- * true if this should delete the serialized build dependencies.
- *
- * @return a list of working copies which must be discarded by the caller
- */
- private synchronized List<ICompilationUnit> computeProjectClosed(boolean deleteState)
- {
- int size = _hiddenBuiltTypes.size() + _reconcileGenTypes.size();
- List<ICompilationUnit> toDiscard = new ArrayList<ICompilationUnit>(size);
- toDiscard.addAll(_hiddenBuiltTypes.values());
- toDiscard.addAll(_reconcileGenTypes.values());
- _reconcileGenTypes.clear();
- _hiddenBuiltTypes.clear();
- _reconcileDeps.clear();
- _reconcileNonDeps.clear();
-
- if (deleteState) {
- _buildDeps.clearState();
- }
- else {
- _buildDeps.clear();
- }
- _clearDuringReconcile.clear();
-
- assert checkIntegrity();
- return toDiscard;
- }
-
- /**
- * Compare <code>contents</code> with the contents of <code>file</code>.
- * @param contents the text to compare with the file's contents on disk.
- * @param file does not have to exist.
- * @return true if the file on disk cannot be read, or if its contents differ.
- */
- private boolean compareFileContents(String contents, IFile file)
- {
- boolean contentsDiffer = true;
- if (file.exists()) {
- InputStream oldData = null;
- InputStream is = null;
- try {
- is = new ByteArrayInputStream(contents.getBytes());
- oldData = new BufferedInputStream(file.getContents());
- contentsDiffer = !FileSystemUtil.compareStreams(oldData, is);
- } catch (CoreException ce) {
- // Do nothing. Assume the new content is different
- } finally {
- if (oldData != null) {
- try {
- oldData.close();
- } catch (IOException ioe) {
- }
- }
- if (is != null) {
- try {
- is.close();
- } catch (IOException ioe) {
- }
- }
- }
- }
- return contentsDiffer;
- }
-
- /**
- * Make the map updates necessary to discard build state. Typically called while
- * processing a clean. In addition to throwing away the build dependencies, we also
- * throw away all the blank working copies used to hide existing generated files, on
- * the premise that since they were deleted in the clean we don't need to hide them
- * any more. We leave the rest of the reconcile-time dependency info, though.
- * <p>
- * This method is atomic with regard to data structure integrity. This method
- * does not touch disk nor create, discard, or modify compilation units.
- *
- * @return a list of working copies that the caller must discard by calling
- * {@link CompilationUnitHelper#discardWorkingCopy(ICompilationUnit)}.
- */
- private synchronized List<ICompilationUnit> computeClean()
- {
- _buildDeps.clearState();
- _clearDuringReconcile.clear();
- _reconcileNonDeps.clear();
- List<ICompilationUnit> toDiscard = new ArrayList<ICompilationUnit>(_hiddenBuiltTypes.values());
- _hiddenBuiltTypes.clear();
-
- assert checkIntegrity();
- return toDiscard;
- }
-
- /**
- * Get the IFolder handles for any additional folders needed to
- * contain a type in package <code>pkgName</code> under root
- * <code>parent</code>. This does not actually create the folders
- * on disk, it just gets resource handles.
- *
- * @return a set containing all the newly created folders.
- */
- private Set<IFolder> computeNewPackageFolders(String pkgName, IFolder parent)
- {
- Set<IFolder> newFolders = new HashSet<IFolder>();
- String[] folders = _PACKAGE_DELIMITER.split(pkgName);
- for (String folderName : folders) {
- final IFolder folder = parent.getFolder(folderName);
- if (!folder.exists()) {
- newFolders.add(folder);
- }
- parent = folder;
- }
- return newFolders;
- }
-
- /**
- * Calculate the list of previously generated files that are no longer
- * being generated and thus need to be deleted.
- * <p>
- * This method does not touch the disk, nor does it create, update, or
- * discard working copies. This method is atomic with regard to the
- * integrity of data structures.
- *
- * @param parentFile only files solely parented by this file will be
- * added to the list to be deleted.
- * @param newlyGeneratedFiles files on this list will be spared.
- * @param toDiscard must be non-null. The caller should pass in an empty
- * list; on return the list will contain working copies which the caller
- * is responsible for discarding.
- * @param toReport must be non-null. The caller should pass in an empty
- * set; on return the set will contain IFiles representing source files
- * (but not non-source files such as text or xml files) which are being
- * deleted and which should therefore be removed from compilation.
- * @return a list of files which the caller should delete, ie by calling
- * {@link #deletePhysicalFile(IFile)}.
- */
- private synchronized Set<IFile> computeObsoleteFiles(
- IFile parentFile, Set<IFile> newlyGeneratedFiles,
- List<ICompilationUnit> toDiscard,
- Set<IFile> toReport)
- {
- Set<IFile> deleted = new HashSet<IFile>();
- Set<IFile> obsoleteFiles = _buildDeps.getValues(parentFile);
- // spare all the newly generated files
- obsoleteFiles.removeAll(newlyGeneratedFiles);
- for (IFile generatedFile : obsoleteFiles) {
- boolean isSource = _buildDeps.isSource(generatedFile);
- _buildDeps.remove(parentFile, generatedFile);
- if (AptPlugin.DEBUG_GFM_MAPS) AptPlugin.trace(
- "removed build file dependency: " + parentFile + " -> " + generatedFile); //$NON-NLS-1$ //$NON-NLS-2$
- // If the file is still parented by any other parent, spare it
- if (!_buildDeps.containsValue(generatedFile)) {
- deleted.add(generatedFile);
- if (isSource) {
- toReport.add(generatedFile);
- }
- }
- }
- _clearDuringReconcile.removeAll(deleted);
- toDiscard.addAll(computeObsoleteHiddenTypes(parentFile, deleted));
- assert checkIntegrity();
- return deleted;
- }
-
- /**
- * Calculate what needs to happen to working copies after a reconcile in order to get
- * rid of any no-longer-generated files. If there's an existing generated file, we
- * need to hide it with a blank working copy; if there's no existing file, we need to
- * get rid of any generated working copy.
- * <p>
- * A case to keep in mind: the user imports a project with already-existing generated
- * files, but without a serialized build dependency map. Then they edit a parent
- * file, causing a generated type to disappear. We need to discover and hide the
- * generated file on disk, even though it is not in the build-time dependency map.
- *
- * @param parentFile
- * the parent type being reconciled, which need not exist on disk.
- * @param newlyGeneratedFiles
- * the set of files generated in the last reconcile
- * @param toSetBlank
- * a list, to which this will add files that the caller must then set blank
- * with {@link CompilationUnitHelper#updateWorkingCopyContents(String,
- * ICompilationUnit, WorkingCopyOwner, boolean)}
- * @param toDiscard
- * a list, to which this will add files that the caller must then discard
- * with {@link CompilationUnitHelper#discardWorkingCopy(ICompilationUnit)}.
- */
- private synchronized void computeObsoleteReconcileTypes(
- IFile parentFile, Set<IFile> newlyGeneratedFiles,
- CompilationUnitHelper cuh,
- List<ICompilationUnit> toSetBlank, List<ICompilationUnit> toDiscard)
- {
- // Get types previously but no longer generated during reconcile
- Set<IFile> obsoleteFiles = _reconcileDeps.getValues(parentFile);
- Map<IFile, ICompilationUnit> typesToDiscard = new HashMap<IFile, ICompilationUnit>();
- obsoleteFiles.removeAll(newlyGeneratedFiles);
- for (IFile obsoleteFile : obsoleteFiles) {
- _reconcileDeps.remove(parentFile, obsoleteFile);
- if (_reconcileDeps.getKeys(obsoleteFile).isEmpty()) {
- ICompilationUnit wc = _reconcileGenTypes.remove(obsoleteFile);
- assert wc != null :
- "Value in reconcile deps missing from reconcile type list: " + obsoleteFile; //$NON-NLS-1$
- typesToDiscard.put(obsoleteFile, wc);
- }
- }
-
- Set<IFile> builtChildren = _buildDeps.getValues(parentFile);
- builtChildren.retainAll(_clearDuringReconcile);
- builtChildren.removeAll(newlyGeneratedFiles);
- for (IFile builtChild : builtChildren) {
- _reconcileNonDeps.put(parentFile, builtChild);
- // If it's on typesToDiscard there are no other reconcile-time parents.
- // If there are no other parents that are not masked by a nonDep entry...
- boolean foundOtherParent = false;
- Set<IFile> parents = _buildDeps.getKeys(builtChild);
- parents.remove(parentFile);
- for (IFile otherParent : parents) {
- if (!_reconcileNonDeps.containsKeyValuePair(otherParent, builtChild)) {
- foundOtherParent = true;
- break;
- }
- }
- if (!foundOtherParent) {
- ICompilationUnit wc = typesToDiscard.remove(builtChild);
- if (wc == null) {
- IPackageFragmentRoot root = _generatedPackageFragmentRoot.get().root;
- String typeName = getTypeNameForDerivedFile(builtChild);
- wc = cuh.getWorkingCopy(typeName, root);
- }
- _hiddenBuiltTypes.put(builtChild, wc);
- toSetBlank.add(wc);
- }
- }
-
- // discard any working copies that we're not setting blank
- toDiscard.addAll(typesToDiscard.values());
-
- assert checkIntegrity();
- }
-
- /**
- * Calculate the list of blank working copies that are no longer needed because the
- * files that they hide have been deleted during a build. Remove these working copies
- * from the _hiddenBuiltTypes list and return them in a list. The caller MUST then
- * discard the contents of the list (outside of any synchronized block) by calling
- * CompilationUnitHelper.discardWorkingCopy().
- * <p>
- * This method does not touch the disk and does not create, update, or discard working
- * copies. This method is atomic with regard to data structure integrity.
- *
- * @param parentFile
- * used to be a parent but may no longer be.
- * @param deletedFiles
- * a list of files which are being deleted, which might or might not have
- * been hidden by blank working copies.
- *
- * @return a list of working copies which the caller must discard
- */
- private synchronized List<ICompilationUnit> computeObsoleteHiddenTypes(IFile parentFile, Set<IFile> deletedFiles)
- {
- List<ICompilationUnit> toDiscard = new ArrayList<ICompilationUnit>();
- for (IFile deletedFile : deletedFiles) {
- if (_reconcileNonDeps.remove(parentFile, deletedFile)) {
- ICompilationUnit wc = _hiddenBuiltTypes.remove(deletedFile);
- if (wc != null) {
- toDiscard.add(wc);
- }
- }
- }
- assert checkIntegrity();
- return toDiscard;
- }
-
- /**
- * Delete a generated file from disk. Also deletes the parent folder hierarchy, up to
- * but not including the root generated source folder, as long as the folders are
- * empty and are marked as "derived".
- * <p>
- * This does not affect or refer to the dependency maps.
- *
- * @param file is assumed to be under the generated source folder.
- */
- private void deletePhysicalFile(IFile file)
- {
- final IFolder genFolder = _gsfm.getFolder();
- assert genFolder != null : "Generated folder == null"; //$NON-NLS-1$
- IContainer parent = file.getParent(); // parent in the folder sense,
- // not the typegen sense
- try {
- if (AptPlugin.DEBUG_GFM) AptPlugin.trace(
- "delete physical file: " + file); //$NON-NLS-1$
- file.delete(true, true, /* progressMonitor */null);
- } catch (CoreException e) {
- // File was locked or read-only
- AptPlugin.logWarning(e, "Unable to delete generated file: " + file); //$NON-NLS-1$
- }
- // Delete the parent folders
- while (!genFolder.equals(parent) && parent != null && parent.isDerived()) {
- IResource[] members = null;
- try {
- members = parent.members();
- } catch (CoreException e) {
- AptPlugin.logWarning(e, "Unable to read contents of generated file folder " + parent); //$NON-NLS-1$
- }
- IContainer grandParent = parent.getParent();
- // last one turns the light off.
- if (members == null || members.length == 0)
- try {
- parent.delete(true, /* progressMonitor */null);
- } catch (CoreException e) {
- AptPlugin.logWarning(e, "Unable to delete generated file folder " + parent); //$NON-NLS-1$
- }
- else
- break;
- parent = grandParent;
- }
- }
-
- /**
- * Given a typename a.b.c, this will return the IFile for the type name, where the
- * IFile is in the GENERATED_SOURCE_FOLDER_NAME.
- * <p>
- * This does not affect or refer to the dependency maps.
- */
- private IFile getIFileForTypeName(String typeName)
- {
- // split the type name into its parts
- String[] parts = _PACKAGE_DELIMITER.split(typeName);
-
- IFolder folder = _gsfm.getFolder();
- for (int i = 0; i < parts.length - 1; i++)
- folder = folder.getFolder(parts[i]);
-
- // the last part of the type name is the file name
- String fileName = parts[parts.length - 1] + ".java"; //$NON-NLS-1$
- IFile file = folder.getFile(fileName);
- return file;
- }
-
- /**
- * 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();
-
- IFolder folder = _gsfm.getFolder();
- 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 );
- }
-
- /**
- * Get a working copy for the specified generated type. If we already have
- * one cached, use that; if not, create a new one. Update the reconcile-time
- * dependency maps.
- * <p>
- * This method does not touch disk, nor does it update or discard any working
- * copies. However, it may call CompilationUnitHelper to get a new working copy.
- * This method is atomic with respect to data structures.
- *
- * @param parentFile the IFile whose processing is causing the new type to be generated
- * @param typeName the name of the type to be generated
- * @param cuh the CompilationUnitHelper utility object
- * @return a working copy ready to be updated with the new type's contents
- */
- private synchronized ICompilationUnit getWorkingCopyForReconcile(IFile parentFile, String typeName, CompilationUnitHelper cuh)
- {
- IPackageFragmentRoot root = _generatedPackageFragmentRoot.get().root;
- IFile generatedFile = getIFileForTypeName(typeName);
- ICompilationUnit workingCopy;
-
- workingCopy = _hiddenBuiltTypes.remove(generatedFile);
- if (null != workingCopy) {
- // file is currently hidden with a blank WC. Move that WC to the regular list.
- _reconcileNonDeps.remove(parentFile, generatedFile);
- _reconcileGenTypes.put(generatedFile, workingCopy);
- _reconcileDeps.put(parentFile, generatedFile);
- if (AptPlugin.DEBUG_GFM_MAPS) AptPlugin.trace(
- "moved working copy from hidden to regular list: " + generatedFile); //$NON-NLS-1$
- } else {
- workingCopy = _reconcileGenTypes.get(generatedFile);
- if (null != workingCopy) {
- if (AptPlugin.DEBUG_GFM_MAPS) AptPlugin.trace(
- "obtained existing working copy from regular list: " + generatedFile); //$NON-NLS-1$
- } else {
- // we've not yet created a working copy for this file, so make one now.
- workingCopy = cuh.getWorkingCopy(typeName, root);
- _reconcileDeps.put(parentFile, generatedFile);
- _reconcileGenTypes.put(generatedFile, workingCopy);
- if (AptPlugin.DEBUG_GFM_MAPS) AptPlugin.trace(
- "added new working copy to regular list: " + generatedFile); //$NON-NLS-1$
- }
- }
-
- assert checkIntegrity();
- return workingCopy;
- }
-
- /**
- * Check whether a child file has any parents that could apply in reconcile.
- *
- * @return true if <code>child</code> has no other parents in
- * {@link #_reconcileDeps}, and also no other parents in {@link #_buildDeps}
- * that are not masked by a corresponding entry in {@link #_reconcileNonDeps}.
- */
- private boolean hasNoOtherReconcileParents(IFile child, IFile parent) {
- if (_reconcileDeps.valueHasOtherKeys(child, parent))
- return true;
- Set<IFile> buildParents = _buildDeps.getKeys(child);
- buildParents.remove(parent);
- buildParents.removeAll(_reconcileNonDeps.getKeys(child));
- return buildParents.isEmpty();
- }
-
- /**
- * Log extra file pairs, with a message like "message p1->g1, p2->g2".
- * Assumes that pairs has at least one entry.
- */
- private void logExtraFilePairs(String message, Map<IFile, IFile> pairs) {
- StringBuilder sb = new StringBuilder();
- sb.append(message);
- Iterator<Map.Entry<IFile, IFile>> iter = pairs.entrySet().iterator();
- while (true) {
- Map.Entry<IFile, IFile> entry = iter.next();
- sb.append(entry.getKey().getName());
- sb.append("->"); //$NON-NLS-1$
- sb.append(entry.getValue().getName());
- if (!iter.hasNext()) {
- break;
- }
- sb.append(", "); //$NON-NLS-1$
- }
- String s = sb.toString();
- AptPlugin.log(new IllegalStateException(s), s);
- }
-
- /**
- * Log extra files, with a message like "message file1, file2, file3".
- * Assumes that files has at least one entry.
- */
- private void logExtraFiles(String message, Iterable<IFile> files) {
- StringBuilder sb = new StringBuilder();
- sb.append(message);
- Iterator<IFile> iter = files.iterator();
- while (true) {
- sb.append(iter.next().getName());
- if (!iter.hasNext()) {
- break;
- }
- sb.append(", "); //$NON-NLS-1$
- }
- String s = sb.toString();
- AptPlugin.log(new IllegalStateException(s), s);
- }
-
- /**
- * Given a fully qualified type name, generate the package name and the local filename
- * including the extension. For instance, type name <code>foo.bar.Baz</code> is
- * turned into package <code>foo.bar</code> and filename <code>Baz.java</code>.
- * <p>
- * TODO: this is almost identical to code in CompilationUnitHelper. Is the difference
- * intentional?
- *
- * @param qualifiedName
- * a fully qualified type name
- * @return a String array containing {package name, filename}
- */
- private static String[] parseTypeName(String qualifiedName) {
-
- //TODO: the code in CompilationUnitHelper doesn't perform this check. Should it?
- if (qualifiedName.indexOf('/') != -1)
- qualifiedName = qualifiedName.replace('/', '.');
-
- String[] names = new String[2];
- String pkgName;
- String fname;
- int idx = qualifiedName.lastIndexOf( '.' );
- if ( idx > 0 )
- {
- pkgName = qualifiedName.substring( 0, idx );
- fname =
- qualifiedName.substring(idx + 1, qualifiedName.length()) + ".java"; //$NON-NLS-1$
- }
- else
- {
- pkgName = ""; //$NON-NLS-1$
- fname = qualifiedName + ".java"; //$NON-NLS-1$
- }
- names[0] = pkgName;
- names[1] = fname;
- return names;
- }
-
- /**
- * Remove a file from the build-time dependency maps, and calculate the consequences
- * of the removal. This is called in response to a file being deleted by the
- * environment.
- * <p>
- * This operation affects the maps only. This operation is atomic with respect to map
- * integrity. This operation does not touch the disk nor create, update, or discard
- * any working copies.
- *
- * @param f
- * can be a parent, generated, both, or neither.
- * @return a list of generated files that are no longer relevant and must be deleted.
- * This operation must be done by the caller without holding any locks. The
- * list may be empty but will not be null.
- */
- private synchronized List<IFile> removeFileFromBuildMaps(IFile f)
- {
- List<IFile> toDelete = new ArrayList<IFile>();
- // Is this file the sole parent of files generated during build?
- // If so, add them to the deletion list. Then remove the file from
- // the build dependency list.
- Set<IFile> childFiles = _buildDeps.getValues(f);
- for (IFile childFile : childFiles) {
- Set<IFile> parentFiles = _buildDeps.getKeys(childFile);
- if (parentFiles.size() == 1 && parentFiles.contains(f)) {
- toDelete.add(childFile);
- }
- }
- boolean removed = _buildDeps.removeKey(f);
- if (removed) {
- if (AptPlugin.DEBUG_GFM_MAPS) AptPlugin.trace(
- "removed parent file from build dependencies: " + f); //$NON-NLS-1$
- }
-
- assert checkIntegrity();
- return toDelete;
- }
-
- /**
- * Remove the generated children of a working copy from the reconcile dependency maps.
- * Typically invoked when a working copy of a parent file has been discarded by the
- * editor; in this case we want to remove any generated working copies that it
- * parented.
- * <p>
- * This method does not touch disk nor create, modify, or discard working copies. This
- * method is atomic with regard to data structure integrity.
- *
- * @param file
- * a file representing a working copy that is not necessarily a parent or
- * generated file
- * @return a list of generated working copies that are no longer referenced and should
- * be discarded by calling
- * {@link CompilationUnitHelper#discardWorkingCopy(ICompilationUnit)}
- */
- private synchronized List<ICompilationUnit> removeFileFromReconcileMaps(IFile file)
- {
- List<ICompilationUnit> toDiscard = new ArrayList<ICompilationUnit>();
- // remove all the orphaned children
- Set<IFile> genFiles = _reconcileDeps.getValues(file);
- for (IFile child : genFiles) {
- if (hasNoOtherReconcileParents(child, file)) {
- ICompilationUnit childWC = _reconcileGenTypes.remove(child);
- assert null != childWC : "Every value in _reconcileDeps must be a key in _reconcileGenTypes"; //$NON-NLS-1$
- toDiscard.add(childWC);
- }
- }
- _reconcileDeps.removeKey(file);
-
- // remove obsolete entries in non-generated list
- Set<IFile> nonGenFiles = _reconcileNonDeps.getValues(file);
- for (IFile child : nonGenFiles) {
- ICompilationUnit hidingWC = _hiddenBuiltTypes.remove(child);
- if (null != hidingWC) {
- toDiscard.add(hidingWC);
- }
- }
- _reconcileNonDeps.removeKey(file);
-
- assert checkIntegrity();
- return toDiscard;
- }
-
- /**
- * Write <code>contents</code> to disk in the form of a compilation unit named
- * <code>name</code> under package fragment <code>pkgFrag</code>. The way in
- * which the write is done depends whether the compilation unit is a working copy.
- * <p>
- * The working copy is used in reconcile. In principle changing the contents during
- * build should be a problem, since the Java builder is based on file contents rather
- * than on the current Java Model. However, annotation processors get their type info
- * from the Java Model even during build, so there is in general no difference between
- * build and reconcile. This causes certain bugs (if a build is performed while there
- * is unsaved content in editors), so it may change in the future, and this routine
- * will need to be fixed. - WHarley 11/06
- * <p>
- * This method touches the disk and modifies working copies. It can only be called
- * during build, not during reconcile, and it should not be called while holding any
- * locks (other than the workspace rules held by the build).
- *
- * @param pkgFrag
- * the package fragment in which the type will be created. The fragment's
- * folders must already exist on disk.
- * @param cuName
- * the simple name of the type, with extension, such as 'Obj.java'
- * @param contents
- * the text of the compilation unit
- * @param progressMonitor
- */
- private void saveCompilationUnit(IPackageFragment pkgFrag, final String cuName, String contents,
- IProgressMonitor progressMonitor)
- {
-
- ICompilationUnit unit = pkgFrag.getCompilationUnit(cuName);
- boolean isWorkingCopy = unit.isWorkingCopy();
- if (isWorkingCopy) {
- try {
- // If we have a working copy, all we
- // need to do is update its contents and commit it...
- _CUHELPER.commitNewContents(unit, contents, progressMonitor);
- if (AptPlugin.DEBUG_GFM) AptPlugin.trace(
- "Committed existing working copy during build: " + unit.getElementName()); //$NON-NLS-1$
- }
- catch (JavaModelException e) {
- // ...unless, that is, the resource has been deleted behind our back
- // due to a clean. In that case, discard the working copy and try again.
- if (e.getJavaModelStatus().getCode() == IJavaModelStatusConstants.INVALID_RESOURCE) {
- _CUHELPER.discardWorkingCopy(unit);
- isWorkingCopy = false;
- if (AptPlugin.DEBUG_GFM) AptPlugin.trace(
- "Discarded invalid existing working copy in order to try again: " + unit.getElementName()); //$NON-NLS-1$
- }
- else {
- AptPlugin.log(e, "Unable to commit working copy to disk: " + unit.getElementName()); //$NON-NLS-1$
- return;
- }
- }
- }
- if (!isWorkingCopy) {
- try {
- unit = pkgFrag.createCompilationUnit(cuName, contents, true, progressMonitor);
- if (AptPlugin.DEBUG_GFM) AptPlugin.trace(
- "Created compilation unit during build: " + unit.getElementName()); //$NON-NLS-1$
- } catch (JavaModelException e) {
- AptPlugin.log(e, "Unable to create compilation unit on disk: " + //$NON-NLS-1$
- cuName + " in pkg fragment: " + pkgFrag.getElementName()); //$NON-NLS-1$
- }
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileMap.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileMap.java
deleted file mode 100644
index 2140acc0bf..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileMap.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 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.generatedfile;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.util.ManyToMany;
-
-/**
- * A bidirectional many-to-many map from parent files to generated files.
- * This extends the functionality of ManyToMany by adding serialization.
- * The object also tracks attributes of the generated files.
- */
-public class GeneratedFileMap extends ManyToMany<IFile, IFile> {
-
- public enum Flags {
- /** Non-source files, e.g., text or xml. */
- NONSOURCE;
- }
-
- // Version 2 since Eclipse 3.3.1: add ability to track attributes of generated files
- private static final int SERIALIZATION_VERSION = 2;
-
- private final IProject _proj;
-
- private final Map<IFile, Set<Flags>> _flags = new HashMap<IFile, Set<Flags>>();
-
- public GeneratedFileMap(IProject proj) {
- _proj = proj;
- readState();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.internal.util.ManyToMany#clear()
- */
- @Override
- public synchronized boolean clear() {
- _flags.clear();
- return super.clear();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.internal.util.ManyToMany#remove(java.lang.Object, java.lang.Object)
- */
- @Override
- public synchronized boolean remove(IFile key, IFile value) {
- boolean removed = super.remove(key, value);
- if (removed) {
- if (!containsValue(value)) {
- _flags.remove(value);
- }
- }
- return removed;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.internal.util.ManyToMany#removeKey(java.lang.Object)
- */
- @Override
- public synchronized boolean removeKey(IFile key) {
- Set<IFile> values = getValues(key);
- boolean removed = super.removeKey(key);
- if (removed) {
- for (IFile value : values) {
- if (!containsValue(value)) {
- _flags.remove(value);
- }
- }
- }
- return removed;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.internal.util.ManyToMany#removeValue(java.lang.Object)
- */
- @Override
- public synchronized boolean removeValue(IFile value) {
- boolean removed = super.removeValue(value);
- if (removed) {
- _flags.remove(value);
- }
- return removed;
- }
-
- /**
- * Clear the file dependencies and delete the serialized state.
- * This will take effect even if the dirty bit is not set.
- */
- public synchronized void clearState() {
- clear();
- File state = getStateFile(_proj);
- if (state != null) {
- boolean successfullyDeleted = state.delete();
- if (!successfullyDeleted && state.exists()) {
- AptPlugin.log(new IOException("Could not delete apt dependency state file"), //$NON-NLS-1$
- state.getPath());
- }
- }
- clearDirtyBit();
- }
-
- /**
- * Convenience method, equivalent to put(key, value, [no flags])
- */
- @Override
- public boolean put(IFile parent, IFile generated) {
- return put(parent, generated, Collections.<Flags>emptySet());
- }
-
- /**
- * Convenience method, equivalent to put(key, value, isSource ? [no flags] : [NONSOURCE])
- */
- public boolean put(IFile parent, IFile generated, boolean isSource) {
- return put(parent, generated, isSource ? Collections.<Flags>emptySet() : EnumSet.of(Flags.NONSOURCE));
- }
-
- /**
- * Add a parent-to-generated association and specify attributes for the generated file.
- * The attributes are associated with the file, not the link: that is, a given generated
- * file can only have one set of attributes, not a different set per parent. The attributes
- * set in the most recent call will override those set in previous calls.
- */
- public synchronized boolean put(IFile parent, IFile generated, Set<Flags> flags) {
- if (flags.isEmpty()) {
- _flags.remove(generated);
- }
- else {
- _flags.put(generated, flags);
- }
- return super.put(parent, generated);
- }
-
- public Set<Flags> getFlags(IFile generated) {
- Set<Flags> flags = _flags.get(generated);
- return flags == null ? Collections.<Flags>emptySet() : flags;
- }
-
- /**
- * Convenience method, equivalent to !getFlags(generated).contains(Flags.NONSOURCE)
- * @return true if the generated file is a source (Java) file rather than text, xml, etc.
- */
- public boolean isSource(IFile generated) {
- return !getFlags(generated).contains(Flags.NONSOURCE);
- }
-
- /**
- * Utility method for serialization
- */
- private String convertIFileToPath(IFile file) {
- IPath path = file.getProjectRelativePath();
- return path.toOSString();
- }
-
- /**
- * Utility method for deserialization
- */
- private IFile convertPathToIFile(String projectRelativeString) {
- IPath path = new Path(projectRelativeString);
- return _proj.getFile(path);
- }
-
- /**
- * Returns the File to use for saving and restoring the last built state for the given project.
- * Returns null if the project does not exists (e.g. has been deleted)
- */
- private File getStateFile(IProject project) {
- if (!project.exists()) return null;
- IPath workingLocation = project.getWorkingLocation(AptPlugin.PLUGIN_ID);
- return workingLocation.append("state.dat").toFile(); //$NON-NLS-1$
- }
-
- /**
- * Reads the last serialized build state into memory. This includes dependency
- * information so that we do not need to do a clean build in order to recreate
- * our dependencies.
- *
- * File format:
- *
- * int version
- * int sizeOfMap
- * String parentIFilePath
- * int numberOfChildren
- * String childIFilePath
- *
- * This method is not synchronized because it is called only from this object's constructor.
- */
- private void readState() {
- File file = getStateFile(_proj);
- if (file == null || !file.exists()) {
- // We'll just start with no dependencies
- return;
- }
- DataInputStream in = null;
- try {
- in= new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
- int version = in.readInt();
- if (version != SERIALIZATION_VERSION) {
- throw new IOException("Dependency map file version does not match. Expected " //$NON-NLS-1$
- + SERIALIZATION_VERSION + ", but found " + version); //$NON-NLS-1$
- }
- int sizeOfMap = in.readInt();
-
- // For each entry, we'll have a parent and a set of children,
- // which we can drop into the parent -> child map.
- for (int parentIndex=0; parentIndex<sizeOfMap; parentIndex++) {
- String parentPath = in.readUTF();
- IFile parent = convertPathToIFile(parentPath);
- int numChildren = in.readInt();
- for (int childIndex = 0; childIndex<numChildren; childIndex++) {
- String childPath = in.readUTF();
- IFile child = convertPathToIFile(childPath);
- // add the child to the parent->child map
- put(parent, child);
- }
- }
-
- // Now the _flags map:
- int sizeOfFlags = in.readInt();
- for (int i = 0; i < sizeOfFlags; ++i) {
- String childPath = in.readUTF();
- IFile child = convertPathToIFile(childPath);
- if (!containsValue(child)) {
- throw new IOException("Error in generated file attributes: did not expect file " + childPath); //$NON-NLS-1$
- }
-
- int attributeCount = in.readInt();
- EnumSet<Flags> flags = EnumSet.noneOf(Flags.class);
- for (int j = 0; j < attributeCount; ++j) {
- String attr = in.readUTF();
- Flags f = Flags.valueOf(attr);
- flags.add(f);
- }
- _flags.put(child, flags);
- }
-
- // our serialized and in-memory states are now identical
- clearDirtyBit();
- }
- catch (IOException ioe) {
- // Avoid partial initialization
- clear();
- // We can safely continue without having read our dependencies.
- AptPlugin.logWarning(ioe, "Could not read APT dependencies: generated files may not be deleted until the next clean"); //$NON-NLS-1$
- }
- catch (IllegalArgumentException iae) {
- // Avoid partial initialization
- clear();
- // We can safely continue without having read our dependencies.
- AptPlugin.logWarning(iae, "Could not read APT dependencies: generated files may not be deleted until the next clean"); //$NON-NLS-1$
- }
- finally {
- if (in != null) {
- try {in.close();} catch (IOException ioe) {}
- }
- }
- }
-
- /**
- * Write our dependencies to disk. If not dirty, nothing is written.
- */
- public synchronized void writeState() {
- if (!isDirty()) {
- return;
- }
- File file = getStateFile(_proj);
- if (file == null) {
- // Cannot write state, as project has been deleted
- return;
- }
- file.delete();
-
- DataOutputStream out = null;
- try {
- out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
-
- out.writeInt(SERIALIZATION_VERSION);
-
- // Number of parent files
- Set<IFile> parents = getKeySet();
- out.writeInt(parents.size());
-
- // for each parent...
- for (IFile parent : parents) {
-
- // ...parent name
- out.writeUTF(convertIFileToPath(parent));
-
- Set<IFile> children = getValues(parent);
-
- // ...number of children
- out.writeInt(children.size());
-
- // for each child...
- for (IFile child : children) {
- // ...child name.
- out.writeUTF(convertIFileToPath(child));
- }
- }
-
- // Number of generated files with attributes
- out.writeInt(_flags.size());
-
- // for each generated file that has attributes...
- for (Entry<IFile, Set<Flags>> entry : _flags.entrySet()) {
- // ...generated file name
- out.writeUTF(convertIFileToPath(entry.getKey()));
-
- Set<Flags> flags = entry.getValue();
- // ...number of attributes
- out.writeInt(flags.size());
- for (Flags f : flags) {
- // ...attribute name
- out.writeUTF(f.name());
- }
- }
-
- // our serialized and in-memory states are now identical
- clearDirtyBit();
- out.flush();
- }
- catch (IOException ioe) {
- // We can safely continue without having written our dependencies.
- AptPlugin.logWarning(ioe, "Could not serialize APT dependencies"); //$NON-NLS-1$
- }
- finally {
- if (out != null) {
- try {
- out.close();
- }
- catch (IOException ioe) {
- // Do nothing
- }
- }
- }
- }
-
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedResourceChangeListener.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedResourceChangeListener.java
deleted file mode 100644
index afcbadcb4c..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedResourceChangeListener.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-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;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.AptProject;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-
-/**
- * A jdt.core pre-process resource change listener that manages generated resources.
- * <p>
- *
- * Note that this is both a pre-build listener and a post-change listener,
- * because there is a bug in the resource change event notification in the platform:
- * sometimes they fail to send out deletion notifications for files in pre-build,
- * but they do send them out in post-change.
- */
-public class GeneratedResourceChangeListener implements IResourceChangeListener
-{
- // Synchronized collection, as post-change notifications could come in
- // simultaneously. Note that pre-build will not though, as it holds the
- // workspace lock
- private final Set<IResource> deletedResources =
- Collections.synchronizedSet(new HashSet<IResource>());
-
- public GeneratedResourceChangeListener(){}
-
- public void resourceChanged(IResourceChangeEvent event)
- {
- if ( event.getType() == IResourceChangeEvent.PRE_CLOSE )
- {
- IProject p = (IProject)event.getResource();
- if( AptPlugin.DEBUG_GFM )
- AptPlugin.trace(
- "generated resource change listener got a pre-close event: project = " + p.getName()); //$NON-NLS-1$
- IJavaProject jp = JavaCore.create(p);
- AptPlugin.getAptProject(jp).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();
- if( AptPlugin.DEBUG_GFM )
- AptPlugin.trace(
- "generated resource change listener got a pre-delete event: project = " + p.getName()); //$NON-NLS-1$
- IJavaProject jp = JavaCore.create(p);
- AptPlugin.getAptProject(jp).projectDeleted();
- AptPlugin.deleteAptProject(jp);
- }
- else if ( event.getType() == IResourceChangeEvent.PRE_BUILD )
- {
- try
- {
- if( AptPlugin.DEBUG_GFM )
- AptPlugin.trace("generated resource change listener got a pre-build event"); //$NON-NLS-1$
-
- final PreBuildVisitor pbv = new PreBuildVisitor();
-
- // First we need to handle previously deleted resources (from the post-change event),
- // because we could not perform file i/o during that event
- for (IResource resource : deletedResources) {
- pbv.handleDeletion(resource);
- }
-
- event.getDelta().accept( pbv );
- addGeneratedSrcFolderTo(pbv.getProjectsThatNeedGenSrcFolder());
-
- // Now clear the set of deleted resources,
- // as we don't want to re-handle them
- deletedResources.clear();
- }
- catch ( CoreException ce )
- {
- AptPlugin.log(ce, "Error during pre-build resource change"); //$NON-NLS-1$
- }
- }
- else if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
- if( AptPlugin.DEBUG_GFM )
- AptPlugin.trace(
- "generated resource change listener got a post-change event"); //$NON-NLS-1$
- PostChangeVisitor pcv = new PostChangeVisitor();
- try {
- event.getDelta().accept(pcv);
- }
- catch (CoreException ce) {
- AptPlugin.log(ce, "Error during post-change resource event"); //$NON-NLS-1$
- }
- }
- }
-
- private void addGeneratedSrcFolderTo(final Set<IProject> projs ){
-
- for(IProject proj : projs ){
- final IJavaProject javaProj = JavaCore.create(proj);
- if(javaProj.getProject().isOpen() && AptConfig.isEnabled(javaProj)){
- final GeneratedSourceFolderManager gsfm = AptPlugin.getAptProject(javaProj).getGeneratedSourceFolderManager();
- gsfm.ensureFolderExists();
- }
- }
-
- }
-
- /**
- * We need a post-change visitor, as there is a bug in the platform for
- * resource change notification -- some items will be reported *only* in the post-change event,
- * so we keep track of them here and handle them in the pre-build
- */
- private class PostChangeVisitor implements IResourceDeltaVisitor {
-
- public boolean visit(IResourceDelta delta) throws CoreException {
- if( delta.getKind() == IResourceDelta.REMOVED ){
- if (AptPlugin.DEBUG_GFM) {
- AptPlugin.trace("generated resource post-change listener adding to deletedResources:" + //$NON-NLS-1$
- delta.getResource().getName());
- }
- deletedResources.add(delta.getResource());
- }
-
- return true;
- }
-
- }
-
- private class PreBuildVisitor implements IResourceDeltaVisitor
- {
- // projects that we need to add the generated source folder to.
- private final Set<IProject> _addGenFolderTo = new HashSet<IProject>();
- // any projects that is closed or about to be deleted
- private final Set<IProject> _removedProjects = new HashSet<IProject>();
- public boolean visit(IResourceDelta delta) throws CoreException
- {
- IResource r = delta.getResource();
- IProject project = r.getProject();
-
- if ( project == null )
- return true;
-
- if( delta.getKind() == IResourceDelta.REMOVED ){
- if (!deletedResources.contains(r)) {
- handleDeletion(r);
- }
- }
- else if( r instanceof IProject ){
- final IProject proj = (IProject)delta.getResource();
- if( canUpdate(proj) ){
- _addGenFolderTo.add(proj);
- }
- else
- _removedProjects.add(proj);
- }
-
- return true;
- }
-
- private void handleDeletion(IResource resource) throws CoreException {
- if (AptPlugin.DEBUG_GFM) {
- AptPlugin.trace("handleDeletion: resource = " + resource.getName()); //$NON-NLS-1$
- }
- IProject project = resource.getProject();
- final IJavaProject javaProj = JavaCore.create(project);
- final AptProject aptProj = AptPlugin.getAptProject(javaProj);
- if( resource instanceof IFile ){
- final GeneratedFileManager gfm = aptProj.getGeneratedFileManager();
- IFile f = (IFile)resource;
- gfm.fileDeleted(f);
- }
- else if( resource instanceof IFolder ){
- final GeneratedSourceFolderManager gsfm = aptProj.getGeneratedSourceFolderManager();
- IFolder f = (IFolder) resource;
- if ( gsfm.isGeneratedSourceFolder( f ) ){
- gsfm.folderDeleted();
- // all deletion occurs before any add (adding the generated source directory)
- if( !_removedProjects.contains(project) ){
- _addGenFolderTo.add(project);
- }
- // if the project is already closed or in the process of being
- // deleted, will ignore this deletion since we cannot correct
- // the classpath anyways.
- }
- }
- else if( resource instanceof IProject ){
- _removedProjects.add((IProject)resource);
- }
- }
-
- Set<IProject> getProjectsThatNeedGenSrcFolder(){
- _addGenFolderTo.removeAll(_removedProjects);
- return _addGenFolderTo;
- }
-
- private boolean canUpdate(IProject proj)
- throws CoreException
- {
- return proj.isOpen() && proj.exists() && proj.hasNature(JavaCore.NATURE_ID);
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedSourceFolderManager.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedSourceFolderManager.java
deleted file mode 100644
index 8aba5a768e..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedSourceFolderManager.java
+++ /dev/null
@@ -1,507 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.generatedfile;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-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.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.AptProject;
-import org.eclipse.jdt.apt.core.internal.util.FileSystemUtil;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaModelException;
-
-/**
- * Manage the generated source folder for an APT project.
- * Every AptProject has a GeneratedSourceFolderManager. Depending on whether APT
- * is enabled for the project, there may or may not be an actual generated
- * source folder on disk; GeneratedSourceFolderManager is responsible for creating
- * and deleting this folder as needed whenever APT settings are changed.
- * <p>
- * The job of the GeneratedSourceFolderManager is to keep the following data
- * in agreement:
- * <ul>
- * <li>whether APT is enabled</li>
- * <li>the name of the generated source folder</li>
- * <li>the existence of the actual folder on disk</li>
- * <li>the presence of a classpath entry for the folder</li>
- * <li>problem markers indicating a disagreement in any of the above</li>
- * </ul>
- * We attempt to change the classpath entry and the folder on disk whenever
- * the enabled/disabled state or the folder name change. These changes are
- * discovered via the preferenceChanged() method.
- * <p>
- * GeneratedSourceFolderManager is responsible only for the folder itself, not
- * its contents. Contents are managed by @see GeneratedFileManager.
- *
- */
-public class GeneratedSourceFolderManager {
-
- private final AptProject _aptProject;
-
- /**
- * The folder where generated source files are placed. This will be
- * null if APT is disabled, or in any other error state (e.g., folder
- * does not exist on disk; folder exists on disk but classpath entry
- * does not exist).
- * <p>
- * In general, if we see that this member is null but the ENABLED
- * preference is true, we will try to create the folder and add it to
- * the classpath; if we see that this member is non-null but the
- * ENABLED preference is false, we will try to delete this folder's
- * contents and remove it from the classpath; and if we see that the
- * ENABLED preference is true, but the GENSRCDIR folder name preference
- * is different than the name of this folder, we will try to delete
- * this folder's contents, remove it from the classpath, and create a
- * new folder and add it to the classpath. When we do this work depends
- * on when we get notified of relevant changes and on what locks we are
- * able to obtain.
- */
- private IFolder _generatedSourceFolder = null;
-
- /**
- * Should be constructed only by AptProject. Other clients should call
- * @see AptProject#getGeneratedSourceFolderManager() to get this object.
- */
- public GeneratedSourceFolderManager(AptProject aptProject)
- {
- _aptProject = aptProject;
- final IJavaProject javaProject = aptProject.getJavaProject();
-
- // Set _generatedSourceFolder only if APT is enabled, the folder exists,
- // and the folder is on the classpath.
- // Otherwise leave it null, which will cause us to try to fix things later on.
- if (AptConfig.isEnabled(javaProject)) {
- final IFolder folder = getFolder();
- if (folder.exists()) {
- if (isOnClasspath(folder)) {
- _generatedSourceFolder = folder;
- }
- }
- }
- }
-
- /**
- * Add the folder to the classpath, unless it's already there.
- * @param srcFolder the folder to add to the classpath. Must not be null.
- * @return true if, at the end of the routine, the folder is on the classpath.
- */
- private boolean addToClasspath(IFolder srcFolder) {
- boolean onClasspath = false;
- try {
- ClasspathUtil.updateProjectClasspath( _aptProject.getJavaProject(), srcFolder, null );
- if(AptPlugin.DEBUG)
- AptPlugin.trace("Ensured classpath has an entry for " + srcFolder); //$NON-NLS-1$
- onClasspath = true;
- }
- catch (CoreException e) {
- e.printStackTrace();
- AptPlugin.log(e, "Failed to add classpath entry for generated source folder " + srcFolder.getName()); //$NON-NLS-1$
- }
- return onClasspath;
- }
-
- /**
- * Call this to create the folder and add it to the classpath, when APT is enabled
- * (in which case the folder did not previously exist) or when the folder name is
- * changed (in which case the old stuff must also be removed).
- * <p>
- * This method will take a resource lock if the generated source folder needs
- * to be created on disk, and it will take a java model lock if the project's
- * source paths need to be updated. Care should be taken when calling this
- * method to ensure that locking behavior is correct.
- * <p>
- * This should only be called on an event thread, with no locks on the project
- * or classpath.
- */
- private void configure() {
-
- assert(_generatedSourceFolder == null): "Should have already removed old folder by now"; //$NON-NLS-1$
- IFolder srcFolder = getFolderPreference();
- if (srcFolder == null) {
- IStatus status = AptPlugin.createStatus(null, "Could not create generated source folder (" + //$NON-NLS-1$
- AptConfig.getGenSrcDir(_aptProject.getJavaProject()) + ")"); //$NON-NLS-1$
- AptPlugin.log(status);
- return;
- }
-
- // Ensure that the new folder exists on disk.
- if (createOnDisk(srcFolder)) {
- // Add it to the classpath.
- if (addToClasspath(srcFolder)) {
- // Only if we get this far do we actually set _generatedSourceFolder.
- synchronized ( this ) {
- _generatedSourceFolder = srcFolder;
- }
- }
- }
- }
-
-
- /**
- * Creates the generated source folder if necessary. This should be called just
- * before doing a build.
- * No changes to the classpath will be made.
- */
- public void ensureFolderExists(){
- // If APT is disabled, do nothing.
- if (!AptConfig.isEnabled(_aptProject.getJavaProject())) {
- return;
- }
-
- // In principle we could bail out here, if (_generatedSourceFolder != null).
- // However, this method is an opportunity to detect and fix problems such
- // as the folder getting deleted without generatedSourceFolderDeleted()
- // getting called (e.g., without user having done a refresh).
- IFolder srcFolder = getFolder();
- if (srcFolder == null) {
- IStatus status = AptPlugin.createStatus(null, "Could not create generated source folder (" + //$NON-NLS-1$
- AptConfig.getGenSrcDir(_aptProject.getJavaProject()) + ")"); //$NON-NLS-1$
- AptPlugin.log(status);
- return;
- }
-
- if (createOnDisk(srcFolder)) {
- if (isOnClasspath(srcFolder)) {
- synchronized (this) {
- // Only set _generatedSourceFolder if folder is on disk and on classpath.
- _generatedSourceFolder = srcFolder;
- }
- }
- }
- }
-
- /**
- * Create a folder on disk, unless it already exists.
- * <p>
- * This method will frequently be called on multiple threads simultaneously
- * (e.g., build thread and UI thread).
- * @param srcFolder the folder to create. Must not be null.
- * @return true if, at the end of the routine, the folder exists on disk.
- */
- private boolean createOnDisk(IFolder srcFolder) {
- boolean exists = false;
- try {
- // don't take any locks while creating the folder, since we are doing file-system operations
- srcFolder.refreshLocal( IResource.DEPTH_INFINITE, null );
- if (!srcFolder.exists()) {
- FileSystemUtil.makeDerivedParentFolders(srcFolder);
- if(AptPlugin.DEBUG)
- AptPlugin.trace("Created folder " + srcFolder + " on disk"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- exists = true;
- }
- catch (CoreException e) {
- e.printStackTrace();
- AptPlugin.log(e, "Failed to ensure existence of generated source folder " + srcFolder.getName()); //$NON-NLS-1$
- }
- return exists;
- }
-
- /**
- * Call this method when the APT_ENABLED preference has changed.
- *
- * Configure the generated source folder according to whether APT is enabled
- * or disabled. If enabled, the folder will be created and a classpath entry
- * will be added. If disabled, the folder and classpath entry will be removed.
- * <p>
- * This should only be called on an event thread, with no locks on the project
- * or classpath.
- */
- public void enabledPreferenceChanged()
- {
- final boolean enable = AptConfig.isEnabled(_aptProject.getJavaProject());
- // Short-circuit if nothing changed.
- if (enable == (_generatedSourceFolder != null)) {
- if( AptPlugin.DEBUG ) {
- AptPlugin.trace("enabledChanged() doing nothing; state is already " + enable); //$NON-NLS-1$
- }
- // no change in state
- return;
- }
-
- if ( AptPlugin.DEBUG ) {
- AptPlugin.trace("enabledChanged() changing state to " + enable + //$NON-NLS-1$
- " for " + _aptProject.getJavaProject().getElementName()); //$NON-NLS-1$
- }
- if( enable ) {
- configure();
- }
- else {
- removeFolder();
- }
- }
-
- /**
- * Respond to a change in the name of the generated source folder.
- * If APT is enabled, remove the old folder and classpath entry and
- * create new ones.
- * <p>
- * This should only be called on an event thread, with no locks on the project
- * or classpath.
- */
- public void folderNamePreferenceChanged()
- {
- // if APT is disabled, we don't need to do anything
- final boolean aptEnabled = AptConfig.isEnabled(_aptProject.getJavaProject());
- if (!aptEnabled) {
- return;
- }
-
- // if name didn't change, we don't need to do anything
- if (_generatedSourceFolder != null && _generatedSourceFolder.equals(getFolderPreference())) {
- if( AptPlugin.DEBUG ) {
- AptPlugin.trace("folderNameChanged() doing nothing; name is already " + //$NON-NLS-1$
- _generatedSourceFolder.getProjectRelativePath());
- }
- return;
- }
-
- removeFolder();
- configure();
- }
-
- /**
- * Invoked when the generated source folder has been deleted. This will
- * flush any in-memory state tracking generated files, and cause the
- * generated source folder to be recreated the next time we build.
- *
- * Note: this should only be called within a resource change event to ensure that the classpath
- * is correct during any build. Resource change event never occurs during a build.
- */
- public void folderDeleted()
- {
- _aptProject.projectClean( false );
-
- IFolder srcFolder;
- synchronized(this){
- srcFolder = _generatedSourceFolder;
- _generatedSourceFolder = null;
- }
- if(AptPlugin.DEBUG)
- AptPlugin.trace("set _generatedSourceFolder to null; was " + srcFolder ); //$NON-NLS-1$
- }
-
- /**
- * This method will return the binary output location for the generated source folder.
- * If the generated-source folder is not configured (i.e., not created or not added to
- * the project's source path, then this method will return the default binary output
- * location for the project.
- *
- * @return the IPath corresponding to the binary output location for the
- * generated source folder. This is relative to the project.
- *
- * @throws JavaModelException
- *
- * @see #getFolder()
- */
- public IPath getBinaryOutputLocation()
- throws JavaModelException
- {
- IPath outputRootPath = null;
- IFolder generatedSourceFolder = getFolder();
- if ( generatedSourceFolder != null && generatedSourceFolder.exists() )
- {
- IClasspathEntry cpe = ClasspathUtil.findProjectSourcePath( _aptProject.getJavaProject(), generatedSourceFolder );
- if ( cpe != null )
- outputRootPath = cpe.getOutputLocation();
- }
-
- // no output root, so get project's default output location
- if ( outputRootPath == null )
- outputRootPath = _aptProject.getJavaProject().getOutputLocation();
-
- // output location is relative to the workspace, we want to make it relative to project
- int segments = outputRootPath.matchingFirstSegments( _aptProject.getJavaProject().getPath() );
- outputRootPath = outputRootPath.removeFirstSegments( segments );
-
- return outputRootPath;
- }
-
- /**
- * Get the current generated source folder; or if it is null, return
- * an IFolder corresponding to the current generated source folder name.
- * This is a handle-only operation and does not have anything to do with
- * whether the folder exists on disk.
- * @throws IllegalArgumentException if the name is invalid (e.g., "..").
- */
- public IFolder getFolder(){
-
- synchronized (this) {
- if( _generatedSourceFolder != null )
- return _generatedSourceFolder;
- }
-
- return getFolderPreference();
- }
-
- /**
- * Get an IFolder that corresponds to the folder name preference.
- * This has nothing to do with whether APT is enabled or disabled,
- * nothing to do with whether the folder exists on disk; it's just
- * a handle corresponding to a name.
- * @return null if the IFolder could not be created, which probably
- * means that the name is something illegal like "..".
- */
- private IFolder getFolderPreference() {
- final String folderName = AptConfig.getGenSrcDir(_aptProject.getJavaProject());
- IFolder folder = null;
- try {
- folder = _aptProject.getJavaProject().getProject().getFolder( folderName );
- }
- catch (IllegalArgumentException e) {
- // In the event that the folderName is invalid, just return null.
- }
- return folder;
- }
-
- /**
- * returns true if the specified folder is the source folder used where
- * generated files are placed.
- *
- * @param folder - the folder to determine if it is the generated source folder
- * @return true if it is the generated source folder, false otherwise.
- *
- * @see #getFolder()
- */
- public boolean isGeneratedSourceFolder( IFolder folder )
- {
- return folder != null && folder.equals( getFolder() );
- }
-
- private boolean isOnClasspath(IFolder srcFolder) {
- boolean found = false;
- try {
- if (ClasspathUtil.doesClasspathContainEntry(
- _aptProject.getJavaProject(), null, srcFolder.getFullPath(), null)) {
- found = true;
- }
- } catch (JavaModelException e) {
- e.printStackTrace();
- }
- return found;
- }
-
- /**
- * Remove a folder from disk and from the classpath.
- * @param srcFolder
- */
- private void removeFolder() {
- final IFolder srcFolder;
- synchronized ( this )
- {
- srcFolder = _generatedSourceFolder;
- _generatedSourceFolder = null;
- }
- if (srcFolder == null) {
- return;
- }
-
- // Clear out the generated file maps
- _aptProject.projectClean(false);
-
- // clean up the classpath first so that when we actually delete the
- // generated source folder we won't cause a classpath error.
- try {
- if (srcFolder.isDerived()) {
- ClasspathUtil.removeFromProjectClasspath( _aptProject.getJavaProject(), srcFolder, null );
- }
- } catch (JavaModelException e) {
- AptPlugin.log( e, "Failed to remove classpath entry for old generated src folder " + srcFolder.getName() ); //$NON-NLS-1$
- }
-
- final IWorkspaceRunnable runnable = new IWorkspaceRunnable(){
- public void run(IProgressMonitor monitor)
- {
- try {
- IResource parent = srcFolder.getParent();
- boolean deleted = FileSystemUtil.deleteDerivedResources(srcFolder);
-
- // We also want to delete our parent folder(s) if they are derived and empty
- if (deleted) {
- while (parent.isDerived() && parent.getType() == IResource.FOLDER) {
- IFolder parentFolder = (IFolder)parent;
- if (parentFolder.members().length == 0) {
- parent = parentFolder.getParent();
- FileSystemUtil.deleteDerivedResources(parentFolder);
- }
- else {
- break;
- }
- }
- }
-
- } catch(CoreException e) {
- AptPlugin.log(e, "failed to delete old generated source folder " + srcFolder.getName() ); //$NON-NLS-1$
- } catch(OperationCanceledException cancel) {
- AptPlugin.log(cancel, "deletion of generated source folder got cancelled"); //$NON-NLS-1$
- }
- }
- };
- IWorkspace ws = ResourcesPlugin.getWorkspace();
- try{
- ws.run(runnable, ws.getRoot(), IWorkspace.AVOID_UPDATE, null);
- }catch(CoreException e){
- AptPlugin.log(e, "Runnable for deleting old generated source folder " + srcFolder.getName() + " failed."); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * Check whether the proposed name is permitted.
- * @param folderName can be anything, including null.
- * @return true if attempting to set the generated source folder to
- * <code>dirString</code> is likely to succeed.
- */
- public static boolean validate(final IJavaProject jproj, final String folderName) {
- boolean succeeded = false;
- try {
- if (jproj != null) {
- // If we have a specific project, we can just ask.
- IFolder folder = null;
- folder = jproj.getProject().getFolder( folderName );
- succeeded = (folder != null);
- }
- else {
- // We're being asked about the default, so no specific project;
- // here we have to guess. The code that will later fail if we
- // get it wrong is IProject.getFolder(String). So we use some
- // heuristics.
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IPath state = AptPlugin.getPlugin().getStateLocation();
- IPath proposed = new Path(folderName);
- IPath combined = state.append(proposed);
- if (combined.segmentCount() <= state.segmentCount()) {
- // proposed folder depth is too shallow
- return false;
- }
- IFolder folder = root.getFolder(combined);
- succeeded = (folder != null);
- }
- }
- catch (IllegalArgumentException e) {
- return false;
- }
- return succeeded;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/WorkingCopyCleanupListener.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/WorkingCopyCleanupListener.java
deleted file mode 100644
index 6dacf3ff15..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/WorkingCopyCleanupListener.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.runtime.CoreException;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.core.ElementChangedEvent;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IElementChangedListener;
-import org.eclipse.jdt.core.IJavaElementDelta;
-import org.eclipse.jdt.core.IJavaProject;
-
-/**
- * Used by the GeneratedFileManager in order to clean up working copies after a build
- */
-public class WorkingCopyCleanupListener implements IElementChangedListener
-{
- public void elementChanged(ElementChangedEvent event)
- {
- Object o = event.getSource();
- if ( o instanceof IJavaElementDelta )
- {
- IJavaElementDelta delta = (IJavaElementDelta) o;
- processElementDelta( delta );
-
- }
- }
-
- private void processElementDelta( IJavaElementDelta delta )
- {
- IJavaElementDelta[] deltas = delta.getAffectedChildren();
- if ( deltas != null && deltas.length > 0 )
- {
- for( int i = 0; i<deltas.length; i++ )
- processElementDelta( deltas[i] );
- }
- if ( delta.getElement() instanceof ICompilationUnit )
- {
- //
- // handle case where a working copy is discarded (e.g., an editor is closed). If an editor
- // is not open, then the compilation unit's isWorkingCopy() will return false.
- //
-
- ICompilationUnit cu = (ICompilationUnit) delta.getElement();
-
- boolean workingCopyDiscarded =
- cu.getOwner() == null ? !cu.isWorkingCopy() : !cu.exists();
-
- if ( workingCopyDiscarded )
- {
- IJavaProject jp = cu.getJavaProject();
- GeneratedFileManager gfm = AptPlugin.getAptProject(jp).getGeneratedFileManager();
- try {
- gfm.workingCopyDiscarded( cu );
- } catch (CoreException e) {
- AptPlugin.log(e, "Failure processing delta: " + delta); //$NON-NLS-1$
- }
- }
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/messages.properties b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/messages.properties
deleted file mode 100644
index 87ca9402b0..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/messages.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 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
-###############################################################################
-AnnotationProcessorFactoryLoader_jarNotFound=Could not find jar:
-AnnotationProcessorFactoryLoader_factorypath_missingLibrary=Project {1} is missing required annotation processor library: ''{0}''
-AnnotationProcessorFactoryLoader_unableToLoadFactoryClass=Unable to load annotation processor factory ''{0}'' for project {1}
-AnnotationProcessorFactoryLoader_factorypath=Annotation processor factory path
-AnnotationProcessorFactoryLoader_ioError=Could not load from jar:
-GeneratedFileManager_missing_classpath_entry=Generated source folder ''{0}'' is missing from classpath
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 cb4798a37e..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/ArrayTypeImpl.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.util.TypeVisitor;
-
-import org.eclipse.jdt.apt.core.internal.declaration.EclipseMirrorType;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-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, EclipseMirrorType
-{
- private final ITypeBinding _arrayBinding;
- private final BaseProcessorEnv _env;
- public ArrayTypeImpl(final ITypeBinding binding, BaseProcessorEnv env)
- {
- _arrayBinding = binding;
- _env = env;
- assert _arrayBinding != null && _arrayBinding.isArray();
- assert env != null : "missing environment"; //$NON-NLS-1$
- }
-
- public void accept(TypeVisitor visitor)
- {
- visitor.visitArrayType(this);
- }
-
- public EclipseMirrorType getComponentType()
- {
- final ITypeBinding elementType = _arrayBinding.getElementType();
- final int dimension = _arrayBinding.getDimensions();
- // guarding around error cases.
- if( dimension == 0 ) return null;
- final ITypeBinding result;
- if( dimension == 1 ) // the element type is the component type.
- result = elementType;
- else{
- final String componentKey = BindingKey.createArrayTypeBindingKey(elementType.getKey(), dimension - 1);
- result = _env.getTypeBindingFromKey(componentKey);
- if( result == null )
- throw new IllegalStateException("unknown component type for " + _arrayBinding); //$NON-NLS-1$
- }
-
- final EclipseMirrorType mirror = Factory.createTypeMirror(result, _env);
- if( mirror == null )
- return (EclipseMirrorType)Factory.createErrorClassType(result);
- return mirror;
- }
-
- public String toString(){
- final ITypeBinding elementType = _arrayBinding.getElementType();
- final StringBuilder buffer = new StringBuilder();
- String name = elementType.getQualifiedName();
- buffer.append(name);
- for( int i=0, dim = _arrayBinding.getDimensions(); i<dim; i++ )
- buffer.append("[]"); //$NON-NLS-1$
-
- return buffer.toString();
- }
-
- public boolean equals(Object obj)
- {
- if( obj instanceof ArrayTypeImpl )
- return _arrayBinding == ((ArrayTypeImpl)obj)._arrayBinding;
- return false;
- }
-
- public ITypeBinding getTypeBinding(){ return _arrayBinding; }
-
- public int hashCode(){ return _arrayBinding.hashCode(); }
-
- public MirrorKind kind(){ return MirrorKind.TYPE_ARRAY; }
-
- public BaseProcessorEnv getEnvironment(){ return _env; }
-
- public boolean isAssignmentCompatible(EclipseMirrorType left) {
- return isSubTypeCompatible(left);
- }
-
- public boolean isSubTypeCompatible(EclipseMirrorType type) {
- if (type.kind() == MirrorKind.TYPE_CLASS)
- return "java.lang.Object".equals(type.getTypeBinding().getQualifiedName()); //$NON-NLS-1$
- if (type.kind() == MirrorKind.TYPE_INTERFACE)
- return "java.lang.Cloneable".equals(type.getTypeBinding().getQualifiedName()) || //$NON-NLS-1$
- "java.io.Serializable".equals(type.getTypeBinding().getQualifiedName()); //$NON-NLS-1$
- if (type.kind() == MirrorKind.TYPE_ARRAY) {
- EclipseMirrorType element1 = getComponentType();
- EclipseMirrorType element2 = ((ArrayTypeImpl)type).getComponentType();
- return element1.isSubTypeCompatible(element2);
- }
- return false;
- }
-
-}
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 d9d4db822b..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/ErrorType.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.declaration.TypeDeclaration;
-import com.sun.mirror.type.AnnotationType;
-import com.sun.mirror.type.ArrayType;
-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.declaration.EclipseMirrorType;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-/**
- * This is the error type marker
- */
-public abstract class ErrorType implements DeclaredType, ReferenceType, EclipseMirrorType
-{
- 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);
- }
-
- public Collection<InterfaceType> getSuperinterfaces(){ return Collections.emptyList(); }
-
- public MirrorKind kind(){ return MirrorKind.TYPE_ERROR; }
-
- public BaseProcessorEnv getEnvironment(){ return null; }
-
- public static final class ErrorClass extends ErrorType implements ClassType
- {
- public ErrorClass(final String name){ super(name); }
-
- public void accept(TypeVisitor 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)
- {
- 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)
- {
- visitor.visitAnnotationType(this);
- }
-
- public AnnotationTypeDeclaration getDeclaration(){ return null; }
- }
-
- public static final class ErrorArrayType extends ErrorType implements ArrayType
- {
- private final int _dimension;
- public ErrorArrayType(final String name, final int dimension )
- {
- super(name);
- _dimension = dimension;
- }
-
- public void accept(TypeVisitor visitor)
- {
- visitor.visitArrayType(this);
- }
-
- public TypeDeclaration getDeclaration() { return null; }
-
- public TypeMirror getComponentType() {
- return new ErrorClass(_name);
- }
-
- public String toString()
- {
- final StringBuilder buffer = new StringBuilder();
- buffer.append(_name);
- for( int i=0; i<_dimension; i++ )
- buffer.append("[]"); //$NON-NLS-1$
- return buffer.toString();
- }
- }
-
- public ITypeBinding getTypeBinding() {
- return null;
- }
-
- public boolean isAssignmentCompatible(EclipseMirrorType left) {
- return false;
- }
-
- public boolean isSubTypeCompatible(EclipseMirrorType type) {
- return false;
- }
-}
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 2c11742e42..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/PrimitiveTypeImpl.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.declaration.EclipseMirrorType;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-public class PrimitiveTypeImpl implements PrimitiveType, EclipseMirrorType
-{
- private final ITypeBinding _binding;
-
- public PrimitiveTypeImpl(ITypeBinding binding)
- {
- assert binding != null;
- _binding = binding;
- }
- public void accept(TypeVisitor visitor)
- {
- visitor.visitPrimitiveType(this);
- }
-
- public PrimitiveType.Kind getKind()
- {
- final String name = getTypeBinding().getName();
- if( "int".equals(name) ) //$NON-NLS-1$
- return PrimitiveType.Kind.INT;
- else if( "byte".equals(name) ) //$NON-NLS-1$
- return PrimitiveType.Kind.BYTE;
- else if( "short".equals(name) ) //$NON-NLS-1$
- return PrimitiveType.Kind.SHORT;
- else if( "char".equals(name) ) //$NON-NLS-1$
- return PrimitiveType.Kind.CHAR;
- else if( "long".equals(name) ) //$NON-NLS-1$
- return PrimitiveType.Kind.LONG;
- else if( "float".equals(name) ) //$NON-NLS-1$
- return PrimitiveType.Kind.FLOAT;
- else if( "double".equals(name) ) //$NON-NLS-1$
- return PrimitiveType.Kind.DOUBLE;
- else if( "boolean".equals(name)) //$NON-NLS-1$
- return PrimitiveType.Kind.BOOLEAN;
- else
- throw new IllegalStateException("unrecognized primitive type " + _binding); //$NON-NLS-1$
- }
-
- 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 BaseProcessorEnv getEnvironment(){ return null; }
-
- public boolean isAssignmentCompatible(EclipseMirrorType left) {
- return getTypeBinding().isAssignmentCompatible(left.getTypeBinding());
- }
- public boolean isSubTypeCompatible(EclipseMirrorType type) {
- return getTypeBinding().isSubTypeCompatible(type.getTypeBinding());
- }
-}
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 7c59f99f0a..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/VoidTypeImpl.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.declaration.EclipseMirrorType;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-public class VoidTypeImpl implements VoidType, EclipseMirrorType
-{
- private final ITypeBinding _binding;
-
- public VoidTypeImpl(final ITypeBinding binding){
- assert binding != null : "missing binding"; //$NON-NLS-1$
- _binding = binding;
- }
-
- public void accept(TypeVisitor visitor)
- {
- visitor.visitVoidType(this);
- }
-
- public String toString(){ return "void"; } //$NON-NLS-1$
-
- public ITypeBinding getTypeBinding(){return _binding;}
-
- public MirrorKind kind(){ return MirrorKind.TYPE_VOID; }
-
- public BaseProcessorEnv getEnvironment(){ return null; }
-
- public boolean isAssignmentCompatible(EclipseMirrorType left) {
- return false;
- }
-
- public boolean isSubTypeCompatible(EclipseMirrorType type) {
- return false;
- }
-}
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 12f4c6e7e8..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/type/WildcardTypeImpl.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.declaration.EclipseMirrorType;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.apt.core.internal.util.Factory;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-public class WildcardTypeImpl implements WildcardType, EclipseMirrorType
-{
- private final ITypeBinding _binding;
- private final BaseProcessorEnv _env;
-
- public WildcardTypeImpl(ITypeBinding binding, BaseProcessorEnv env)
- {
- _binding = binding;
- _env = env;
- assert _binding != null && _binding.isWildcardType();
- assert env != null : "missing environment"; //$NON-NLS-1$
- }
-
- public void accept(TypeVisitor visitor)
- {
- 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 getTypeBinding(){ return _binding; }
-
- public BaseProcessorEnv getEnvironment(){ return _env; }
-
- public boolean isAssignmentCompatible(EclipseMirrorType left) {
- return false;
- }
-
- public boolean isSubTypeCompatible(EclipseMirrorType type) {
- return false;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/AnnotationScanner.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/AnnotationScanner.java
deleted file mode 100644
index 6b232c56a7..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/AnnotationScanner.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.internal.util;
-
-import java.io.IOException;
-
-import static org.eclipse.jdt.apt.core.internal.util.AnnotationScanner.State.*;
-
-/**
- * Utility scanner for quickly determining if a file contains annotations
- */
-public abstract class AnnotationScanner {
-
- enum State {
- NORMAL,
- SEEN_SLASH,
- IN_COMMENT,
- IN_COMMENT_SEEN_STAR,
- IN_SINGLE_LINE_COMMENT,
- IN_SINGLE_QUOTE,
- IN_DOUBLE_QUOTE
- }
-
- public AnnotationScanner() {}
-
- public boolean containsAnnotations() throws IOException {
- State state = NORMAL;
-
- // for escaping quotes -- need to ignore the next single character
- // Since this applies to all states it's handled separately
- boolean seenBackslash = false;
-
- int c = getNext();
- while (c != -1) {
-
- if (seenBackslash) {
- // Skip one character
- seenBackslash = false;
- }
- else if (c == '\\') {
- // Skip the next character
- seenBackslash = true;
- }
- else {
- // Handle the character based on state
- switch (state) {
-
- case NORMAL :
- if (c == '@')
- return true;
- if (c == '/') {
- state = SEEN_SLASH;
- }
- else if (c == '\'') {
- state = IN_SINGLE_QUOTE;
- }
- else if (c == '\"') {
- state = IN_DOUBLE_QUOTE;
- }
- break;
-
- case SEEN_SLASH :
- if (c == '*') {
- state = IN_COMMENT;
- }
- else if (c == '/') {
- state = IN_SINGLE_LINE_COMMENT;
- }
- else {
- state = NORMAL;
- }
- break;
-
- case IN_COMMENT :
- if (c == '*') {
- state = IN_COMMENT_SEEN_STAR;
- }
- break;
-
- case IN_COMMENT_SEEN_STAR :
- if (c == '/') {
- state = NORMAL;
- }
- else {
- state = IN_COMMENT;
- }
- break;
-
- case IN_SINGLE_LINE_COMMENT :
- if (c == '\n' || c == '\r') {
- state = NORMAL;
- }
- break;
-
- case IN_SINGLE_QUOTE :
- if (c == '\'') {
- state = NORMAL;
- }
- break;
-
- case IN_DOUBLE_QUOTE :
- if (c == '\"') {
- state = NORMAL;
- }
- break;
-
- default :
- throw new IllegalStateException("Unhandled state: " + state); //$NON-NLS-1$
- }
- }
- c = getNext();
- }
- return false;
- }
-
- /**
- * Returns -1 at the end of the input
- */
- protected abstract int getNext() throws IOException;
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/AptCorePreferenceInitializer.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/AptCorePreferenceInitializer.java
deleted file mode 100644
index 9f3e413982..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/AptCorePreferenceInitializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.core.internal.util;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.util.AptPreferenceConstants;
-
-/**
- * This class is used to extend org.eclipse.core.runtime.preferences.
- */
-public class AptCorePreferenceInitializer extends AbstractPreferenceInitializer {
-
- @Override
- public void initializeDefaultPreferences() {
- IEclipsePreferences defaultPreferences = new DefaultScope().getNode(AptPlugin.PLUGIN_ID);
- for (Map.Entry<String,String> entry : AptPreferenceConstants.DEFAULT_OPTIONS_MAP.entrySet()) {
- defaultPreferences.put(entry.getKey(), entry.getValue());
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/CharArrayAnnotationScanner.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/CharArrayAnnotationScanner.java
deleted file mode 100644
index 780fb692e1..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/CharArrayAnnotationScanner.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.internal.util;
-
-import java.io.IOException;
-
-
-public class CharArrayAnnotationScanner extends AnnotationScanner {
-
- private final char[] _data;
- private int index = 0;
-
- public CharArrayAnnotationScanner(final char[] data) {
- _data = data;
- }
-
- @Override
- protected int getNext() throws IOException {
- if (index == _data.length - 1)
- return -1;
- return _data[index++];
- }
-
-}
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 afae96af96..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/DeclarationsUtil.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.NonEclipseImplementationException;
-import org.eclipse.jdt.apt.core.internal.declaration.DeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.EclipseDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.EclipseMirrorObject;
-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;
-
- if( ! ((EclipseDeclarationImpl)sub).isBindingBased() ||
- ! ((EclipseDeclarationImpl)sup).isBindingBased() )
- 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 EclipseMirrorObject ){
- if( memberDecl instanceof DeclarationImpl )
- return ((DeclarationImpl)memberDecl).getDeclarationBinding();
- else
- return null;
- }
- throw new NonEclipseImplementationException("only applicable to eclipse type system objects." + //$NON-NLS-1$
- " Found " + memberDecl.getClass().getName()); //$NON-NLS-1$
- }
-
- 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 7fdbf55b08..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/Factory.java
+++ /dev/null
@@ -1,711 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.declaration.ParameterDeclaration;
-import com.sun.mirror.type.AnnotationType;
-import com.sun.mirror.type.ArrayType;
-import com.sun.mirror.type.ClassType;
-import com.sun.mirror.type.InterfaceType;
-import com.sun.mirror.type.PrimitiveType;
-import com.sun.mirror.type.TypeMirror;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.declaration.*;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-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.ASTNode;
-import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration;
-import org.eclipse.jdt.core.dom.IAnnotationBinding;
-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;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
-
-public class Factory
-{
- private static final String NULL_BINDING_NAME = "[NullBinding]"; //$NON-NLS-1$
- // using auto-boxing to take advantage of caching, if any.
- // the dummy value picked here falls within the caching range.
- public static final Byte DUMMY_BYTE = 0;
- public static final Character DUMMY_CHAR = '0';
- public static final Double DUMMY_DOUBLE = 0d;
- public static final Float DUMMY_FLOAT = 0f;
- public static final Integer DUMMY_INTEGER = 0;
- public static final Long DUMMY_LONG = 0l;
- public static final Short DUMMY_SHORT = 0;
- public static TypeDeclarationImpl createReferenceType(ITypeBinding binding, BaseProcessorEnv env)
- {
- if(binding == null || binding.isNullType()) return null;
- // "Recovered" bindings are bindings to unresolved types. The type itself may be considered
- // to exist (as an ErrorType) but there is no declaration.
- if (binding.isRecovered()) 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); //$NON-NLS-1$
-
- return mirror;
- }
-
- public static EclipseDeclarationImpl createDeclaration(IBinding binding, BaseProcessorEnv 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); //$NON-NLS-1$
- if( typeBinding.isTypeVariable() )
- return new TypeParameterDeclarationImpl(typeBinding, env);
- else
- 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); //$NON-NLS-1$
- }
- }
-
- public static EclipseDeclarationImpl createDeclaration(
- ASTNode node,
- IFile file,
- BaseProcessorEnv env)
- {
- if( node == null )
- return null;
- switch( node.getNodeType() )
- {
- case ASTNode.SINGLE_VARIABLE_DECLARATION:
- return new SourceParameterDeclarationImpl((SingleVariableDeclaration)node, file, env);
- case ASTNode.VARIABLE_DECLARATION_FRAGMENT:
- return new ASTBasedFieldDeclarationImpl( (VariableDeclarationFragment)node, file, env );
- case ASTNode.METHOD_DECLARATION :
- final org.eclipse.jdt.core.dom.MethodDeclaration methodDecl =
- (org.eclipse.jdt.core.dom.MethodDeclaration)node;
- if( methodDecl.isConstructor() )
- return new ASTBasedConstructorDeclarationImpl(methodDecl, file, env);
- else
- return new ASTBasedMethodDeclarationImpl(methodDecl, file, env );
- case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION:
- return new ASTBasedMethodDeclarationImpl((AnnotationTypeMemberDeclaration)node, file, env);
- default :
- throw new UnsupportedOperationException(
- "cannot create mirror type from " + //$NON-NLS-1$
- node.getClass().getName() );
- }
- }
-
- public static EclipseMirrorType createTypeMirror(ITypeBinding binding, BaseProcessorEnv env)
- {
- if( binding == null ) return null;
-
- if( binding.isPrimitive() ){
- if( "int".equals(binding.getName()) ) //$NON-NLS-1$
- return env.getIntType();
- else if( "byte".equals(binding.getName()) ) //$NON-NLS-1$
- return env.getByteType();
- else if( "short".equals(binding.getName()) ) //$NON-NLS-1$
- return env.getShortType();
- else if( "char".equals(binding.getName()) ) //$NON-NLS-1$
- return env.getCharType();
- else if( "long".equals(binding.getName()) ) //$NON-NLS-1$
- return env.getLongType();
- else if( "float".equals(binding.getName()) ) //$NON-NLS-1$
- return env.getFloatType();
- else if( "double".equals(binding.getName()) ) //$NON-NLS-1$
- return env.getDoubleType();
- else if( "boolean".equals(binding.getName())) //$NON-NLS-1$
- return env.getBooleanType();
- else if( "void".equals(binding.getName()) ) //$NON-NLS-1$
- return env.getVoidType();
- else
- throw new IllegalStateException("unrecognized primitive type: " + binding); //$NON-NLS-1$
- }
- 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);
- }
-
- public static ParameterDeclaration createParameterDeclaration(
- final SingleVariableDeclaration param,
- final IFile file,
- final BaseProcessorEnv env)
- {
- return new SourceParameterDeclarationImpl(param, file, env);
- }
-
-
- public static ParameterDeclaration createParameterDeclaration(
- final ExecutableDeclarationImpl exec,
- final int paramIndex,
- final ITypeBinding type,
- final BaseProcessorEnv env )
- {
- return new BinaryParameterDeclarationImpl(exec, type, paramIndex, 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 IAnnotationBinding annotation,
- final EclipseDeclarationImpl annotated,
- final BaseProcessorEnv env)
- {
- return new AnnotationMirrorImpl(annotation, annotated, env);
- }
-
- public static AnnotationValue createDefaultValue(
- Object domValue,
- AnnotationElementDeclarationImpl decl,
- BaseProcessorEnv env)
- {
- if( domValue == null ) return null;
- final Object converted = convertDOMValueToMirrorValue(
- domValue, null, decl, decl, env, decl.getReturnType());
-
- return createAnnotationValueFromDOMValue(converted, null, -1, decl, 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 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,
- ASTBasedAnnotationElementDeclarationImpl decl,
- BaseProcessorEnv env)
- {
- if( domValue == null ) return null;
- final Object converted = convertDOMValueToMirrorValue(
- domValue, null, decl, decl, env, decl.getReturnType());
-
- return createAnnotationValueFromDOMValue(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,
- BaseProcessorEnv env,
- TypeMirror expectedType)
- {
- if( domValue == null ) return null;
- final Object converted = convertDOMValueToMirrorValue(
- domValue, elementName, anno,
- anno.getAnnotatedDeclaration(), env, expectedType);
- return createAnnotationValueFromDOMValue(converted, elementName, -1, anno, env);
- }
-
- /**
- * @param convertedValue value in mirror form.
- * @param name the name of the annotation member or null for default value
- * @param index the number indicate the source order of the annotation member value
- * in the annotation instance.
- * @param mirror either {@link AnnotationMirrorImpl } or {@link AnnotationElementDeclarationImpl}
- * @param env
- */
- public static AnnotationValue createAnnotationValueFromDOMValue(Object convertedValue,
- String name,
- int index,
- EclipseMirrorObject mirror,
- BaseProcessorEnv 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.
- * @param expectedType the declared type of the member value.
- * @param needBoxing <code>true</code> indicate an array should be returned.
- * @return the converted annotation value or null if the conversion failed
- */
- private static Object convertDOMValueToMirrorValue(Object domValue,
- String name,
- EclipseMirrorObject parent,
- EclipseDeclarationImpl decl,
- BaseProcessorEnv env,
- TypeMirror expectedType)
- {
- if( domValue == null ) return null;
-
- final Object returnValue;
- 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 )
- returnValue = domValue;
-
- else if( domValue instanceof IVariableBinding )
- {
- returnValue = 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);
- final TypeMirror leaf;
- if( expectedType instanceof ArrayType )
- leaf = ((ArrayType)expectedType).getComponentType();
- else
- leaf = expectedType; // doing our best here.
- 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;
-
- Object o = convertDOMValueToMirrorValue( elements[i], name, parent, decl, env, leaf );
- if( o == null )
- return null;
- assert( !( o instanceof IAnnotationBinding ) ) :
- "Unexpected return value from convertDomValueToMirrorValue! o.getClass().getName() = " //$NON-NLS-1$
- + o.getClass().getName();
-
- final AnnotationValue annoValue = createAnnotationValueFromDOMValue(o, name, i, parent, env);
- if( annoValue != null )
- annoValues.add(annoValue);
- }
- return annoValues;
- }
- // caller should have caught this case.
- else if( domValue instanceof ITypeBinding )
- returnValue = Factory.createTypeMirror((ITypeBinding)domValue, env);
-
- else if( domValue instanceof IAnnotationBinding )
- {
- returnValue = Factory.createAnnotationMirror((IAnnotationBinding)domValue, decl, env);
- }
- else
- // should never reach this point
- throw new IllegalStateException("cannot build annotation value object from " + domValue); //$NON-NLS-1$
-
- return performNecessaryTypeConversion(expectedType, returnValue, name, parent, env);
- }
-
- public static Object getMatchingDummyValue(final Class<?> expectedType){
- if( expectedType.isPrimitive() ){
- if(expectedType == boolean.class)
- return Boolean.FALSE;
- else if( expectedType == byte.class )
- return DUMMY_BYTE;
- else if( expectedType == char.class )
- return DUMMY_CHAR;
- else if( expectedType == double.class)
- return DUMMY_DOUBLE;
- else if( expectedType == float.class )
- return DUMMY_FLOAT;
- else if( expectedType == int.class )
- return DUMMY_INTEGER;
- else if( expectedType == long.class )
- return DUMMY_LONG;
- else if(expectedType == short.class)
- return DUMMY_SHORT;
- else // expectedType == void.class. can this happen?
- return DUMMY_INTEGER; // anything would work
- }
- else
- return null;
- }
-
- /**
- * This method is designed to be invoke by the invocation handler and anywhere that requires
- * a AnnotationValue (AnnotationMirror member values and default values from anonotation member).
- *
- * Regardless of the path, there are common primitive type conversion that needs to take place.
- * The type conversions are respects the type widening and narrowing rules from JLS 5.1.2 and 5.1.2.
- *
- * The only question remains is what is the type of the return value when the type conversion fails? *
- * When <code>avoidReflectException</code> is set to <code>true</code>
- * Return <code>false</code> if the expected type is <code>boolean</code>
- * Return numeric 0 for all numeric primitive types and '0' for <code>char</code>
- *
- * Otherwise:
- * Return the value unchanged.
- *
- * In the invocation handler case:
- * The value returned by {@link java.lang.reflect.InvocationHandler#invoke}
- * will be converted into the expected type by the {@link java.lang.reflect.Proxy}.
- * If the value and the expected type does not agree, and the value is not null,
- * a ClassCastException will be thrown. A NullPointerException will be resulted if the
- * expected type is a primitive type and the value is null.
- * This behavior is currently causing annotation processor a lot of pain and the decision is
- * to not throw such unchecked exception. In the case where a ClassCastException or
- * NullPointerException will be thrown return some dummy value. Otherwise, return
- * the original value.
- * Chosen dummy values:
- * Return <code>false</code> if the expected type is <code>boolean</code>
- * Return numeric 0 for all numeric primitive types and '0' for <code>char</code>
- *
- * This behavior is triggered by setting <code>avoidReflectException</code> to <code>true</code>
- *
- * Note: the new behavior deviates from what's documented in
- * {@link java.lang.reflect.InvocationHandler#invoke} and also deviates from
- * Sun's implementation.
- *
- * see CR260743 and 260563.
- * @param value the current value from the annotation instance.
- * @param expectedType the expected type of the value.
- *
- */
- public static Object performNecessaryPrimitiveTypeConversion(
- final Class<?> expectedType,
- final Object value,
- final boolean avoidReflectException)
- {
- assert expectedType.isPrimitive() : "expectedType is not a primitive type: " + expectedType.getName(); //$NON-NLS-1$
- if( value == null)
- return avoidReflectException ? getMatchingDummyValue(expectedType) : null;
- // apply widening conversion based on JLS 5.1.2 and 5.1.3
- final String typeName = expectedType.getName();
- final char expectedTypeChar = typeName.charAt(0);
- final int nameLen = typeName.length();
- // widening byte -> short, int, long, float or double
- // narrowing byte -> char
- if( value instanceof Byte )
- {
- final byte b = ((Byte)value).byteValue();
- switch( expectedTypeChar )
- {
- case 'b':
- if(nameLen == 4) // byte
- return value; // exact match.
- else
- return avoidReflectException ? Boolean.FALSE : value;
- case 'c':
- return new Character((char)b); // narrowing.
- case 'd':
- return new Double(b); // widening.
- case 'f':
- return new Float(b); // widening.
- case 'i':
- return new Integer(b); // widening.
- case 'l':
- return new Long(b); // widening.
- case 's':
- return new Short(b); // widening.
- default:
- throw new IllegalStateException("unknown type " + expectedTypeChar); //$NON-NLS-1$
- }
- }
- // widening short -> int, long, float, or double
- // narrowing short -> byte or char
- else if( value instanceof Short )
- {
- final short s = ((Short)value).shortValue();
- switch( expectedTypeChar )
- {
- case 'b':
- if(nameLen == 4) // byte
- return new Byte((byte)s); // narrowing.
- else
- return avoidReflectException ? Boolean.FALSE : value; // completely wrong.
- case 'c':
- return new Character((char)s); // narrowing.
- case 'd':
- return new Double(s); // widening.
- case 'f':
- return new Float(s); // widening.
- case 'i':
- return new Integer(s); // widening.
- case 'l':
- return new Long(s); // widening.
- case 's':
- return value; // exact match
- default:
- throw new IllegalStateException("unknown type " + expectedTypeChar); //$NON-NLS-1$
- }
- }
- // widening char -> int, long, float, or double
- // narrowing char -> byte or short
- else if( value instanceof Character )
- {
- final char c = ((Character)value).charValue();
- switch( expectedTypeChar )
- {
- case 'b':
- if(nameLen == 4) // byte
- return new Byte((byte)c); // narrowing.
- else
- return avoidReflectException ? Boolean.FALSE : value; // completely wrong.
- case 'c':
- return value; // exact match
- case 'd':
- return new Double(c); // widening.
- case 'f':
- return new Float(c); // widening.
- case 'i':
- return new Integer(c); // widening.
- case 'l':
- return new Long(c); // widening.
- case 's':
- return new Short((short)c); // narrowing.
- default:
- throw new IllegalStateException("unknown type " + expectedTypeChar); //$NON-NLS-1$
- }
- }
-
- // widening int -> long, float, or double
- // narrowing int -> byte, short, or char
- else if( value instanceof Integer )
- {
- final int i = ((Integer)value).intValue();
- switch( expectedTypeChar )
- {
- case 'b':
- if(nameLen == 4) // byte
- return new Byte((byte)i); // narrowing.
- else
- return avoidReflectException ? Boolean.FALSE : value; // completely wrong.
- case 'c':
- return new Character((char)i); // narrowing
- case 'd':
- return new Double(i); // widening.
- case 'f':
- return new Float(i); // widening.
- case 'i':
- return value; // exact match
- case 'l':
- return new Long(i); // widening.
- case 's':
- return new Short((short)i); // narrowing.
- default:
- throw new IllegalStateException("unknown type " + expectedTypeChar); //$NON-NLS-1$
- }
- }
- // widening long -> float or double
- else if( value instanceof Long )
- {
- final long l = ((Long)value).longValue();
- switch( expectedTypeChar )
- {
- case 'b': // both byte and boolean
- case 'c':
- case 'i':
- case 's':
- // completely wrong.
- return avoidReflectException ? getMatchingDummyValue(expectedType) : value;
- case 'd':
- return new Double(l); // widening.
- case 'f':
- return new Float(l); // widening.
- case 'l':
- return value; // exact match.
-
- default:
- throw new IllegalStateException("unknown type " + expectedTypeChar); //$NON-NLS-1$
- }
- }
-
- // widening float -> double
- else if( value instanceof Float )
- {
- final float f = ((Float)value).floatValue();
- switch( expectedTypeChar )
- {
- case 'b': // both byte and boolean
- case 'c':
- case 'i':
- case 's':
- case 'l':
- // completely wrong.
- return avoidReflectException ? getMatchingDummyValue(expectedType) : value;
- case 'd':
- return new Double(f); // widening.
- case 'f':
- return value; // exact match.
- default:
- throw new IllegalStateException("unknown type " + expectedTypeChar); //$NON-NLS-1$
- }
- }
- else if( value instanceof Double ){
- if(expectedTypeChar == 'd' )
- return value; // exact match
- else{
- return avoidReflectException ? getMatchingDummyValue(expectedType) : value; // completely wrong.
- }
- }
- else if( value instanceof Boolean ){
- if( expectedTypeChar == 'b' && nameLen == 7) // "boolean".length() == 7
- return value;
- else
- return avoidReflectException ? getMatchingDummyValue(expectedType) : value; // completely wrong.
- }
- else // can't convert
- return avoidReflectException ? getMatchingDummyValue(expectedType) : value;
- }
-
- private static Class<?> getJavaLangClass_Primitive(final PrimitiveType primitiveType){
- switch( primitiveType.getKind() ){
- case BOOLEAN: return boolean.class;
- case BYTE: return byte.class;
- case CHAR: return char.class;
- case DOUBLE: return double.class;
- case FLOAT: return float.class;
- case INT: return int.class;
- case LONG: return long.class;
- case SHORT: return short.class;
- default:
- throw new IllegalStateException("unknow primitive type " + primitiveType ); //$NON-NLS-1$
- }
- }
-
- /**
- * Apply type conversion according to JLS 5.1.2 and 5.1.3 and / or auto-boxing.
- * @param expectedType the expected type
- * @param value the value where conversion may be applied to
- * @param name name of the member value
- * @param parent the of the annotation of the member value
- * @param env
- * @return the value matching the expected type or itself if no conversion can be applied.
- */
- private static Object performNecessaryTypeConversion(final TypeMirror expectedType,
- final Object value,
- final String name,
- final EclipseMirrorObject parent,
- final BaseProcessorEnv env)
- {
- if( expectedType == null )return value;
- if( expectedType instanceof PrimitiveType )
- {
- final Class<?> primitiveClass = getJavaLangClass_Primitive( (PrimitiveType)expectedType );
- return performNecessaryPrimitiveTypeConversion(primitiveClass, value, false);
- }
- // handle auto-boxing
- else if( expectedType instanceof ArrayType)
- {
- final TypeMirror componentType = ((ArrayType)expectedType).getComponentType();
- Object converted = value;
- // if it is an error case, will just leave it as is.
- if( !(componentType instanceof ArrayType ) )
- converted = performNecessaryTypeConversion(componentType, value, name, parent, env);
-
- final AnnotationValue annoValue = createAnnotationValueFromDOMValue(converted, name, 0, parent, env);
- return Collections.singletonList(annoValue);
- }
- else // no change
- return value;
- }
-
- public static InterfaceType createErrorInterfaceType(final ITypeBinding binding)
- {
- String name = null == binding ? NULL_BINDING_NAME : binding.getName();
- return new ErrorType.ErrorInterface(name);
- }
-
- public static ClassType createErrorClassType(final ITypeBinding binding)
- {
- String name = null == binding ? NULL_BINDING_NAME : binding.getName();
- return createErrorClassType(name);
- }
-
- public static ClassType createErrorClassType(final String name)
- {
- return new ErrorType.ErrorClass(name);
- }
-
- public static AnnotationType createErrorAnnotationType(final ITypeBinding binding)
- {
- String name = null == binding ? NULL_BINDING_NAME : binding.getName();
- return createErrorAnnotationType(name);
- }
-
- public static AnnotationType createErrorAnnotationType(String name)
- {
- return new ErrorType.ErrorAnnotation(name);
- }
-
- public static ArrayType createErrorArrayType(final String name, final int dimension)
- {
- return new ErrorType.ErrorArrayType(name, dimension);
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FactoryContainer.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FactoryContainer.java
deleted file mode 100644
index 153d6b442f..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FactoryContainer.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.util;
-
-import java.io.IOException;
-import java.util.Map;
-
-/**
- * An entry on the processor factory path. Typically a jar, plug-in,
- * etc. that contains annotation processors. It may contain Java 5
- * processors, Java 6 processors, both or neither.
- */
-public abstract class FactoryContainer
-{
- public enum FactoryType {
- PLUGIN, // Eclipse plugin
- EXTJAR, // external jar file (not in workspace)
- WKSPJAR, // jar file within workspace
- VARJAR; // external jar file referenced by classpath variable
- }
-
- /**
- * Returns an ID that is guaranteed to be sufficiently unique for this container --
- * that is, all necessary state can be reconstructed from just the id and FactoryType.
- * For plugins, it's the plugin id, for jar files, the path to the jar, etc.
- */
- public abstract String getId();
-
- /**
- * This method is used to display the container in the UI.
- * If this default implementation is not adequate for a particular
- * container, that container should provide an override.
- */
- @Override
- public String toString() {
- return getId();
- }
-
- public abstract FactoryType getType();
-
- /**
- * Test whether the resource that backs this container exists,
- * can be located, and is (at least in principle) accessible for
- * factories to be loaded from. For instance, a plugin exists if
- * the plugin is loaded in Eclipse; a jar exists if the jar file
- * can be found on disk. The test is not required to be perfect:
- * for instance, a jar file might exist but be corrupted and
- * therefore not really readable, but this method would still return
- * true.
- * @return true if the resource backing the container exists.
- */
- public abstract boolean exists();
-
- /**
- * Subclasses must return a map of implementation name to service
- * name, for all the processor services this container provides.
- * @throws IOException
- */
- protected abstract Map<String, String> loadFactoryNames() throws IOException;
-
- /**
- * Map of implementation name to service name. For instance,
- * "org.xyz.FooProcessor" -> "javax.annotation.processing.Processor".
- */
- protected Map<String, String> _factoryNames;
-
- public Map<String, String> getFactoryNames() throws IOException
- {
- if ( _factoryNames == null )
- _factoryNames = loadFactoryNames();
- return _factoryNames;
- }
-
- @Override
- public int hashCode() {
- return getType().hashCode() ^ getId().hashCode();
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof FactoryContainer)) {
- return false;
- }
-
- FactoryContainer other = (FactoryContainer) o;
- return other.getType() == getType() && other.getId().equals(getId());
- }
-}
-
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FactoryPath.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FactoryPath.java
deleted file mode 100644
index 9943db1ec0..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FactoryPath.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.util;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.FactoryPluginManager;
-import org.eclipse.jdt.apt.core.util.IFactoryPath;
-
-/**
- * Provides access to the annotation processor factory path for a Java project.
- * This class should not be instantiated or subclassed.
- *
- * The factory path is an ordered Map<FactoryContainer, FactoryPath.Attributes>.
- * Containers are things like jar files or plugins, that contain one or more
- * annotation processor factories. In the context of a particular project,
- * processors are given precedence according to the order of their container on
- * the factory path; and they are executed according to the container's attributes
- * on the factory path.
- */
-public class FactoryPath implements IFactoryPath {
-
- /**
- * Attributes of entries on the factory path. These belong here,
- * rather than on FactoryContainer itself, because the same container
- * might have different attributes in different projects - e.g., it
- * might be enabled in one project and disabled in another.
- */
- public static class Attributes {
- /** Should this container's processors be executed? */
- private boolean _enabled;
- /** Should this container's processors execute in Sun apt compatibility mode? (Slow and limiting!) */
- private boolean _runInBatchMode;
-
- // CONSTRUCTORS
- public Attributes(boolean enabled, boolean runInBatchMode) {
- _enabled = enabled;
- _runInBatchMode = runInBatchMode;
- }
- public Attributes(Attributes attr) {
- _enabled = attr._enabled;
- _runInBatchMode = attr._runInBatchMode;
- }
-
- // SUPPORT
- public boolean equals(Object o) {
- if (o == null || !(o instanceof Attributes))
- return false;
- Attributes oA = (Attributes)o;
- return (_enabled == oA._enabled) && (_runInBatchMode == oA._runInBatchMode );
- }
- public int hashCode() {
- return (_enabled ? 1 : 0) + (_runInBatchMode ? 2 : 0);
- }
-
-
- // GETTERS
- public boolean isEnabled() {
- return _enabled;
- }
- public boolean runInBatchMode() {
- return _runInBatchMode;
- }
-
- // SETTERS
- public void setEnabled(boolean enabled) {
- _enabled = enabled;
- }
- public void setRunInBatchMode(boolean runInBatchMode) {
- _runInBatchMode = runInBatchMode;
- }
- }
-
- /**
- * The factory path.
- */
- private final Map<FactoryContainer, Attributes> _path = Collections.synchronizedMap(
- new LinkedHashMap<FactoryContainer, Attributes>());
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.util.IFactoryPath#addExternalJar(java.io.File)
- */
- public void addExternalJar(File jar) {
- FactoryContainer fc = FactoryPathUtil.newExtJarFactoryContainer(jar);
- Attributes a = new Attributes(true, false);
- internalAdd(fc, a);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.util.IFactoryPath#removeExternalJar(java.io.File)
- */
- public void removeExternalJar(File jar) {
- FactoryContainer fc = FactoryPathUtil.newExtJarFactoryContainer(jar);
- _path.remove(fc);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.util.IFactoryPath#addVarJar(org.eclipse.core.runtime.IPath)
- */
- public void addVarJar(IPath jarPath) {
- FactoryContainer fc = FactoryPathUtil.newVarJarFactoryContainer(jarPath);
- Attributes a = new Attributes(true, false);
- internalAdd(fc, a);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.util.IFactoryPath#removeVarJar(org.eclipse.core.runtime.IPath)
- */
- public void removeVarJar(IPath jarPath) {
- FactoryContainer fc = FactoryPathUtil.newVarJarFactoryContainer(jarPath);
- _path.remove(fc);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.util.IFactoryPath#addWkspJar(org.eclipse.core.runtime.IPath)
- */
- public void addWkspJar(IPath jarPath) {
- FactoryContainer fc = FactoryPathUtil.newWkspJarFactoryContainer(jarPath);
- Attributes a = new Attributes(true, false);
- internalAdd(fc, a);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.util.IFactoryPath#removeWkspJar(org.eclipse.core.runtime.IPath)
- */
- public void removeWkspJar(IPath jarPath) {
- FactoryContainer fc = FactoryPathUtil.newWkspJarFactoryContainer(jarPath);
- _path.remove(fc);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.util.IFactoryPath#enablePlugin(java.lang.String)
- */
- public void enablePlugin(String pluginId) throws CoreException {
- FactoryContainer fc = FactoryPluginManager.getPluginFactoryContainer(pluginId);
- Attributes a = _path.get(fc);
- if (a == null) {
- Status status = AptPlugin.createWarningStatus(new IllegalArgumentException(),
- "Specified plugin was not found, so it could not be added to the annotation processor factory path: " + pluginId); //$NON-NLS-1$
- throw new CoreException(status);
- }
- a.setEnabled(true);
- internalAdd(fc, a);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.core.util.IFactoryPath#disablePlugin(java.lang.String)
- */
- public void disablePlugin(String pluginId) {
- FactoryContainer fc = FactoryPluginManager.getPluginFactoryContainer(pluginId);
- Attributes a = _path.get(fc);
- if (a != null) {
- a.setEnabled(false);
- }
- }
-
- /**
- * Add a single factory container to the head of the FactoryPath,
- * and save the new path to the appropriate settings file.
- * If the container specified is already in the project's list in
- * some other FactoryPathEntry, the existing entry will be removed
- * before the new one is added.
- * @param fc must not be null.
- */
- public void addEntryToHead(FactoryContainer fc, boolean enabled, boolean runInBatchMode) {
- Attributes a = new Attributes(enabled, runInBatchMode);
- internalAdd(fc, a);
- }
-
- /**
- * Set the factory path based on the contents of an ordered map.
- * @param map should be an ordered map, such as LinkedHashMap; should contain no
- * nulls; and should contain no duplicate FactoryContainers.
- */
- public void setContainers(Map<FactoryContainer, Attributes> map) {
- synchronized(_path) {
- _path.clear();
- _path.putAll(map);
- }
- }
-
- /**
- * Add a factory container, and attributes, to the head of the list.
- * If it already existed in the list, remove the old instance before
- * adding the new one.
- * <p>
- * @param fc must not be null
- * @param a must not be null
- */
- private void internalAdd(FactoryContainer fc, Attributes a) {
- synchronized(_path) {
- _path.remove(fc);
- // LinkedHashMap doesn't have any way to add to the head,
- // so we're forced to do two copies. Make the new map
- // large enough that we don't have to rehash midway through the putAll().
- Map<FactoryContainer, Attributes> newPath =
- new LinkedHashMap<FactoryContainer, Attributes>(1 + 4*(_path.size() + 1)/3);
- newPath.put(fc, a);
- newPath.putAll(_path);
- _path.clear();
- _path.putAll(newPath);
- }
- }
-
- public Map<FactoryContainer, Attributes> getEnabledContainers() {
- Map<FactoryContainer, Attributes> map = new LinkedHashMap<FactoryContainer, Attributes>();
- synchronized(_path) {
- for (Map.Entry<FactoryContainer, Attributes> entry : _path.entrySet()) {
- Attributes attr = entry.getValue();
- if (attr.isEnabled()) {
- Attributes attrClone = new Attributes(attr);
- map.put(entry.getKey(), attrClone);
- }
- }
- }
- return map;
- }
-
- /**
- * @return a copy of the path
- */
- public Map<FactoryContainer, Attributes> getAllContainers() {
- Map<FactoryContainer, Attributes> map = new LinkedHashMap<FactoryContainer, Attributes>(_path.size());
- synchronized(_path) {
- for( Map.Entry<FactoryContainer, Attributes> entry : _path.entrySet() ){
- map.put( entry.getKey(), new Attributes(entry.getValue()) );
- }
- }
- return map;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FactoryPathUtil.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FactoryPathUtil.java
deleted file mode 100644
index d939b1e273..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FactoryPathUtil.java
+++ /dev/null
@@ -1,443 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.internal.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.ExtJarFactoryContainer;
-import org.eclipse.jdt.apt.core.internal.FactoryPluginManager;
-import org.eclipse.jdt.apt.core.internal.VarJarFactoryContainer;
-import org.eclipse.jdt.apt.core.internal.WkspJarFactoryContainer;
-import org.eclipse.jdt.apt.core.internal.util.FactoryContainer.FactoryType;
-import org.eclipse.jdt.apt.core.util.IFactoryPath;
-import org.eclipse.jdt.core.IJavaProject;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * Utility class for dealing with the factory path
- */
-public final class FactoryPathUtil {
-
- private static final String FACTORYPATH_TAG = "factorypath"; //$NON-NLS-1$
- private static final String FACTORYPATH_ENTRY_TAG = "factorypathentry"; //$NON-NLS-1$
- private static final String KIND = "kind"; //$NON-NLS-1$
- private static final String ID = "id"; //$NON-NLS-1$
- private static final String ENABLED = "enabled"; //$NON-NLS-1$
- private static final String RUN_IN_BATCH_MODE = "runInBatchMode"; //$NON-NLS-1$
-
- private static final String FACTORYPATH_FILE = ".factorypath"; //$NON-NLS-1$
-
- // four spaces for indent
- private static final String INDENT = " "; //$NON-NLS-1$
-
- // Private c-tor to prevent construction
- private FactoryPathUtil() {}
-
- /**
- * Test whether a resource is a factory path file. The criteria are
- * that it is a file, it belongs to a project, it is located in the root
- * of that project, and it is named ".factorypath". Note that the
- * workspace-wide factorypath file does NOT meet these criteria.
- * @param res any sort of IResource, or null.
- * @return true if the resource is a project-specific factory path file.
- */
- public static boolean isFactoryPathFile(IResource res) {
- if (res == null || res.getType() != IResource.FILE || res.getProject() == null) {
- return false;
- }
- IPath path = res.getProjectRelativePath();
- if (path.segmentCount() != 1) {
- return false;
- }
- return FACTORYPATH_FILE.equals(path.lastSegment());
- }
-
- /**
- * Loads a map of factory containers from the factory path for a given
- * project. If no factorypath file was found, returns null.
- */
- public static Map<FactoryContainer, FactoryPath.Attributes> readFactoryPathFile(IJavaProject jproj)
- throws CoreException
- {
- String data = null;
- try {
- // If project is null, use workspace-level data
- if (jproj == null) {
- File file = getFileForWorkspace();
- if (!file.exists()) {
- return null;
- }
- data = FileSystemUtil.getContentsOfFile(file);
- }
- else {
- IFile ifile = getIFileForProject(jproj);
- if (!ifile.exists()) {
- return null;
- }
- data = FileSystemUtil.getContentsOfIFile(ifile);
- }
- }
- catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, AptPlugin.PLUGIN_ID, -1, Messages.FactoryPathUtil_status_ioException, e));
- }
-
- return FactoryPathUtil.decodeFactoryPath(data);
- }
-
- /**
- * Stores a map of factory containers to the factorypath file
- * for a given project. If null is passed in, the factorypath file
- * is deleted.
- */
- public static void saveFactoryPathFile(IJavaProject jproj, Map<FactoryContainer, FactoryPath.Attributes> containers)
- throws CoreException
- {
- IFile projFile;
- File wkspFile;
- if (jproj != null) {
- projFile = getIFileForProject(jproj);
- wkspFile = null;
- }
- else {
- wkspFile = getFileForWorkspace();
- projFile = null;
- }
-
- try {
- if (containers != null) {
- String data = FactoryPathUtil.encodeFactoryPath(containers);
- // If project is null, set workspace-level data
- if (jproj == null) {
- FileSystemUtil.writeStringToFile(wkspFile, data);
- }
- else {
- FileSystemUtil.writeStringToIFile(projFile, data);
- }
- }
- else { // restore defaults by deleting the factorypath file.
- if (jproj != null) {
- projFile.delete(true, null);
- }
- else {
- wkspFile.delete();
- }
- }
- }
- catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, AptPlugin.PLUGIN_ID, -1, Messages.FactoryPathUtil_status_ioException, e));
- }
- }
-
- /**
- * Returns an XML string encoding all of the factories.
- * @param factories
- */
- public static String encodeFactoryPath(Map<FactoryContainer, FactoryPath.Attributes> factories) {
- StringBuilder sb = new StringBuilder();
- sb.append("<").append(FACTORYPATH_TAG).append(">\n"); //$NON-NLS-1$ //$NON-NLS-2$
- for (Map.Entry<FactoryContainer, FactoryPath.Attributes> entry : factories.entrySet()) {
- FactoryContainer container = entry.getKey();
- FactoryPath.Attributes attr = entry.getValue();
- sb.append(INDENT);
- sb.append("<"); //$NON-NLS-1$
- sb.append(FACTORYPATH_ENTRY_TAG).append(" "); //$NON-NLS-1$
- sb.append(KIND).append("=\"").append(container.getType()).append("\" "); //$NON-NLS-1$ //$NON-NLS-2$
- sb.append(ID).append("=\"").append(container.getId()).append("\" "); //$NON-NLS-1$ //$NON-NLS-2$
- sb.append(ENABLED).append("=\"").append(attr.isEnabled()).append("\" "); //$NON-NLS-1$ //$NON-NLS-2$
- sb.append(RUN_IN_BATCH_MODE).append("=\"").append(attr.runInBatchMode()).append("\"/>\n"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- sb.append("</").append(FACTORYPATH_TAG).append(">\n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- return sb.toString();
- }
-
- /**
- * Create a factory container based on an external jar file (not in the
- * workspace).
- * @param jar a java.io.File representing the jar file.
- */
- public static FactoryContainer newExtJarFactoryContainer(File jar) {
- return new ExtJarFactoryContainer(jar);
- }
-
- /**
- * Create a factory container based on a jar file in the workspace.
- * @param jar an Eclipse IPath representing the jar file; the path is
- * relative to the workspace root.
- */
- public static FactoryContainer newWkspJarFactoryContainer(IPath jar) {
- return new WkspJarFactoryContainer(jar);
- }
-
- /**
- * Create a factory container based on an external jar file specified
- * by a classpath variable (and possibly a path relative to that variable).
- * @param jar an Eclipse IPath representing the jar file; the first
- * segment of the path is assumed to be the variable name.
- */
- public static FactoryContainer newVarJarFactoryContainer(IPath jar) {
- return new VarJarFactoryContainer(jar);
- }
-
- public static Map<FactoryContainer, FactoryPath.Attributes> decodeFactoryPath(final String xmlFactoryPath)
- throws CoreException
- {
- Map<FactoryContainer, FactoryPath.Attributes> result = new LinkedHashMap<FactoryContainer, FactoryPath.Attributes>();
- StringReader reader = new StringReader(xmlFactoryPath);
- Element fpElement = null;
-
- try {
- DocumentBuilder parser =
- DocumentBuilderFactory.newInstance().newDocumentBuilder();
- fpElement = parser.parse(new InputSource(reader)).getDocumentElement();
-
- }
- catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, AptPlugin.PLUGIN_ID, -1, Messages.FactoryPathUtil_status_ioException, e));
- }
- catch (SAXException e) {
- throw new CoreException(new Status(IStatus.ERROR, AptPlugin.PLUGIN_ID, -1, Messages.FactoryPathUtil_status_couldNotParse, e));
- }
- catch (ParserConfigurationException e) {
- throw new CoreException(new Status(IStatus.ERROR, AptPlugin.PLUGIN_ID, -1, Messages.FactoryPathUtil_status_parserConfigError, e));
- }
- finally {
- reader.close();
- }
-
- if (!fpElement.getNodeName().equalsIgnoreCase(FACTORYPATH_TAG)) {
- IOException e = new IOException("Incorrect file format. File must begin with " + FACTORYPATH_TAG); //$NON-NLS-1$
- throw new CoreException(new Status(IStatus.ERROR, AptPlugin.PLUGIN_ID, -1, Messages.FactoryPathUtil_status_ioException, e));
- }
- NodeList nodes = fpElement.getElementsByTagName(FACTORYPATH_ENTRY_TAG);
- for (int i=0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element element = (Element)node;
- String kindString = element.getAttribute(KIND);
- // deprecated container type "JAR" is now "EXTJAR"
- if ("JAR".equals(kindString)) { //$NON-NLS-1$
- kindString = "EXTJAR"; //$NON-NLS-1$
- }
- String idString = element.getAttribute(ID);
- String enabledString = element.getAttribute(ENABLED);
- String runInAptModeString = element.getAttribute(RUN_IN_BATCH_MODE);
- FactoryType kind = FactoryType.valueOf(kindString);
- FactoryContainer container = null;
- switch (kind) {
-
- case WKSPJAR :
- container = newWkspJarFactoryContainer(new Path(idString));
- break;
-
- case EXTJAR :
- container = newExtJarFactoryContainer(new File(idString));
- break;
-
- case VARJAR :
- container = newVarJarFactoryContainer(new Path(idString));
- break;
-
- case PLUGIN :
- container = FactoryPluginManager.getPluginFactoryContainer(idString);
- break;
-
- default :
- throw new IllegalStateException("Unrecognized kind: " + kind + ". Original string: " + kindString); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- if (null != container) {
- FactoryPath.Attributes a = new FactoryPath.Attributes(
- Boolean.parseBoolean(enabledString), Boolean.parseBoolean(runInAptModeString));
- result.put(container, a);
- }
- }
- }
-
- return result;
- }
-
- /**
- * Get a file designator for the workspace-level factory path settings file.
- * Typically this is [workspace]/.metadata/plugins/org.eclipse.jdt.apt.core/.factorypath
- * @return a java.io.File
- */
- private static File getFileForWorkspace() {
- return AptPlugin.getPlugin().getStateLocation().append(FACTORYPATH_FILE).toFile();
- }
-
- /**
- * Get an Eclipse IFile for the project-level factory path settings file.
- * Typically this is [project]/.factorypath
- * @param jproj must not be null
- * @return an Eclipse IFile
- */
- private static IFile getIFileForProject(IJavaProject jproj) {
- IProject proj = jproj.getProject();
- return proj.getFile(FACTORYPATH_FILE);
- }
-
- /**
- * Does a factory path file already exist for the specified project,
- * or for the workspace as a whole?
- * @param jproj if this is null, check for workspace-level settings.
- * @return true if a settings file exists.
- */
- public static boolean doesFactoryPathFileExist(IJavaProject jproj) {
- if (jproj == null) {
- File wkspFile = getFileForWorkspace();
- return wkspFile.exists();
- }
- else {
- IFile projFile = getIFileForProject(jproj);
- return projFile.exists();
- }
- }
-
- /**
- * Calculates the active factory path for the specified project. This
- * depends on the stored information in the .factorypath file, as well as
- * on the set of plugins that were found at load time of this Eclipse instance.
- * Returns all containers for the provided project, including disabled ones.
- * @param jproj The java project in question, or null for the workspace
- * @return an ordered map, where the key is the container and the value
- * indicates whether the container is enabled.
- */
- private static synchronized Map<FactoryContainer, FactoryPath.Attributes> calculatePath(IJavaProject jproj) {
- Map<FactoryContainer, FactoryPath.Attributes> map = null;
- boolean foundPerProjFile = false;
- if (jproj != null) {
- try {
- map = FactoryPathUtil.readFactoryPathFile(jproj);
- foundPerProjFile = (map != null);
- }
- catch (CoreException ce) {
- AptPlugin.log(ce, "Could not get factory containers for project: " + jproj); //$NON-NLS-1$
- }
- }
- // Workspace if no project data was found
- if (map == null) {
- try {
- map = FactoryPathUtil.readFactoryPathFile(null);
- }
- catch (CoreException ce) {
- AptPlugin.log(ce, "Could not get factory containers for project: " + jproj); //$NON-NLS-1$
- }
- }
- // if no project and no workspace data was found, we'll get the defaults
- if (map == null) {
- map = new LinkedHashMap<FactoryContainer, FactoryPath.Attributes>();
- }
- boolean disableNewPlugins = (jproj != null) && foundPerProjFile;
- updatePluginContainers(map, disableNewPlugins);
- return map;
- }
-
- /**
- * Removes missing plugin containers, and adds any plugin containers
- * that were added since the map was originally created. The order
- * of the original list will be maintained, and new entries will be
- * added to the end of the list in alphabetic order. The resulting
- * list has the same contents as PLUGIN_FACTORY_MAP (that is, all the
- * loaded plugins and nothing else), but the order is as close as possible
- * to the input.
- *
- * @param path the factory path (in raw Map form) to be modified.
- * @param disableNewPlugins if true, newly discovered plugins will be
- * disabled. If false, they will be enabled or disabled according to
- * their setting in the extension declaration.
- */
- private static void updatePluginContainers(
- Map<FactoryContainer, FactoryPath.Attributes> path, boolean disableNewPlugins) {
-
- // Get the alphabetically-ordered list of all plugins we found at startup.
- Map<FactoryContainer, FactoryPath.Attributes> pluginContainers = FactoryPluginManager.getAllPluginFactoryContainers();
-
- // Remove from the path any plugins which we did not find at startup
- for (Iterator<FactoryContainer> i = path.keySet().iterator(); i.hasNext(); ) {
- FactoryContainer fc = i.next();
- if (fc.getType() == FactoryContainer.FactoryType.PLUGIN && !pluginContainers.containsKey(fc)) {
- i.remove();
- }
- }
-
- // Add to the end any plugins which are not in the path (i.e., which
- // have been discovered since the config was last saved)
- for (Map.Entry<FactoryContainer, FactoryPath.Attributes> entry : pluginContainers.entrySet()) {
- if (!path.containsKey(entry.getKey())) {
- FactoryPath.Attributes newAttr;
- FactoryPath.Attributes oldAttr = entry.getValue();
- if (disableNewPlugins) {
- newAttr = new FactoryPath.Attributes(false, oldAttr.runInBatchMode());
- } else {
- newAttr = oldAttr;
- }
- path.put(entry.getKey(), newAttr);
- }
- }
- }
-
- /**
- * Get a factory path corresponding to the default values: if jproj is
- * non-null, return the current workspace factory path (workspace prefs
- * are the default for a project); if jproj is null, return the default
- * list of plugin factories (which is the "factory default").
- */
- public static IFactoryPath getDefaultFactoryPath(IJavaProject jproj) {
- FactoryPath fp = new FactoryPath();
- if (jproj != null) {
- fp.setContainers(calculatePath(null));
- }
- else {
- fp.setContainers(FactoryPluginManager.getAllPluginFactoryContainers());
- }
- return fp;
- }
-
- public static FactoryPath getFactoryPath(IJavaProject jproj) {
- Map<FactoryContainer, FactoryPath.Attributes> map = calculatePath(jproj);
- FactoryPath fp = new FactoryPath();
- fp.setContainers(map);
- return fp;
- }
-
- public static void setFactoryPath(IJavaProject jproj, FactoryPath path)
- throws CoreException {
- Map<FactoryContainer, FactoryPath.Attributes> map = (path != null) ?
- path.getAllContainers() : null;
- saveFactoryPathFile(jproj, map);
- }
-
-
-}
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 ab6ffd5fef..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/FileSystemUtil.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-
-/**
- * Simple utility class to encapsulate an mkdirs() that avoids a timing issue
- * in the jdk.
- */
-public final class FileSystemUtil
-{
- private FileSystemUtil() {}
-
- /**
- * If the given resource is a folder, then recursively deleted all derived
- * files and folders contained within it. Delete the folder if it becomes empty
- * and if itself is also a derived resource.
- * If the given resource is a file, delete it iff it is a derived resource.
- * The resource is left untouched if it is no a folder or a file.
- * @param resource
- * @return <code>true</code> iff the resource has been deleted.
- * @throws CoreException
- */
- public static boolean deleteDerivedResources(final IResource resource)
- throws CoreException
- {
- if (null == resource) {
- return false;
- }
- if( resource.getType() == IResource.FOLDER ){
- boolean deleteFolder = resource.isDerived();
- IResource[] members = ((IFolder)resource).members();
- for( int i=0, len=members.length; i<len; i++ ){
- deleteFolder &= deleteDerivedResources(members[i]);
- }
- if( deleteFolder ){
- deleteResource(resource);
- return true;
- }
- return false;
- }
- else if( resource.getType() == IResource.FILE ){
- if( resource.isDerived() ){
- deleteResource(resource);
- return true;
- }
- return false;
- }
- // will skip pass everything else.
- else
- return false;
- }
-
- /**
- * Delete a resource without throwing an exception.
- */
- private static void deleteResource(IResource resource) {
- try {
- resource.delete(true, null);
- } catch (CoreException e) {
- // might have been concurrently deleted
- if (resource.exists()) {
- AptPlugin.log(e, "Unable to delete derived resource " + resource); //$NON-NLS-1$
- }
- }
- }
-
- 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();
- }
- }
- }
-
- public static void makeDerivedParentFolders (IContainer container) throws CoreException {
- // synchronize the "does it exist - if not, create it" sequence.
- if ((container instanceof IFolder) && !container.exists()) {
- makeDerivedParentFolders(container.getParent());
- try {
- ((IFolder)container).create(true, true, null);
- }
- catch (CoreException e) {
- // Ignore race condition where another thread created the folder at the
- // same time, causing checkDoesNotExist() to throw within create().
- if (!container.exists()) {
- throw e;
- }
- }
- container.setDerived(true);
- }
- }
-
- /**
- * Returns the contents of a file as a string in UTF8 format
- */
- public static String getContentsOfIFile(IFile file) throws IOException, CoreException {
- return getContents(file.getContents(true));
- }
-
- public static String getContentsOfFile(File file) throws IOException {
- return getContents(new FileInputStream(file));
- }
-
- private static String getContents(InputStream in) throws IOException {
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] buffer = new byte[512];
- int len;
- while ((len = in.read(buffer)) > 0) {
- out.write(buffer, 0, len);
- }
- out.close();
- String s = new String(out.toByteArray(), "UTF8"); //$NON-NLS-1$
- return s;
- }
- finally {
- try {in.close();} catch (IOException ioe) {}
- }
- }
-
- /**
- * Stores a string into an Eclipse file in UTF8 format. The file
- * will be created if it does not already exist.
- * @throws IOException, CoreException
- */
- public static void writeStringToIFile(IFile file, String contents) throws IOException, CoreException {
- byte[] data = contents.getBytes("UTF8"); //$NON-NLS-1$
- ByteArrayInputStream input = new ByteArrayInputStream(data);
- if (file.exists()) {
- if (file.isReadOnly()) {
- // provide opportunity to checkout read-only .factorypath file
- ResourcesPlugin.getWorkspace().validateEdit(new IFile[]{file}, null);
- }
- file.setContents(input, true, false, null);
- }
- else {
- // Even with FORCE, create() will still throw if the file already exists.
- file.create(input, IResource.FORCE, null);
- }
- }
-
- /**
- * Stores a string into an ordinary workspace file in UTF8 format.
- * The file will be created if it does not already exist.
- * @throws IOException
- */
- public static void writeStringToFile(File file, String contents) throws IOException {
- byte[] data = contents.getBytes("UTF8"); //$NON-NLS-1$
- OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
- try {
- for (byte b : data) {
- out.write(b);
- }
- }
- finally {
- try {out.close();} catch (IOException ioe) {}
- }
- }
-
- /**
- * Return true if the content of the streams is identical,
- * false if not.
- */
- public 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;
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/InputStreamAnnotationScanner.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/InputStreamAnnotationScanner.java
deleted file mode 100644
index 3fc5deeb3d..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/InputStreamAnnotationScanner.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.internal.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-
-public class InputStreamAnnotationScanner extends AnnotationScanner {
-
- private final InputStream input;
-
- public InputStreamAnnotationScanner(final InputStream input) {
- this.input = input;
- }
-
- @Override
- protected int getNext() throws IOException {
- return input.read();
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/ManyToMany.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/ManyToMany.java
deleted file mode 100644
index 8f399a2ad9..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/ManyToMany.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 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.util;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Manage a Map<T1, Set<T2>>, with reverse links so that it is possible to
- * efficiently find all T1s that have a particular T2 associated with them.
- * Access to the map is synchronized, so that it is possible to read and
- * write simultaneously from multiple threads. Set semantics are preserved
- * in both directions, so there is no distinction between calling this a
- * Map<T1, Set<T2>> versus a Map<T2, Set<T1>>. It is symmetric.
- * <p>
- * The map permits the null value for keys and for value elements.
- * <p>
- * Design invariants preserved by all operations on this map are as follows:
- * <ul>
- * <li> If a key exists, it has at least one value associated with it; that is,
- * for all k such that null != containsKey(k), getValues(k) returns a non-empty
- * set.</li>
- * <li> If a value exists, it has at least one key associated with it; that is,
- * for all v such that null != containsValue(v), getKeys(v) returns a non-empty
- * set.</li>
- */
-public class ManyToMany<T1, T2> {
-
- private final Map<T1, Set<T2>> _forward = new HashMap<T1, Set<T2>>();
- private final Map<T2, Set<T1>> _reverse = new HashMap<T2, Set<T1>>();
- private boolean _dirty = false;
-
- /**
- * Empty all maps. If the maps previously contained entries,
- * this will set the dirty bit.
- * @return true if the maps contained any entries prior to being cleared
- */
- public synchronized boolean clear() {
- boolean hadContent = !_forward.isEmpty() || !_reverse.isEmpty();
- _reverse.clear();
- _forward.clear();
- _dirty |= hadContent;
- return hadContent;
- }
-
- /**
- * Sets the dirty bit to false. Internal operations do not use the dirty
- * bit; clearing it will not affect behavior of the map. It's just there
- * for the convenience of callers who don't want to keep track of every
- * put() and remove().
- */
- public synchronized void clearDirtyBit() {
- _dirty = false;
- }
-
- /**
- * Equivalent to keySet().contains(key).
- * @return true if the map contains the specified key.
- */
- public synchronized boolean containsKey(T1 key) {
- return _forward.containsKey(key);
- }
-
- /**
- * Is there a key that is mapped to the specified value?
- * Search within the forward map.
- * @return true if such a key exists
- */
- public synchronized boolean containsKeyValuePair(T1 key, T2 value) {
- Set<T2> values = _forward.get(key);
- if (null == values) {
- return false;
- }
- return values.contains(value);
- }
-
- /**
- * Equivalent to values().contains(value).
- * @return true if the map contains the specified value (regardless
- * of what key it might be associated with).
- */
- public synchronized boolean containsValue(T2 value) {
- return _reverse.containsKey(value);
- }
-
- /**
- * Search the reverse map for all keys that have been associated with
- * a particular value.
- * @return the set of keys that are associated with the specified value,
- * or an empty set if the value does not exist in the map.
- */
- public synchronized Set<T1> getKeys(T2 value) {
- Set<T1> keys = _reverse.get(value);
- if (null == keys) {
- return Collections.emptySet();
- }
- return new HashSet<T1>(keys);
- }
-
- /**
- * Search the forward map for all values associated with a particular key.
- * Returns a copy of the set of values.
- * @return a copy of the set of values that are associated with the
- * specified key, or an empty set if the key does not exist in the map.
- */
- public synchronized Set<T2> getValues(T1 key) {
- Set<T2> values = _forward.get(key);
- if (null == values) {
- return Collections.emptySet();
- }
- return new HashSet<T2>(values);
- }
-
- /**
- * @return a copy of the set of all keys (that is, all items of type T1).
- * If the maps are empty, the returned set will be empty, not null. The
- * returned set can be modified by the caller without affecting the map.
- * @see #getValueSet()
- */
- public synchronized Set<T1> getKeySet() {
- Set<T1> keys = new HashSet<T1>(_forward.keySet());
- return keys;
- }
-
- /**
- * @return a copy of the set of all values (that is, all items of type T2).
- * If the maps are empty, the returned set will be empty, not null. The
- * returned set can be modified by the caller without affecting the map.
- * @see #getKeySet()
- */
- public synchronized Set<T2> getValueSet() {
- Set<T2> values = new HashSet<T2>(_reverse.keySet());
- return values;
- }
-
- /**
- * Return the state of the dirty bit. All operations that change the state
- * of the maps, including @see #clear(), set the dirty bit if any content actually
- * changed. The only way to clear the dirty bit is to call @see #clearDirtyBit().
- * @return true if the map content has changed since it was created or since
- * the last call to clearDirtyBit().
- * @see #clearDirtyBit()
- */
- public synchronized boolean isDirty() {
- return _dirty;
- }
-
- /**
- * Check whether <code>key</code> has an association to any values other
- * than <code>value</code> - that is, whether the same key has been added
- * with multiple values. Equivalent to asking whether the intersection of
- * <code>getValues(key)</code> and the set containing <code>value</code> is
- * non-empty.
- * @return true iff <code>key</code> is in the map and is associated
- * with values other than <code>value</code>.
- * @see #valueHasOtherKeys(Object, Object)
- */
- public synchronized boolean keyHasOtherValues(T1 key, T2 value) {
- Set<T2> values = _forward.get(key);
- if (values == null)
- return false;
- int size = values.size();
- if (size == 0)
- return false;
- else if (size > 1)
- return true;
- else // size == 1
- return !values.contains(value);
- }
-
- /**
- * Associate the specified value with the key. Adds the entry
- * to both the forward and reverse maps. Adding the same value
- * twice to a particular key has no effect. Because this is a
- * many-to-many map, adding a new value for an existing key does
- * not change the existing association, it adds a new one.
- * @param key can be null
- * @param value can be null
- * @return true if the key/value pair did not exist prior to being added
- */
- public synchronized boolean put(T1 key, T2 value) {
- // Add to forward map
- Set<T2> values = _forward.get(key);
- if (null == values) {
- values = new HashSet<T2>();
- _forward.put(key, values);
- }
- boolean added = values.add(value);
- _dirty |= added;
-
- // Add to reverse map
- Set<T1> keys = _reverse.get(value);
- if (null == keys) {
- keys = new HashSet<T1>();
- _reverse.put(value, keys);
- }
- keys.add(key);
-
- assert checkIntegrity();
- return added;
- }
-
- /**
- * Remove a particular key-value association. This is the inverse
- * of put(key, value). If the key does not exist, or the value
- * does not exist, or the association does not exist, this call
- * has no effect.
- * @return true if the key/value pair existed in the map prior to removal
- */
- public synchronized boolean remove(T1 key, T2 value) {
- Set<T2> values = _forward.get(key);
- if (values == null) {
- assert checkIntegrity();
- return false;
- }
- boolean removed = values.remove(value);
- if (values.isEmpty()) {
- _forward.remove(key);
- }
- if (removed) {
- _dirty = true;
- // it existed, so we need to remove from reverse map as well
- Set<T1> keys = _reverse.get(value);
- keys.remove(key);
- if (keys.isEmpty()) {
- _reverse.remove(value);
- }
- }
- assert checkIntegrity();
- return removed;
- }
-
- /**
- * Remove the key and its associated key/value entries.
- * Calling removeKey(k) is equivalent to calling remove(k,v)
- * for every v in getValues(k).
- * @return true if the key existed in the map prior to removal
- */
- public synchronized boolean removeKey(T1 key) {
- // Remove all back-references to key.
- Set<T2> values = _forward.get(key);
- if (null == values) {
- // key does not exist in map.
- assert checkIntegrity();
- return false;
- }
- for (T2 value : values) {
- Set<T1> keys = _reverse.get(value);
- if (null != keys) {
- keys.remove(key);
- if (keys.isEmpty()) {
- _reverse.remove(value);
- }
- }
- }
- // Now remove the forward references from key.
- _forward.remove(key);
- _dirty = true;
- assert checkIntegrity();
- return true;
- }
-
- /**
- * Remove the value and its associated key/value entries.
- * Calling removeValue(v) is equivalent to calling remove(k,v)
- * for every k in getKeys(v).
- * @return true if the value existed in the map prior to removal.
- */
- public synchronized boolean removeValue(T2 value) {
- // Remove any forward references to value
- Set<T1> keys = _reverse.get(value);
- if (null == keys) {
- // value does not exist in map.
- assert checkIntegrity();
- return false;
- }
- for (T1 key : keys) {
- Set<T2> values = _forward.get(key);
- if (null != values) {
- values.remove(value);
- if (values.isEmpty()) {
- _forward.remove(key);
- }
- }
- }
- // Now remove the reverse references from value.
- _reverse.remove(value);
- _dirty = true;
- assert checkIntegrity();
- return true;
- }
-
- /**
- * Check whether <code>value</code> has an association from any keys other
- * than <code>key</code> - that is, whether the same value has been added
- * with multiple keys. Equivalent to asking whether the intersection of
- * <code>getKeys(value)</code> and the set containing <code>key</code> is
- * non-empty.
- * @return true iff <code>value</code> is in the map and is associated
- * with keys other than <code>key</code>.
- * @see #keyHasOtherValues(Object, Object)
- */
- public synchronized boolean valueHasOtherKeys(T2 value, T1 key) {
- Set<T1> keys = _reverse.get(key);
- if (keys == null)
- return false;
- int size = keys.size();
- if (size == 0)
- return false;
- else if (size > 1)
- return true;
- else // size == 1
- return !keys.contains(key);
- }
-
- /**
- * Check the integrity of the internal data structures. This is intended to
- * be called within an assert, so that if asserts are disabled the integrity
- * checks will not cause a performance impact.
- * @return true if everything is okay.
- * @throws IllegalStateException if there is a problem.
- */
- private boolean checkIntegrity() {
- // For every T1->T2 mapping in the forward map, there should be a corresponding
- // T2->T1 mapping in the reverse map.
- for (Map.Entry<T1, Set<T2>> entry : _forward.entrySet()) {
- Set<T2> values = entry.getValue();
- if (values.isEmpty()) {
- throw new IllegalStateException("Integrity compromised: forward map contains an empty set"); //$NON-NLS-1$
- }
- for (T2 value : values) {
- Set<T1> keys = _reverse.get(value);
- if (null == keys || !keys.contains(entry.getKey())) {
- throw new IllegalStateException("Integrity compromised: forward map contains an entry missing from reverse map: " + value); //$NON-NLS-1$
- }
- }
- }
- // And likewise in the other direction.
- for (Map.Entry<T2, Set<T1>> entry : _reverse.entrySet()) {
- Set<T1> keys = entry.getValue();
- if (keys.isEmpty()) {
- throw new IllegalStateException("Integrity compromised: reverse map contains an empty set"); //$NON-NLS-1$
- }
- for (T1 key : keys) {
- Set<T2> values = _forward.get(key);
- if (null == values || !values.contains(entry.getKey())) {
- throw new IllegalStateException("Integrity compromised: reverse map contains an entry missing from forward map: " + key); //$NON-NLS-1$
- }
- }
- }
- return true;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/Messages.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/Messages.java
deleted file mode 100644
index 34ea77a55e..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/Messages.java
+++ /dev/null
@@ -1,35 +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.util;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- *
- */
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.jdt.apt.core.internal.util.messages"; //$NON-NLS-1$
-
- private Messages() {
- }
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- public static String FactoryPathUtil_status_ioException;
-
- public static String FactoryPathUtil_status_couldNotParse;
-
- public static String FactoryPathUtil_status_parserConfigError;
-}
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 e28407fe44..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/PackageUtil.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.util;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaModelException;
-
-/**
- * Utility class for dealing with packages, using
- * Eclipse's underlying SearchEngine
- */
-public class PackageUtil {
-
- private PackageUtil() {}
-
- public static IPackageFragment[] getPackageFragments(
- final String packageName,
- final BaseProcessorEnv env) {
-
- List<IPackageFragment> packages = new ArrayList<IPackageFragment>();
- try {
- // The environment caches our package fragment roots
- IPackageFragmentRoot[] roots = env.getAllPackageFragmentRoots();
- for (IPackageFragmentRoot root : roots) {
- IPackageFragment fragment = root.getPackageFragment(packageName);
- if (fragment != null && fragment.exists())
- packages.add(fragment);
- }
- }
- catch (JavaModelException e) {
- return new IPackageFragment[0];
- }
-
- return packages.toArray(new IPackageFragment[packages.size()]);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/ReaderAnnotationScanner.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/ReaderAnnotationScanner.java
deleted file mode 100644
index 6a6e16fbd7..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/ReaderAnnotationScanner.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.internal.util;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-
-public class ReaderAnnotationScanner extends AnnotationScanner {
-
- private final InputStreamReader _reader;
-
- public ReaderAnnotationScanner(final InputStreamReader reader) {
- _reader = reader;
- }
-
- @Override
- protected int getNext() throws IOException {
- return _reader.read();
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/ScannerUtil.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/ScannerUtil.java
deleted file mode 100644
index 80194b6014..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/ScannerUtil.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.env.BuildEnv;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.JavaCore;
-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;
-
-public class ScannerUtil {
-
- /**
- * scan the source code to see if there are any annotation tokens
- */
- public static boolean hasAnnotationInstance( IFile f ) {
-
- InputStreamReader reader = null;
- InputStream input = null;
- try {
- AnnotationScanner scanner;
- // If this is a single byte encoding, we can deal directly
- // with the bytes, which is *much* faster
- if (SINGLE_BYTE_ENCODINGS.contains(f.getCharset())) {
- input = BuildEnv.getInputStream(f);
- scanner = new InputStreamAnnotationScanner(input);
- }
- else {
- reader = BuildEnv.getFileReader( f );
- scanner = new ReaderAnnotationScanner(reader);
- }
- return scanner.containsAnnotations();
- }
- catch( Exception ioe ) {
- return false;
- }
- finally {
- if (reader != null) { try {reader.close();} catch (IOException ioe) {} }
- if (input != null) { try {input.close();} catch (IOException ioe) {} }
- }
- }
-
-
- 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, JavaCore.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 )
- {
- AptPlugin.log(e, "Failure scanning source: \n" + new String(source)); //$NON-NLS-1$
- // TODO: deal with this exception
- return false;
- }
- }
-
- private static final String[] SINGLE_BYTE_ENCODING_ARRAY = {
- "ASCII", //$NON-NLS-1$
- "Cp1250", //$NON-NLS-1$
- "Cp1251", //$NON-NLS-1$
- "Cp1252", //$NON-NLS-1$
- "Cp1253", //$NON-NLS-1$
- "Cp1254", //$NON-NLS-1$
- "Cp1257", //$NON-NLS-1$
- "ISO8859_1", //$NON-NLS-1$
- "ISO8859_2", //$NON-NLS-1$
- "ISO8859_4", //$NON-NLS-1$
- "ISO8859_5", //$NON-NLS-1$
- "ISO8859_7", //$NON-NLS-1$
- "ISO8859_9", //$NON-NLS-1$
- "ISO8859_13", //$NON-NLS-1$
- "ISO8859_15", //$NON-NLS-1$
- "UTF8" //$NON-NLS-1$
- };
-
- private static final Set<String> SINGLE_BYTE_ENCODINGS =
- new HashSet<String>(SINGLE_BYTE_ENCODING_ARRAY.length);
-
- static {
- for (String encoding : SINGLE_BYTE_ENCODING_ARRAY) {
- SINGLE_BYTE_ENCODINGS.add(encoding);
- }
- }
-
-}
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 17f9258b1b..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/SourcePositionImpl.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-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.EclipseDeclarationImpl;
-import org.eclipse.jdt.apt.core.internal.declaration.EclipseMirrorObject;
-
-public class SourcePositionImpl implements SourcePosition
-{
- private final int _startingOffset;
- private final int _length;
- private final int _line;
- private final int _column;
- /** the back pointer to the declaration that created this object */
- private final EclipseMirrorObject _decl;
-
- public SourcePositionImpl(final int startingOffset,
- final int length,
- final int line,
- final int column,
- final EclipseDeclarationImpl decl)
- {
- _startingOffset = startingOffset;
- _length = length;
- _line = line < 1 ? 1 : line;
- _column = column < 0 ? 0 : column;
- _decl = decl;
- assert decl != null : "missing declaration [decl] == null."; //$NON-NLS-1$
- }
-
- public SourcePositionImpl(final int startingOffset,
- final int length,
- final int line,
- final int column,
- final AnnotationValueImpl decl )
- {
- _startingOffset = startingOffset;
- _length = length;
- _line = line < 1 ? 1 : line;
- _column = column < 0 ? 0 : column;
- _decl = decl;
- assert decl != null : "missing declaration [decl] == null."; //$NON-NLS-1$
- }
-
- public SourcePositionImpl(final int startingOffset,
- final int length,
- final int line,
- final int column,
- final AnnotationMirrorImpl decl )
- {
- _startingOffset = startingOffset;
- _length = length;
- _line = line < 1 ? 1 : line;
- _column = column < 0 ? 0 : column;
- _decl = decl;
- assert decl != null : "missing declaration [decl] == null."; //$NON-NLS-1$
- }
-
- public int line(){ return _line; }
- public int column(){ return _column; }
- 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 IFile getResource(){
- if( _decl instanceof EclipseDeclarationImpl )
- return ((EclipseDeclarationImpl)_decl).getResource();
- else if( _decl instanceof AnnotationMirrorImpl )
- return ((AnnotationMirrorImpl)_decl).getResource();
- else if( _decl instanceof AnnotationValueImpl )
- return ((AnnotationValueImpl)_decl).getResource();
-
- throw new IllegalStateException();
- }
-
- public String toString()
- {
- StringBuilder buffer = new StringBuilder();
- buffer.append("offset = "); //$NON-NLS-1$
- buffer.append(_startingOffset);
- buffer.append(" line = "); //$NON-NLS-1$
- buffer.append( _line );
- buffer.append(" column = "); //$NON-NLS-1$
- buffer.append( _column );
- buffer.append(" length = "); //$NON-NLS-1$
- buffer.append( _length );
-
- return buffer.toString();
- }
-}
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 32300984e3..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/TypesUtil.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.NonEclipseImplementationException;
-import org.eclipse.jdt.apt.core.internal.declaration.*;
-import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
-import org.eclipse.jdt.apt.core.internal.type.ArrayTypeImpl;
-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 BaseProcessorEnv _env;
-
- public static void main(String[] args){}
-
- public TypesUtil(BaseProcessorEnv env){
- _env = env;
- assert env != null : "null environment."; //$NON-NLS-1$
- }
-
- public ArrayType getArrayType(TypeMirror componentType)
- {
- if( componentType == null ) return null;
- if( componentType instanceof EclipseMirrorType ){
- final EclipseMirrorType impl = (EclipseMirrorType)componentType;
- // the leaf type of the array
- final ITypeBinding leaf;
- final int dimension;
- switch( impl.kind() )
- {
- case TYPE_ERROR: case TYPE_VOID:
- throw new IllegalArgumentException("Illegal element type for array"); //$NON-NLS-1$
- case TYPE_ARRAY:
- final ITypeBinding array = ((ArrayTypeImpl)componentType).getTypeBinding();
- dimension = array.getDimensions() + 1;
- leaf = array.getElementType();
- break;
- default:
- leaf = impl.getTypeBinding();
- dimension = 1;
- break;
- }
- 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.getTypeBindingFromKey(bindingKey);
- if(arrayType == null)
- return null;
- return (ArrayType)Factory.createTypeMirror(arrayType, _env);
- }
-
- throw new NonEclipseImplementationException("only applicable to eclipse type system objects." + //$NON-NLS-1$
- " Found " + componentType.getClass().getName()); //$NON-NLS-1$
-
- }
-
- /**
- * @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"; //$NON-NLS-1$
- argKeys[i] = binding.getKey();
- }
-
- final ITypeBinding[] typeParams = memberBinding.getTypeParameters();
- final int numTypeParams = typeParams == null ? 0 : typeParams.length;
- // if no argument then a raw type will be created, otherwise it's an error when the
- // number of type parameter and arguments don't agree.
- if( numTypeParams != numArgs && numArgs != 0 )
- throw new IllegalArgumentException("type, " + memberBinding.getQualifiedName() + ", require " + numTypeParams + " type arguments " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "but found " + numArgs ); //$NON-NLS-1$
-
- final String typeKey = BindingKey.createParameterizedTypeBindingKey(memberBinding.getKey(), argKeys);
- final ITypeBinding resultBinding = _env.getTypeBindingFromKey(typeKey);
- return Factory.createReferenceType(resultBinding, _env);
- }
- else{
- if( numArgs != 0 )
- throw new IllegalArgumentException("type, " + memberBinding + " is not a generic type and cannot have type arguments."); //$NON-NLS-1$ //$NON-NLS-2$
- // 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 EclipseMirrorType){
- final EclipseMirrorType impl = (EclipseMirrorType)t;
- final ITypeBinding binding;
- switch( impl.kind() )
- {
- case TYPE_PRIMITIVE:
- case TYPE_VOID:
- case TYPE_ERROR:
- return t;
-
- default:
- binding = impl.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." + //$NON-NLS-1$
- " Found " + t.getClass().getName()); //$NON-NLS-1$
- }
-
- 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); //$NON-NLS-1$
- }
- }
-
- 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." + //$NON-NLS-1$
- " Found " + tparam.getClass().getName()); //$NON-NLS-1$
- }
-
- 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."); //$NON-NLS-1$
-
- final String wildcardkey = BindingKey.createWilcardTypeBindingKey(boundKey, boundKind);
- final ITypeBinding wildcard = _env.getTypeBindingFromKey(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)
- {
- EclipseMirrorType left = (EclipseMirrorType)t1;
- EclipseMirrorType right = (EclipseMirrorType)t2;
- return left.isAssignmentCompatible(right);
-
- }
-
- public boolean isSubtype(TypeMirror t1, TypeMirror t2)
- {
- EclipseMirrorType left = (EclipseMirrorType)t1;
- EclipseMirrorType right = (EclipseMirrorType)t2;
-
- return left.isSubTypeCompatible(right);
- }
-
- /**
- * @return the binding correspond to the given type.
- * Return null if the type is an error marker.
- * @throws NonEclipseImplementationException
- */
-
- private static ITypeBinding getTypeBinding(TypeMirror type)
- throws NonEclipseImplementationException
- {
- if(type == null ) return null;
- if( type instanceof EclipseMirrorType ){
- return ((EclipseMirrorType)type).getTypeBinding();
- }
-
- throw new NonEclipseImplementationException("only applicable to eclipse type system objects." + //$NON-NLS-1$
- " Found " + type.getClass().getName()); //$NON-NLS-1$
- }
-
- /**
- * @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 EclipseMirrorObject ){
- return ((TypeDeclarationImpl)type).getTypeBinding();
- }
- throw new NonEclipseImplementationException("only applicable to eclipse type system objects." + //$NON-NLS-1$
- " Found " + type.getClass().getName()); //$NON-NLS-1$
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/Visitors.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/Visitors.java
deleted file mode 100644
index ccf50e3c93..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/Visitors.java
+++ /dev/null
@@ -1,421 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ASTVisitor;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration;
-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.DoStatement;
-import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
-import org.eclipse.jdt.core.dom.EnumDeclaration;
-import org.eclipse.jdt.core.dom.FieldDeclaration;
-import org.eclipse.jdt.core.dom.ForStatement;
-import org.eclipse.jdt.core.dom.IExtendedModifier;
-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.TypeDeclaration;
-
-/**
- * Home for ast visitors of various flavors.
- */
-@SuppressWarnings("unchecked") // JDT DOM AST API returns raw collections
-public class Visitors {
-
- /**
- * Traverse the ast looking for annotations at the declaration level.
- * This visitor only operates at the declaration level. Method body
- * and field initializers and static block will be ignored.
- */
- public static final class AnnotationVisitor extends ASTVisitor
- {
- private final List<Annotation> _annotations;
- /**
- * @param annotations to be populated by this visitor
- */
- 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 void reset(){ _annotations.clear(); }
- }
-
- /**
- * Locate all the annotations and the declaration that they annotate.
- * This visitor only operates at the declaration level. Method body
- * and field initializers and static block will be ignored.
- */
- public static final class AnnotatedNodeVisitor extends ASTVisitor
- {
- private final Map<ASTNode, List<Annotation>> _result;
-
- /**
- * @param map to be populated by this visitor.
- * Key is the declaration ast node and the value is the list
- * of annotation ast nodes that annotate the declaration.
- */
- public 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; }
- }
-
- /**
- * Given an annotation locate the declaration that its annotates.
- * This visitor only operates at the declaration level. Method body
- * and field initializers and static block will be ignored.
- *
- */
- public static final class DeclarationFinder extends ASTVisitor
- {
- private final Annotation _anno;
- // The declaration, could be a body declaration or a parameter
- // could also remain null if the annotation doesn't actually
- // annotates anything.
- private ASTNode _result = null;
- public DeclarationFinder(final Annotation annotation)
- {
- _anno = annotation;
- }
-
- /**
- * @return back the result of the search.
- */
- public ASTNode getAnnotatedNode(){return _result;}
-
- /**
- * We only visit nodes that can have annotations on them
- */
- public boolean visit(AnnotationTypeDeclaration node) {
- return internalVisit(node);
- }
-
- public boolean visit(AnnotationTypeMemberDeclaration node) {
- return internalVisit(node);
- }
-
- public boolean visit(EnumDeclaration node) {
- return internalVisit(node);
- }
-
- public boolean visit(EnumConstantDeclaration node) {
- return internalVisit(node);
- }
-
- public boolean visit(FieldDeclaration node) {
- return internalVisit(node);
- }
-
- public boolean visit(MethodDeclaration node) {
- return internalVisit(node);
- }
-
- public boolean visit(TypeDeclaration node) {
- return internalVisit(node);
- }
-
- public boolean visit(SingleVariableDeclaration node) {
- return internalVisit(node);
- }
-
- private boolean internalVisit(ASTNode node) {
- // terminate the search.
- if( _result != null ) return false;
- int nodeStart = node.getStartPosition();
- int nodeEnd = nodeStart + node.getLength();
- int annoStart = _anno.getStartPosition();
- int annoEnd = annoStart + _anno.getLength();
-
- if (nodeStart > annoEnd) {
- // We've passed our position. No need to search any further
- return false;
- }
- if (nodeEnd > annoStart) { // nodeStart <= annoEnd && nodeEnd > annoStart
- // This annotation declaration surrounds the offset
- List<IExtendedModifier> extendedModifiers;
- if (node.getNodeType() == ASTNode.SINGLE_VARIABLE_DECLARATION) {
- SingleVariableDeclaration declaration = (SingleVariableDeclaration)node;
- extendedModifiers = declaration.modifiers();
- }
- else {
- BodyDeclaration declaration = (BodyDeclaration)node;
- extendedModifiers = declaration.modifiers();
- }
- for (IExtendedModifier modifier : extendedModifiers) {
- // found what we came to look for.
- if( modifier == _anno ){
- _result = node;
- return false;
- }
- }
- }
-
- // Keep searching
- return true;
- }
-
- /**
- * @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; }
- }
- /**
- * Responsible for finding the ending offset of the tighest ast node match that starts
- * at a given offset. This ast visitor can operator on an array of offsets in one pass.
- * @author tyeung
- */
- public static class EndingOffsetFinder extends ASTVisitor
- {
- private final int[] _sortedStartingOffset;
- /**
- * parallel to <code>_sortedOffsets</code> and contains
- * the ending offset of the ast node that has the tightest match for the
- * corresponding starting offset.
- */
- private final int[] _endingOffsets;
-
- /**
- * @param offsets the array of offsets which will be sorted.
- * @throws IllegalArgumentException if <code>offsets</code> is <code>null</code>.
- */
- public EndingOffsetFinder(int[] offsets)
- {
- if(offsets == null)
- throw new IllegalArgumentException("argument cannot be null."); //$NON-NLS-1$
- // sort the array first
- Arrays.sort(offsets);
-
- // look for duplicates.
- int count = 0;
- for( int i=1, len=offsets.length; i<len; i++){
- if( offsets[i-1] == offsets[i] )
- continue;
- count ++;
- }
-
- if( count != offsets.length ){
- _sortedStartingOffset = new int[count];
-
- int index = 0;
- for( int i=0, len=offsets.length; i<len; i++){
- if( i != 0 && offsets[i-1] == offsets[i] )
- continue;
- _sortedStartingOffset[index++] = offsets[i];
- }
- }
- else{
- _sortedStartingOffset = offsets;
- }
-
- _endingOffsets = new int[count];
- for( int i=0; i<count; i++ )
- _endingOffsets[i] = 0;
- }
-
- public void preVisit(ASTNode node)
- {
- final int startingOffset = node.getStartPosition();
- final int endingOffset = startingOffset + node.getLength();
- // starting offset is inclusive
- int startIndex = Arrays.binarySearch(_sortedStartingOffset, startingOffset);
- // ending offset is exclusive
- int endIndex = Arrays.binarySearch(_sortedStartingOffset, endingOffset);
- if( startIndex < 0 )
- startIndex = - startIndex - 1;
- if( endIndex < 0 )
- endIndex = - endIndex - 1;
- else
- // endIndex needs to be exclusive and we want to
- // include the 'endIndex'th entry in our computation.
- endIndex ++;
- if( startIndex >= _sortedStartingOffset.length )
- return;
-
- for( int i=startIndex; i<endIndex; i++ ){
- if( _endingOffsets[i] == 0 )
- _endingOffsets[i] = endingOffset;
- else if( endingOffset < _endingOffsets[i] )
- _endingOffsets[i] = endingOffset;
- }
- }
-
-
- public int getEndingOffset(final int startingOffset)
- {
- int index = Arrays.binarySearch(_sortedStartingOffset, startingOffset);
- if( index == -1 ) return 0;
- return _endingOffsets[index];
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/messages.properties b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/messages.properties
deleted file mode 100644
index d7df567d0a..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/messages.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 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
-###############################################################################
-FactoryPathUtil_status_ioException=I/O exception
-FactoryPathUtil_status_couldNotParse=Could not parse
-FactoryPathUtil_status_parserConfigError=Parser configuration error
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/AptConfig.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/AptConfig.java
deleted file mode 100644
index b1f05acaef..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/AptConfig.java
+++ /dev/null
@@ -1,936 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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, wharley@bea.com - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.jdt.apt.core.util;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IPreferencesService;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.AptProject;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPathUtil;
-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.osgi.service.prefs.BackingStoreException;
-
-/**
- * Accesses configuration data for APT.
- * Note that some of the code in org.eclipse.jdt.ui reads and writes settings
- * data directly, rather than calling into the methods of this class.
- *
- * This class is static. Instances should not be constructed.
- *
- * Helpful information about the Eclipse preferences mechanism can be found at:
- * http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/platform-core-home/documents/user_settings/faq.html
- */
-public class AptConfig {
-
- /** regex to identify substituted token in path variables */
- private static final String PATHVAR_TOKEN = "^%[^%/\\\\ ]+%.*"; //$NON-NLS-1$
- /** path variable meaning "workspace root" */
- private static final String PATHVAR_ROOT = "%ROOT%"; //$NON-NLS-1$
- /** path variable meaning "project root" */
- private static final String PATHVAR_PROJECTROOT = "%PROJECT.DIR%"; //$NON-NLS-1$
-
- /*
- * Hide constructor; this is a static object
- */
- private AptConfig() {}
-
- /**
- * Add the equivalent of -Akey=val to the list of processor options.
- * @param key must be a nonempty string. It should only include the key;
- * that is, it should not start with "-A".
- * @param jproj a project, or null to set the option workspace-wide.
- * @param val can be null (equivalent to -Akey). This does not mean
- * remove the key; for that functionality, @see #removeProcessorOption(IJavaProject, String).
- */
- public static void addProcessorOption(IJavaProject jproj, String key, String val) {
- if (key == null || key.length() < 1) {
- throw new IllegalArgumentException();
- }
- IScopeContext context = (null != jproj) ?
- new ProjectScope(jproj.getProject()) : new InstanceScope();
- IEclipsePreferences node = context.getNode(AptPlugin.PLUGIN_ID + "/" + //$NON-NLS-1$
- AptPreferenceConstants.APT_PROCESSOROPTIONS);
- String nonNullVal = val == null ? AptPreferenceConstants.APT_NULLVALUE : val;
- node.put(key, nonNullVal);
- try {
- node.flush();
- } catch (BackingStoreException e) {
- AptPlugin.log(e, "Unable to save annotation processor option" + key); //$NON-NLS-1$
- }
- }
-
- /**
- * Remove an option from the list of processor options.
- * @param jproj a project, or null to remove the option workspace-wide.
- * @param key must be a nonempty string. It should only include the key;
- * that is, it should not start with "-A".
- */
- public static void removeProcessorOption(IJavaProject jproj, String key) {
- if (key == null || key.length() < 1) {
- throw new IllegalArgumentException();
- }
- IScopeContext context = (null != jproj) ?
- new ProjectScope(jproj.getProject()) : new InstanceScope();
- IEclipsePreferences node = context.getNode(AptPlugin.PLUGIN_ID + "/" + //$NON-NLS-1$
- AptPreferenceConstants.APT_PROCESSOROPTIONS);
- node.remove(key);
- try {
- node.flush();
- } catch (BackingStoreException e) {
- AptPlugin.log(e, "Unable to save annotation processor option" + key); //$NON-NLS-1$
- }
- }
-
- /**
- * Get the options that are presented to annotation processors by the
- * AnnotationProcessorEnvironment. Options are key/value pairs which
- * are set in the project properties.
- *
- * Option values can begin with a percent-delimited token representing
- * a classpath variable or one of several predefined values. The token
- * must either be followed by a path delimiter, or be the entire value.
- * Such tokens will be replaced with their resolved value. The predefined
- * values are <code>%ROOT%</code>, which is replaced by the absolute pathname
- * of the workspace root directory, and <code>%PROJECT.DIR%</code>, which
- * will be replaced by the absolute pathname of the project root directory.
- * For example, a value of <code>%ECLIPSE_HOME%/configuration/config.ini</code>
- * might be resolved to <code>d:/eclipse/configuration/config.ini</code>.
- *
- * This method returns some options which are set programmatically but
- * are not directly editable, are not displayed in the configuration GUI,
- * and are not persisted to the preference store. This is meant to
- * emulate the behavior of Sun's apt command-line tool, which passes
- * most of its command line options to the processor environment. The
- * programmatically set options are:
- * <code>-classpath</code> [set to Java build path]
- * <code>-sourcepath</code> [set to Java source path]
- * <code>-s</code> [set to generated src dir]
- * <code>-d</code> [set to binary output dir]
- * <code>-target</code> [set to compiler target version]
- * <code>-source</code> [set to compiler source version]
- *
- * There are some slight differences between the options returned by this
- * method and the options returned from this implementation of @see
- * AnnotationProcessorEnvironment#getOptions(). First, that method returns
- * additional options which are only meaningful during a build, such as
- * <code>phase</code>. Second, that method also adds alternate encodings
- * of each option, to be compatible with a bug in Sun's apt implementation:
- * specifically, for each option key="k", value="v", an additional option
- * is created with key="-Ak=v", value=null. This includes the user-created
- * options, but does not include the programmatically defined options listed
- * above.
- *
- * @param jproj a project, or null to query the workspace-wide setting.
- * @return a mutable, possibly empty, map of (key, value) pairs.
- * The value part of a pair may be null (equivalent to "-Akey" on the Sun apt
- * command line).
- * The value part may contain spaces.
- */
- public static Map<String, String> getProcessorOptions(IJavaProject jproj) {
- Map<String,String> rawOptions = getRawProcessorOptions(jproj);
- // map is large enough to also include the programmatically generated options
- Map<String, String> options = new HashMap<String, String>(rawOptions.size() + 6);
-
- // Resolve path metavariables like %ROOT%
- for (Map.Entry<String, String> entry : rawOptions.entrySet()) {
- String resolvedValue = resolveVarPath(jproj, entry.getValue());
- String value = (resolvedValue == null) ? entry.getValue() : resolvedValue;
- options.put(entry.getKey(), value);
- }
-
- if (jproj == null) {
- // there are no programmatically set options at the workspace level
- return options;
- }
-
- IWorkspaceRoot root = jproj.getProject().getWorkspace().getRoot();
-
- // Add sourcepath and classpath variables
- try {
- IClasspathEntry[] classpathEntries = jproj.getResolvedClasspath(true);
- Set<String> classpath = new LinkedHashSet<String>();
- Set<String> sourcepath = new LinkedHashSet<String>();
-
- // For projects on the classpath, loops can exist; need to make sure we
- // don't loop forever
- Set<IJavaProject> projectsProcessed = new HashSet<IJavaProject>();
- projectsProcessed.add(jproj);
- for (IClasspathEntry entry : classpathEntries) {
- int kind = entry.getEntryKind();
- if (kind == IClasspathEntry.CPE_LIBRARY) {
- IPath cpPath = entry.getPath();
-
- IResource res = root.findMember(cpPath);
-
- // If res is null, the path is absolute (it's an external jar)
- if (res == null) {
- classpath.add(cpPath.toOSString());
- }
- else {
- // It's relative
- classpath.add(res.getLocation().toOSString());
- }
- }
- else if (kind == IClasspathEntry.CPE_SOURCE) {
- IResource res = root.findMember(entry.getPath());
- if (res == null) {
- continue;
- }
- IPath srcPath = res.getLocation();
- if (srcPath == null) {
- continue;
- }
-
- sourcepath.add(srcPath.toOSString());
- }
- else if (kind == IClasspathEntry.CPE_PROJECT) {
- // Add the dependent project's build path and classpath to ours
- IPath otherProjectPath = entry.getPath();
- IProject otherProject = root.getProject(otherProjectPath.segment(0));
-
- // Note: JavaCore.create() is safe, even if the project is null --
- // in that case, we get null back
- IJavaProject otherJavaProject = JavaCore.create(otherProject);
-
- // If it doesn't exist, ignore it
- if (otherJavaProject != null && otherJavaProject.isOpen()) {
- addProjectClasspath(root, otherJavaProject, projectsProcessed, classpath);
- }
- }
- }
- // if you add options here, also add them in isAutomaticProcessorOption(),
- // and document them in docs/reference/automatic_processor_options.html.
-
- // Classpath and sourcepath
- options.put("-classpath",convertPathCollectionToString(classpath)); //$NON-NLS-1$
- options.put("-sourcepath", convertPathCollectionToString(sourcepath)); //$NON-NLS-1$
-
- // Get absolute path for generated source dir
- IFolder genSrcDir = jproj.getProject().getFolder(getGenSrcDir(jproj));
- String genSrcDirString = genSrcDir.getRawLocation().toOSString();
- options.put("-s", genSrcDirString); //$NON-NLS-1$
-
- // Absolute path for bin dir as well
- IPath binPath = jproj.getOutputLocation();
- IResource binPathResource = root.findMember(binPath);
- String binDirString;
- if (binPathResource != null) {
- binDirString = root.findMember(binPath).getLocation().toOSString();
- }
- else {
- binDirString = binPath.toOSString();
- }
- options.put("-d", binDirString); //$NON-NLS-1$
-
- String target = jproj.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true);
- options.put("-target", target); //$NON-NLS-1$
-
- String source = jproj.getOption(JavaCore.COMPILER_SOURCE, true);
- options.put("-source", source); //$NON-NLS-1$
- }
- catch (JavaModelException jme) {
- AptPlugin.log(jme, "Could not get the classpath for project: " + jproj); //$NON-NLS-1$
- }
-
- return options;
- }
-
- /**
- * If the value starts with a path variable such as %ROOT%, replace it with
- * the absolute path.
- * @param value the value of a -Akey=value command option
- */
- private static String resolveVarPath(IJavaProject jproj, String value) {
- if (value == null) {
- return null;
- }
- // is there a token to substitute?
- if (!Pattern.matches(PATHVAR_TOKEN, value)) {
- return value;
- }
- IPath path = new Path(value);
- String firstToken = path.segment(0);
- // If it matches %ROOT%/project, it is a project-relative path.
- if (PATHVAR_ROOT.equals(firstToken)) {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IResource proj = root.findMember(path.segment(1));
- if (proj == null) {
- return value;
- }
- // all is well; do the substitution
- IPath relativePath = path.removeFirstSegments(2);
- IPath absoluteProjPath = proj.getLocation();
- IPath absoluteResPath = absoluteProjPath.append(relativePath);
- return absoluteResPath.toOSString();
- }
-
- // If it matches %PROJECT.DIR%/project, the path is relative to the current project.
- if (jproj != null && PATHVAR_PROJECTROOT.equals(firstToken)) {
- // all is well; do the substitution
- IPath relativePath = path.removeFirstSegments(1);
- IPath absoluteProjPath = jproj.getProject().getLocation();
- IPath absoluteResPath = absoluteProjPath.append(relativePath);
- return absoluteResPath.toOSString();
- }
-
- // otherwise it's a classpath-var-based path.
- String cpvName = firstToken.substring(1, firstToken.length() - 1);
- IPath cpvPath = JavaCore.getClasspathVariable(cpvName);
- if (cpvPath != null) {
- IPath resolved = cpvPath.append(path.removeFirstSegments(1));
- return resolved.toOSString();
- }
- else {
- return value;
- }
- }
-
- // We need this as a separate method, as we'll put dependent projects' output
- // on the classpath
- private static void addProjectClasspath(
- IWorkspaceRoot root,
- IJavaProject otherJavaProject,
- Set<IJavaProject> projectsProcessed,
- Set<String> classpath) {
-
- // Check for cycles. If we've already seen this project,
- // no need to go any further.
- if (projectsProcessed.contains(otherJavaProject)) {
- return;
- }
- projectsProcessed.add(otherJavaProject);
-
- try {
- // Add the output directory first as a binary entry for other projects
- IPath binPath = otherJavaProject.getOutputLocation();
- IResource binPathResource = root.findMember(binPath);
- String binDirString;
- if (binPathResource != null) {
- binDirString = root.findMember(binPath).getLocation().toOSString();
- }
- else {
- binDirString = binPath.toOSString();
- }
- classpath.add(binDirString);
-
- // Now the rest of the classpath
- IClasspathEntry[] classpathEntries = otherJavaProject.getResolvedClasspath(true);
- for (IClasspathEntry entry : classpathEntries) {
- if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
- IPath cpPath = entry.getPath();
-
- IResource res = root.findMember(cpPath);
-
- // If res is null, the path is absolute (it's an external jar)
- if (res == null) {
- classpath.add(cpPath.toOSString());
- }
- else {
- // It's relative
- classpath.add(res.getLocation().toOSString());
- }
- }
- else if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
- IPath otherProjectPath = entry.getPath();
- IProject otherProject = root.getProject(otherProjectPath.segment(0));
- IJavaProject yetAnotherJavaProject = JavaCore.create(otherProject);
- if (yetAnotherJavaProject != null) {
- addProjectClasspath(root, yetAnotherJavaProject, projectsProcessed, classpath);
- }
- }
- // Ignore source types
- }
- }
- catch (JavaModelException jme) {
- AptPlugin.log(jme, "Failed to get the classpath for the following project: " + otherJavaProject); //$NON-NLS-1$
- }
- }
-
- private static String convertPathCollectionToString(Collection<String> paths) {
- if (paths.size() == 0) {
- return ""; //$NON-NLS-1$
- }
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- for (String path : paths) {
- if (first) {
- first = false;
- }
- else {
- sb.append(File.pathSeparatorChar);
- }
- sb.append(path);
- }
- return sb.toString();
- }
-
- /**
- * Set all the processor options in one call. This will delete any
- * options that are not passed in, so callers who do not wish to
- * destroy pre-existing options should use addProcessorOption() instead.
- * @param options a map of keys to values. The keys should not include
- * any automatic options (@see #isAutomaticProcessorOption(String)),
- * and the "-A" should not be included. That is, to perform the
- * equivalent of the apt command line "-Afoo=bar", use the key "foo"
- * and the value "bar". Keys cannot contain spaces; values can
- * contain anything at all. Keys cannot be null, but values can be.
- */
- public static void setProcessorOptions(Map<String, String> options, IJavaProject jproj) {
- IScopeContext context = (null != jproj) ?
- new ProjectScope(jproj.getProject()) : new InstanceScope();
-
- // TODO: this call is needed only for backwards compatibility with
- // settings files previous to 2005.11.13. At some point it should be
- // removed.
- removeOldStyleSettings(context);
-
- IEclipsePreferences node = context.getNode(AptPlugin.PLUGIN_ID + "/" + //$NON-NLS-1$
- AptPreferenceConstants.APT_PROCESSOROPTIONS);
- try {
- node.clear();
- for (Entry<String, String> option : options.entrySet()) {
- String nonNullVal = option.getValue() == null ?
- AptPreferenceConstants.APT_NULLVALUE : option.getValue();
- node.put(option.getKey(), nonNullVal);
- }
- node.flush();
- } catch (BackingStoreException e) {
- AptPlugin.log(e, "Unable to save annotation processor options"); //$NON-NLS-1$
- }
- }
-
- /**
- * Is the named option automatically generated in getProcessorOptions(),
- * or did it come from somewhere else, such as a -A processor option?
- * @param key the name of an AnnotationProcessorEnvironment option
- * @return true if the option is automatically set.
- */
- public static boolean isAutomaticProcessorOption(String key) {
- if ("-classpath".equals(key)) //$NON-NLS-1$
- return true;
- if ("-sourcepath".equals(key)) //$NON-NLS-1$
- return true;
- if ("-s".equals(key)) //$NON-NLS-1$
- return true;
- if ("-d".equals(key)) //$NON-NLS-1$
- return true;
- if ("-target".equals(key)) //$NON-NLS-1$
- return true;
- if ("-source".equals(key)) //$NON-NLS-1$
- return true;
- return false;
- }
-
- /**
- * Get the options that are presented to annotation processors by the
- * AnnotationProcessorEnvironment. The -A and = are stripped out, so
- * (key, value) is the equivalent of -Akey=value.
- *
- * This method differs from getProcessorOptions in that the options returned
- * by this method do NOT include any programmatically set options. This
- * method returns only the options that are persisted to the preference
- * store and that are displayed in the configuration GUI.
- *
- * @param jproj a project, or null to query the workspace-wide setting.
- * If jproj is not null, but the project has no per-project settings,
- * this method will fall back to the workspace-wide settings.
- * @return a mutable, possibly empty, map of (key, value) pairs.
- * The value part of a pair may be null (equivalent to "-Akey").
- * The value part can contain spaces, if it is quoted: -Afoo="bar baz".
- */
- public static Map<String, String> getRawProcessorOptions(IJavaProject jproj) {
- Map<String, String> options = new HashMap<String, String>();
-
- // TODO: this code is needed only for backwards compatibility with
- // settings files previous to 2005.11.13. At some point it should be
- // removed.
- // If an old-style setting exists, add it into the mix for backward
- // compatibility.
- options.putAll(getOldStyleRawProcessorOptions(jproj));
-
- // Fall back from project to workspace scope on an all-or-nothing basis,
- // not value by value. (Never fall back to default scope; there are no
- // default processor options.) We can't use IPreferencesService for this
- // as we would normally do, because we don't know the names of the keys.
- IScopeContext[] contexts;
- if (jproj != null) {
- contexts = new IScopeContext[] {
- new ProjectScope(jproj.getProject()), new InstanceScope() };
- }
- else {
- contexts = new IScopeContext[] { new InstanceScope() };
- }
- for (IScopeContext context : contexts) {
- IEclipsePreferences prefs = context.getNode(AptPlugin.PLUGIN_ID);
- try {
- if (prefs.childrenNames().length > 0) {
- IEclipsePreferences procOptionsNode = context.getNode(
- AptPlugin.PLUGIN_ID + "/" + AptPreferenceConstants.APT_PROCESSOROPTIONS); //$NON-NLS-1$
- if (procOptionsNode != null) {
- for (String key : procOptionsNode.keys()) {
- String nonNullVal = procOptionsNode.get(key, null);
- String val = AptPreferenceConstants.APT_NULLVALUE.equals(nonNullVal) ?
- null : nonNullVal;
- options.put(key, val);
- }
- break;
- }
- }
- } catch (BackingStoreException e) {
- AptPlugin.log(e, "Unable to load annotation processor options"); //$NON-NLS-1$
- }
- }
- return options;
- }
-
- /**
- * TODO: this code is needed only for backwards compatibility with
- * settings files previous to 2005.11.13. At some point it should be
- * removed.
- * Get the processor options as an APT-style string ("-Afoo=bar -Abaz=quux")
- */
- private static Map<String, String> getOldStyleRawProcessorOptions(IJavaProject jproj) {
- Map<String, String> options;
- String allOptions = getString(jproj, AptPreferenceConstants.APT_PROCESSOROPTIONS);
- if (null == allOptions) {
- options = new HashMap<String, String>();
- }
- else {
- ProcessorOptionsParser op = new ProcessorOptionsParser(allOptions);
- options = op.parse();
- }
- return options;
- }
- /**
- * TODO: this code is needed only for backwards compatibility with
- * settings files previous to 2005.11.13. At some point it should be
- * removed.
- *
- * Used to parse an apt-style command line string into a map of key/value
- * pairs.
- * Parsing ignores errors and simply tries to gobble up as many well-formed
- * pairs as it can find.
- */
- private static class ProcessorOptionsParser {
- final String _s;
- int _start; // everything before this is already parsed.
- boolean _hasVal; // does the last key found have a value token?
-
- public ProcessorOptionsParser(String s) {
- _s = s;
- _start = 0;
- _hasVal = false;
- }
-
- public Map<String, String> parse() {
- Map<String, String> options = new HashMap<String, String>();
- String key;
- while (null != (key = parseKey())) {
- options.put(key, parseVal());
- }
- return options;
- }
-
- /**
- * Skip until a well-formed key (-Akey[=val]) is found, and
- * return the key. Set _start to the beginning of the value,
- * or to the first character after the end of the key and
- * delimiter, for a valueless key. Set _hasVal according to
- * whether a value was found.
- * @return a key, or null if no well-formed keys can be found.
- */
- private String parseKey() {
- String key;
- int spaceAt = -1;
- int equalsAt = -1;
-
- _hasVal = false;
-
- while (true) {
- _start = _s.indexOf("-A", _start); //$NON-NLS-1$
- if (_start < 0) {
- return null;
- }
-
- // we found a -A. The key is everything up to the next '=' or ' ' or EOL.
- _start += 2;
- if (_start >= _s.length()) {
- // it was just a -A, nothing following.
- return null;
- }
-
- spaceAt = _s.indexOf(' ', _start);
- equalsAt = _s.indexOf('=', _start);
- if (spaceAt == _start || equalsAt == _start) {
- // false alarm. Keep trying.
- ++_start;
- continue;
- }
- break;
- }
-
- // We found a legitimate -A with some text after it.
- // Where does the key end?
- if (equalsAt > 0) {
- if (spaceAt < 0 || equalsAt < spaceAt) {
- // there is an equals, so there is a value.
- key = new String(_s.substring(_start, equalsAt));
- _start = equalsAt + 1;
- _hasVal = (_start < _s.length());
- }
- else {
- // the next thing is a space, so this is a valueless key
- key = new String(_s.substring(_start, spaceAt));
- _start = spaceAt + 1;
- }
- }
- else {
- if (spaceAt < 0) {
- // no equals sign and no spaces: a valueless key, up to the end of the string.
- key = new String(_s.substring(_start));
- _start = _s.length();
- }
- else {
- // the next thing is a space, so this is a valueless key
- key = new String(_s.substring(_start, spaceAt));
- _start = spaceAt + 1;
- }
- }
- return key;
- }
-
- /**
- * A value token is delimited by a space; but spaces inside quoted
- * regions are ignored. A value may include multiple quoted regions.
- * An unmatched quote is treated as if there was a matching quote at
- * the end of the string. Quotes are returned as part of the value.
- * @return the value, up to the next nonquoted space or end of string.
- */
- private String parseVal() {
- if (!_hasVal || _start < 0 || _start >= _s.length()) {
- return null;
- }
- boolean inQuotedRegion = false;
- int start = _start;
- int end = _start;
- while (end < _s.length()) {
- char c = _s.charAt(end);
- if (c == '"') {
- inQuotedRegion = !inQuotedRegion;
- }
- else if (!inQuotedRegion && c == ' ') {
- // end of token.
- _start = end + 1;
- break;
- }
- ++end;
- }
-
- return new String(_s.substring(start, end));
- }
- }
-
- /**
- * TODO: this code is needed only for backwards compatibility with
- * settings files previous to 2005.11.13. At some point it should be
- * removed.
- * Delete the key that saves annotation processor options as a single
- * command-line-type string ("-Afoo=bar -Abaz=quux").
- */
- private static void removeOldStyleSettings(IScopeContext context) {
- IEclipsePreferences node = context.getNode(AptPlugin.PLUGIN_ID);
- node.remove(AptPreferenceConstants.APT_PROCESSOROPTIONS);
- }
-
- /**
- * Flush unsaved preferences and perform any other config-related shutdown.
- * This is called once, from AptPlugin.shutdown().
- */
- public static void dispose() {
- try {
- new InstanceScope().getNode(AptPlugin.PLUGIN_ID).flush();
- }
- catch (BackingStoreException e) {
- // log failure and continue
- AptPlugin.log(e, "Couldn't flush preferences to disk"); //$NON-NLS-1$
- }
- }
-
- /**
- * Initialize preferences lookups, and register change listeners.
- * This is called once, from AptPlugin.startup().
- */
- public static void initialize() {
- // If we cached workspace-level preferences, we would want to install
- // some change listeners here.
- }
-
- /**
- * Is annotation processing turned on for this project?
- * <p>
- * Prior to Eclipse 3.3, this read the org.eclipse.jdt.apt.aptEnabled
- * setting. In Eclipse 3.3, it reads the org.eclipse.jdt.core.compiler.processingEnabled
- * setting; the result is logically or-ed with value of the older setting in order to
- * preserve backward compatibility.
- * @param jproject an IJavaProject, or null to request workspace preferences.
- * @return true if annotation processing is turned on.
- */
- public static boolean isEnabled(IJavaProject jproject) {
- if ("enabled".equals(getString(jproject, AptPreferenceConstants.APT_PROCESSANNOTATIONS))) { //$NON-NLS-1$
- return true;
- }
- // backward compatibility: also return true if old setting is enabled
- return getBoolean(jproject, AptPreferenceConstants.APT_ENABLED);
- }
-
-
- /**
- * Turn annotation processing on or off for this project.
- * <p>
- * Prior to Eclipse 3.3, this affected the org.eclipse.jdt.apt.aptEnabled
- * setting. In Eclipse 3.3, it affects the org.eclipse.jdt.core.compiler.processingEnabled
- * setting; the older setting is still set (and read) in order to preserve backward
- * compatibility.
- * @param jproject an IJavaProject, or null to set workspace preferences.
- * @param enabled
- */
- public static void setEnabled(IJavaProject jproject, boolean enabled) {
- if (jproject == null && enabled == true) {
- IllegalArgumentException e = new IllegalArgumentException();
- IStatus status = AptPlugin.createWarningStatus(e,
- "Illegal attempt to enable annotation processing workspace-wide"); //$NON-NLS-1$
- AptPlugin.log(status);
- throw e;
- }
- setString(jproject, AptPreferenceConstants.APT_PROCESSANNOTATIONS,
- enabled ? AptPreferenceConstants.ENABLED : AptPreferenceConstants.DISABLED);
- // backward compatibility: also save old setting
- setBoolean(jproject, AptPreferenceConstants.APT_ENABLED, enabled);
- }
-
- /**
- * Is annotation processing turned on during reconcile, or only during build?
- * Note that if isEnabled() is false, processing will not occur at all; the
- * two settings are independent.
- * @param jproject an IJavaProject to query, or null to get the default value.
- * @return true if processing is enabled during both reconcile and build
- */
- public static boolean shouldProcessDuringReconcile(IJavaProject jproject) {
- return getBoolean(jproject, AptPreferenceConstants.APT_RECONCILEENABLED);
- }
-
- /**
- * Turn processing during reconcile on or off. Processing during build is
- * unaffected. Note that if isEnabled() is false, processing will not occur
- * at all; the two settings are independent.
- * @param jproject the IJavaProject to modify. This setting is only valid
- * on individual projects.
- */
- public static void setProcessDuringReconcile(IJavaProject jproject, boolean enabled) {
- setBoolean(jproject, AptPreferenceConstants.APT_RECONCILEENABLED, enabled);
- }
-
- private static boolean getBoolean(IJavaProject jproj, String optionName) {
- IPreferencesService service = Platform.getPreferencesService();
- IScopeContext[] contexts;
- if (jproj != null) {
- contexts = new IScopeContext[] {
- new ProjectScope(jproj.getProject()), new InstanceScope(), new DefaultScope() };
- }
- else {
- contexts = new IScopeContext[] { new InstanceScope(), new DefaultScope() };
- }
- return service.getBoolean(
- AptPlugin.PLUGIN_ID,
- optionName,
- Boolean.parseBoolean(AptPreferenceConstants.DEFAULT_OPTIONS_MAP.get(optionName)),
- contexts);
- }
-
- /**
- * Get a factory path corresponding to the default values: if jproj is
- * non-null, return the current workspace factory path (workspace prefs
- * are the default for a project); if jproj is null, return the default
- * list of plugin factories (which is the "factory default").
- */
- public static IFactoryPath getDefaultFactoryPath(IJavaProject jproj) {
- return FactoryPathUtil.getDefaultFactoryPath(jproj);
- }
-
- /**
- * Get the factory path for a given project or for the workspace.
- * @param jproj the project, or null to get the factory path for the workspace.
- * @return a FactoryPath representing the current state of the specified project.
- * Note that changes made to the project after this call will not affect the
- * returned object - that is, it behaves like a value, not like a live link to
- * the project state.
- */
- public static IFactoryPath getFactoryPath(IJavaProject jproj) {
- return FactoryPathUtil.getFactoryPath(jproj);
- }
-
- /**
- * Set the factory path for a given project or for the workspace.
- * Does not perform any validation on the path.
- * @param jproj the project, or null to set the factory path for the workspace.
- * @param path a factory path, or null to reset the factory path to the default.
- */
- public static void setFactoryPath(IJavaProject jproj, IFactoryPath path)
- throws CoreException
- {
- FactoryPath fp = (FactoryPath)path;
- FactoryPathUtil.setFactoryPath(jproj, fp);
- // Project-specific factory path files are resources, so changes
- // get picked up by the resource listener. Workspace changes aren't.
- if (jproj == null) {
- AnnotationProcessorFactoryLoader.getLoader().resetAll();
- }
- }
-
- /**
- * Has an explicit factory path been set for the specified project, or
- * is it just defaulting to the workspace settings?
- * @return true if there is a project-specific factory path.
- */
- public static boolean hasProjectSpecificFactoryPath(IJavaProject jproj) {
- if (null == jproj) {
- // say no, even if workspace-level factory path does exist.
- return false;
- }
- return FactoryPathUtil.doesFactoryPathFileExist(jproj);
- }
-
- /**
- * Helper method to get a single preference setting, e.g., APT_GENSRCDIR.
- * This is a different level of abstraction than the processor -A settings!
- * The -A settings are all contained under one single preference node,
- * APT_PROCESSOROPTIONS. Use @see #getProcessorOptions(IJavaProject) to
- * get the -A settings; use @see #getOptions(IJavaProject) to get all the
- * preference settings as a map; and use this helper method to get a single
- * preference setting.
- *
- * @param jproj the project, or null for workspace.
- * @param optionName a preference constant from @see AptPreferenceConstants.
- * @return the string value of the setting.
- */
- public static String getString(IJavaProject jproj, String optionName) {
- IPreferencesService service = Platform.getPreferencesService();
- IScopeContext[] contexts;
- if (jproj != null) {
- contexts = new IScopeContext[] {
- new ProjectScope(jproj.getProject()), new InstanceScope(), new DefaultScope() };
- }
- else {
- contexts = new IScopeContext[] { new InstanceScope(), new DefaultScope() };
- }
- String pluginId = null;
- if (AptPreferenceConstants.APT_PROCESSANNOTATIONS.equals(optionName)) {
- pluginId = JavaCore.PLUGIN_ID;
- }
- else {
- pluginId = AptPlugin.PLUGIN_ID;
- }
- return service.getString(
- pluginId,
- optionName,
- AptPreferenceConstants.DEFAULT_OPTIONS_MAP.get(optionName),
- contexts);
- }
-
- public static String getGenSrcDir(IJavaProject jproject) {
- return getString(jproject, AptPreferenceConstants.APT_GENSRCDIR);
- }
-
- public static void setGenSrcDir(IJavaProject jproject, String dirString) {
- if (!GeneratedSourceFolderManager.validate(jproject, dirString)) {
- throw new IllegalArgumentException("Illegal name for generated source folder: " + dirString); //$NON-NLS-1$
- }
- setString(jproject, AptPreferenceConstants.APT_GENSRCDIR, dirString);
- }
-
- public static boolean validateGenSrcDir(IJavaProject jproject, String dirName) {
- return GeneratedSourceFolderManager.validate(jproject, dirName);
- }
-
- private static void setBoolean(IJavaProject jproject, String optionName, boolean value) {
- IScopeContext context = (null != jproject) ?
- new ProjectScope(jproject.getProject()) : new InstanceScope();
- IEclipsePreferences node = context.getNode(AptPlugin.PLUGIN_ID);
- // get old val as a String, so it can be null if setting doesn't exist yet
- String oldValue = node.get(optionName, null);
- node.putBoolean(optionName, value);
- if (jproject != null && oldValue == null || (value != Boolean.parseBoolean(oldValue))) {
- AptProject aproj = AptPlugin.getAptProject(jproject);
- aproj.preferenceChanged(optionName);
- }
- flushPreference(optionName, node);
- }
-
- private static void setString(IJavaProject jproject, String optionName, String value) {
- IScopeContext context = (null != jproject) ?
- new ProjectScope(jproject.getProject()) : new InstanceScope();
- IEclipsePreferences node;
- if (AptPreferenceConstants.APT_PROCESSANNOTATIONS.equals(optionName)) {
- node = context.getNode(JavaCore.PLUGIN_ID);
- }
- else {
- node = context.getNode(AptPlugin.PLUGIN_ID);
- }
- String oldValue = node.get(optionName, null);
- node.put(optionName, value);
- if (jproject != null && !value.equals(oldValue)) {
- AptProject aproj = AptPlugin.getAptProject(jproject);
- aproj.preferenceChanged(optionName);
- }
- flushPreference(optionName, node);
- }
-
- private static void flushPreference(String optionName, IEclipsePreferences node) {
- try {
- node.flush();
- }
- catch (BackingStoreException e){
- AptPlugin.log(e, "Failed to save preference: " + optionName); //$NON-NLS-1$
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/AptPreferenceConstants.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/AptPreferenceConstants.java
deleted file mode 100644
index c0ffbbf1f7..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/AptPreferenceConstants.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.util;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * String constants used to access APT preference store
- *
- * This class is not intended to be subclassed or instantiated.
- */
-public class AptPreferenceConstants {
- public static final String APT_STRING_BASE = "org.eclipse.jdt.apt"; //$NON-NLS-1$
- public static final String APT_GENSRCDIR = APT_STRING_BASE + ".genSrcDir"; //$NON-NLS-1$
- public static final String APT_PROCESSOROPTIONS = APT_STRING_BASE + ".processorOptions"; //$NON-NLS-1$
- public static final String APT_RECONCILEENABLED = APT_STRING_BASE + ".reconcileEnabled"; //$NON-NLS-1$
- public static final String APT_PROCESSANNOTATIONS = "org.eclipse.jdt.core.compiler.processAnnotations"; //$NON-NLS-1$
- // backward compatibility prior to Eclipse 3.3:
- public static final String APT_ENABLED = APT_STRING_BASE + ".aptEnabled"; //$NON-NLS-1$
-
- // used for APT_PROCESSANNOTATIONS setting:
- public static final String ENABLED = "enabled"; //$NON-NLS-1$
- public static final String DISABLED = "disabled"; //$NON-NLS-1$
-
- // Used in preference to indicate null value for processor option
- public static final String APT_NULLVALUE = APT_STRING_BASE + ".NULLVALUE"; //$NON-NLS-1$
-
- public static final String DEFAULT_GENERATED_SOURCE_FOLDER_NAME = ".apt_generated"; //$NON-NLS-1$
-
- /**
- * Processors should report this option in {@link com.sun.mirror.apt.AnnotationProcessorFactory#supportedOptions()}
- * in order to enable type generation while editing, that is, during reconcile. This setting will be ignored if
- * the processor also reports {@link #PROCESSING_IN_EDITOR_DISABLED_OPTION}.
- */
- public static final String RTTG_ENABLED_OPTION = "enableTypeGenerationInEditor"; //$NON-NLS-1$
-
- /**
- * Processors should report this option in {@link com.sun.mirror.apt.AnnotationProcessorFactory#supportedOptions()}
- * in order to disable processing while editing, that is, during reconcile. If this option is set, ie if processing
- * is disabled, then the value of {@link #RTTG_ENABLED_OPTION} will be ignored. Whether a processor is called
- * during reconcile is also influenced by the project settings and the project factory path.
- * <p>
- * @see AptConfig#setProcessDuringReconcile(org.eclipse.jdt.core.IJavaProject, boolean)
- */
- public static final String PROCESSING_IN_EDITOR_DISABLED_OPTION = "disableProcessingInEditor"; //$NON-NLS-1$
-
- public static Map<String,String> DEFAULT_OPTIONS_MAP;
-
- static {
- Map<String,String> options = new HashMap<String,String>();
- options.put(AptPreferenceConstants.APT_ENABLED, "false"); //$NON-NLS-1$
- options.put(AptPreferenceConstants.APT_GENSRCDIR, DEFAULT_GENERATED_SOURCE_FOLDER_NAME);
- options.put(AptPreferenceConstants.APT_PROCESSOROPTIONS, ""); //$NON-NLS-1$
- options.put(AptPreferenceConstants.APT_RECONCILEENABLED, "true"); //$NON-NLS-1$
- DEFAULT_OPTIONS_MAP = Collections.unmodifiableMap(options);
- }
-
- /**
- * Names of all apt settings that can be read from APT preference store.
- * Order is unimportant. Note that not all "apt settings" may be in the
- * APT preference store - for instance, the factory path is kept in a
- * separate file. This list only applies to the information available
- * from IPreferencesService. See AptConfig for usage.
- */
- public static final String[] OPTION_NAMES = {
- APT_ENABLED,
- APT_GENSRCDIR,
- APT_PROCESSOROPTIONS,
- APT_RECONCILEENABLED,
- };
-
- /**
- * Number of apt settings in the APT preference store.
- */
- public static final int NSETTINGS = OPTION_NAMES.length;
-}
-
-
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 972a4a199d..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/AptUtil.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.util;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader;
-import org.eclipse.jdt.core.IJavaProject;
-
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-
-public final class AptUtil {
-
- // Private c-tor to prevent construction
- private AptUtil() {}
-
- /**
- * Returns the matching annotation processor factory for a given
- * annotation in a given project.
- *
- * @param fullyQualifiedAnnotation the annotation for which a factory
- * is desired. This must be fully qualfied -- e.g. "org.eclipse.annotation.Foo"
- */
- public static AnnotationProcessorFactory getFactoryForAnnotation(
- final String fullyQualifiedAnnotation,
- final IJavaProject jproj) {
-
- AnnotationProcessorFactoryLoader loader = AnnotationProcessorFactoryLoader.getLoader();
- List<AnnotationProcessorFactory> factories = loader.getJava5FactoriesForProject( jproj );
-
- for (AnnotationProcessorFactory factory : factories) {
- Collection<String> supportedAnnos = factory.supportedAnnotationTypes();
- for (String anno : supportedAnnos) {
- if (anno.equals(fullyQualifiedAnnotation)) {
- return factory;
- }
- else if ("*".equals(anno)) { //$NON-NLS-1$
- return factory;
- }
- else if (anno.endsWith("*")) { //$NON-NLS-1$
- final String prefix = anno.substring(0,
- anno.length() - 2);
- if (fullyQualifiedAnnotation.startsWith(prefix)) {
- return factory;
- }
- }
- }
- }
-
- return null;
- }
-
-
-
-}
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 43170e742f..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/EclipseMessager.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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;
-import com.sun.mirror.util.SourcePosition;
-
-/**
- * Extend the APT {@link Messager} to allow the registrating of diagnostics on ast nodes.
- */
-public interface EclipseMessager extends Messager
-{
- /**
- * Problem ID for APT problems that do not have quick fixes
- */
- public static final int APT_PROBLEM_ID = /*TODO: switch to IProblem.ExternalProblemNotFixable*/ 901;
-
- /**
- * Problem ID for APT problems that have quick fixes.
- * If an APT plugin wants to write a quick-fix for their problems,
- * they should look for this ID.
- *
- * see org.eclipse.jdt.ui.text.java.IQuickAssistProcessor
- */
- public static final int APT_QUICK_FIX_PROBLEM_ID = /* TODO: switch to IProblem.ExternalProblemFixable*/ 900;
-
-
- /**
- * 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);
-
- /**
- * Print an error including the given arguments for use
- * in quick-fixes. Any APT Quick Fix processors (@see IAPTQuickFixProcessor)
- * registered with the provided pluginId and errorId will
- * then get called if the user attempt to quick-fix that error.
- *
- * @param pos position of the error
- * @param msg message to display to the user
- * @param pluginId plugin which will provide an apt quick fix processor
- * for this error. Cannot be null.
- * @param errorId a plugin-provided error code which will be meaningful
- * to the quick fix processor (e.g. "invalidAnnotationValue", etc.)
- * Cannot be null.
- */
- void printFixableError(SourcePosition pos, String msg, String pluginId, String errorId);
-
- /**
- * Print a warning including the given arguments for use
- * in quick-fixes. Any APT Quick Fix processors (@see IAPTQuickFixProcessor)
- * registered with the provided pluginId and errorId will
- * then get called if the user attempt to quick-fix that warning.
- *
- * @param pos position of the error
- * @param msg message to display to the user
- * @param pluginId plugin which will provide an apt quick fix processor
- * for this error. Cannot be null.
- * @param errorId a plugin-provided error code which will be meaningful
- * to the quick fix processor (e.g. "invalidAnnotationValue", etc.)
- * Cannot be null.
- */
- void printFixableWarning(SourcePosition pos, String msg, String pluginId, String errorId);
-
- /**
- * Print a notice including the given arguments for use
- * in quick-fixes. Any APT Quick Fix processors (@see IAPTQuickFixProcessor)
- * registered with the provided pluginId and errorId will
- * then get called if the user attempt to quick-fix that notice.
- *
- * @param pos position of the error
- * @param msg message to display to the user
- * @param pluginId plugin which will provide an apt quick fix processor
- * for this error. Cannot be null.
- * @param errorId a plugin-provided error code which will be meaningful
- * to the quick fix processor (e.g. "invalidAnnotationValue", etc.)
- * Cannot be null.
- */
- void printFixableNotice(SourcePosition pos, String msg, String pluginId, String errorId);
-
- /**
- * Print an error including the given arguments for use
- * in quick-fixes. Any APT Quick Fix processors (@see IAPTQuickFixProcessor)
- * registered with the provided pluginId and errorId will
- * then get called if the user attempt to quick-fix that error.
- *
- * @param msg message to display to the user
- * @param pluginId plugin which will provide an apt quick fix processor
- * for this error. Cannot be null.
- * @param errorId a plugin-provided error code which will be meaningful
- * to the quick fix processor (e.g. "invalidAnnotationValue", etc.)
- * Cannot be null.
- */
- void printFixableError(String msg, String pluginId, String errorId);
-
- /**
- * Print a warning including the given arguments for use
- * in quick-fixes. Any APT Quick Fix processors (@see IAPTQuickFixProcessor)
- * registered with the provided pluginId and errorId will
- * then get called if the user attempt to quick-fix that warning.
- *
- * @param msg message to display to the user
- * @param pluginId plugin which will provide an apt quick fix processor
- * for this error. Cannot be null.
- * @param errorId a plugin-provided error code which will be meaningful
- * to the quick fix processor (e.g. "invalidAnnotationValue", etc.)
- * Cannot be null.
- */
- void printFixableWarning(String msg, String pluginId, String errorId);
-
- /**
- * Print a notice including the given arguments for use
- * in quick-fixes. Any APT Quick Fix processors (@see IAPTQuickFixProcessor)
- * registered with the provided pluginId and errorId will
- * then get called if the user attempt to quick-fix that notice.
- *
- * @param msg message to display to the user
- * @param pluginId plugin which will provide an apt quick fix processor
- * for this error. Cannot be null.
- * @param errorId a plugin-provided error code which will be meaningful
- * to the quick fix processor (e.g. "invalidAnnotationValue", etc.)
- * Cannot be null.
- */
- void printFixableNotice(String msg, String pluginId, String errorId);
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/IFactoryPath.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/IFactoryPath.java
deleted file mode 100644
index 415bfad3e3..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/IFactoryPath.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.util;
-
-import java.io.File;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * A minimal API for manipulating the annotation processor factory path.
- * The factory path is an ordered list of containers, each of which has
- * certain attributes, e.g., isEnabled, runInBatchMode. Containers on
- * the path do not necessarily contain implementations of any particular
- * service; in particular, a path may have both Java 5 and Java 6 annotation
- * processors, as well as entries that contain supporting classes or
- * resources.
- * <p>
- * Clients should not implement this interface.
- */
-public interface IFactoryPath {
-
- /**
- * Add an external jar file (not in the workspace) to the head of the
- * factory path. If the jar is already on the path, move it to the
- * head. The jar will be added with default attributes, e.g.,
- * isEnabled=true, runInBatchMode=false.
- * @param jar a java.io.File representing the jar file. Must not be null.
- */
- public void addExternalJar(File jar);
-
- /**
- * Remove an external jar file from the factory path.
- * If the jar isn't on the path, do nothing.
- * @param jar must not be null.
- */
- public void removeExternalJar(File jar);
-
- /**
- * Add a jar file in the workspace to the head of the
- * factory path. If the jar is already on the path, move it to the
- * head. The jar will be added with default attributes, e.g.,
- * isEnabled=true, runInBatchMode=false.
- * @param jarPath an Eclipse IPath representing the jar file; the path is
- * relative to the workspace root. Must not be null.
- */
- public void addWkspJar(IPath jarPath);
-
- /**
- * Remove a workspace-relative jar from the factory path.
- * If the jar isn't on the path, do nothing.
- * @param jarPath an Eclipse IPath representing the jar file; the path is
- * relative to the workspace root. Must not be null.
- */
- public void removeWkspJar(IPath jarPath);
-
- /**
- * Add a jar file in the workspace, specified with a classpath variable,
- * to the head of the factory path. If the jar is already on the path,
- * move it to the head. The jar will be added with default attributes,
- * e.g., isEnabled=true, runInBatchMode=false.
- * @param jarPath an Eclipse IPath representing the jar file; the first
- * segment of the path is assumed to be the variable name. Must not
- * be null.
- */
- public void addVarJar(IPath jarPath);
-
- /**
- * Remove from the factory path a jar file whose name is based on a
- * classpath variable. If the jar isn't on the path, do nothing.
- * @param jarPath an Eclipse IPath representing the jar file; the first
- * segment of the path is assumed to be the variable name. Must not
- * be null.
- */
- public void removeVarJar(IPath jarPath);
-
- /**
- * Enable a plugin on the factory path, and move it to the head of the
- * path.
- * @param pluginId the unique id of the processor plugin, e.g.,
- * "org.example.myProcessors"
- * @throws CoreException if the plugin is not installed.
- */
- public void enablePlugin(String pluginId) throws CoreException;
-
- /**
- * Disable a plugin on the factory path.
- * If the plugin is not installed, do nothing.
- * @param pluginId the unique id of the processor plugin, e.g.,
- * "org.example.myProcessors"
- */
- public void disablePlugin(String pluginId);
-}
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/package.html b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/package.html
deleted file mode 100644
index 3400d4154e..0000000000
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/util/package.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="BEA Systems Inc.">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-This package contains miscellaneous APIs related to Java annotation processing.
-<h2>
-Package Specification</h2>
-
-<p><br>This package contains miscellaneous utilities related to Java annotation
-processing, such as the APIs needed to configure the annotation processor
-settings and factory path.
-</body>
-</html>
diff --git a/org.eclipse.jdt.apt.pluggable.core/.classpath b/org.eclipse.jdt.apt.pluggable.core/.classpath
deleted file mode 100644
index 121e527a93..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jdt.apt.pluggable.core/.cvsignore b/org.eclipse.jdt.apt.pluggable.core/.cvsignore
deleted file mode 100644
index c5e82d7458..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.pluggable.core/.options b/org.eclipse.jdt.apt.pluggable.core/.options
deleted file mode 100644
index 45c4b5cd5d..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/.options
+++ /dev/null
@@ -1,3 +0,0 @@
-# Debug tracing for org.eclipse.jdt.apt.pluggable.core plugin
-# Includes traces needed for most client-visible problems
-org.eclipse.jdt.apt.pluggable.core/debug=false
diff --git a/org.eclipse.jdt.apt.pluggable.core/.project b/org.eclipse.jdt.apt.pluggable.core/.project
deleted file mode 100644
index 6617d61df4..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.apt.pluggable.core</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.pluggable.core/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jdt.apt.pluggable.core/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index f4e7111bcc..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-#Fri Feb 23 10:07:50 PST 2007
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.eclipse.jdt.apt.pluggable.core/META-INF/MANIFEST.MF b/org.eclipse.jdt.apt.pluggable.core/META-INF/MANIFEST.MF
deleted file mode 100644
index b2d4649889..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,22 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jdt.apt.pluggable.core;singleton:=true
-Bundle-Version: 1.0.100.qualifier
-Bundle-Activator: org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin
-Bundle-Vendor: %providerName
-Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.jdt.apt.core,
- org.eclipse.jdt.core,
- org.eclipse.core.resources
-Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.jdt.internal.apt.pluggable.core;x-internal:=true,
- org.eclipse.jdt.internal.apt.pluggable.core.dispatch;x-internal:=true,
- org.eclipse.jdt.internal.apt.pluggable.core.filer;x-internal:=true
-Bundle-Localization: plugin
-Import-Package: org.eclipse.jdt.internal.compiler.tool,
- org.eclipse.jdt.internal.compiler.apt.dispatch,
- org.eclipse.jdt.internal.compiler.apt.model,
- org.eclipse.jdt.internal.compiler.apt.util
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-
diff --git a/org.eclipse.jdt.apt.pluggable.core/about.html b/org.eclipse.jdt.apt.pluggable.core/about.html
deleted file mode 100644
index 460233046e..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 2, 2006</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.pluggable.core/build.properties b/org.eclipse.jdt.apt.pluggable.core/build.properties
deleted file mode 100644
index b153d47473..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/build.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###############################################################################
-# Copyright (c) 2007 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- about.html,\
- plugin.properties,\
- plugin.xml,\
- .options
-src.includes = about.html
diff --git a/org.eclipse.jdt.apt.pluggable.core/plugin.properties b/org.eclipse.jdt.apt.pluggable.core/plugin.properties
deleted file mode 100644
index d6e7bfcdb5..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-providerName=Eclipse.org
-pluginName=Java Compiler Apt IDE
-compileProblemMarkerName=Annotation Problem (Java 6 processor) \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.pluggable.core/plugin.xml b/org.eclipse.jdt.apt.pluggable.core/plugin.xml
deleted file mode 100644
index 84942a7992..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/plugin.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.2"?>
-<plugin>
- <extension
- point="org.eclipse.jdt.core.annotationProcessorManager">
- <annotationProcessorManager
- class="org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager"
- id="org.eclipse.jdt.apt.pluggable.core.annotationProcessorManager">
- </annotationProcessorManager>
- </extension>
- <extension
- point="org.eclipse.jdt.core.compilationParticipant">
- <compilationParticipant
- class="org.eclipse.jdt.internal.apt.pluggable.core.Apt6CompilationParticipant"
- id="org.eclipse.jdt.apt.pluggable.core.compilationParticipant"
- requiredSourceLevel="1.6">
- <managedMarker
- markerType="org.eclipse.jdt.apt.pluggable.core.compileProblem">
- </managedMarker>
- </compilationParticipant>
- </extension>
- <extension
- id="compileProblem"
- name="%compileProblemMarkerName"
- point="org.eclipse.core.resources.markers">
- <super
- type="org.eclipse.core.resources.problemmarker">
- </super>
- <super
- type="org.eclipse.core.resources.textmarker">
- </super>
- <persistent
- value="true">
- </persistent>
- </extension>
-
-</plugin>
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/Apt6CompilationParticipant.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/Apt6CompilationParticipant.java
deleted file mode 100644
index 32144309c9..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/Apt6CompilationParticipant.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.apt.pluggable.core;
-
-import org.eclipse.jdt.core.compiler.CompilationParticipant;
-
-/**
- * Compilation participant for Java 6 annotation processing. Java 6 annotation
- * processors are dispatched via the org.eclipse.jdt.core.annotationProcessorManager
- * extension point, but this compilation participant is still required in order
- * to register a managed problem marker.
- * @since 3.3
- */
-public class Apt6CompilationParticipant extends CompilationParticipant {
-
- public Apt6CompilationParticipant() {
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/Apt6Plugin.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/Apt6Plugin.java
deleted file mode 100644
index 023fb92f0d..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/Apt6Plugin.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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 - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.apt.pluggable.core;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.osgi.framework.BundleContext;
-
-/**
- * The plug-in responsible for dispatch of Java 6 (JSR269 Pluggable Annotation
- * Processing API) annotation processors in the IDE.
- * This is named Apt6Plugin to distinguish it from AptPlugin, which is responsible
- * for Java 5 (com.sun.mirror) processors.
- */
-public class Apt6Plugin extends Plugin {
-
- private static final SimpleDateFormat TRACE_DATE_FORMAT = new SimpleDateFormat("HH:mm:ss.SSS"); //$NON-NLS-1$
-
- public static final String PLUGIN_ID = "org.eclipse.jdt.apt.pluggable.core"; //$NON-NLS-1$
-
- /**
- * Status IDs for system log entries. Must be unique per plugin.
- */
- public static final int STATUS_EXCEPTION = 1;
-
- // Tracing options
- public static boolean DEBUG = false;
- public final static String APT_DEBUG_OPTION = Apt6Plugin.PLUGIN_ID + "/debug"; //$NON-NLS-1$
-
- private static Apt6Plugin thePlugin = null; // singleton object
-
- public Apt6Plugin() {
- }
-
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- thePlugin = this;
- initDebugTracing();
- }
-
- private void initDebugTracing() {
- String option = Platform.getDebugOption(APT_DEBUG_OPTION);
- if (option != null) {
- DEBUG = option.equalsIgnoreCase("true"); //$NON-NLS-1$
- }
- }
-
- public static Apt6Plugin getPlugin() {
- return thePlugin;
- }
-
- /**
- * Log a status message to the platform log. Use this for reporting exceptions.
- * @param status
- */
- public static void log(IStatus status) {
- thePlugin.getLog().log(status);
- }
-
- /**
- * Convenience wrapper around log(IStatus), to log an exception
- * with severity of ERROR.
- */
- public static void log(Throwable e, String message) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, STATUS_EXCEPTION, message, e));
- }
-
- /**
- * Convenience wrapper around log(IStatus), to log an exception
- * with severity of WARNING.
- */
- public static void logWarning(Throwable e, String message) {
- log(createWarningStatus(e, message));
- }
-
- /**
- * Convenience wrapper for rethrowing exceptions as CoreExceptions,
- * with severity of ERROR.
- */
- public static Status createStatus(Throwable e, String message) {
- return new Status(IStatus.ERROR, PLUGIN_ID, STATUS_EXCEPTION, message, e);
- }
-
- /**
- * Convenience wrapper for rethrowing exceptions as CoreExceptions,
- * with severity of WARNING.
- */
- public static Status createWarningStatus(Throwable e, String message) {
- return new Status(IStatus.WARNING, PLUGIN_ID, STATUS_EXCEPTION, message, e);
- }
-
- /**
- * Convenience wrapper for rethrowing exceptions as CoreExceptions,
- * with severity of INFO.
- */
- public static Status createInfoStatus(Throwable e, String message) {
- return new Status(IStatus.INFO, PLUGIN_ID, STATUS_EXCEPTION, message, e);
- }
-
- public static void trace(final String msg) {
- if (DEBUG) {
- StringBuffer sb = new StringBuffer();
- sb.append('[');
- // SimpleDateFormat is not thread-safe, according to javadoc
- synchronized (TRACE_DATE_FORMAT) {
- sb.append(TRACE_DATE_FORMAT.format(new Date()));
- }
- sb.append('-');
- // Some threads have qualified type names; too long.
- String threadName = Thread.currentThread().getName();
- int dot = threadName.lastIndexOf('.');
- if (dot < 0) {
- sb.append(threadName);
- } else {
- sb.append(threadName.substring(dot + 1));
- }
- sb.append(']');
- sb.append(msg);
- System.out.println(sb);
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeAnnotationProcessorManager.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeAnnotationProcessorManager.java
deleted file mode 100644
index a640b71ae8..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeAnnotationProcessorManager.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.apt.pluggable.core.dispatch;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.annotation.processing.Processor;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader;
-import org.eclipse.jdt.apt.core.internal.IServiceFactory;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath.Attributes;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin;
-import org.eclipse.jdt.internal.compiler.Compiler;
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager;
-import org.eclipse.jdt.internal.compiler.apt.dispatch.ProcessorInfo;
-import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.core.CompilationUnitProblemFinder;
-import org.eclipse.jdt.internal.core.builder.ICompilationUnitLocator;
-
-/**
- * Java 6 annotation processor manager used when compiling within the IDE.
- * @see org.eclipse.jdt.internal.compiler.apt.dispatch.BatchAnnotationProcessorManager
- */
-public class IdeAnnotationProcessorManager extends BaseAnnotationProcessorManager {
-
- private IJavaProject _javaProject;
- private ICompilationUnitLocator _cuLocator;
- private Map<IServiceFactory, FactoryPath.Attributes> _processorFactories;
- private Iterator<Entry<IServiceFactory, Attributes>> _processorIter;
-
- /**
- * Initialize the processor manager for a particular project. It is an error
- * to initialize a manager more than once.
- *
- * @param abstractImageBuilder must be an instanceof AbstractImageBuilder.
- * (But it can't be prototyped that way because the abstract base class must
- * compile without Eclipse platform code.)
- *
- * @param javaProject must be an instanceof IJavaProject. (But it can't be
- * prototyped that way because the abstract base class must compile without
- * Eclipse platform code.)
- */
- @Override
- public void configureFromPlatform(Compiler compiler, Object compilationUnitLocator, Object javaProject) {
- _javaProject = (IJavaProject) javaProject;
- _cuLocator = (ICompilationUnitLocator) compilationUnitLocator;
- if (null != _processingEnv) {
- throw new IllegalStateException(
- "Calling configure() more than once on an AnnotationProcessorManager is not supported"); //$NON-NLS-1$
- }
- // If it's a CompilationUnitProblemFinder, we're in reconcile phase. Else it's build.
- if (compiler instanceof CompilationUnitProblemFinder) {
- _processingEnv = new IdeReconcileProcessingEnvImpl(this, _javaProject, compiler);
- } else {
- _processingEnv = new IdeBuildProcessingEnvImpl(this, _javaProject, compiler);
- }
- if (Apt6Plugin.DEBUG) {
- Apt6Plugin.trace("Java 6 annotation processor manager initialized for compiler " +
- compiler.toString() + " on project " + _javaProject.getElementName());
- }
- }
-
- /**
- * If this project has a ProcessorPath defined, use it. Else, construct
- * one from the classpath.
- */
- @Override
- public ProcessorInfo discoverNextProcessor() {
- // _processorIter gets initialized the first time through processAnnotations()
- if (_processorIter.hasNext()) {
- Entry<IServiceFactory, Attributes> entry = _processorIter.next();
- Processor p;
- try {
- p = (Processor)entry.getKey().newInstance();
- p.init(_processingEnv);
- ProcessorInfo pi = new ProcessorInfo(p);
- if (Apt6Plugin.DEBUG) {
- Apt6Plugin.trace("Discovered processor " + p.toString());
- }
- _processors.add(pi);
- return pi;
- } catch (CoreException e) {
- Apt6Plugin.log(e, "Unable to create instance of annotation processor " + entry.getKey()); //$NON-NLS-1$
- }
- }
- return null;
- }
-
- @Override
- public void reportProcessorException(Processor p, Exception e) {
- Apt6Plugin.log(e, "Exception thrown by Java annotation processor " + p); //$NON-NLS-1$
- }
-
- /**
- * @return an ICompilationUnit corresponding to the specified file. In IDE mode this
- * will be backed by an org.eclipse.jdt.internal.core.builder.SourceFile.
- */
- public ICompilationUnit findCompilationUnit(IFile file) {
- return _cuLocator.fromIFile(file);
- }
-
- /**
- * In IDE mode, we are able to determine whether there are no processors. If that's the case,
- * then we can avoid doing the work of walking the ASTs to search for annotations. We still
- * need to clean up no-longer-generated files when the factory path is changed, but the best
- * way to do that is to force a clean build.
- * @see BaseAnnotationProcessorManager#processAnnotations(CompilationUnitDeclaration[], boolean)
- */
- @Override
- public void processAnnotations(CompilationUnitDeclaration[] units, ReferenceBinding[] referenceBindings, boolean isLastRound) {
- if (null == _processorFactories ) {
- _processorFactories = AnnotationProcessorFactoryLoader.getLoader().getJava6FactoriesAndAttributesForProject(_javaProject);
- _processorIter = _processorFactories.entrySet().iterator();
- }
- if (!_processorFactories.isEmpty()) {
- super.processAnnotations(units, referenceBindings, isLastRound);
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeBuildProcessingEnvImpl.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeBuildProcessingEnvImpl.java
deleted file mode 100644
index 94e1437e92..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeBuildProcessingEnvImpl.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.apt.pluggable.core.dispatch;
-
-import org.eclipse.jdt.apt.core.env.Phase;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.internal.compiler.Compiler;
-
-/**
- * ProcessingEnvironment for build phase in IDE.
- * @since 3.3
- */
-public class IdeBuildProcessingEnvImpl extends IdeProcessingEnvImpl {
-
- public IdeBuildProcessingEnvImpl(IdeAnnotationProcessorManager dispatchManager,
- IJavaProject jproject, Compiler compiler) {
- super(dispatchManager, jproject, compiler);
- }
-
- @Override
- public Phase getPhase() {
- return Phase.BUILD;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeMessagerImpl.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeMessagerImpl.java
deleted file mode 100644
index 12b095a4b3..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeMessagerImpl.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.apt.pluggable.core.dispatch;
-
-import javax.annotation.processing.Messager;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.tools.Diagnostic.Kind;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin;
-import org.eclipse.jdt.internal.compiler.CompilationResult;
-import org.eclipse.jdt.internal.compiler.apt.dispatch.AptProblem;
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BatchMessagerImpl;
-
-/**
- *
- * @since 3.3
- */
-public class IdeMessagerImpl implements Messager {
-
- private final IdeAnnotationProcessorManager _manager;
- private final IdeProcessingEnvImpl _env;
-
- public IdeMessagerImpl(IdeAnnotationProcessorManager manager,
- IdeProcessingEnvImpl env) {
- _manager = manager;
- _env = env;
- // This check is just here so the compiler doesn't complain about unread fields:
- if (null == _manager || null == _env) {
- throw new NullPointerException();
- }
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Messager#printMessage(javax.tools.Diagnostic.Kind, java.lang.CharSequence)
- */
- public void printMessage(Kind kind, CharSequence msg) {
- printMessage(kind, msg, null, null, null);
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Messager#printMessage(javax.tools.Diagnostic.Kind, java.lang.CharSequence, javax.lang.model.element.Element)
- */
- public void printMessage(Kind kind, CharSequence msg, Element e) {
- printMessage(kind, msg, e, null, null);
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Messager#printMessage(javax.tools.Diagnostic.Kind, java.lang.CharSequence, javax.lang.model.element.Element, javax.lang.model.element.AnnotationMirror)
- */
- public void printMessage(Kind kind, CharSequence msg, Element e,
- AnnotationMirror a) {
- printMessage(kind, msg, e, a, null);
-
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Messager#printMessage(javax.tools.Diagnostic.Kind, java.lang.CharSequence, javax.lang.model.element.Element, javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationValue)
- */
- public void printMessage(Kind kind, CharSequence msg, Element e, AnnotationMirror a,
- AnnotationValue v) {
- AptProblem problem = BatchMessagerImpl.createProblem(kind, msg, e);
- if (kind == Kind.NOTE) {
- Apt6Plugin.log(new Status(IStatus.INFO, Apt6Plugin.PLUGIN_ID, Apt6Plugin.STATUS_EXCEPTION, problem.getMessage(), null));
- }
- else if (null != problem._referenceContext) {
- CompilationResult result = problem._referenceContext.compilationResult();
- result.record(problem, problem._referenceContext);
- }
- else {
- // Unknown reference context; e.g., reported against an element not being compiled.
- // TODO: report against project?? log??
- Apt6Plugin.log(new Status(IStatus.INFO, Apt6Plugin.PLUGIN_ID, Apt6Plugin.STATUS_EXCEPTION, problem.getMessage(), null));
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeProcessingEnvImpl.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeProcessingEnvImpl.java
deleted file mode 100644
index c1e9fa69e3..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeProcessingEnvImpl.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.apt.pluggable.core.dispatch;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.lang.model.element.Element;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.apt.core.env.Phase;
-import org.eclipse.jdt.apt.core.internal.AptCompilationParticipant;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.AptProject;
-import org.eclipse.jdt.apt.core.internal.generatedfile.FileGenerationResult;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeFilerImpl;
-import org.eclipse.jdt.internal.compiler.Compiler;
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.apt.model.IElementInfo;
-
-/**
- * Implementation of ProcessingEnvironment when running inside IDE.
- * The lifetime of this object corresponds to the lifetime of the
- * {@link IdeAnnotationProcessorManager} that owns it.
- * @see org.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl
- */
-public abstract class IdeProcessingEnvImpl extends BaseProcessingEnvImpl {
-
- private final IdeAnnotationProcessorManager _dispatchManager;
- private final IJavaProject _javaProject;
- protected final AptProject _aptProject;
-
- public IdeProcessingEnvImpl(IdeAnnotationProcessorManager dispatchManager,
- IJavaProject jproject, Compiler compiler)
- {
- _dispatchManager = dispatchManager;
- _javaProject = jproject;
- _compiler = compiler;
- _aptProject = AptPlugin.getAptProject(jproject);
- _filer = new IdeFilerImpl(_dispatchManager, this);
- _messager = new IdeMessagerImpl(_dispatchManager, this);
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.ProcessingEnvironment#getLocale()
- */
- @Override
- public Locale getLocale() {
- return Locale.getDefault();
- }
-
- @Override
- public Map<String, String> getOptions() {
- if (null == _processorOptions) {
- // Java 5 processor options include items on the command line such as -s,
- // -classpath, etc., but Java 6 options only include the options specified
- // with -A, which will have been parsed into key/value pairs with no dash.
- Map<String, String> allOptions = AptConfig.getProcessorOptions(_javaProject);
- Map<String, String> procOptions = new HashMap<String, String>();
- for (Map.Entry<String, String> entry : allOptions.entrySet()) {
- if (!entry.getKey().startsWith("-")) { //$NON-NLS-1$
- procOptions.put(entry.getKey(), entry.getValue());
- }
- }
- procOptions.put("phase", getPhase().toString()); //$NON-NLS-1$
- _processorOptions = Collections.unmodifiableMap(procOptions);
- }
- return _processorOptions;
- }
-
- public AptProject getAptProject() {
- return _aptProject;
- }
-
- public IJavaProject getJavaProject() {
- return _javaProject;
- }
-
- public IProject getProject() {
- return _javaProject.getProject();
- }
-
- /**
- * @return whether this environment supports building or reconciling.
- */
- public abstract Phase getPhase();
-
- /**
- * Get the IFile that contains or represents the specified source element.
- * If the element is a package, get the IFile corresponding to its
- * package-info.java file. If the element is a top-level type, get the
- * IFile corresponding to its type. If the element is a nested element
- * of some sort (nested type, method, etc.) then get the IFile corresponding
- * to the containing top-level type.
- * If the element is not a source type at all, then return null.
- * @param elem
- * @return may be null
- */
- public IFile getEnclosingIFile(Element elem) {
- // if this cast fails it could be that a non-Eclipse element got passed in somehow.
- IElementInfo impl = (IElementInfo)elem;
- String name = impl.getFileName();
- if (name == null) {
- return null;
- }
- // The name will be workspace-relative, e.g., /project/src/packages/File.java.
- IFile file = _javaProject.getProject().getParent().getFile(new Path(name));
- return file;
- }
-
- /**
- * Inform the environment that a new Java file has been generated.
- * @param result must be non-null
- */
- public void addNewUnit(FileGenerationResult result) {
- AptCompilationParticipant.getInstance().addJava6GeneratedFile(result.getFile());
- addNewUnit(_dispatchManager.findCompilationUnit(result.getFile()));
- }
-
- /**
- * Inform the environment that a new non-Java file has been generated.
- * This file will not be submitted to a subsequent round of processing in
- * the current build, even if the file happens to be in a source location
- * and named with a Java-like name. However, its dependencies will be
- * tracked in the same manner as Java files, e.g., it will be deleted
- * if changes in source cause it to no longer be generated.
- * @param file must be non-null
- */
- public void addNewResource(IFile file) {
- AptCompilationParticipant.getInstance().addJava6GeneratedFile(file);
- }
-
- public boolean currentProcessorSupportsRTTG()
- {
- // Reconcile time type generation is not currently enabled for Java 6 processors
- return false;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeReconcileProcessingEnvImpl.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeReconcileProcessingEnvImpl.java
deleted file mode 100644
index 128c8b0a3a..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeReconcileProcessingEnvImpl.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.apt.pluggable.core.dispatch;
-
-import org.eclipse.jdt.apt.core.env.Phase;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.internal.compiler.Compiler;
-
-/**
- * ProcessingEnvironment for reconciles in IDE.
- * @since 3.3
- */
-public class IdeReconcileProcessingEnvImpl extends IdeProcessingEnvImpl {
-
- public IdeReconcileProcessingEnvImpl(IdeAnnotationProcessorManager dispatchManager,
- IJavaProject jproject, Compiler compiler) {
- super(dispatchManager, jproject, compiler);
- }
-
- @Override
- public Phase getPhase() {
- return Phase.RECONCILE;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeFilerImpl.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeFilerImpl.java
deleted file mode 100644
index 482711797c..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeFilerImpl.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.internal.apt.pluggable.core.filer;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.annotation.processing.Filer;
-import javax.lang.model.element.Element;
-import javax.tools.FileObject;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardLocation;
-import javax.tools.JavaFileManager.Location;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin;
-import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager;
-import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl;
-
-/**
- * Implementation of the Filer interface that is used in IDE mode.
- * @see org.eclipse.jdt.internal.compiler.apt.dispatch.BatchFilerImpl
- * @since 3.3
- */
-public class IdeFilerImpl implements Filer {
-
- //private final IdeAnnotationProcessorManager _dispatchManager;
- private final IdeProcessingEnvImpl _env;
-
- public IdeFilerImpl(IdeAnnotationProcessorManager dispatchManager,
- IdeProcessingEnvImpl env) {
- //_dispatchManager = dispatchManager;
- _env = env;
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Filer#createClassFile(java.lang.CharSequence, javax.lang.model.element.Element[])
- */
- @Override
- public JavaFileObject createClassFile(CharSequence name, Element... originatingElements)
- throws IOException {
- //TODO
- throw new UnsupportedOperationException("Creating class files is not yet implemented"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Filer#createResource(javax.tools.JavaFileManager.Location, java.lang.CharSequence, java.lang.CharSequence, javax.lang.model.element.Element[])
- * In the IDE implementation, we support only two Locations: SOURCE_OUTPUT, which means the APT generated source folder,
- * and CLASS_OUTPUT, which means the binary output folder associated with the APT generated source folder.
- */
- @Override
- public FileObject createResource(Location location, CharSequence pkg,
- CharSequence relativeName, Element... originatingElements) throws IOException
- {
- // Pre-emptively check parameters here, rather than later on when the resource is written and closed.
- if (null == location) {
- throw new IllegalArgumentException("Location is null");
- }
- if (!location.isOutputLocation()) {
- throw new IllegalArgumentException("Location " + location.getName() + " is not an output location");
- }
-
- if (null == pkg) {
- throw new IllegalArgumentException("Package is null");
- }
- if (null == relativeName) {
- throw new IllegalArgumentException("Relative name is null");
- }
- if ( relativeName.length() == 0) {
- throw new IllegalArgumentException("Relative name is zero length");
- }
- IFile file = getFileFromOutputLocation(location, pkg, relativeName);
-
- //TODO: check whether file has already been generated in this run
- Set<IFile> parentFiles = new HashSet<IFile>(originatingElements.length);
- for (Element elem : originatingElements) {
- IFile enclosing = _env.getEnclosingIFile(elem);
- if (null != enclosing) {
- parentFiles.add(enclosing);
- }
- }
- return new IdeOutputNonSourceFileObject(_env, file, parentFiles);
- }
-
- /**
- * @param originatingElements should all be source types; binary types (ie elements in jar files)
- * will be ignored.
- * @see javax.annotation.processing.Filer#createSourceFile(java.lang.CharSequence, javax.lang.model.element.Element[])
- */
- @Override
- public JavaFileObject createSourceFile(CharSequence name, Element... originatingElements)
- throws IOException
- {
- // Pre-emptively check parameters here, rather than later on when the resource is written and closed.
- if (null == name) {
- throw new IllegalArgumentException("Name is null");
- }
- //TODO: check whether file has already been generated in this run
- Set<IFile> parentFiles = new HashSet<IFile>(originatingElements.length);
- for (Element elem : originatingElements) {
- IFile enclosing = _env.getEnclosingIFile(elem);
- if (null != enclosing) {
- parentFiles.add(enclosing);
- }
- }
- return new IdeOutputJavaFileObject(_env, name, parentFiles);
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Filer#getResource(javax.tools.JavaFileManager.Location, java.lang.CharSequence, java.lang.CharSequence)
- * Returns a FileObject representing the specified resource. The only supported locations
- * are CLASS_OUTPUT and SOURCE_OUTPUT.
- */
- @Override
- public FileObject getResource(Location location, CharSequence pkg, CharSequence relativeName)
- throws IOException
- {
- IFile file = getFileFromOutputLocation(location, pkg, relativeName);
- return new IdeInputFileObject(file);
- }
-
- /**
- * Return a project-relative path. This does not create the file nor its parent directories,
- * but it does validate the path.
- * @param pkg must be non-null but can be empty.
- * @param relPath must be non-null and non-empty.
- * @throws IOException if the path is not valid.
- */
- protected IFile getFileFromOutputLocation( Location loc, CharSequence pkg, CharSequence relPath )
- throws IOException
- {
- GeneratedSourceFolderManager gsfm = _env.getAptProject().getGeneratedSourceFolderManager();
- IPath path = null;
- if ( loc == StandardLocation.CLASS_OUTPUT )
- {
- try
- {
- path = gsfm.getBinaryOutputLocation();
- }
- catch ( JavaModelException e )
- {
- Apt6Plugin.log(e, "Failure getting the binary output location"); //$NON-NLS-1$
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
- }
- else if ( loc == StandardLocation.SOURCE_OUTPUT ) {
- path = gsfm.getFolder().getProjectRelativePath();
- }
- else {
- throw new IllegalArgumentException("Unsupported location: " + loc);
- }
-
- if( pkg.length() > 0 )
- path = path.append(pkg.toString().replace('.', File.separatorChar) );
-
- path = path.append(relPath.toString());
-
- IFile file = _env.getProject().getFile(path);
-
- validatePath(file);
-
- return file;
- }
-
- /**
- * Validate that a path fits the rules for being created.
- * @see IWorkspace#validatePath()
- * @throws IOException
- */
- private void validatePath(IFile file) throws IOException
- {
- IStatus status = _env.getProject().getWorkspace().validatePath(file.getFullPath().toOSString(), IResource.FILE);
- if (!status.isOK()) {
- CoreException ce = new CoreException(status);
- IOException ioe = new IOException("Invalid path: " + file.toString()); //$NON-NLS-1$
- ioe.initCause(ce);
- throw ioe;
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeInputFileObject.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeInputFileObject.java
deleted file mode 100644
index 599c728bbe..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeInputFileObject.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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 implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.internal.apt.pluggable.core.filer;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.URI;
-
-import javax.tools.FileObject;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * Implementation of a FileObject returned by Filer.getResource().
- * @since 3.4
- */
-public class IdeInputFileObject implements FileObject {
-
- private final IFile _file;
-
- public IdeInputFileObject(IFile file) {
- _file = file;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#delete()
- */
- @Override
- public boolean delete() {
- throw new IllegalStateException("An annotation processor is not permitted to delete resources");
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#getCharContent(boolean)
- */
- @Override
- public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
- //TODO
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#getLastModified()
- */
- @Override
- public long getLastModified() {
- return _file.getModificationStamp();
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#getName()
- */
- @Override
- public String getName() {
- return _file.getProjectRelativePath().toString();
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openInputStream()
- */
- @Override
- public InputStream openInputStream() throws IOException {
- try {
- return _file.getContents();
- } catch (CoreException e) {
- throw new IOException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openOutputStream()
- */
- @Override
- public OutputStream openOutputStream() throws IOException {
- throw new IllegalStateException("Writing to a non-generated file is not permitted");
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openReader(boolean)
- */
- @Override
- public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
- return new BufferedReader(new InputStreamReader(openInputStream()));
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openWriter()
- */
- @Override
- public Writer openWriter() throws IOException {
- throw new IllegalStateException("Writing to a non-generated file is not permitted");
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#toUri()
- */
- @Override
- public URI toUri() {
- return _file.getLocationURI();
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeJavaSourceOutputStream.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeJavaSourceOutputStream.java
deleted file mode 100644
index 772c18d95d..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeJavaSourceOutputStream.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.apt.pluggable.core.filer;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.Collection;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.apt.core.env.Phase;
-import org.eclipse.jdt.apt.core.internal.generatedfile.FileGenerationResult;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedFileManager;
-import org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin;
-import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl;
-
-/**
- * OutputStream used by the IdeFilerImpl to generate Java source files.
- * @since 3.3
- */
-public class IdeJavaSourceOutputStream extends ByteArrayOutputStream {
-
- private final IdeProcessingEnvImpl _env;
- private final CharSequence _name;
- private final Collection<IFile> _parentFiles;
- private boolean _closed = false;
-
- public IdeJavaSourceOutputStream(IdeProcessingEnvImpl env, CharSequence name,
- Collection<IFile> parentFiles)
- {
- _env = env;
- _name = name;
- _parentFiles = parentFiles;
- }
-
- /* (non-Javadoc)
- * @see java.io.ByteArrayOutputStream#close()
- */
- @Override
- public void close() throws IOException {
- synchronized(this) {
- if (_closed) {
- return;
- }
- _closed = true;
- }
- try {
- GeneratedFileManager gfm = _env.getAptProject().getGeneratedFileManager();
- Phase phase = _env.getPhase();
-
- FileGenerationResult result = null;
- if ( phase == Phase.RECONCILE )
- {
- //TODO - implement reconcile
- }
- else if ( phase == Phase.BUILD) {
- result = gfm.generateFileDuringBuild(
- _parentFiles, _name.toString(), this.toString(),
- _env.currentProcessorSupportsRTTG(), null /* progress monitor */ );
- }
- if (result != null) {
- _env.addNewUnit(result);
- }
- }
- catch (CoreException ce) {
- Apt6Plugin.log(ce, "Unable to generate type when IdeJavaSourceOutputStream was closed"); //$NON-NLS-1$
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream.java
deleted file mode 100644
index 4095661328..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.apt.pluggable.core.filer;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.apt.core.internal.env.BinaryFileOutputStream;
-import org.eclipse.jdt.apt.core.internal.util.FileSystemUtil;
-import org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin;
-import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl;
-
-/**
- * @see BinaryFileOutputStream
- */
-public class IdeNonSourceOutputStream extends ByteArrayOutputStream
-{
- private final IdeProcessingEnvImpl _env;
- private final IFile _file;
- private final Collection<IFile> _parentFiles;
-
- public IdeNonSourceOutputStream(IdeProcessingEnvImpl env, IFile file, Collection<IFile> parentFiles) {
- _env = env;
- _file = file;
- _parentFiles = parentFiles;
- }
-
- @Override
- public void close() throws IOException {
- super.close();
-
- InputStream contents = new ByteArrayInputStream(toByteArray());
- try {
-
- boolean contentsChanged = true;
- if (!_file.exists()) {
- saveToDisk(contents, true);
- }
- else {
- InputStream in = null;
- InputStream oldData = null;
- try {
- // Only write the contents if the data is different
- in = new ByteArrayInputStream(toByteArray());
- oldData = new BufferedInputStream(_file.getContents());
- if (FileSystemUtil.compareStreams(in, oldData)) {
- contentsChanged = false;
- }
- }
- catch (CoreException ce) {
- // Ignore -- couldn't read the old data, so assume it's different
- contentsChanged = true;
- }
- finally {
- closeInputStream(in);
- closeInputStream(oldData);
- }
- if (contentsChanged) {
- contents.reset();
- saveToDisk(contents, false);
- }
- }
- }
- finally {
- closeInputStream(contents);
- }
-
- // If there are no parents, we don't need to track dependencies
- if (_parentFiles != null && !_parentFiles.isEmpty()) {
- _env.getAptProject().getGeneratedFileManager().addGeneratedFileDependency(_parentFiles, _file);
- _env.addNewResource(_file);
- }
- }
-
- private void closeInputStream(InputStream stream) {
- if (stream != null) {
- try {
- stream.close();
- }
- catch (IOException ioe) {}
- }
- }
-
- private void saveToDisk(InputStream toSave, boolean create) throws IOException{
- try {
- FileSystemUtil.makeDerivedParentFolders(_file.getParent());
- if (create) {
- _file.create(toSave, true, null);
- _file.setDerived(true);
- }
- else {
- _file.setContents(toSave, true, false, null);
- }
- }
- catch (CoreException ce) {
- if (_file.exists()) {
- // Do nothing. This is a case-insensitive file system mismatch,
- // and the underlying platform has saved the contents already.
- }
- else {
- Apt6Plugin.log(ce, "Could not create generated non-Java file " + _file.getName()); //$NON-NLS-1$
- IOException ioe = new IOException();
- ioe.initCause(ce);
- throw ioe;
- }
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeOutputFileObject.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeOutputFileObject.java
deleted file mode 100644
index 315a96c533..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeOutputFileObject.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.apt.pluggable.core.filer;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-
-import javax.tools.FileObject;
-
-public abstract class IdeOutputFileObject implements FileObject {
-
- @Override
- public boolean delete() {
- throw new IllegalStateException("Deleting a file is not permitted from within an annotation processor");
- }
-
- @Override
- public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
- throw new IllegalStateException("Generated files are write-only");
- }
-
- @Override
- public long getLastModified() {
- //TODO
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- @Override
- public InputStream openInputStream() throws IOException {
- throw new IllegalStateException("Opening an input stream on a generated file is not permitted");
- }
-
- @Override
- public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
- throw new IllegalStateException("Opening a reader on a generated file is not permitted");
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeOutputJavaFileObject.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeOutputJavaFileObject.java
deleted file mode 100644
index 78a41ace09..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeOutputJavaFileObject.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.apt.pluggable.core.filer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.net.URI;
-import java.util.Collection;
-
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.NestingKind;
-import javax.tools.JavaFileObject;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl;
-
-/**
- * Implementation of JavaFileObject used for Java 6 annotation processing within the IDE.
- * This object is used only for writing source and class files.
- *
- * @since 3.3
- */
-public class IdeOutputJavaFileObject extends IdeOutputFileObject implements JavaFileObject {
-
- private final IdeProcessingEnvImpl _env;
- private final CharSequence _name;
- private final Collection<IFile> _parentFiles;
-
- public IdeOutputJavaFileObject(IdeProcessingEnvImpl env, CharSequence name, Collection<IFile> parentFiles) {
- _env = env;
- _parentFiles = parentFiles;
- _name = name;
- }
-
- @Override
- public Modifier getAccessLevel() {
- //TODO
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileObject#getKind()
- */
- @Override
- public Kind getKind() {
- //TODO
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#getName()
- */
- @Override
- public String getName() {
- return _name.toString();
- }
-
- @Override
- public NestingKind getNestingKind() {
- //TODO
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- @Override
- public boolean isNameCompatible(String simpleName, Kind kind) {
- //TODO
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openOutputStream()
- */
- @Override
- public OutputStream openOutputStream() throws IOException {
- return new IdeJavaSourceOutputStream(_env, _name, _parentFiles);
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openWriter()
- */
- @Override
- public Writer openWriter() throws IOException {
- return new PrintWriter(openOutputStream());
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#toUri()
- */
- @Override
- public URI toUri() {
- // The file does not exist until its writer is closed.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeOutputNonSourceFileObject.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeOutputNonSourceFileObject.java
deleted file mode 100644
index 4612e171f1..0000000000
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeOutputNonSourceFileObject.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.apt.pluggable.core.filer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.net.URI;
-import java.util.Collection;
-import java.util.Set;
-
-import javax.tools.JavaFileManager.Location;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl;
-
-/**
- * Implementation of FileObject for generating resource files in the IDE.
- * This is used for files that are neither class files nor Java source files.
- * @see IdeOutputJavaFileObject
- */
-public class IdeOutputNonSourceFileObject extends IdeOutputFileObject
-{
- private final IdeProcessingEnvImpl _env;
- private final IFile _file;
- private final Collection<IFile> _parentFiles;
-
-
- /**
- * Create a new IdeOutputFileObject for writing. The file will not actually be written until the Writer or OutputStream is closed.
- * @param env among other roles, the ProcessingEnvironment tracks what files have been generated in a given build.
- * @param location must be an output location (see {@link Location#isOutputLocation()}).
- * @param pkg
- * @param relativeName
- * @param parentFiles
- * @see javax.tools.StandardLocation
- */
- public IdeOutputNonSourceFileObject(IdeProcessingEnvImpl env, IFile file, Set<IFile> parentFiles) {
- _env = env;
- _file = file;
- _parentFiles = parentFiles;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#getName()
- */
- @Override
- public String getName()
- {
- // TODO
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openOutputStream()
- */
- @Override
- public OutputStream openOutputStream() throws IOException
- {
- return new IdeNonSourceOutputStream(_env, _file, _parentFiles);
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openWriter()
- */
- @Override
- public Writer openWriter() throws IOException
- {
- return new PrintWriter(openOutputStream());
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#toUri()
- */
- @Override
- public URI toUri()
- {
- // TODO
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/.classpath b/org.eclipse.jdt.apt.pluggable.tests/.classpath
deleted file mode 100644
index 121e527a93..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jdt.apt.pluggable.tests/.cvsignore b/org.eclipse.jdt.apt.pluggable.tests/.cvsignore
deleted file mode 100644
index c5e82d7458..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.pluggable.tests/.project b/org.eclipse.jdt.apt.pluggable.tests/.project
deleted file mode 100644
index d342b3fd4e..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.apt.pluggable.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.pluggable.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jdt.apt.pluggable.tests/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 8f2e7b6251..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-#Tue Jul 31 14:14:53 EDT 2007
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-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.6
diff --git a/org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF
deleted file mode 100644
index 43913d89bd..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,21 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jdt.apt.pluggable.tests;singleton:=true
-Bundle-Version: 3.3.100.qualifier
-Bundle-ClassPath: .
-Bundle-Activator: org.eclipse.jdt.apt.pluggable.tests.Apt6TestsPlugin
-Bundle-Localization: plugin
-Require-Bundle: org.junit,
- org.eclipse.jdt.apt.pluggable.core,
- org.eclipse.core.resources,
- org.eclipse.core.runtime,
- org.eclipse.jdt.apt.core,
- org.eclipse.jdt.core.tests.builder,
- org.eclipse.jdt.core.tests.compiler,
- org.eclipse.test.performance,
- org.eclipse.jdt.core,
- org.eclipse.ui.ide
-Bundle-ActivationPolicy: lazy
-Bundle-Vendor: %providerName
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/org.eclipse.jdt.apt.pluggable.tests/META-INF/services/javax.annotation.processing.Processor b/org.eclipse.jdt.apt.pluggable.tests/META-INF/services/javax.annotation.processing.Processor
deleted file mode 100644
index d0380e084c..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/META-INF/services/javax.annotation.processing.Processor
+++ /dev/null
@@ -1,3 +0,0 @@
-org.eclipse.jdt.apt.pluggable.tests.processors.genclass6.GenClass6Proc
-org.eclipse.jdt.apt.pluggable.tests.processors.message6.Message6Proc
-org.eclipse.jdt.apt.pluggable.tests.processors.filertester.FilerTesterProc
diff --git a/org.eclipse.jdt.apt.pluggable.tests/about.html b/org.eclipse.jdt.apt.pluggable.tests/about.html
deleted file mode 100644
index 460233046e..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 2, 2006</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.pluggable.tests/annotations.jardesc b/org.eclipse.jdt.apt.pluggable.tests/annotations.jardesc
deleted file mode 100644
index 00370b5d64..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/annotations.jardesc
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
-<jardesc>
- <jar path="org.eclipse.jdt.apt.pluggable.tests/lib/annotations.jar"/>
- <options buildIfNeeded="true" compress="true" descriptionLocation="/org.eclipse.jdt.apt.pluggable.tests/annotations.jardesc" exportErrors="false" exportWarnings="true" includeDirectoryEntries="false" overwrite="true" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
- <storedRefactorings deprecationInfo="true" structuralOnly="false"/>
- <selectedProjects/>
- <manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
- <sealing sealJar="false">
- <packagesToSeal/>
- <packagesToUnSeal/>
- </sealing>
- </manifest>
- <selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
- <javaElement handleIdentifier="=org.eclipse.jdt.apt.pluggable.tests/src&lt;org.eclipse.jdt.apt.pluggable.tests.annotations"/>
- </selectedElements>
-</jardesc>
diff --git a/org.eclipse.jdt.apt.pluggable.tests/build.properties b/org.eclipse.jdt.apt.pluggable.tests/build.properties
deleted file mode 100644
index 8d83d4832e..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/build.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-###############################################################################
-# Copyright (c) 2007 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
-###############################################################################
-bin.includes = .,\
- plugin.xml,\
- test.xml,\
- META-INF/,\
- about.html,\
- plugin.properties,\
- resources/,\
- lib/
-src.includes = about.html,\
- plugin.properties,\
- plugin.xml,\
- .classpath,\
- .cvsignore,\
- .project,\
- build.properties
-jars.compile.order = .
-source.. = src/
-output.. = bin/
diff --git a/org.eclipse.jdt.apt.pluggable.tests/lib/annotations.jar b/org.eclipse.jdt.apt.pluggable.tests/lib/annotations.jar
deleted file mode 100644
index c0d88bde37..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/lib/annotations.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.apt.pluggable.tests/plugin.properties b/org.eclipse.jdt.apt.pluggable.tests/plugin.properties
deleted file mode 100644
index c85df60b17..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/plugin.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 BEA Systems Inc. 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:
-# BEA Systems Inc. - initial implementation
-###############################################################################
-providerName=Eclipse.org
-pluginName=Java Annotation Processing Tests
diff --git a/org.eclipse.jdt.apt.pluggable.tests/plugin.xml b/org.eclipse.jdt.apt.pluggable.tests/plugin.xml
deleted file mode 100644
index 6416730842..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/plugin.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin>
- <extension
- point="org.eclipse.jdt.apt.core.annotationProcessorFactory">
- <java6processors
- enableDefault="true">
- <java6processor
- class="org.eclipse.jdt.apt.pluggable.tests.processors.genclass6.GenClass6Proc">
- </java6processor>
- <java6processor
- class="org.eclipse.jdt.apt.pluggable.tests.processors.message6.Message6Proc">
- </java6processor>
- <java6processor
- class="org.eclipse.jdt.apt.pluggable.tests.processors.filertester.FilerTesterProc">
- </java6processor>
- </java6processors>
- </extension>
-</plugin>
diff --git a/org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer01a/Parent01.java b/org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer01a/Parent01.java
deleted file mode 100644
index d21cfbd1ad..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer01a/Parent01.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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 targets.filer;
-
-import org.eclipse.jdt.apt.pluggable.tests.annotations.GenClass6;
-
-/**
- * Processing this class should result in creation of a source file
- */
-@GenClass6(name="Generated01", pkg="gen6", summary=true)
-public class Parent01 {
-
-}
-
diff --git a/org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer01b/Parent01.java b/org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer01b/Parent01.java
deleted file mode 100644
index 5195db6651..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer01b/Parent01.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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 targets.filer;
-
-//import org.eclipse.jdt.apt.pluggable.tests.annotations.GenClass6;
-
-/**
- * Processing this class should NOT result in creation of a source file
- */
-//@GenClass6(name="Generated01", pkg="gen6", summary=true)
-public class Parent01 {
-
-}
-
diff --git a/org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer02a/Parent02.java b/org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer02a/Parent02.java
deleted file mode 100644
index 15561b0342..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer02a/Parent02.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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 targets.filer;
-
-import org.eclipse.jdt.apt.pluggable.tests.annotations.GenClass6;
-
-/**
- * Processing this class should result in creation of a source file,
- * thereby allowing this class to compile
- */
-@GenClass6(name="Generated02", pkg="gen6")
-public class Parent02 {
- gen6.Generated02 _gen;
-}
-
-
-
diff --git a/org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer02b/Parent02.java b/org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer02b/Parent02.java
deleted file mode 100644
index a4699710ad..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/resources/targets/filer02b/Parent02.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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 targets.filer;
-
-import org.eclipse.jdt.apt.pluggable.tests.annotations.GenClass6;
-
-/**
- * Processing this class should result in removal of the previously
- * generated type and creation of a new one, resulting in a compilation error.
- */
-@GenClass6(name="XxxGenerated02", pkg="gen6")
-public class Parent02 {
- gen6.Generated02 _gen;
-}
-
diff --git a/org.eclipse.jdt.apt.pluggable.tests/resources/targets/infrastructure/NoAnno.java b/org.eclipse.jdt.apt.pluggable.tests/resources/targets/infrastructure/NoAnno.java
deleted file mode 100644
index b53144baa3..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/resources/targets/infrastructure/NoAnno.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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 targets.infrastructure;
-
-import org.eclipse.jdt.apt.pluggable.tests.annotations.Message6;
-
-/**
- * A simple class with no annotations, to test compilation of vanilla projects
- */
-public class NoAnno {
- // This is here to verify that we have access to the annotations jar from within the test project.
- Class<?> _annoClass = Message6.class;
-}
-
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/Apt6TestsPlugin.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/Apt6TestsPlugin.java
deleted file mode 100644
index 0639b9e728..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/Apt6TestsPlugin.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.eclipse.jdt.apt.pluggable.tests;
-
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.BundleContext;
-
-public class Apt6TestsPlugin extends Plugin {
-
- public static final String PLUGIN_ID = "org.eclipse.jdt.apt.pluggable.tests"; //$NON-NLS-1$
-
- private static Apt6TestsPlugin _thePlugin = null;
-
- @Override
- public void start(BundleContext context) throws Exception
- {
- super.start(context);
- _thePlugin = this;
- }
-
- public Apt6TestsPlugin() {
- // TODO Auto-generated constructor stub
- }
-
- public static Apt6TestsPlugin thePlugin() {
- return _thePlugin;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/FilerTests.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/FilerTests.java
deleted file mode 100644
index d948217ef6..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/FilerTests.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.pluggable.tests;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.apt.pluggable.tests.processors.filertester.FilerTesterProc;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.compiler.CategorizedProblem;
-import org.eclipse.jdt.core.tests.builder.Problem;
-
-/**
- * Basic tests for the Filer interface in the IDE.
- * @see javax.annotation.processing.Filer
- */
-public class FilerTests extends TestBase
-{
-
- public FilerTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(FilerTests.class);
- }
-
- /**
- * Test generation of a source file, using the GenClass6 annotation
- * @see javax.annotation.processing.Filer#createClassFile(CharSequence, javax.lang.model.element.Element...)
- */
- public void testCreateSourceFile() throws Throwable
- {
- // Temporary workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=201931
- // Bail out on Linux
- String osName = System.getProperty("os.name");
- if (null == osName || !osName.contains("Windows")) {
- return;
- }
-
- IJavaProject jproj = createJavaProject(_projectName);
- IProject proj = jproj.getProject();
- IdeTestUtils.copyResources(proj, "targets/filer01a", "src/targets/filer");
- AptConfig.setEnabled(jproj, true);
- fullBuild();
- expectingNoProblems();
-
- // Check whether generated sources were generated and compiled
- expectingFile(proj, ".apt_generated/gen6/Generated01.java");
- final String[] expectedClasses = { "targets.filer.Parent01", "gen6.Generated01" };
- expectingUniqueCompiledClasses(expectedClasses);
-
- // Check whether non-source resource was generated in final round
- expectingFile( proj, ".apt_generated/summary.txt" );
-
- //TODO: if a parent file is modified,
- // the generated file should be regenerated and recompiled.
- // The generated resource file should be regenerated (but not compiled).
-
- // Modify target file to remove annotation and incrementally rebuild;
- // generated file should be deleted.
- IdeTestUtils.copyResources(proj, "targets/filer01b", "src/targets/filer");
- incrementalBuild();
- expectingNoProblems();
-
- final String[] expectedClasses2 = { "targets.filer.Parent01" };
- expectingUniqueCompiledClasses(expectedClasses2);
-
- expectingNoFile(proj, ".apt_generated/gen6/Generated01.java");
- expectingNoFile( proj, ".apt_generated/summary.txt" );
- }
-
- /**
- * Test generation of a source file that is referenced by the parent, using the GenClass6 annotation
- * @see javax.annotation.processing.Filer#createSourceFile(CharSequence, javax.lang.model.element.Element...)
- */
- public void testCreateSourceFileWithGenReference() throws Throwable
- {
- // Temporary workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=201931
- // Bail out on Linux
- String osName = System.getProperty("os.name");
- if (null == osName || !osName.contains("Windows")) {
- return;
- }
-
- IJavaProject jproj = createJavaProject(_projectName);
- IProject proj = jproj.getProject();
- IdeTestUtils.copyResources(proj, "targets/filer02a", "src/targets/filer");
-
- disableJava5Factories(jproj);
- AptConfig.setEnabled(jproj, true);
- fullBuild();
- expectingNoProblems();
-
- // Check whether generated sources were generated and compiled
- expectingFile(proj, ".apt_generated/gen6/Generated02.java");
- final String[] expectedClasses = { "targets.filer.Parent02", "gen6.Generated02" };
- expectingUniqueCompiledClasses(expectedClasses);
-
- // Modify target file to change name of generated file and incrementally rebuild;
- // generated file should be deleted.
- IdeTestUtils.copyResources(proj, "targets/filer02b", "src/targets/filer");
- incrementalBuild();
-
- IPath parentPath = proj.getFullPath().append("src/targets/filer/Parent02.java");
- expectingOnlySpecificProblemFor(parentPath, new Problem("Parent02", "gen6.Generated02 cannot be resolved to a type", parentPath, 842, 858, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR));
-
- // This test only works if there are no Java 5 processors (e.g., apt.tests plugin) in the factory path.
- // If Java 5 processors are present, then gen6.Generated02 will also be recompiled, before it's deleted.
- final String[] expectedClasses2 = { "gen6.XxxGenerated02", "targets.filer.Parent02" };
- expectingUniqueCompiledClasses(expectedClasses2);
-
- expectingNoFile(proj, ".apt_generated/gen6/Generated02.java");
- }
-
- /**
- * Call FilerTesterProc.testGetResource01(), which checks getResource() in SOURCE_OUTPUT location
- */
- public void testGetResource01() throws Throwable {
- ProcessorTestStatus.reset();
- IJavaProject jproj = createJavaProject(_projectName);
- disableJava5Factories(jproj);
- IProject proj = jproj.getProject();
- IPath projPath = proj.getFullPath();
-
- env.addClass(projPath.append("src"), "p", "Trigger",
- "package p;\n" +
- "import org.eclipse.jdt.apt.pluggable.tests.annotations.FilerTestTrigger;\n" +
- "@FilerTestTrigger(test = \"testGetResource01\", arg0 = \"g\", arg1 = \"Test.java\")" +
- "public class Trigger {\n" +
- "}"
- );
-
- AptConfig.setEnabled(jproj, true);
-
- // FilerTesterProc looks for the existence and contents of this class:
- env.addClass(projPath.append(".apt_generated"), "g", "Test",
- FilerTesterProc.resource01FileContents);
-
- fullBuild();
- expectingNoProblems();
- assertTrue("Processor did not run", ProcessorTestStatus.processorRan());
- assertEquals("Processor reported errors", ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Call FilerTesterProc.testGetResource02(), which checks getResource() in CLASS_OUTPUT location
- */
- public void testGetResource02() throws Throwable {
- ProcessorTestStatus.reset();
- IJavaProject jproj = createJavaProject(_projectName);
- disableJava5Factories(jproj);
- IProject proj = jproj.getProject();
- IPath projPath = proj.getFullPath();
-
- env.addClass(projPath.append("src"), "p", "Trigger",
- "package p;\n" +
- "import org.eclipse.jdt.apt.pluggable.tests.annotations.FilerTestTrigger;\n" +
- "@FilerTestTrigger(test = \"testGetResource02\", arg0 = \"t\", arg1 = \"Test.txt\")" +
- "public class Trigger {\n" +
- "}"
- );
-
- AptConfig.setEnabled(jproj, true);
-
- // FilerTesterProc looks for the existence and contents of this file after it is copied to the output folder:
- IFolder textFileFolder = proj.getFolder("src/t");
- textFileFolder.create(false, true, null);
- IFile textFile = proj.getFile(textFileFolder.getProjectRelativePath().append("Test.txt"));
- InputStream textSource = new ByteArrayInputStream(FilerTesterProc.resource02FileContents.getBytes());
- textFile.create(textSource, false, null);
-
- fullBuild();
- expectingNoProblems();
- assertTrue("Processor did not run", ProcessorTestStatus.processorRan());
- assertEquals("Processor reported errors", ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/IdeTestUtils.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/IdeTestUtils.java
deleted file mode 100644
index 9d0a7e7f9c..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/IdeTestUtils.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.pluggable.tests;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URL;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * Helper class to support compilation and results checking for tests running in batch mode.
- * @since 3.3.1
- */
-public class IdeTestUtils {
- /**
- * Name of the subdirectory within the test bundle where target resources are stored.
- */
- public static final String RESOURCES_DIR = "resources";
-
- /**
- * Copy files from a bundle into a project in the target workspace. Newlines will be
- * converted according to {@link #shouldConvertToIndependentLineDelimiter(File)}.
- * Directories named "CVS" will be ignored.
- *
- * @param proj
- * the project within which the files will be created.
- * @param resourceFolderName
- * the name of the folder within the plug-in that the files will be copied
- * from, relative to <code>[plugin-root]/resources</code>
- * @param destFolderName
- * the name of the folder within the target workspace that the files will
- * be copied to, relative to the project
- * @throws Exception
- * might be an IOException or a CoreException
- */
- public static void copyResources(IProject proj, String resourceFolderName, String destFolderName) throws Exception {
- String destFolderOSName = proj.getFolder( destFolderName ).getLocation().toOSString(); //$NON-NLS-1$
- File destFolder = new File(destFolderOSName);
- File resourceFolder = TestUtils.concatPath(getPluginDirectoryPath(), RESOURCES_DIR, resourceFolderName);
- copyResources(resourceFolder, destFolder);
- proj.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
-
- /**
- * @return the absolute filesystem-based path of the root of the bundle filesystem.
- * This will cause the bundle to be extracted to a temporary directory on the filesystem
- * if necessary; see {@link FileLocator#toFileURL(URL)}.
- */
- public static String getPluginDirectoryPath() {
- try {
- URL platformURL = Platform.getBundle("org.eclipse.jdt.apt.pluggable.tests").getEntry("/");
- return new File(FileLocator.toFileURL(platformURL).getFile()).getAbsolutePath();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * Copy a file from one location to another, unless the destination file already exists and has
- * the same timestamp and file size. Create the destination location if necessary. Convert line
- * delimiters according to {@link #shouldConvertToIndependentLineDelimiter(File)}.
- *
- * @param src
- * the full path to the resource location.
- * @param destFolder
- * the full path to the destination location.
- * @throws IOException
- */
- private static void copyResource(File src, File dest) throws IOException {
- if (dest.exists() &&
- src.lastModified() < dest.lastModified() &&
- src.length() == dest.length())
- {
- return;
- }
-
- // read source bytes
- byte[] srcBytes = null;
- srcBytes = read(src);
-
- if (shouldConvertToIndependentLineDelimiter(src)) {
- String contents = new String(srcBytes);
- contents = TestUtils.convertToIndependentLineDelimiter(contents);
- srcBytes = contents.getBytes();
- }
-
- File destFolder = dest.getParentFile();
- if (!destFolder.exists()) {
- if (!destFolder.mkdirs()) {
- throw new IOException("Unable to create directory " + destFolder);
- }
- }
- // write bytes to dest
- FileOutputStream out = null;
- try {
- out = new FileOutputStream(dest);
- out.write(srcBytes);
- out.flush();
- } finally {
- if (out != null) {
- out.close();
- }
- }
- }
-
- private static void copyResources(File resourceFolder, File destFolder) throws IOException {
- if (resourceFolder == null) {
- return;
- }
- // Copy all resources in this folder
- String[] children = resourceFolder.list();
- if (null == children) {
- return;
- }
- // if there are any children, (recursively) copy them
- for (String child : children) {
- if ("CVS".equals(child)) {
- continue;
- }
- File childRes = new File(resourceFolder, child);
- File childDest = new File(destFolder, child);
- if (childRes.isDirectory()) {
- copyResources(childRes, childDest);
- }
- else {
- copyResource(childRes, childDest);
- }
- }
- }
-
- private static byte[] read(java.io.File file) throws java.io.IOException {
- int fileLength;
- byte[] fileBytes = new byte[fileLength = (int) file.length()];
- java.io.FileInputStream stream = null;
- try {
- stream = new java.io.FileInputStream(file);
- int bytesRead = 0;
- int lastReadSize = 0;
- while ((lastReadSize != -1) && (bytesRead != fileLength)) {
- lastReadSize = stream.read(fileBytes, bytesRead, fileLength - bytesRead);
- bytesRead += lastReadSize;
- }
- } finally {
- if (stream != null) {
- stream.close();
- }
- }
- return fileBytes;
- }
-
- /**
- * @return true if this file's end-of-line delimiters should be replaced with
- * a platform-independent value, e.g. for compilation.
- */
- private static boolean shouldConvertToIndependentLineDelimiter(File file) {
- return file.getName().endsWith(".java");
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/InfrastructureTests.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/InfrastructureTests.java
deleted file mode 100644
index f94b7c5f0b..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/InfrastructureTests.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.pluggable.tests;
-
-import java.util.Map;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.apt.pluggable.tests.processors.message6.Message6Proc;
-import org.eclipse.jdt.core.IJavaProject;
-import org.osgi.framework.Bundle;
-
-/**
- * Ensure that the apt.pluggable code is getting loaded, the test environment is as expected,
- * and the test utilities themselves are working.
- * Keeping these "infrastructure" tests separate from the "real" tests helps avoid confusion when
- * the real tests fail.
- */
-public class InfrastructureTests extends TestBase
-{
- public InfrastructureTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(InfrastructureTests.class);
- }
-
- /**
- * Test that the apt.pluggable.core plug-in is present. Obviously since this test plug-in
- * depends on it, this test will never fail; it will either succeed or not run at all.
- */
- public void testPluginLoaded() throws Throwable
- {
- Bundle bundle = Platform.getBundle("org.eclipse.jdt.apt.pluggable.core");
- assertNotNull("Couldn't get org.eclipse.jdt.apt.pluggable.core bundle", bundle);
- }
-
- /**
- * Can we create a Java 1.6 test project populated with resources from this plug-in?
- * If not, there is not much point in testing the rest of annotation processing.
- */
- public void testProjectBuild() throws Throwable
- {
- IJavaProject jproj = createJavaProject(_projectName);
- IProject proj = jproj.getProject();
- IdeTestUtils.copyResources(proj, "targets/infrastructure", "src/targets/infrastructure"); // source code
- fullBuild();
- expectingNoProblems();
- String[] expectedClasses = { "targets.infrastructure.NoAnno" };
- expectingCompiledClasses(expectedClasses);
- }
-
- /**
- * Does the factory path show Java 6 processors from this plug-in?
- */
- public void testFactoryPathContents() throws Throwable
- {
- IJavaProject jproj = createJavaProject(_projectName);
- FactoryPath fpath = (FactoryPath) AptConfig.getFactoryPath(jproj);
- Map<FactoryContainer, FactoryPath.Attributes> map = fpath.getAllContainers();
- boolean foundThisPlugin = false;
- for (Map.Entry<FactoryContainer, FactoryPath.Attributes> entry : map.entrySet()) {
- FactoryContainer fc = entry.getKey();
- if (Apt6TestsPlugin.PLUGIN_ID.equals(fc.getId())) {
- foundThisPlugin = true;
- Map<String, String> names = fc.getFactoryNames();
- String service = names.get(Message6Proc.class.getName());
- assertNotNull("Message6Proc was not found in apt.pluggable.tests plug-in", service);
- break;
- }
- }
- assertTrue("apt.pluggable.tests plug-in was not found in project factory path", foundThisPlugin);
- }
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/ProcessorTestStatus.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/ProcessorTestStatus.java
deleted file mode 100644
index a317b05207..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/ProcessorTestStatus.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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 - original implementation in org.eclipse.jdt.apt.tests
- * wharley@bea.com - copied to org.eclipse.jdt.apt.pluggable.tests
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.pluggable.tests;
-
-/**
- * Utility class to hold results of processor-based tests.
- * All methods are static.
- */
-public final class ProcessorTestStatus {
-
- /**
- * Marker string to indicate that no errors were encountered.
- */
- public static final String NO_ERRORS = "NO ERRORS";
-
- /**
- * Marker string to indicate processor never ran.
- */
- public static final String NOT_RUN = "NOT RUN";
-
- /** Error status. Will be == NO_ERRORS if no errors were encountered **/
- private static String s_errorStatus = NOT_RUN;
-
- /**
- * Was a processor run at all?
- */
- private static boolean s_processorRan = false;
-
- /** An expected condition failed. Record the error **/
- public static void failWithoutException(final String error) {
- s_errorStatus = error;
- }
-
- /** Returns true if any errors were encountered **/
- public static boolean hasErrors() {
- return s_errorStatus != NO_ERRORS;
- }
-
- /** Get the error string. Will be NO_ERRORS if none were encountered **/
- public static String getErrors() {
- return s_errorStatus;
- }
-
- /** Reset the status. Needs to be called before each set of tests that could fail **/
- public static void reset() {
- s_errorStatus = NOT_RUN;
- s_processorRan = false;
- }
-
- /** Did a processor call the setProcessorRan() method since the last reset()? */
- public static boolean processorRan() {
- return s_processorRan;
- }
-
- /** A processor can call this to indicate that it has run (with or without errors) */
- public static void setProcessorRan() {
- s_processorRan = true;
- if (NOT_RUN.equals(s_errorStatus))
- s_errorStatus = NO_ERRORS;
- }
-
- // Private c-tor to prevent construction
- private ProcessorTestStatus() {}
-
- public static void assertEquals(String reason, Object expected, Object actual) {
- if (expected == actual)
- return;
- if (expected != null && expected.equals(actual))
- return;
- ProcessorTestStatus.fail("Expected " + expected + ", but saw " + actual + ". Reason: " + reason);
- }
-
- public static void assertEquals(String reason, String expected, String actual) {
- if (expected == actual)
- return;
- if (expected != null && expected.equals(actual))
- return;
- ProcessorTestStatus.fail("Expected " + expected + ", but saw " + actual + ". Reason: " + reason);
- }
-
- public static void assertEquals(String reason, int expected, int actual) {
- if (expected == actual)
- return;
- ProcessorTestStatus.fail("Expected " + expected + ", but saw " + actual + ". Reason: " + reason);
- }
-
- public static void assertTrue(String reason, boolean expected) {
- if (!expected)
- ProcessorTestStatus.fail(reason);
- }
-
- public static void fail(final String reason) {
- failWithoutException(reason);
- throw new IllegalStateException("Failed during test: " + reason);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/ScalingTests.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/ScalingTests.java
deleted file mode 100644
index 4421d0143a..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/ScalingTests.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.pluggable.tests;
-
-import java.io.File;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.core.IJavaProject;
-
-/**
- *
- */
-public class ScalingTests extends TestBase
-{
- private final boolean VERBOSE = true;
-
- public ScalingTests(String name) {
- super(name);
- }
-
- public static Test suite()
- {
- return new TestSuite( ScalingTests.class );
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
- }
-
- /**
- * A customer reports that projects with ~2000 files abort generation.
- * Note, this test will take quite a long time to run.
- */
- public void testGeneratingLotsOfFiles() throws Exception
- {
- final int FILES_TO_GENERATE = 4000; // total number of files to create
- final int PAUSE_EVERY = 200; // wait for indexer to catch up after creating this many files
- final int PAUSE_TIME = 2000; // milliseconds to wait for indexer
-
- // set up project with unique name
- IJavaProject jproj = createJavaProject(_projectName);
-
- IProject project = jproj.getProject();
- IFolder srcFolder = project.getFolder( "src" );
- IPath srcRoot = srcFolder.getFullPath();
-
- String template =
- "package p;\n" +
- "import org.eclipse.jdt.apt.pluggable.tests.annotations.GenClass6;\n" +
- "@GenClass6(pkg=\"g\", name=\"Generated%05d\")\n" +
- "public class Test%05d {}";
- for (int i = 1; i <= FILES_TO_GENERATE; ++i) {
- String name = String.format("Test%05d", i);
- String contents = String.format(template, i, i);
- env.addClass( srcRoot, "p", name, contents ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // pause to let indexer catch up
- if (i % PAUSE_EVERY == 0) {
- if (VERBOSE)
- System.out.println("Created " + i + " files; pausing for indexer");
- Thread.sleep(PAUSE_TIME);
- }
- }
-
- if (VERBOSE)
- System.out.println("Done creating source files");
-
- // Set some per-project preferences
- AptConfig.setEnabled(jproj, true);
-
- long start = System.currentTimeMillis();
- fullBuild( project.getFullPath() );
- if (VERBOSE)
- System.out.println("Done with build after " + ((System.currentTimeMillis() - start)/1000L) + " sec");
-
- expectingNoProblems();
-
- IPath projPath = jproj.getProject().getLocation();
- for (int i = 1; i <= FILES_TO_GENERATE; ++i) {
- // check that file was generated
- String genFileName = String.format(".apt_generated/g/Generated%05d.java", i);
- File genFile = new File(projPath.append(genFileName).toOSString());
- assertTrue("Expected generated source file " + genFileName + " was not found", genFile != null && genFile.exists());
- // check that generated file was compiled
- String genClassName = String.format("bin/g/Generated%05d.class", i);
- File genClass = new File(projPath.append(genClassName).toOSString());
- assertTrue("Compiled file " + genClassName + " was not found", genClass != null && genClass.exists());
- }
-
- if (VERBOSE)
- System.out.println("Done checking output");
-
- // Now delete the project!
- ResourcesPlugin.getWorkspace().delete(new IResource[] { project }, true, null);
-
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestAll.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestAll.java
deleted file mode 100644
index 499d0e94bb..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestAll.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.pluggable.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(InfrastructureTests.suite());
- suite.addTest(FilerTests.suite());
-
- return suite;
-
- }
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestBase.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestBase.java
deleted file mode 100644
index 1ce97b81aa..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestBase.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package org.eclipse.jdt.apt.pluggable.tests;
-
-import java.io.File;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
-import org.eclipse.jdt.apt.core.internal.util.FactoryContainer.FactoryType;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.tests.builder.BuilderTests;
-import org.eclipse.jdt.core.tests.util.Util;
-
-public class TestBase extends BuilderTests
-{
-
- protected static final String JAVA_16_COMPLIANCE = "1.6";
-
- protected String _projectName;
- protected static int _projectSerial = 0; // used to create unique project names, to avoid resource deletion problems
-
- public TestBase(String name) {
- super(name);
- }
-
- /**
- * Extract lib/annotations.jar from the test bundle and add it to the specified project
- */
- private static void addAnnotationJar(IJavaProject jproj) throws Exception {
- final String resName = "lib/annotations.jar"; // name in bundle
- final String libName = resName; // name in destination project
- InputStream is = null;
- URL resURL = Apt6TestsPlugin.thePlugin().getBundle().getEntry(resName);
- is = resURL.openStream();
- IPath projPath = jproj.getPath();
- IProject proj = jproj.getProject();
- IFile libFile = proj.getFile(libName);
- env.addFolder(projPath, "lib");
- if (libFile.exists()) {
- libFile.setContents(is, true, false, null);
- } else {
- libFile.create(is, true, null);
- }
- env.addLibrary(projPath, libFile.getFullPath(), null, null);
- }
-
- /**
- * Create a java project with java libraries and test annotations on classpath
- * (compiler level is 1.6). Use "src" as source folder and "bin" as output folder. APT
- * is not enabled.
- *
- * @param projectName
- * @return a java project that has been added to the current workspace.
- * @throws Exception
- */
- protected static IJavaProject createJavaProject(final String projectName) throws Exception
- {
- IPath projectPath = env.addProject(projectName, JAVA_16_COMPLIANCE);
- env.addExternalJars(projectPath, Util.getJavaClassLibs());
- // 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$
- final IJavaProject javaProj = env.getJavaProject(projectPath);
- addAnnotationJar(javaProj);
- return javaProj;
- }
-
- /**
- * Ensure that there are no Java 5 processors on the factory path, as they can cause
- * units to be multiply compiled, which can mess up tests that expect a certain number
- * of compilations to occur.
- * @param jproj the project whose factory path will be edited
- * @throws CoreException
- */
- protected void disableJava5Factories(IJavaProject jproj) throws CoreException {
- FactoryPath fp = (FactoryPath) AptConfig.getFactoryPath(jproj);
- for (Map.Entry<FactoryContainer, FactoryPath.Attributes> entry : fp.getAllContainers().entrySet()) {
- if (entry.getKey().getType() == FactoryType.PLUGIN) {
- String id = entry.getKey().getId();
- if (!Apt6TestsPlugin.PLUGIN_ID.equals(id)) {
- fp.disablePlugin(id);
- }
- }
- }
- AptConfig.setFactoryPath(jproj, fp);
- }
-
- /**
- * Verify that an expected file exists within a project.
- * @param fileName the filename relative to the project root.
- */
- protected void expectingFile(IProject proj, String fileName) throws Exception
- {
- IPath path = proj.getLocation().append(fileName);
- File file = new File(path.toOSString());
- assertTrue("Expected file " + fileName + " was missing from project", file != null && file.exists());
- }
-
- /**
- * Verify that an expected file exists within a project.
- * @param fileName the filename relative to the project root.
- */
- protected void expectingNoFile(IProject proj, String fileName) throws Exception
- {
- IPath path = proj.getLocation().append(fileName);
- File file = new File(path.toOSString());
- boolean exists = file.exists();
- // work around a timing bug in some versions of JRE 1.6 on Linux:
- // Before assuming the test has failed, wait half a second and try again.
- // This delay is not encountered when the test is passing normally.
- if (exists) {
- Thread.sleep(500);
- exists = file.exists();
- }
- assertTrue("File " + fileName + " was expected to not exist", file == null || !exists);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- env.setAutoBuilding(false);
- _projectName = String.format("testproj%04d", ++_projectSerial);
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestUtils.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestUtils.java
deleted file mode 100644
index 8224fe7267..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/TestUtils.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.pluggable.tests;
-
-import java.io.File;
-
-/**
- * @since 3.3
- */
-public class TestUtils {
-
- /**
- * Convert an array of strings into a path.
- * E.g., turn { "a", "b", "c.d" } into a File representing "a/b/c.d".
- */
- public static File concatPath(String... names) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < names.length; ++i) {
- if (i > 0) {
- sb.append(File.separator);
- }
- sb.append(names[i]);
- }
- return new File(sb.toString());
- }
-
- public static String convertToIndependentLineDelimiter(String source) {
- if (source.indexOf('\n') == -1 && source.indexOf('\r') == -1) return source;
- StringBuffer buffer = new StringBuffer();
- for (int i = 0, length = source.length(); i < length; i++) {
- char car = source.charAt(i);
- if (car == '\r') {
- buffer.append('\n');
- if (i < length-1 && source.charAt(i+1) == '\n') {
- i++; // skip \n after \r
- }
- } else {
- buffer.append(car);
- }
- }
- return buffer.toString();
- }
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/annotations/FilerTestTrigger.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/annotations/FilerTestTrigger.java
deleted file mode 100644
index 9f596dcb83..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/annotations/FilerTestTrigger.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.pluggable.tests.annotations;
-
-/**
- *
- * @since 3.4
- */
-public @interface FilerTestTrigger {
- /** Name of test method to run */
- String test();
-
- /** Arbitrary argument */
- String arg0() default "";
-
- /** Arbitrary argument */
- String arg1() default "";
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/annotations/GenClass6.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/annotations/GenClass6.java
deleted file mode 100644
index e967a323d3..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/annotations/GenClass6.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.pluggable.tests.annotations;
-
-/**
- * This annotation may be processed to generate a
- * specified Java class.
- */
-public @interface GenClass6 {
- /**
- * Name of class to generate
- */
- String name();
-
- /**
- * Name of package in which to place class
- * (empty for default package)
- */
- String pkg() default "";
-
- /**
- * Name of method to create
- * (empty for no method creation)
- */
- String method() default "";
-
- /**
- * Produce a summary .txt file which contains the names of all generated classes
- * that specify this flag.
- */
- boolean summary() default false;
-
- /**
- * Number of additional rounds to induce. If the number is greater than one, a GenClass6
- * annotation will be added to the produced class, and given a rounds() value one less than the
- * value specified here and an appropriately suffixed name() value. Thus, specifying rounds=2
- * and name=Foo will produce Foo, which will be annotated with rounds=1 and name=Foo1, which
- * will produce Foo1, which will not be annotated.
- */
- int rounds() default 1;
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/annotations/Message6.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/annotations/Message6.java
deleted file mode 100644
index 267a3be046..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/annotations/Message6.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.pluggable.tests.annotations;
-
-import javax.tools.Diagnostic;
-
-
-/**
- * This annotation may be processed to produce a log entry,
- * warning, or error via the Messager API.
- */
-public @interface Message6 {
- /**
- * Message severity. INFO will be reported as a log entry.
- */
- Diagnostic.Kind value() default Diagnostic.Kind.WARNING;
-
- /**
- * Optional message text
- */
- String text() default "";
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/processors/filertester/FilerTesterProc.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/processors/filertester/FilerTesterProc.java
deleted file mode 100644
index a393d6241b..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/processors/filertester/FilerTesterProc.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.pluggable.tests.processors.filertester;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Set;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.Filer;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedOptions;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-import javax.tools.FileObject;
-import javax.tools.StandardLocation;
-
-import org.eclipse.jdt.apt.pluggable.tests.ProcessorTestStatus;
-import org.eclipse.jdt.apt.pluggable.tests.annotations.FilerTestTrigger;
-
-/**
- * Testing annotation processors through JUnit in the IDE is complex, because each test requires
- * something different of the processor and all processors must coexist in the plugin registry, and
- * because the processor has very limited communication with the rest of the IDE. So, we make one
- * processor run many tests. The JUnit tests specify which test to run by passing its name in to the
- * FilerTest annotation. Test failures are reported via the Messager interface.
- *
- * @since 3.4
- */
-@SupportedAnnotationTypes( { "org.eclipse.jdt.apt.pluggable.tests.annotations.FilerTestTrigger" })
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-@SupportedOptions( {})
-public class FilerTesterProc extends AbstractProcessor {
-
- private ProcessingEnvironment _processingEnv;
- private Filer _filer;
-
- public static final String resource01FileContents =
- "package g;\n" +
- "public class Test {}\n";
- public static final String resource01Name =
- ".apt_generated/g/Test.java";
-
- public static final String resource02FileContents =
- "This is some test text\n";
- public static final String resource02Name =
- "bin/t/Test.txt";
-
- /*
- * (non-Javadoc)
- *
- * @see javax.annotation.processing.AbstractProcessor#init(javax.annotation.processing.ProcessingEnvironment)
- */
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- _processingEnv = processingEnv;
- _filer = _processingEnv.getFiler();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.annotation.processing.AbstractProcessor#process(java.util.Set,
- * javax.annotation.processing.RoundEnvironment)
- */
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- ProcessorTestStatus.setProcessorRan();
- if (!roundEnv.processingOver() && !annotations.isEmpty()) {
- round(annotations, roundEnv);
- }
- return true;
- }
-
- /**
- * Perform a round of processing: for a given annotation instance, determine what test method it
- * specifies, and invoke that method, passing in the annotated element.
- */
- private void round(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- TypeElement filerTesterAnno = annotations.iterator().next();
- Set<? extends Element> annotatedEls = roundEnv.getElementsAnnotatedWith(filerTesterAnno);
- for (Element annotatedEl : annotatedEls) {
- FilerTestTrigger filerTesterMirror = annotatedEl.getAnnotation(FilerTestTrigger.class);
- String testMethodName = filerTesterMirror.test();
- String arg0 = filerTesterMirror.arg0();
- String arg1 = filerTesterMirror.arg1();
- if (null != testMethodName && testMethodName.length() > 0) {
- try {
- Method testMethod = FilerTesterProc.class.getMethod(testMethodName,
- Element.class, String.class, String.class);
- testMethod.invoke(this, annotatedEl, arg0, arg1);
- } catch (Exception e) {
- Throwable t;
- t = (e instanceof InvocationTargetException) ? t = e.getCause() : e;
- t.printStackTrace();
- // IllegalStateException probably means test method called ProcessorTestStatus.fail()
- String msg = (t instanceof IllegalStateException) ?
- t.getMessage() :
- t.getClass().getSimpleName() + " invoking test method " +
- testMethodName + " - see console for details";
- ProcessorTestStatus.fail(msg);
- }
- }
- }
- }
-
- /**
- * Attempt to get an existing resource from the SOURCE_OUTPUT.
- */
- public void testGetResource01(Element e, String arg0, String arg1) throws Exception {
- FileObject resource = _filer.getResource(StandardLocation.SOURCE_OUTPUT, arg0, arg1);
- checkResourceContents01(resource, resource01Name, resource01FileContents);
- }
-
- /**
- * Attempt to get an existing resource from the CLASS_OUTPUT.
- */
- public void testGetResource02(Element e, String arg0, String arg1) throws Exception {
- FileObject resource = _filer.getResource(StandardLocation.CLASS_OUTPUT, arg0, arg1);
- checkResourceContents01(resource, resource02Name, resource02FileContents);
- }
-
- /**
- * Check that the resource can be opened, examined, and its contents match
- * {@link #checkResourceContents01(FileObject)}getResource01FileContents
- */
- private void checkResourceContents01(FileObject resource, String expectedName, String expectedContents) throws Exception {
-
- long modTime = resource.getLastModified();
- if (modTime <= 0) {
- ProcessorTestStatus.fail("resource had unexpected mod time: " + modTime);
- }
-
- String actualName = resource.getName();
- if (!expectedName.equals(actualName)) {
- System.out.println("Resource had unexpected name. Expected " + expectedName +
- ", actual was " + actualName);
- ProcessorTestStatus.fail("Resource had unexpected name");
- }
-
- InputStream stream = resource.openInputStream();
- if (stream.available() <= 0) {
- ProcessorTestStatus.fail("stream contained no data");
- }
- byte actualBytes[] = new byte[512];
- int length = stream.read(actualBytes);
- String actualStringContents = new String(actualBytes, 0, length);
- if (!expectedContents.equals(actualStringContents)) {
- System.out.println("Expected stream contents:\n" + expectedContents);
- System.out.println("Actual contents were:\n" + actualStringContents);
- ProcessorTestStatus.fail("stream did not contain expected contents");
- }
- stream.close();
-
- char actualChars[] = new char[512];
- Reader reader = resource.openReader(true);
- length = reader.read(actualChars, 0, actualChars.length);
- actualStringContents = new String(actualChars, 0, length);
- if (!expectedContents.equals(actualStringContents)) {
- System.out.println("Expected reader contents:\n" + expectedContents);
- System.out.println("Actual contents were:\n" + actualStringContents);
- ProcessorTestStatus.fail("reader did not contain expected contents");
- }
- reader.close();
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/processors/genclass6/GenClass6Proc.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/processors/genclass6/GenClass6Proc.java
deleted file mode 100644
index 5c9b0ce5ed..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/processors/genclass6/GenClass6Proc.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.pluggable.tests.processors.genclass6;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.Filer;
-import javax.annotation.processing.Messager;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedOptions;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic;
-import javax.tools.FileObject;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardLocation;
-
-import org.eclipse.jdt.apt.pluggable.tests.annotations.GenClass6;
-
-/**
- * A processor that reads the GenClass6 annotation and produces the specified Java type
- */
-@SupportedAnnotationTypes({ "org.eclipse.jdt.apt.pluggable.tests.annotations.GenClass6" })
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-@SupportedOptions({})
-public class GenClass6Proc extends AbstractProcessor {
-
- private ProcessingEnvironment _processingEnv;
- private Messager _messager;
- private Filer _filer;
- private Map<String, Element> _classesToSummarize; // map of generated name to element that produced it
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.AbstractProcessor#init(javax.annotation.processing.ProcessingEnvironment)
- */
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- _processingEnv = processingEnv;
- _filer = _processingEnv.getFiler();
- _messager = _processingEnv.getMessager();
- _classesToSummarize = new HashMap<String, Element>();
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.AbstractProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)
- */
- @Override
- public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv)
- {
- if (roundEnv.processingOver() && !_classesToSummarize.isEmpty()) {
- summarize();
- }
- else if (!annotations.isEmpty()) {
- round(annotations, roundEnv);
- }
- return true;
- }
-
- /**
- * Perform a round of processing
- */
- private void round(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- TypeElement genClassAnno = annotations.iterator().next();
- Set<? extends Element> annotatedEls = roundEnv.getElementsAnnotatedWith(genClassAnno);
- for (Element e : annotatedEls) {
- GenClass6 genClassMirror = e.getAnnotation(GenClass6.class);
- generateType(genClassMirror, e);
- }
- }
-
- /**
- * @param genClassMirror
- */
- private void generateType(GenClass6 genClassMirror, Element annotatedEl) {
- // Collect and validate the parameters of the annotation
- String pkg = null;
- String name = null;
- String method = null;
- boolean summary = false;
- int rounds = 1;
- try {
- pkg = genClassMirror.pkg();
- name = genClassMirror.name();
- method = genClassMirror.method();
- summary = genClassMirror.summary();
- rounds = genClassMirror.rounds();
- } catch (Exception e) {
- _messager.printMessage(Diagnostic.Kind.WARNING, "Unable to read @GenClass6 annotation" + e.getLocalizedMessage(), annotatedEl);
- return;
- }
- if (name.length() == 0) {
- // User hasn't specified name yet
- _messager.printMessage(Diagnostic.Kind.WARNING, "The name attribute is missing", annotatedEl);
- return;
- }
- if (pkg == null) {
- pkg = "";
- }
- String qname = (pkg.length() > 0) ? pkg + '.' + name : name;
- if (method == null) {
- method = "";
- }
-
- // Get a writer
- JavaFileObject jfo = null;
- try {
- jfo = _filer.createSourceFile(qname, annotatedEl);
- } catch (IOException e) {
- _messager.printMessage(Diagnostic.Kind.WARNING, "Unable to open file for class " + qname, annotatedEl);
- return;
- }
- PrintWriter pw = null;
- try {
- pw = new PrintWriter(jfo.openWriter());
- } catch (IOException e) {
- _messager.printMessage(Diagnostic.Kind.WARNING, "Unable to get writer for file " + jfo.getName());
- return;
- }
-
- // Generate the class
- if (summary) {
- _classesToSummarize.put(qname, annotatedEl);
- }
- pw.println("// Generated by " + this.getClass().getName());
- pw.println("package " + pkg + ";");
- if (rounds > 1) {
- pw.println("import " + GenClass6.class.getCanonicalName() + ";");
- StringBuilder sb = new StringBuilder();
- sb.append("@GenClass6(");
- if (pkg.length() > 0) {
- sb.append("pkg = \"");
- sb.append(pkg);
- sb.append("\", ");
- }
- sb.append("name = \"");
- sb.append(name);
- sb.append("Gen\"");
- if (method.length() > 0) {
- sb.append(", method = \"");
- sb.append(method);
- sb.append("\"");
- }
- if (--rounds > 1) {
- sb.append(", rounds = ");
- sb.append(rounds);
- }
- if (summary) {
- sb.append(", summary = true");
- }
- sb.append(")");
- pw.println(sb.toString());
- }
- pw.println("public class " + name + "{");
- if (method != null && method.length() > 0) {
- pw.println("\tpublic String " + method + "() { return null; }");
- }
- pw.println("}");
- pw.close();
- }
-
- /**
- * Generate the summary.txt file if requested
- */
- protected void summarize() {
- PrintWriter pw = null;
- try {
- Element[] parents = new Element[_classesToSummarize.size()];
- parents = _classesToSummarize.values().toArray(parents);
- FileObject summaryFile = _filer.createResource(StandardLocation.SOURCE_OUTPUT, "", "summary.txt", parents);
- pw = new PrintWriter(summaryFile.openWriter());
- for (String clazz : _classesToSummarize.keySet()) {
- pw.println(clazz);
- }
- pw.flush();
- } catch (IOException e) {
- _messager.printMessage(Diagnostic.Kind.ERROR, "Unable to create summary.txt: " + e.getLocalizedMessage());
- } finally {
- if (pw != null) {
- pw.close();
- }
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/processors/message6/Message6Proc.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/processors/message6/Message6Proc.java
deleted file mode 100644
index dc5a6f2ad1..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/processors/message6/Message6Proc.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.pluggable.tests.processors.message6;
-
-import java.util.Set;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.Messager;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedOptions;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic;
-
-import org.eclipse.jdt.apt.pluggable.tests.annotations.Message6;
-
-/**
- * A processor that reads the Message6 annotation and sends output via the Messager API
- */
-@SupportedAnnotationTypes({"org.eclipse.jdt.apt.pluggable.tests.annotations.Message6"})
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-@SupportedOptions({})
-public class Message6Proc extends AbstractProcessor {
-
- private ProcessingEnvironment _processingEnv;
- private Messager _messager;
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.AbstractProcessor#init(javax.annotation.processing.ProcessingEnvironment)
- */
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- _processingEnv = processingEnv;
- _messager = _processingEnv.getMessager();
- }
- /* (non-Javadoc)
- * @see javax.annotation.processing.AbstractProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)
- */
- @Override
- public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv)
- {
- if (!annotations.isEmpty()) {
- round(annotations, roundEnv);
- }
- return true;
- }
-
- /**
- * Perform a round of processing
- */
- private void round(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- TypeElement genClassAnno = annotations.iterator().next();
- Set<? extends Element> annotatedEls = roundEnv.getElementsAnnotatedWith(genClassAnno);
- for (Element annotatedEl : annotatedEls) {
- Message6 messageMirror = annotatedEl.getAnnotation(Message6.class);
- Diagnostic.Kind kind = Diagnostic.Kind.OTHER;
- String text = null;
- try {
- kind = messageMirror.value();
- text = messageMirror.text();
- } catch (Exception e) {
- // Do nothing: compiler will have put up a syntax error on the annotation already
- return;
- }
- if (kind != Diagnostic.Kind.OTHER) {
- _messager.printMessage(kind, text, annotatedEl);
- }
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.pluggable.tests/test.xml b/org.eclipse.jdt.apt.pluggable.tests/test.xml
deleted file mode 100644
index 8ce77809e1..0000000000
--- a/org.eclipse.jdt.apt.pluggable.tests/test.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0"?>
-
-<project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <property name="eclipse-home" value="${basedir}\..\.."/>
-
- <!-- sets the properties eclipse-home, and library-file -->
- <property name="plugin-name" value="org.eclipse.jdt.apt.pluggable.tests"/>
- <property name="library-file"
- value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/>
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- <delete>
- <fileset dir="${eclipse-home}" includes="org*.xml"/>
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
-
- <property name="jdt-apt-pluggable-folder" value="${eclipse-home}/jdt_apt_pluggable_folder"/>
- <delete dir="${jdt-apt-pluggable-folder}" quiet="true"/>
-
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${jdt-apt-pluggable-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname" value="org.eclipse.jdt.apt.pluggable.tests.TestAll"/>
- </ant>
-
- </target>
-
- <!-- This target holds code to cleanup the testing environment after -->
- <!-- after all of the tests have been run. You can use this target to -->
- <!-- delete temporary files that have been created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen -->
- <!-- after all the tests have been run should go here. -->
- <target name="run" depends="init,suite,cleanup">
- <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
- <property name="includes" value="org*.xml"/>
- <property name="output-file" value="${plugin-name}.xml"/>
- </ant>
- </target>
-
- <!-- This target runs the performance test suites. -->
- <target name="performance">
- </target>
-
-</project>
diff --git a/org.eclipse.jdt.apt.tests/.classpath b/org.eclipse.jdt.apt.tests/.classpath
deleted file mode 100644
index ef8693cf91..0000000000
--- a/org.eclipse.jdt.apt.tests/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" output="bin-resources" path="src-resources"/>
- <classpathentry kind="src" output="binext" path="srcext"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <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 d30794a23b..0000000000
--- a/org.eclipse.jdt.apt.tests/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-bin
-binext
diff --git a/org.eclipse.jdt.apt.tests/.project b/org.eclipse.jdt.apt.tests/.project
deleted file mode 100644
index c6eff215f7..0000000000
--- 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 dfbf52ad3b..0000000000
--- a/org.eclipse.jdt.apt.tests/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-#Fri Oct 14 11:24:46 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.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/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.jdt.apt.tests/.settings/org.eclipse.jdt.ui.prefs
deleted file mode 100644
index 8bdd4c9444..0000000000
--- a/org.eclipse.jdt.apt.tests/.settings/org.eclipse.jdt.ui.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tue Jun 28 11:32:33 PDT 2005
-eclipse.preferences.version=1
-internal.default.compliance=default
diff --git a/org.eclipse.jdt.apt.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.apt.tests/META-INF/MANIFEST.MF
deleted file mode 100644
index 530b96c5b6..0000000000
--- a/org.eclipse.jdt.apt.tests/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,42 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jdt.apt.tests; singleton:=true
-Bundle-Version: 3.3.100.qualifier
-Bundle-ClassPath: apt.jar,
- aptext.jar
-Bundle-Activator: org.eclipse.jdt.apt.tests.plugin.AptTestsPlugin
-Bundle-Localization: plugin
-Export-Package: org.eclipse.jdt.apt.tests,
- org.eclipse.jdt.apt.tests.annotations,
- org.eclipse.jdt.apt.tests.annotations.apitest,
- org.eclipse.jdt.apt.tests.annotations.aptrounding,
- org.eclipse.jdt.apt.tests.annotations.exceptionhandling,
- org.eclipse.jdt.apt.tests.annotations.extradependency,
- org.eclipse.jdt.apt.tests.annotations.filegen,
- org.eclipse.jdt.apt.tests.annotations.generic,
- org.eclipse.jdt.apt.tests.annotations.helloworld,
- org.eclipse.jdt.apt.tests.annotations.messager,
- org.eclipse.jdt.apt.tests.annotations.mirrortest,
- org.eclipse.jdt.apt.tests.annotations.nestedhelloworld,
- org.eclipse.jdt.apt.tests.annotations.noop,
- org.eclipse.jdt.apt.tests.annotations.readAnnotationType,
- org.eclipse.jdt.apt.tests.annotations.readannotation,
- org.eclipse.jdt.apt.tests.annotations.valueconversion,
- org.eclipse.jdt.apt.tests.external.annotations.batch,
- org.eclipse.jdt.apt.tests.external.annotations.classloader,
- org.eclipse.jdt.apt.tests.external.annotations.loadertest,
- org.eclipse.jdt.apt.tests.jdtcoretests,
- org.eclipse.jdt.apt.tests.plugin
-Require-Bundle: org.junit,
- org.eclipse.jdt.apt.core,
- org.eclipse.jdt.core,
- org.eclipse.jdt.core.tests.builder,
- org.eclipse.jdt.core.tests.compiler,
- org.eclipse.jdt.core.tests.model,
- org.eclipse.core.resources,
- org.eclipse.core.runtime,
- org.eclipse.test.performance
-Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Bundle-Vendor: %providerName
diff --git a/org.eclipse.jdt.apt.tests/about.html b/org.eclipse.jdt.apt.tests/about.html
deleted file mode 100644
index 460233046e..0000000000
--- a/org.eclipse.jdt.apt.tests/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 2, 2006</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/build.properties b/org.eclipse.jdt.apt.tests/build.properties
deleted file mode 100644
index 7dddec3f77..0000000000
--- a/org.eclipse.jdt.apt.tests/build.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 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
-###############################################################################
-source.apt.jar = src/
-source.aptext.jar = srcext/
-output.apt.jar = bin/
-bin.includes = plugin.xml,\
- test.xml,\
- perf-test-project.zip,\
- META-INF/,\
- resources/,\
- *.jar,\
- about.html,\
- plugin.properties
-src.includes = about.html
diff --git a/org.eclipse.jdt.apt.tests/plugin.properties b/org.eclipse.jdt.apt.tests/plugin.properties
deleted file mode 100644
index c85df60b17..0000000000
--- a/org.eclipse.jdt.apt.tests/plugin.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 BEA Systems Inc. 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:
-# BEA Systems Inc. - initial implementation
-###############################################################################
-providerName=Eclipse.org
-pluginName=Java Annotation Processing Tests
diff --git a/org.eclipse.jdt.apt.tests/plugin.xml b/org.eclipse.jdt.apt.tests/plugin.xml
deleted file mode 100644
index d2afb2aa8a..0000000000
--- a/org.eclipse.jdt.apt.tests/plugin.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin>
- <extension
- point="org.eclipse.jdt.apt.core.annotationProcessorFactory">
- <factories enableDefault="true">
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldWildcardAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.extradependency.ExtraDependencyAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.noop.NoOpAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.mirrortest.MirrorTestAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.nestedhelloworld.NestedHelloWorldAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.readannotation.ReadAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.mirrortest.MirrorDeclarationTestAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.mirrortest.MirrorUtilTestAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.valueconversion.ValueConversionProcessorFactory">
- </factory>
- <factory class="org.eclipse.jdt.apt.tests.annotations.readAnnotationType.ReadAnnotationTypeProcessorFactory"/>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.filegen.FileGenLocationAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.filegen.FirstGenAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.filegen.SecondGenAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.filegen.TextGenAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.messager.MessagerAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.aptrounding.Round1GenAnnotationFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.aptrounding.Round2GenAnnotationFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.mirrortest.DefaultConstantAnnotationFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.apitest.APIAnnotationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.mirrortest.ASTBasedMirrorDeclarationProcessorFactory">
- </factory>
- <factory
- class="org.eclipse.jdt.apt.tests.annotations.exceptionhandling.ExceptionHandlingProcessorFactory">
- </factory>
- <factory class="org.eclipse.jdt.apt.tests.annotations.generic.GenericFactory"/>
- <factory class="org.eclipse.jdt.apt.tests.annotations.pause.PauseAnnotationProcessorFactory"/>
- <factory class="org.eclipse.jdt.apt.tests.annotations.listener.ListenerAnnotationProcessorFactory"/>
- </factories>
- </extension>
-
-</plugin>
diff --git a/org.eclipse.jdt.apt.tests/resources.jardesc b/org.eclipse.jdt.apt.tests/resources.jardesc
deleted file mode 100644
index 7d1a24c57b..0000000000
--- a/org.eclipse.jdt.apt.tests/resources.jardesc
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
-<jardesc>
- <jar path="org.eclipse.jdt.apt.tests/resources/question.jar"/>
- <options buildIfNeeded="true" compress="true" descriptionLocation="/org.eclipse.jdt.apt.tests/resources.jardesc" exportErrors="false" exportWarnings="true" includeDirectoryEntries="false" overwrite="true" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
- <storedRefactorings deprecationInfo="true" structuralOnly="false"/>
- <selectedProjects/>
- <manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
- <sealing sealJar="false">
- <packagesToSeal/>
- <packagesToUnSeal/>
- </sealing>
- </manifest>
- <selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
- <javaElement handleIdentifier="=org.eclipse.jdt.apt.tests/src-resources"/>
- </selectedElements>
-</jardesc>
diff --git a/org.eclipse.jdt.apt.tests/resources/question.jar b/org.eclipse.jdt.apt.tests/resources/question.jar
deleted file mode 100644
index d9c37792ee..0000000000
--- a/org.eclipse.jdt.apt.tests/resources/question.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.apt.tests/src-resources/notypes/package-info.java b/org.eclipse.jdt.apt.tests/src-resources/notypes/package-info.java
deleted file mode 100644
index 678f0ff93c..0000000000
--- a/org.eclipse.jdt.apt.tests/src-resources/notypes/package-info.java
+++ /dev/null
@@ -1 +0,0 @@
-@question.SimpleAnnotation("foo") package notypes; \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/src-resources/question/AnnotationTest.java b/org.eclipse.jdt.apt.tests/src-resources/question/AnnotationTest.java
deleted file mode 100644
index 8236af02ac..0000000000
--- a/org.eclipse.jdt.apt.tests/src-resources/question/AnnotationTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package question;
-
-@Deprecated
-@RTVisibleAnno(anno=@SimpleAnnotation("test"), clazzes={})
-@RTInvisibleAnno("question")
-public interface AnnotationTest{
-
- @RTVisibleAnno(name = "Foundation",
- boolValue = false,
- byteValue = 0x10,
- charValue = 'c',
- doubleValue = 99.0,
- floatValue = (float)9.0,
- intValue = 999,
- longValue = 3333,
- shortValue = 3,
- colors ={ Color.RED, Color.BLUE },
- anno = @SimpleAnnotation("core"),
- simpleAnnos = {@SimpleAnnotation("org"),
- @SimpleAnnotation("eclipse"),
- @SimpleAnnotation("jdt") },
- clazzes = {Object.class, String.class},
- clazz = Object.class)
- @RTInvisibleAnno("org.eclipse.jdt.core")
- @Deprecated
- public int field0 = 0;
-
- @Deprecated
- public int field1 = 1;
-
- @RTVisibleAnno(anno=@SimpleAnnotation("field"), clazzes={})
- @RTInvisibleAnno("2")
- public int field2 = 2;
-
- @RTInvisibleAnno("3")
- public int field3 = 3;
-
- @SimpleAnnotation("4")
- public int field4 = 4;
-
- @RTVisibleAnno(anno=@SimpleAnnotation("method0"), clazzes={})
- @RTInvisibleAnno("0")
- @Deprecated
- public int method0();
-
- @Deprecated
- public int method1();
-
- @RTVisibleAnno(anno=@SimpleAnnotation("method2"), clazzes={})
- @RTInvisibleAnno("2")
- public int method2();
-
- @RTInvisibleAnno("3")
- public int method3();
-
- @SimpleAnnotation("method4")
- public int method4();
-
- public int method5(int p0,
- @Deprecated
- int p1,
- @RTVisibleAnno(anno=@SimpleAnnotation("param2"), clazzes={})
- @RTInvisibleAnno("2")
- int p2);
-
- public int method6(int p0, int p1, int p2);
-
- } \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/src-resources/question/Color.java b/org.eclipse.jdt.apt.tests/src-resources/question/Color.java
deleted file mode 100644
index e6fb90e7da..0000000000
--- a/org.eclipse.jdt.apt.tests/src-resources/question/Color.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package question;
-
-public enum Color { RED, WHITE, BLUE; } \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/src-resources/question/RTInvisibleAnno.java b/org.eclipse.jdt.apt.tests/src-resources/question/RTInvisibleAnno.java
deleted file mode 100644
index bb59e7f31d..0000000000
--- a/org.eclipse.jdt.apt.tests/src-resources/question/RTInvisibleAnno.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package question;
-
- public @interface RTInvisibleAnno{
- String value();
- } \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/src-resources/question/RTVisibleAnno.java b/org.eclipse.jdt.apt.tests/src-resources/question/RTVisibleAnno.java
deleted file mode 100644
index 884ed6e314..0000000000
--- a/org.eclipse.jdt.apt.tests/src-resources/question/RTVisibleAnno.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package question;
-
-import java.lang.annotation.*;
-
-@Retention(value=RetentionPolicy.RUNTIME)
-public @interface RTVisibleAnno
-{
- String name() default "eclipse";
- boolean boolValue() default true;
- byte byteValue() default 0x0001;
- char charValue() default 'e';
- double doubleValue() default 0.0;
- float floatValue() default 0;
- int intValue() default 17;
- long longValue() default 43;
- short shortValue() default 1;
- Color[] colors() default {Color.RED, Color.WHITE, Color.BLUE};
- SimpleAnnotation anno();
- SimpleAnnotation[] simpleAnnos() default { @SimpleAnnotation("org.eclipse.org") };
- Class<?>[] clazzes();
- Class<?> clazz() default java.lang.String.class;
-
- } \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/src-resources/question/SimpleAnnotation.java b/org.eclipse.jdt.apt.tests/src-resources/question/SimpleAnnotation.java
deleted file mode 100644
index d9fb6193f7..0000000000
--- a/org.eclipse.jdt.apt.tests/src-resources/question/SimpleAnnotation.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package question;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(value=RetentionPolicy.RUNTIME)
-public @interface SimpleAnnotation {
-
- String value();
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/src-resources/question/package-info.java b/org.eclipse.jdt.apt.tests/src-resources/question/package-info.java
deleted file mode 100644
index 69c4985133..0000000000
--- a/org.eclipse.jdt.apt.tests/src-resources/question/package-info.java
+++ /dev/null
@@ -1 +0,0 @@
-@Deprecated package question; \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/APITests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/APITests.java
deleted file mode 100644
index a66266f746..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/APITests.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.ILogListener;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.util.AptUtil;
-import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;
-import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotationProcessorFactory;
-import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldWildcardAnnotationProcessorFactory;
-import org.eclipse.jdt.apt.tests.annotations.messager.MessagerAnnotationProcessor;
-import org.eclipse.jdt.apt.tests.annotations.messager.MessagerCodeExample;
-import org.eclipse.jdt.core.IJavaProject;
-
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-
-public class APITests extends APTTestBase {
-
- private class LogListener implements ILogListener {
- private final List<IStatus> _messages = new ArrayList<IStatus>();
-
- public void logging(IStatus status, String plugin) {
- _messages.add(status);
- }
-
- public void clear() {
- _messages.clear();
- }
-
- public List<IStatus> getList() {
- return _messages;
- }
- }
-
- private LogListener _logListener;
-
- public APITests(final String name) {
- super( name );
- }
-
- public static Test suite() {
- return new TestSuite( APITests.class );
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
-
- _logListener = new LogListener();
- AptPlugin.getPlugin().getLog().addLogListener(_logListener);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- AptPlugin.getPlugin().getLog().removeLogListener(_logListener);
- _logListener = null;
- }
-
- public void testAptUtil() throws Exception {
- IJavaProject jproj = env.getJavaProject( getProjectName() );
-
- // Check getting a known annotation
- AnnotationProcessorFactory factory =
- AptUtil.getFactoryForAnnotation(HelloWorldAnnotation.class.getName(), jproj);
- assertEquals(factory.getClass(), HelloWorldAnnotationProcessorFactory.class);
-
- // Check getting an annotation with a partial wildcard ("org.eclipse.jdt.apt.tests.*")
- factory =
- AptUtil.getFactoryForAnnotation(HelloWorldAnnotation.class.getName() + "qwerty", jproj); //$NON-NLS-1$
-
- assertEquals(factory.getClass(), HelloWorldWildcardAnnotationProcessorFactory.class);
-
- // Check getting an annotation with a full wildcard ("*")
- // Note that these tests require that we do not cache what annotations
- // a factory claims to support. Specifically, the HelloWorldWildcard one
- // will swap out what it returns based on this static boolean.
- // If we change to cache the results, this test will need to be modified to work
- // in that scenario, probably by created a new external jar with
- // a processor that claims *.
- HelloWorldWildcardAnnotationProcessorFactory.CLAIM_ALL_ANNOTATIONS = true;
- try {
- factory =
- AptUtil.getFactoryForAnnotation("org.eclipse.Foo", jproj); //$NON-NLS-1$
-
- assertEquals(factory.getClass(), HelloWorldWildcardAnnotationProcessorFactory.class);
- }
- finally {
- HelloWorldWildcardAnnotationProcessorFactory.CLAIM_ALL_ANNOTATIONS = false;
- }
-
- // Make sure we've unset the wildcard behavior
- factory =
- AptUtil.getFactoryForAnnotation("org.eclipse.Foo", jproj); //$NON-NLS-1$
-
- assertNull(factory);
-
- }
-
- public void testMessagerAPI() throws Exception {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
- IPath code = env.addClass(srcRoot, MessagerCodeExample.CODE_PACKAGE, MessagerCodeExample.CODE_CLASS_NAME, MessagerCodeExample.CODE1);
- ExpectedProblem prob1 = new ExpectedProblem("", MessagerAnnotationProcessor.PROBLEM_TEXT_WARNING, code, //$NON-NLS-1$
- MessagerCodeExample.WARNING_START,
- MessagerCodeExample.WARNING_END);
- ExpectedProblem prob2 = new ExpectedProblem("", MessagerAnnotationProcessor.PROBLEM_TEXT_ERROR, code, //$NON-NLS-1$
- MessagerCodeExample.ERROR_START,
- MessagerCodeExample.ERROR_END);
- ExpectedProblem[] problems = new ExpectedProblem[] { prob1, prob2 };
-
- // Code example with info, warning, and error messages
- _logListener.clear();
- fullBuild( project.getFullPath() );
- expectingOnlySpecificProblemsFor(code, problems);
- checkMessagerAnnotationLogEntry(
- MessagerAnnotationProcessor.PROBLEM_TEXT_INFO,
- MessagerCodeExample.INFO_START,
- MessagerCodeExample.INFO_END);
-
- // Code example with info and warning messages
- env.removeClass(code, MessagerCodeExample.CODE_CLASS_NAME);
- code = env.addClass(srcRoot, MessagerCodeExample.CODE_PACKAGE, MessagerCodeExample.CODE_CLASS_NAME, MessagerCodeExample.CODE2);
- _logListener.clear();
- fullBuild( project.getFullPath() );
- problems = new ExpectedProblem[] { prob1 };
- expectingOnlySpecificProblemsFor(code, problems);
- checkMessagerAnnotationLogEntry(
- MessagerAnnotationProcessor.PROBLEM_TEXT_INFO,
- MessagerCodeExample.INFO_START,
- MessagerCodeExample.INFO_END);
-
- // Code example with only a warning message
- env.removeClass(code, MessagerCodeExample.CODE_CLASS_NAME);
- code = env.addClass(srcRoot, MessagerCodeExample.CODE_PACKAGE, MessagerCodeExample.CODE_CLASS_NAME, MessagerCodeExample.CODE3);
- _logListener.clear();
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- checkMessagerAnnotationLogEntry(
- MessagerAnnotationProcessor.PROBLEM_TEXT_INFO,
- MessagerCodeExample.INFO_START,
- MessagerCodeExample.INFO_END);
-
- // Code example with no problems
- env.removeClass(code, MessagerCodeExample.CODE_CLASS_NAME);
- code = env.addClass(srcRoot, MessagerCodeExample.CODE_PACKAGE, MessagerCodeExample.CODE_CLASS_NAME, MessagerCodeExample.CODE4);
- _logListener.clear();
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- assertTrue(_logListener.getList().isEmpty());
- }
-
- /**
- * Check that there are exactly [targetCount] messages in the log that contain
- * [targetMsg] and also contain "starting offset=[start]; ending offset=[end]".
- */
- private void checkMessagerAnnotationLogEntry(String targetMsg, int start, int end) {
- int count = 0;
- final String offsetMsg = "starting offset=" + start + "; ending offset=" + end;
- for (IStatus status : _logListener.getList()) {
- String logMessage = status.getMessage();
- if (logMessage.contains(targetMsg) && logMessage.contains(offsetMsg)) {
- ++count;
- }
- }
- assertEquals(1, count);
- }
-
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/APTTestBase.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/APTTestBase.java
deleted file mode 100644
index 77b8b6bf6a..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/APTTestBase.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.tests;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-import org.eclipse.jdt.apt.tests.annotations.generic.GenericFactory;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.tests.builder.BuilderTests;
-import org.eclipse.jdt.core.tests.builder.Problem;
-import org.eclipse.jdt.core.tests.util.Util;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-
-/**
- * Setup a project for common APT testing.
- */
-public abstract class APTTestBase extends BuilderTests{
-
- private IJavaProject _jproj;
-
- public APTTestBase(final String name)
- {
- super(name);
- }
-
- /**
- * Set up a basic project with the following properties.
- * - java compliance level is 1.5
- * - 'src' is the source folder
- * - 'bin' is the output folder
- * - add java class library into the build class path
- * - create and add an annotation jar.
- */
- public void setUp() throws Exception
- {
- runFinalizers();
- ProcessorTestStatus.reset();
-
- super.setUp();
-
- env.resetWorkspace();
- TestUtil.enableAutoBuild(false);
-
- // project will be deleted by super-class's tearDown() method
- final String projectName = getProjectName();
- if( projectName == null )
- throw new IllegalStateException();
- _jproj = createJavaProject(projectName);
- AptConfig.setEnabled(_jproj, true);
- }
-
- /**
- * @return the java project created in setUp(). Note that some tests may
- * create more than one project; this method only returns the one named
- * by getProjectName().
- */
- protected IJavaProject getCurrentJavaProject() {
- return _jproj;
- }
-
- /**
- * Create a java project with java libraries and test annotations on classpath
- * (compiler level is 1.5). Use "src" as source folder and "bin" as output folder.
- * APT is not enabled.
- *
- * @param projectName
- * @return a java project that has been added to the current workspace.
- * @throws Exception
- */
- protected IJavaProject createJavaProject(final String projectName )
- throws Exception
- {
- IPath projectPath = env.addProject( projectName, "1.5" );
- env.addExternalJars( projectPath, Util.getJavaClassLibs() );
- // 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$
- final IJavaProject javaProj = env.getJavaProject( projectPath );
- TestUtil.createAndAddAnnotationJar( javaProj );
- return javaProj;
- }
-
- protected void tearDown()
- throws Exception
- {
- AptPlugin.trace("Tearing down " + getProjectName() );
- runFinalizers();
- GenericFactory.PROCESSOR = null;
- super.tearDown();
- }
-
- private static void runFinalizers() {
- // GC in an attempt to release file lock on Classes.jar
- System.gc();
- System.runFinalization();
- System.gc();
- System.runFinalization();
- }
-
- public String getProjectName()
- {
- return this.getClass().getName() + "Project"; //$NON-NLS-1$
- }
-
- public IPath getSourcePath()
- {
- IProject project = env.getProject( getProjectName() );
- IFolder srcFolder = project.getFolder( "src" ); //$NON-NLS-1$
- IPath srcRoot = srcFolder.getFullPath();
- return srcRoot;
- }
-
- private String concate(String[] messages){
- final int len = messages == null ? 0 : messages.length;
- StringBuilder buffer = new StringBuilder();
- for(int i=0; i<len; i++ ){
- buffer.append(messages[i]);
- buffer.append('\n');
- }
- return buffer.toString();
- }
-
- private String concate(IMarker[] markers){
- final int len = markers == null ? 0 : markers.length;
- StringBuilder buffer = new StringBuilder();
- for(int i=0; i<len; i++ ){
- try{
- buffer.append(markers[i].getAttribute(IMarker.MESSAGE));
- }
- catch(CoreException ce){
- assertTrue("unexpected core exception" + ce.getMessage(), false); //$NON-NLS-1$
- }
- buffer.append('\n');
- }
- return buffer.toString();
- }
-
- protected void clearProcessorResult(Class<? extends AnnotationProcessor> processor) {
- String propertyName = BaseProcessor.getPropertyName(processor);
- System.clearProperty(propertyName);
- }
-
- /*
- * Processors can set a result message with BaseProcessor.reportError() or reportSuccess().
- * This method will cause the test to fail if the processor reported an error. The result
- * value will be cleared regardless of success or failure.
- */
- protected String checkProcessorResult(Class<? extends AnnotationProcessor> processor) {
- String propertyName = BaseProcessor.getPropertyName(processor);
- String result = System.getProperty(propertyName);
- System.clearProperty(propertyName);
- if (!BaseProcessor.SUCCESS.equals(result)) {
- fail(result);
- }
- return result;
- }
-
- /*
- * Processors can set a result message with BaseProcessor.reportError() or reportSuccess().
- * This method returns the message reported by the processor, and clears the result value.
- */
- protected String getProcessorResult(Class<? extends AnnotationProcessor> processor) {
- String propertyName = BaseProcessor.getPropertyName(processor);
- String result = System.getProperty(propertyName);
- System.clearProperty(propertyName);
- return result;
- }
-
- protected void expectingMarkers(String[] messages)
- {
- final IMarker[] markers = getAllAPTMarkers(env.getWorkspaceRootPath());
- final Set<String> expectedMessages = new HashSet<String>();
- for(String msg : messages ){
- expectedMessages.add(msg);
- }
- boolean fail = false;
- try{
- for( IMarker marker : markers ){
- final String markerMsg = (String)marker.getAttribute(IMarker.MESSAGE);
- if( expectedMessages.contains(markerMsg) )
- expectedMessages.remove(markerMsg);
- else{
- fail = true;
- break;
- }
- }
- if( !expectedMessages.isEmpty() )
- fail = true;
- }catch(CoreException ce){
- assertTrue("unexpected core exception" + ce.getMessage(), false); //$NON-NLS-1$
- }
- if( fail )
- assertEquals(concate(messages), concate(markers));
- }
-
- protected void expectingNoMarkers() {
- expectingNoMarkers(env.getWorkspaceRootPath());
- }
-
- protected void expectingNoMarkers(IPath path)
- {
- final IMarker[] markers = getAllAPTMarkers(path);
-
- if( markers != null && markers.length != 0 ){
- try{
- assertTrue("unexpected marker(s) : " + markers[0].getAttribute(IMarker.MESSAGE), false); //$NON-NLS-1$
- }
- catch(CoreException ce){
- assertTrue("unexpected core exception" + ce.getMessage(), false); //$NON-NLS-1$
- }
- }
- }
-
- protected IMarker[] getAllAPTMarkers(IPath path){
- IResource resource;
- if(path.equals(env.getWorkspaceRootPath())){
- resource = env.getWorkspace().getRoot();
- } else {
- IProject p = env.getProject(path);
- if(p != null && path.equals(p.getFullPath())) {
- resource = env.getProject(path.lastSegment());
- } else if(path.getFileExtension() == null) {
- resource = env.getWorkspace().getRoot().getFolder(path);
- } else {
- resource = env.getWorkspace().getRoot().getFile(path);
- }
- }
- try {
- IMarker[] markers = null;
- int total = 0;
- final IMarker[] processorMarkers = resource.findMarkers(AptPlugin.APT_BATCH_PROCESSOR_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
- total = processorMarkers.length;
- markers = processorMarkers;
-
- final IMarker[] factoryPathMarkers = resource.findMarkers(AptPlugin.APT_LOADER_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
- if( factoryPathMarkers.length != 0 ){
- if( total != 0 ){
- final int len = factoryPathMarkers.length;
- final IMarker[] temp = new IMarker[len + total ];
- System.arraycopy(markers, 0, temp, 0, total);
- System.arraycopy(factoryPathMarkers, 0, temp, total, len);
- markers = temp;
- total += len;
- }
- else
- markers = factoryPathMarkers;
- }
- final IMarker[] configMarkers = resource.findMarkers(AptPlugin.APT_CONFIG_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
- if( configMarkers.length != 0 ){
- if( total != 0 ){
- final int len = configMarkers.length;
- final IMarker[] temp = new IMarker[len + total];
- System.arraycopy(markers, 0, temp, 0, total);
- System.arraycopy(configMarkers, 0, temp, total, len);
- markers = temp;
- total += len;
- }
- else
- markers = configMarkers;
- }
- return markers;
- } catch(CoreException e){
- return null;
- }
- }
-
- /**
- * Verifies that the given element has specifics problems and
- * only the given problems.
- * @see Tests#expectingOnlySpecificProblemsFor(IPath, Problem[]), and
- * @see Tests#expectingSpecificProblemsFor(IPath, Problem[], boolean).
- * Unfortunately this variant isn't implemented there.
- */
- protected void expectingOnlySpecificProblemsFor(IPath root, ExpectedProblem[] expectedProblems) {
- if (DEBUG)
- printProblemsFor(root);
-
- Problem[] rootProblems = env.getProblemsFor(root);
-
- for (int i = 0; i < expectedProblems.length; i++) {
- ExpectedProblem expectedProblem = expectedProblems[i];
- boolean found = false;
- for (int j = 0; j < rootProblems.length; j++) {
- if(expectedProblem.equalsProblem(rootProblems[j])) {
- found = true;
- rootProblems[j] = null;
- break;
- }
- }
- if (!found) {
- printProblemsFor(root);
- }
- assertTrue("problem not found: " + expectedProblem.toString(), found); //$NON-NLS-1$
- }
- for (int i = 0; i < rootProblems.length; i++) {
- if(rootProblems[i] != null) {
- printProblemsFor(root);
- assertTrue("unexpected problem: " + rootProblems[i].toString(), false); //$NON-NLS-1$
- }
- }
- }
-
- /** Verifies that the given element has specific problems.
- */
- protected void expectingSpecificProblemsFor(IPath root, ExpectedProblem[] problems) {
- if (DEBUG)
- printProblemsFor(root);
-
- Problem[] rootProblems = env.getProblemsFor(root);
- next : for (int i = 0; i < problems.length; i++) {
- ExpectedProblem problem = problems[i];
- for (int j = 0; j < rootProblems.length; j++) {
- Problem rootProblem = rootProblems[j];
- if (rootProblem != null) {
- if (problem.equalsProblem(rootProblem)) {
- rootProblems[j] = null;
- continue next;
- }
- }
- }
- for (int j = 0; j < rootProblems.length; j++) {
- Problem pb = rootProblems[j];
- if (pb == null) continue;
- System.out.print("got pb: new Problem(\"" + pb.getLocation() + "\", \"" + pb.getMessage() + "\", \"" + pb.getResourcePath() + "\"");
- System.out.print(", " + pb.getStart() + ", " + pb.getEnd() + ", " + pb.getCategoryId());
- System.out.println(")");
- }
- assertTrue("missing expected problem : " + problem, false);
- }
- }
-
- /** Verifies that the given element has a specific problem and
- * only the given problem.
- */
- protected void expectingOnlySpecificProblemFor(IPath root, ExpectedProblem problem) {
- expectingOnlySpecificProblemsFor(root, new ExpectedProblem[] { problem });
- }
-
- protected 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/AnnotationValueConversionTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationValueConversionTests.java
deleted file mode 100644
index 8ee0201a2e..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationValueConversionTests.java
+++ /dev/null
@@ -1,780 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.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.ProcessorTestStatus;
-import org.eclipse.jdt.core.tests.util.Util;
-
-public class AnnotationValueConversionTests extends APTTestBase
-{
- private int counter = 0;
- private String projectName = null;
- public AnnotationValueConversionTests(final String name) {
- super( name );
- }
-
- public static Test suite() {
- return new TestSuite( AnnotationValueConversionTests.class );
- }
-
- public String getUniqueProjectName(){
- projectName = AnnotationValueConversionTests.class.getName() + "Project" + counter; //$NON-NLS-1$
- counter ++;
- return projectName;
- }
-
-
- public IPath getSourcePath() {
- IProject project = env.getProject( getProjectName() );
- IFolder srcFolder = project.getFolder( "src" ); //$NON-NLS-1$
- IPath srcRoot = srcFolder.getFullPath();
- return srcRoot;
- }
-
- public IPath getBinaryPath(){
- IProject project = env.getProject( getProjectName() );
- IFolder srcFolder = project.getFolder( "binary" ); //$NON-NLS-1$
- IPath lib = srcFolder.getFullPath();
- return lib;
- }
-
- public IPath getOutputPath(){
- IProject project = env.getProject( getProjectName() );
- IFolder binFolder = project.getFolder( "bin" ); //$NON-NLS-1$
- IPath bin = binFolder.getFullPath();
- return bin;
- }
-
- private IProject setupTest() throws Exception
- {
- ProcessorTestStatus.reset();
- // project will be deleted by super-class's tearDown() method
- IPath projectPath = env.addProject( getUniqueProjectName(), "1.5" ); //$NON-NLS-1$
- env.setOutputFolder(projectPath, "bin"); //$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$
- return env.getProject(getProjectName());
- }
-
- public void testByteConversion() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.Annotation;\n" +
- "@Annotation(z=(byte)49,\n" +
- " b=(byte)49,\n" +
- " s=(byte)49,\n" +
- " i=(byte)49,\n" +
- " l=(byte)49,\n" +
- " f=(byte)49,\n" +
- " d=(byte)49,\n" +
- " c=(byte)49)\n\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from byte to boolean", testPath),
- new ExpectedProblem("", "type mismatch for member z expected java.lang.Boolean but got java.lang.Byte", testPath)
- });
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- public void testByteConversion_Reflection() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.RefAnnotation;\n" +
- "@RefAnnotation(z=(byte)49,\n" +
- " b=(byte)49,\n" +
- " s=(byte)49,\n" +
- " i=(byte)49,\n" +
- " l=(byte)49,\n" +
- " f=(byte)49,\n" +
- " d=(byte)49,\n" +
- " c=(byte)49)\n\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from byte to boolean", testPath),
- new ExpectedProblem("", "value mismatch for member z expected true but got false", testPath)
- });
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Test conversion on short.
- * @throws Exception
- */
- public void testShortConversion() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.Annotation;\n" +
- "@Annotation(z=(short)49,\n" +
- " b=(short)49,\n" +
- " s=(short)49,\n" +
- " i=(short)49,\n" +
- " l=(short)49,\n" +
- " f=(short)49,\n" +
- " d=(short)49,\n" +
- " c=(short)49)\n\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from short to boolean", testPath),
- new ExpectedProblem("", "type mismatch for member z expected java.lang.Boolean but got java.lang.Short", testPath)
- });
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- public void testShortConversion_Reflection() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.RefAnnotation;\n" +
- "@RefAnnotation(z=(short)49,\n"+
- " b=(short)49,\n" +
- " s=(short)49,\n" +
- " i=(short)49,\n" +
- " l=(short)49,\n" +
- " f=(short)49,\n" +
- " d=(short)49,\n" +
- " c=(short)49)\n\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from short to boolean", testPath),
- new ExpectedProblem("", "value mismatch for member z expected true but got false", testPath)
- });
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Test conversion on char.
- * @throws Exception
- */
- public void testCharConversion() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.Annotation;\n" +
- "@Annotation(z='1',\n" +
- " b='1',\n" +
- " s='1',\n" +
- " i='1',\n" +
- " l='1',\n" +
- " f='1',\n" +
- " d='1',\n" +
- " c='1')\n\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from char to boolean", testPath),
- new ExpectedProblem("", "type mismatch for member z expected java.lang.Boolean but got java.lang.Character", testPath)
- });
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Test conversion on char through reflection
- * @throws Exception
- */
- public void testCharConversion_Reflection() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.RefAnnotation;\n" +
- "@RefAnnotation(z='1',\n" +
- " b='1',\n" +
- " s='1',\n" +
- " i='1',\n" +
- " l='1',\n" +
- " f='1',\n" +
- " d='1',\n" +
- " c='1')\n\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from char to boolean", testPath),
- new ExpectedProblem("", "value mismatch for member z expected true but got false", testPath)
- });
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Test conversion on int.
- * @throws Exception
- */
- public void testIntConversion() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.Annotation;\n" +
- "@Annotation(z=49,\n" +
- " b=49,\n" +
- " s=49,\n" +
- " i=49,\n" +
- " l=49,\n" +
- " f=49,\n" +
- " d=49,\n" +
- " c=49)\n\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from int to boolean", testPath),
- new ExpectedProblem("", "type mismatch for member z expected java.lang.Boolean but got java.lang.Integer", testPath)
- });
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Test conversion on int through reflection
- * @throws Exception
- */
- public void testIntConversion_Reflection() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.RefAnnotation;\n" +
- "@RefAnnotation(z=49,\n" +
- " b=49,\n" +
- " s=49,\n" +
- " i=49,\n" +
- " l=49,\n" +
- " f=49,\n" +
- " d=49,\n" +
- " c=49)\n\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from int to boolean", testPath),
- new ExpectedProblem("", "value mismatch for member z expected true but got false", testPath)
- });
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Test conversion on long.
- * @throws Exception
- */
- public void testLongConversion() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.Annotation;\n" +
- "@Annotation(z=49l,\n" +
- " c=49l,\n" +
- " b=49l,\n" +
- " s=49l,\n" +
- " i=49l,\n" +
- " l=49l,\n" +
- " f=49l,\n" +
- " d=49l)\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from long to boolean", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from long to char", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from long to byte", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from long to short", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from long to int", testPath),
- new ExpectedProblem("", "type mismatch for member z expected java.lang.Boolean but got java.lang.Long", testPath),
- new ExpectedProblem("", "type mismatch for member s expected java.lang.Short but got java.lang.Long", testPath),
- new ExpectedProblem("", "type mismatch for member i expected java.lang.Integer but got java.lang.Long", testPath),
- new ExpectedProblem("", "type mismatch for member c expected java.lang.Character but got java.lang.Long", testPath),
- new ExpectedProblem("", "type mismatch for member b expected java.lang.Byte but got java.lang.Long", testPath),
- });
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Test conversion on long.
- * @throws Exception
- */
- public void testLongConversion_Reflection() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.RefAnnotation;\n" +
- "@RefAnnotation(z=49l,\n" +
- " c=49l,\n" +
- " b=49l,\n" +
- " s=49l,\n" +
- " i=49l,\n" +
- " l=49l,\n" +
- " f=49l,\n" +
- " d=49l)\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from long to boolean", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from long to char", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from long to byte", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from long to short", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from long to int", testPath),
- new ExpectedProblem("", "value mismatch for member z expected true but got false", testPath),
- new ExpectedProblem("", "value mismatch for member s expected 49 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member i expected 49 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member c expected 1 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member b expected 49 but got 0", testPath),
- });
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Test conversion on Float.
- * @throws Exception
- */
- public void testFloatConversion() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.Annotation;\n" +
- "@Annotation(z=49f,\n" +
- " c=49f,\n" +
- " b=49f,\n" +
- " s=49f,\n" +
- " i=49f,\n" +
- " l=49f,\n" +
- " f=49f,\n" +
- " d=49f)\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass(
- srcRoot,
- "sample",
- "Test",
- content );
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from float to boolean", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from float to int", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from float to long", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from float to char", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from float to byte", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from float to short", testPath),
- new ExpectedProblem("", "type mismatch for member z expected java.lang.Boolean but got java.lang.Float", testPath),
- new ExpectedProblem("", "type mismatch for member s expected java.lang.Short but got java.lang.Float", testPath),
- new ExpectedProblem("", "type mismatch for member i expected java.lang.Integer but got java.lang.Float", testPath),
- new ExpectedProblem("", "type mismatch for member c expected java.lang.Character but got java.lang.Float", testPath),
- new ExpectedProblem("", "type mismatch for member b expected java.lang.Byte but got java.lang.Float", testPath),
- new ExpectedProblem("", "type mismatch for member l expected java.lang.Long but got java.lang.Float", testPath),
- });
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Test conversion on Float.
- * @throws Exception
- */
- public void testFloatConversion_Reflection() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.RefAnnotation;\n" +
- "@RefAnnotation(z=49f,\n" +
- " c=49f,\n" +
- " b=49f,\n" +
- " s=49f,\n" +
- " i=49f,\n" +
- " l=49f,\n" +
- " f=49f,\n" +
- " d=49f)\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass(
- srcRoot,
- "sample",
- "Test",
- content );
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from float to boolean", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from float to int", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from float to long", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from float to char", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from float to byte", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from float to short", testPath),
- new ExpectedProblem("", "value mismatch for member z expected true but got false", testPath),
- new ExpectedProblem("", "value mismatch for member s expected 49 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member i expected 49 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member c expected 1 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member b expected 49 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member l expected 49 but got 0", testPath),
- });
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Test conversion on double. No arrayification.
- * @throws Exception
- */
- public void testDoubleConversion() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.Annotation;\n" +
- "@Annotation(z=49d," +
- " c=49d,\n" +
- " b=49d,\n" +
- " s=49d,\n" +
- " i=49d,\n" +
- " l=49d,\n" +
- " f=49d,\n" +
- " d=49d)\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass(srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from double to boolean", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from double to int", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from double to long", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from double to char", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from double to byte", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from double to short", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from double to float", testPath),
- new ExpectedProblem("", "type mismatch for member z expected java.lang.Boolean but got java.lang.Double", testPath),
- new ExpectedProblem("", "type mismatch for member s expected java.lang.Short but got java.lang.Double", testPath),
- new ExpectedProblem("", "type mismatch for member i expected java.lang.Integer but got java.lang.Double", testPath),
- new ExpectedProblem("", "type mismatch for member c expected java.lang.Character but got java.lang.Double", testPath),
- new ExpectedProblem("", "type mismatch for member b expected java.lang.Byte but got java.lang.Double", testPath),
- new ExpectedProblem("", "type mismatch for member l expected java.lang.Long but got java.lang.Double", testPath),
- new ExpectedProblem("", "type mismatch for member f expected java.lang.Float but got java.lang.Double", testPath)
- });
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Test conversion on double. No arrayification.
- * @throws Exception
- */
- public void testDoubleConversion_Reflection() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.RefAnnotation;\n" +
- "@RefAnnotation(z=49d,\n" +
- " c=49d,\n" +
- " b=49d,\n" +
- " s=49d,\n" +
- " i=49d,\n" +
- " l=49d,\n" +
- " f=49d,\n" +
- " d=49d)\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass(srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from double to boolean", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from double to int", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from double to long", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from double to char", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from double to byte", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from double to short", testPath),
- new ExpectedProblem("", "Type mismatch: cannot convert from double to float", testPath),
- new ExpectedProblem("", "value mismatch for member z expected true but got false", testPath),
- new ExpectedProblem("", "value mismatch for member s expected 49 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member i expected 49 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member c expected 1 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member b expected 49 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member l expected 49 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member f expected 49.0 but got 0.0", testPath)
- });
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Convert "singleton" instance to array of the correct type
- * @throws Exception
- */
- public void testArrayification() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.AnnotationWithArray;\n" +
- "@AnnotationWithArray(booleans=true,\n" +
- " bytes=(byte)49,\n" +
- " shorts=(short)49,\n" +
- " ints=49,\n" +
- " longs=49,\n" +
- " floats=49,\n" +
- " doubles=49,\n" +
- " chars='1')\n\n" +
- "public class Test {}\n" ;
-
- env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Convert "singleton" instance to array of the correct type
- * @throws Exception
- */
- public void testArrayification_Reflection() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.RefAnnotationWithArray;\n" +
- "@RefAnnotationWithArray(booleans=true,\n" +
- " bytes=(byte)49,\n" +
- " shorts=(short)49,\n" +
- " ints=49,\n" +
- " longs=49,\n" +
- " floats=49,\n" +
- " doubles=49,\n" +
- " chars='1')\n\n" +
- "public class Test {}\n" ;
-
- env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Test conversion on array elements.
- * @throws Exception
- */
- public void testArrayElementConversion() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.AnnotationWithArray;\n" +
- "@AnnotationWithArray(booleans={true, true },\n" +
- " bytes= {(byte)49, 50}, \n" +
- " shorts= {(byte)49, 50},\n" +
- " ints= {(byte)49, 50},\n" +
- " longs= {(byte)49, 50},\n" +
- " floats= {(byte)49, 50},\n" +
- " doubles={(byte)49, 50},\n" +
- " chars= {'1','2'})\n\n" +
- "public class Test {}\n";
-
- env.addClass(
- srcRoot,
- "sample",
- "Test",
- content );
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Test conversion on array elements.
- * @throws Exception
- */
- public void testArrayElementConversion_Reflection() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.RefAnnotationWithArray;\n" +
- "@RefAnnotationWithArray(booleans={true, true },\n" +
- " bytes= {(byte)49, 50}, \n" +
- " shorts= {(byte)49, 50},\n" +
- " ints= {(byte)49, 50},\n" +
- " longs= {(byte)49, 50},\n" +
- " floats= {(byte)49, 50},\n" +
- " doubles={(byte)49, 50},\n" +
- " chars= {'1','2'})\n\n" +
- "public class Test {}\n" ;
-
- env.addClass(
- srcRoot,
- "sample",
- "Test",
- content );
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- public void testErrorStringValue() throws Exception {
-
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.AnnotationWithArray;\n" +
- "@AnnotationWithArray(booleans={true, true },\n" +
- " bytes= {(byte)49, 50}, \n" +
- " shorts= {(byte)49, 50},\n" +
- " ints= {(byte)49, 50},\n" +
- " longs= {(byte)49, 50},\n" +
- " floats= {(byte)49, 50},\n" +
- " doubles={(byte)49, 50},\n" +
- " chars= {'1','2'},\n" +
- " str=true)\n\n" +
- "public class Test {}\n";
-
- env.addClass(
- srcRoot,
- "sample",
- "Test",
- content );
- IPath testPath = env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
-
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from boolean to String", testPath),
- new ExpectedProblem("", "type mismatch for member str expected java.lang.String but got java.lang.Boolean", testPath)
- });
- }
-
- public void testErrorStringValue_Reflection() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.RefAnnotationWithArray;\n" +
- "@RefAnnotationWithArray(booleans={true, true },\n" +
- " bytes= {(byte)49, 50}, \n" +
- " shorts= {(byte)49, 50},\n" +
- " ints= {(byte)49, 50},\n" +
- " longs= {(byte)49, 50},\n" +
- " floats= {(byte)49, 50},\n" +
- " doubles={(byte)49, 50},\n" +
- " chars= {'1','2'},\n" +
- " str=true)\n\n" +
- "public class Test {}\n";
-
- IPath testPath = env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
-
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "Type mismatch: cannot convert from boolean to String", testPath),
- new ExpectedProblem("", "value mismatch for member str expected string but got null", testPath)
- });
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- public void testMissingPrimitiveTypeValues_Reflection() throws Exception {
- IProject project = setupTest();
- IPath srcRoot = getSourcePath();
-
- String content =
- "package sample; \n\n" +
- "import org.eclipse.jdt.apt.tests.annotations.valueconversion.RefAnnotation;\n" +
- "@RefAnnotation()\n"+
- "public class Test {}\n";
-
- IPath testPath = env.addClass( srcRoot, "sample", "Test", content );
- fullBuild( project.getFullPath() );
-
- expectingSpecificProblemsFor(testPath, new ExpectedProblem[]{
- new ExpectedProblem("", "The annotation @RefAnnotation must define the attribute z", testPath),
- new ExpectedProblem("", "The annotation @RefAnnotation must define the attribute c", testPath),
- new ExpectedProblem("", "The annotation @RefAnnotation must define the attribute b", testPath),
- new ExpectedProblem("", "The annotation @RefAnnotation must define the attribute s", testPath),
- new ExpectedProblem("", "The annotation @RefAnnotation must define the attribute i", testPath),
- new ExpectedProblem("", "The annotation @RefAnnotation must define the attribute l", testPath),
- new ExpectedProblem("", "The annotation @RefAnnotation must define the attribute f", testPath),
- new ExpectedProblem("", "The annotation @RefAnnotation must define the attribute d", testPath),
- new ExpectedProblem("", "value mismatch for member z expected true but got false", testPath),
- new ExpectedProblem("", "value mismatch for member s expected 49 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member i expected 49 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member c expected 1 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member b expected 49 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member l expected 49 but got 0", testPath),
- new ExpectedProblem("", "value mismatch for member f expected 49.0 but got 0.0", testPath),
- new ExpectedProblem("", "value mismatch for member d expected 49.0 but got 0.0", testPath)
- });
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-}
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 3bab682368..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java
+++ /dev/null
@@ -1,707 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.core.runtime.Path;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.apt.core.util.AptPreferenceConstants;
-import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotationProcessor;
-import org.eclipse.jdt.apt.tests.annotations.messager.MessagerAnnotationProcessor;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.tests.util.Util;
-
-public class AptBuilderTests extends APTTestBase
-{
-
- 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
- // create a project with a src directory as the project root directory
- //
- IPath projectPath = env.addProject( getProjectName_ProjectRootAsSrcDir(), "1.5" );
- env.addExternalJars( projectPath, Util.getJavaClassLibs() );
- fullBuild( projectPath );
-
- // remove old package fragment root so that names don't collide
- env.setOutputFolder( projectPath, "bin" ); //$NON-NLS-1$
-
- IJavaProject jproj = env.getJavaProject( projectPath );
- AptConfig.setEnabled( jproj, true );
- TestUtil.createAndAddAnnotationJar( jproj );
-
- }
-
- public static String getProjectName_ProjectRootAsSrcDir()
- {
- return AptBuilderTests.class.getName() + "NoSrcProject"; //$NON-NLS-1$
- }
-
- public IPath getSourcePath( String projectName )
- {
- if ( getProjectName_ProjectRootAsSrcDir().equals( projectName) )
- return new Path( "/" + getProjectName_ProjectRootAsSrcDir() );
- else
- {
- IProject project = env.getProject( projectName );
- IFolder srcFolder = project.getFolder( "src" ); //$NON-NLS-1$
- IPath srcRoot = srcFolder.getFullPath();
- return srcRoot;
- }
- }
- public void testGeneratedFileInBuilder() throws Exception
- {
- _testGeneratedFileInBuilder0( getProjectName() );
- }
-
- /**
- * Regresses Buzilla 103745 & 95661
- */
-
- public void testGeneratedFileInBuilder_ProjectRootAsSourceDir() throws Exception
- {
- _testGeneratedFileInBuilder0( getProjectName_ProjectRootAsSrcDir() );
- }
-
-
- public void testGeneratedFileInBuilder1() throws Exception{
- _testGeneratedFileInBuilder1( getProjectName() );
- }
-
- private void _testGeneratedFileInBuilder0(String projectName){
- IProject project = env.getProject( projectName );
- IPath srcRoot = getSourcePath( projectName );
-
- 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 ExpectedProblem(
- "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] );
- }
-
- /**
- * slight variation to _testGeneratedFileInBuilder0.
- * Difference:
- * The method invocation is not fully qualified and an import is added.
- */
- private void _testGeneratedFileInBuilder1( String projectName )
- {
- IProject project = env.getProject( projectName );
- IPath srcRoot = getSourcePath( projectName );
-
- String code = "package p1;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;"
- + "import generatedfilepackage.GeneratedFileTest;"
- + "\n" + "public class A " + "\n" + "{"
- + " @HelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " GeneratedFileTest.helloWorld();"
- + "\n" + " }" + "\n" + "}" + "\n";
-
- env.addClass( srcRoot, "p1", "A", code );
- fullBuild( project.getFullPath() );
-
- expectingOnlyProblemsFor( new IPath[0] );
- }
-
- /**
- * Try generating a bogus type name; expect exception
- */
- public void testGeneratingIllegalTypeName()
- {
- String projectName = getProjectName();
- clearProcessorResult(HelloWorldAnnotationProcessor.class);
- IProject project = env.getProject( projectName );
- IPath srcRoot = getSourcePath( projectName );
-
- String code = "package p1;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;"
- + "import generatedfilepackage.GeneratedFileTest;"
- + "\n" + "public class A " + "\n" + "{"
- + " @HelloWorldAnnotation(\"Bad-Type-Name\")" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " GeneratedFileTest.helloWorld();"
- + "\n" + " }" + "\n" + "}" + "\n";
-
- env.addClass( srcRoot, "p1", "A", code );
- fullBuild( project.getFullPath() );
- assertEquals("Could not generate text file due to IOException", getProcessorResult(HelloWorldAnnotationProcessor.class));
-
- // Type "lowercase" would cause a warning in the new type wizard, because it doesn't start with caps.
- // Test that we do not issue a warning or error in this case.
- String code2 = "package p1;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;"
- + "import generatedfilepackage.lowercase;"
- + "\n" + "public class A " + "\n" + "{"
- + " @HelloWorldAnnotation(\"lowercase\")" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " lowercase.helloWorld();"
- + "\n" + " }" + "\n" + "}" + "\n";
-
- env.addClass( srcRoot, "p1", "A", code2 );
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- }
-
- /**
- * Try running two processors on the same file, and look for interactions.
- * Regression for https://bugs.eclipse.org/bugs/show_bug.cgi?id=175794
- */
- public void testTwoAnnotations()
- {
- String projectName = getProjectName();
- clearProcessorResult(HelloWorldAnnotationProcessor.class);
- clearProcessorResult(MessagerAnnotationProcessor.class);
- IProject project = env.getProject( projectName );
- IPath srcRoot = getSourcePath( projectName );
-
- String codeMessageFirst = "package p1;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.messager.MessagerAnnotation;\n"
- + "import generatedfilepackage.GeneratedFileTest;\n"
- + "@MessagerAnnotation(severity=MessagerAnnotation.Severity.ERROR)\n"
- + "@HelloWorldAnnotation\n"
- + "public class A {\n"
- + " public static void main( String[] argv ) {\n"
- + " GeneratedFileTest.helloWorld();\n"
- + " }\n"
- + "}\n";
-
- IPath p1aPath = env.addClass( srcRoot, "p1", "A", codeMessageFirst );
- fullBuild( project.getFullPath() );
- checkProcessorResult(HelloWorldAnnotationProcessor.class);
- checkProcessorResult(MessagerAnnotationProcessor.class);
- expectingOnlySpecificProblemFor( p1aPath, new ExpectedProblem(
- "A", MessagerAnnotationProcessor.PROBLEM_TEXT_ERROR, p1aPath ) ); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
-
- /**
- * 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( getProjectName() );
-
- String code = "package p1;\n"
- + "//import org.eclipse.jdt.apt.tests.annotations.nestedhelloworld.NestedHelloWorldAnnotation;"
- + "import generatedfilepackage.GeneratedFileTest;"
- + "\n" + "public class A " + "\n" + "{"
- + " //@NestedHelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " 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 ExpectedProblem(
- "A", "GeneratedFileTest cannot be resolved", p1aPath ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- code = "package p1;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.nestedhelloworld.NestedHelloWorldAnnotation;\n"
- + "import generatedfilepackage.GeneratedFileTest;"
- + "\n" + "public class A " + "\n" + "{"
- + " @NestedHelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " 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; }";
-
- 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 codeC2 = "package p1.p2.p3.p4;\n"
- + "public class C { public int foo; }";
-
- 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( getProjectName() );
-
- 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 { }";
-
- env.addClass( srcRoot, "p1.p2.p3.p4", "A", //$NON-NLS-1$ //$NON-NLS-2$
- codeA );
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- // touch C
- env.addClass( srcRoot, "p1.p2.p3.p4", "C", //$NON-NLS-1$ //$NON-NLS-2$
- codeC2 );
-
- 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.C", "p1.p2.p3.p4.A", "p1.p2.p3.p4.A"}); //$NON-NLS-1$ //$NON-NLS-2$
- expectingCompilingOrder(new String[]{"p1.p2.p3.p4.C", "p1.p2.p3.p4.A", "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 remove 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 );
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- // touch C
- env.addClass( srcRoot, "p1.p2.p3.p4", "C", //$NON-NLS-1$ //$NON-NLS-2$
- codeC2 );
-
- 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.C" }); //$NON-NLS-1$ //$NON-NLS-2$
- expectingCompilingOrder(new String[]{"p1.p2.p3.p4.C" }); //$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"
- + " }"
- + "\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"
- + " "
- + "\n"
- + " }"
- + "\n"
- + " public static void otherMethod()" + "\n" + " {"
- + " System.out.println();\n"
- + " }"
- + "}"
- + "\n";
-
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath( getProjectName() );
-
- 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$
-
- // 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( getProjectName() );
-
- 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
- // TODO: Is there a more reliable, consistent, and efficient way to wait?
- sleep( 1000 );
-
- incrementalBuild( project.getFullPath() );
- expectingOnlyProblemsFor( p1bPath );
- expectingOnlySpecificProblemFor( p1bPath, new ExpectedProblem(
- "B", "generatedfilepackage 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( getProjectName() );
-
- String code = "package p1;\n"
- + "//import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;\n"
- + "import generatedfilepackage.GeneratedFileTest;"
- + "\n" + "public class A " + "\n" + "{"
- + " //@HelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " 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 );
- expectingOnlySpecificProblemsFor( p1aPath, new ExpectedProblem[]{
- new ExpectedProblem( "A", "The import generatedfilepackage cannot be resolved", p1aPath ),
- new ExpectedProblem( "A", "GeneratedFileTest cannot be resolved", p1aPath ) }
- ); //$NON-NLS-1$ //$NON-NLS-2$
-
- code = "package p1;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;"
- + "import generatedfilepackage.GeneratedFileTest;"
- + "\n" + "public class A " + "\n" + "{"
- + " @HelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " 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;"
- + "import generatedfilepackage.GeneratedFileTest;"
- + "\n" + "public class A " + "\n" + "{"
- + " //@HelloWorldAnnotation" + "\n"
- + " public static void main( String[] argv )" + "\n" + " {"
- + "\n"
- + " GeneratedFileTest.helloWorld();"
- + "\n" + " }" + "\n" + "}" + "\n";
-
- env.addClass( srcRoot, "p1", "A", code );
-
- if ( fullBuild )
- fullBuild( project.getFullPath() );
- else
- incrementalBuild( project.getFullPath() );
-
- expectingOnlyProblemsFor( p1aPath );
-
- expectingOnlySpecificProblemFor( p1aPath,
- new ExpectedProblem( "A", "GeneratedFileTest cannot be resolved", p1aPath ) ); //$NON-NLS-1$
- }
-
- public void testAPTRounding()
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath( getProjectName() );
-
- String codeX = "package p1;\n"
- + "\n import org.eclipse.jdt.apt.tests.annotations.aptrounding.*;"
- + "\n@GenBean\n"
- + "public class X {}\n";
-
- env.addClass( srcRoot, "p1", "X", codeX );
-
- String codeY = "package p1;\n"
- + "\n import org.eclipse.jdt.apt.tests.annotations.aptrounding.*;"
- + "public class Y { @GenBean2 test.Bean _bean = null; }\n";
-
- env.addClass( srcRoot, "p1", "Y", codeY );
-
- fullBuild( project.getFullPath() );
-
- expectingNoProblems();
- }
-
- public void testConfigMarker() throws Exception{
- final String projectName = "ConfigMarkerTestProject";
- final IJavaProject javaProj = createJavaProject( projectName );
- // apt is currently disabled save off the cp before configuration
- final IClasspathEntry[] cp = javaProj.getRawClasspath();
- IProject project = env.getProject( projectName );
- IPath srcRoot = getSourcePath( projectName );
- // this will cause a type generation.
- String code = "package pkg;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;"
- + "\npublic class Foo{\n"
- + " @HelloWorldAnnotation\n"
- + " public static void main( String[] argv ){}"
- + "\n}";
-
- env.addClass( srcRoot, "pkg", "Foo", code );
-
- AptConfig.setEnabled(javaProj, true);
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- expectingNoMarkers();
-
- // wipe out the source folder from the classpath.
- javaProj.setRawClasspath(cp, null);
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- // make sure we post the marker about the incorrect classpath
- expectingMarkers(new String[]{"Generated source folder '" +
- AptPreferenceConstants.DEFAULT_GENERATED_SOURCE_FOLDER_NAME +
- "' is missing from classpath"} );
-
- // take out the annotation and no type generation will occur.
- code = "package pkg;\n"
- + "\npublic class Foo{\n"
- + " public static void main( String[] argv ){}"
- + "\n}";
-
- env.addClass( srcRoot, "pkg", "Foo", code );
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- // Make sure we cleaned out config marker from previous build
- // We don't need to generate types, hence we should not register the config marker
- expectingNoMarkers();
- }
-
- public void testDeletedGeneratedSourceFolder()
- throws Exception
- {
- final String projectName = "DeleteGenSourceFolderTestProject";
- final IJavaProject javaProj = createJavaProject( projectName );
- IProject project = env.getProject( projectName );
- IPath srcRoot = getSourcePath( projectName );
- // this will cause a type generation.
- String code = "package pkg;\n"
- + "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;"
- + "\npublic class Foo{\n"
- + " @HelloWorldAnnotation\n"
- + " public static void main( String[] argv ){}"
- + "\n}";
-
- env.addClass( srcRoot, "pkg", "Foo", code );
- AptConfig.setEnabled(javaProj, true);
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- expectingNoMarkers();
-
- GeneratedSourceFolderManager mgr = AptPlugin.getAptProject(javaProj).getGeneratedSourceFolderManager();
- IFolder srcFolder = mgr.getFolder();
- assertEquals(true, srcFolder.exists());
- // delete the gen source folder
- srcFolder.delete(true, false, null);
- assertEquals(false, srcFolder.exists());
-
- // we would have re-created the folder on the next build
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- expectingNoMarkers();
- }
-
-}
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 12ec82f2a0..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptReconcileTests.java
+++ /dev/null
@@ -1,556 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedFileManager;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-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
-{
- IJavaProject _jproject;
-
- public AptReconcileTests(String name)
- {
- super( name );
- }
-
- public static Test suite() {
- return new TestSuite(AptReconcileTests.class);
- }
-
- public void testGeneratedFile() throws Throwable
- {
- String fname = _testFolder + "/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 /" + _testProject + "/src/test/A.java (at line 8)\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();\n" +
- " ^^^^^^^^^^^^^^^^^^^^\n" +
- "generatedfilepackage cannot be resolved\n" +
- "----------\n" +
- "----------\n" +
- "2. ERROR in /" + _testProject + "/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.
- * TODO: re-enable this test - it seems sporadically flaky, need to find out why.
- * @throws Throwable
- */
- public void testNestedGeneratedFile() throws Throwable
- {
- String fname = _testFolder + "/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 /" + _testProject + "/src/test/A.java (at line 8)\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();\n" +
- " ^^^^^^^^^^^^^^^^^^^^\n" +
- "generatedfilepackage cannot be resolved\n" +
- "----------\n" +
- "----------\n" +
- "2. ERROR in /" + _testProject + "/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 testStopGeneratingFileInReconciler() throws Exception
- {
- String fname = _testFolder + "/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 /" + _testProject + "/src/test/A.java (at line 8)\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();\n" +
- " ^^^^^^^^^^^^^^^^^^^^\n" +
- "generatedfilepackage cannot be resolved\n" +
- "----------\n" +
- "----------\n" +
- "2. ERROR in /" + _testProject + "/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" );
-
- //
- // now make sure errors come back when annotations are taken away
- //
- setWorkingCopyContents( codeWithErrors );
- this._workingCopy.reconcile( ICompilationUnit.NO_AST, true, null,
- null );
-
- String expectedProblems2 = "----------\n" +
- "1. ERROR in /" + _testProject + "/src/test/A.java (at line 8)\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();\n" +
- " ^^^^^^^^^^^^^^^^^^^^\n" +
- "generatedfilepackage cannot be resolved\n" +
- "----------\n";
- assertProblems( "Unexpected problems", expectedProblems2 );
- }
- catch (Exception e )
- {
- e.printStackTrace();
- throw e;
- }
- }
-
- /**
- * Tests that when a working copy is discarded, we clean up any cached data in the
- * GeneratedFileManager.
- */
- public void testDiscardParentWorkingCopy()
- throws Throwable
- {
- String fname = _testFolder + "/A.java";
- try
- {
- 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" +
- "}";
-
- createFile( fname, codeWithOutErrors );
- this._problemRequestor = new ProblemRequestor();
- setUpWorkingCopy( fname, codeWithOutErrors );
-
- // use new problem requestor to remove any errors that occurred in setUpWorkingCopy()
- this._problemRequestor = new ProblemRequestor();
- this._workingCopy.reconcile( ICompilationUnit.NO_AST, true, null,
- null );
-
- assertProblems( "UnexpectedProblems", "" );
-
- IJavaProject jp = _workingCopy.getJavaProject();
- GeneratedFileManager gfm = AptPlugin.getAptProject(jp).getGeneratedFileManager();
-
- if ( !gfm.containsWorkingCopyMapEntriesForParent((IFile)_workingCopy.getResource()))
- fail( "Expected to find map entries in GeneratedFileManager");
-
- _workingCopy.discardWorkingCopy();
-
- if ( gfm.containsWorkingCopyMapEntriesForParent( (IFile)_workingCopy.getResource() ) )
- fail( "Unexpected map entries in GeneratedFileManager!");
- }
- finally
- {
- deleteFile( fname );
- }
- }
-
- public void testBasicReconcile() throws Exception {
- String fname = _testFolder + "/X.java";
- try
- {
-
- String code = "package test;" + "\n" +
- "@org.eclipse.jdt.apt.tests.annotations.apitest.Common\n" +
- "public class X " + "\n" +
- "{" + "\n" +
- " public static void main( String[] argv )" + "\n" +
- " {" + "\n" +
- " }" + "\n" +
- "}";
-
- createFile( fname, code );
- this._problemRequestor = new ProblemRequestor();
-
- setUpWorkingCopy( fname, code );
- this._workingCopy.reconcile( ICompilationUnit.NO_AST, true, null,
- null );
-
- assertProblems( "UnexpectedProblems", "----------\n----------\n----------\n----------\n" );
-
- }
- finally
- {
- deleteFile( fname );
- }
-
- }
-
- public void testNoReconcile() throws Throwable {
- // Start by disabling reconcile-time processing
- AptConfig.setProcessDuringReconcile(_jproject, false);
- String fname = _testFolder + "/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 /" + _testProject + "/src/test/A.java (at line 8)\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();\n" +
- " ^^^^^^^^^^^^^^^^^^^^\n" +
- "generatedfilepackage cannot be resolved\n" +
- "----------\n" +
- "----------\n" +
- "2. ERROR in /" + _testProject + "/src/test/A.java (at line 8)\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();\n" +
- " ^^^^^^^^^^^^^^^^^^^^\n" +
- "generatedfilepackage cannot be resolved\n" +
- "----------\n";
-
- assertProblems( "Unexpected problems", expectedProblems );
-
-
- //
- // should still see errors when annotations are present but reconcile is off
- //
- String codeWithOutErrors1 = "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( codeWithOutErrors1 );
- this._workingCopy.reconcile( ICompilationUnit.NO_AST, true, null,
- null );
-
- String expectedProblems2 = "----------\n" +
- "1. ERROR in /" + _testProject + "/src/test/A.java (at line 8)\n" +
- " generatedfilepackage.GeneratedFileTest.helloWorld();\n" +
- " ^^^^^^^^^^^^^^^^^^^^\n" +
- "generatedfilepackage cannot be resolved\n" +
- "----------\n";
-
- assertProblems( "Unexpected problems", expectedProblems2 );
-
- //
- // now enable reconcile-time processing and make sure errors go away
- //
- AptConfig.setProcessDuringReconcile(_jproject, true);
- String codeWithOutErrors2 = "package test;" + "\n\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( codeWithOutErrors2 );
- 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
- {
- // This increments the project name for each test, which helps get past
- // sporadic threading problems. It has not been necessary lately - WHarley 12/06
- //++_testProjectNum;
- _testProject = TEST_PROJECT + _testProjectNum;
- _testFolder = "/" + _testProject + "/src/test";
- AptPlugin.trace("Setting up " + _testProject );
-
- super.setUp();
- // disable auto-build. We don't want build-time type-generation interfering with
- // our reconcile tests.
- String key = ResourcesPlugin.PREF_AUTO_BUILDING;
- boolean value = false;
- ResourcesPlugin.getPlugin().getPluginPreferences().setValue(key, value);
-
- this._problemRequestor = new ProblemRequestor();
-
- final IJavaProject project = createJavaProject( _testProject,
- new String[] { "src" }, new String[] { "JCL15_LIB" },
- "bin", "1.5" );
- TestUtil.createAndAddAnnotationJar(project);
- AptConfig.setEnabled(project, true);
-
- createFolder( _testFolder );
- _jproject = project;
-
- }
- public void tearDown() throws Exception
- {
- _jproject = null;
- AptPlugin.trace("Tearing down " + _testProject );
-
- deleteProject( _testProject );
- super.tearDown();
- }
-
- /***************************************************************************
- *
- * copied from ReconcilerTests...
- *
- */
-
- private void setWorkingCopyContents(String contents)
- throws JavaModelException
- {
- this._workingCopy.getBuffer().setContents( contents );
- this._problemRequestor.initialize( contents.toCharArray() );
- }
-
- @SuppressWarnings("deprecation")
- 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;
-
- private static String _testProject;
-
- private static String _testFolder;
-
- private static int _testProjectNum = 0;
-
- private static final String TEST_PROJECT = AptReconcileTests.class.getName() + "Project"; //$NON-NLS-1$
-
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/DeclarationVisitorTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/DeclarationVisitorTests.java
deleted file mode 100644
index 2e0aa609c9..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/DeclarationVisitorTests.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.tests.annotations.generic.AbstractGenericProcessor;
-import org.eclipse.jdt.apt.tests.annotations.generic.GenericFactory;
-
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
-import com.sun.mirror.declaration.ClassDeclaration;
-import com.sun.mirror.declaration.ConstructorDeclaration;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.EnumConstantDeclaration;
-import com.sun.mirror.declaration.EnumDeclaration;
-import com.sun.mirror.declaration.ExecutableDeclaration;
-import com.sun.mirror.declaration.FieldDeclaration;
-import com.sun.mirror.declaration.InterfaceDeclaration;
-import com.sun.mirror.declaration.MemberDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.PackageDeclaration;
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.declaration.TypeParameterDeclaration;
-import com.sun.mirror.util.DeclarationVisitor;
-
-/**
- * Tests for the JDT-APT implementation of Declaration Visitors
- */
-public class DeclarationVisitorTests extends APTTestBase {
-
- public DeclarationVisitorTests(final String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(DeclarationVisitorTests.class);
- }
-
- public void testPackageDeclarationVisitor() {
- testCaseIdentifier = Cases.PackageDeclaration;
- runProcessorBasedTest();
- }
-
- public void testClassDeclarationVisitor() {
- testCaseIdentifier = Cases.ClassDeclaration;
- runProcessorBasedTest();
- }
-
- public void testEnumDeclarationVisitor() {
- testCaseIdentifier = Cases.EnumDeclaration;
- runProcessorBasedTest();
- }
-
- public void testInterfaceDeclarationVisitor() {
- testCaseIdentifier = Cases.InterfaceDeclaration;
- runProcessorBasedTest();
- }
-
- public void testAnnotationTypeDeclarationVisitor() {
- testCaseIdentifier = Cases.AnnotationTypeDeclaration;
- runProcessorBasedTest();
- }
-
- public void testFieldDeclarationVisitor() {
- testCaseIdentifier = Cases.FieldDeclaration;
- runProcessorBasedTest();
- }
-
- public void testEnumConstantDeclarationVisitor() {
- testCaseIdentifier = Cases.EnumConstantDeclaration;
- runProcessorBasedTest();
- }
-
- public void testConstructorDeclarationVisitor() {
- testCaseIdentifier = Cases.ConstructorDeclaration;
- runProcessorBasedTest();
- }
-
- public void testMethodDeclarationVisitor() {
- testCaseIdentifier = Cases.MethodDeclaration;
- runProcessorBasedTest();
- }
-
- public void testAnnotationTypeElementDeclarationVisitor() {
- testCaseIdentifier = Cases.AnnotationTypeElementDeclaration;
- runProcessorBasedTest();
- }
-
- public void testParameterDeclarationVisitor() {
- testCaseIdentifier = Cases.ParameterDeclaration;
- runProcessorBasedTest();
- }
-
- public void testTypeParameterDeclarationVisitor() {
- testCaseIdentifier = Cases.TypeParameterDeclaration;
- runProcessorBasedTest();
- }
-
-
- /**
- * Instantiate the AnnotationProcessor to run the actual tests
- */
- void runProcessorBasedTest() {
- DeclarationVisitorProc p = new DeclarationVisitorProc();
- GenericFactory.PROCESSOR = p;
-
- IProject project = env.getProject(getProjectName());
- IPath srcRoot = getSourcePath();
-
- env.addClass(srcRoot, "test", "Test", code);
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- assertTrue("Processor not invoked", p.called);
- }
-
-
- /**
- * Annotation Processor containing the actual tests
- */
- class DeclarationVisitorProc extends AbstractGenericProcessor {
- boolean called;
-
- public void _process() {
-
- called = true;
- assertTrue(decls.size() == 1);
-
- initDeclVisitList();
-
- TypeDeclaration typeDecl = env.getTypeDeclarations().iterator().next();
- Collection<TypeDeclaration> nestedTypes = typeDecl.getNestedTypes();
- ClassDeclaration classDecl = null;
- EnumDeclaration enumDecl = null;
- InterfaceDeclaration interfaceDecl = null;
- AnnotationTypeDeclaration annoTypeDecl = null;
- EnumConstantDeclaration enumConstantDecl = null;
- MethodDeclaration methodDecl = null;
-
- switch (testCaseIdentifier) {
-
- case PackageDeclaration :
- PackageDeclaration packageDecl = typeDecl.getPackage();
- packageDecl.accept(new DeclarationVisitorImpl());
- assertEquals("Expect one visitor", 1, declarationsVisited.size());
- assertEquals("Expected PackageDeclaration visitor", "PackageDeclarationImpl", declarationsVisited.get(0).getClass().getSimpleName());
- break;
-
- case ClassDeclaration :
- for(TypeDeclaration tempDecl : nestedTypes) {
- if(tempDecl.getSimpleName().equals("C")) {
- classDecl = (ClassDeclaration)tempDecl;
- }
- }
- classDecl.accept(new DeclarationVisitorImpl());
- assertEquals("Expect one visitor", 1, declarationsVisited.size());
- assertEquals("Expected ClassDeclaration visitor", "ClassDeclarationImpl", declarationsVisited.get(0).getClass().getSimpleName());
- break;
-
- case EnumDeclaration :
- for(TypeDeclaration tempDecl : nestedTypes) {
- if(tempDecl.getSimpleName().equals("E")) {
- enumDecl = (EnumDeclaration)tempDecl;
- }
- }
- enumDecl.accept(new DeclarationVisitorImpl());
- assertEquals("Expect one visitor", 1, declarationsVisited.size());
- assertEquals("Expected EnumDeclaration visitor", "EnumDeclarationImpl", declarationsVisited.get(0).getClass().getSimpleName());
- break;
-
- case InterfaceDeclaration :
- for(TypeDeclaration tempDecl : nestedTypes) {
- if(tempDecl.getSimpleName().equals("I")) {
- interfaceDecl = (InterfaceDeclaration)tempDecl;
- }
- }
- interfaceDecl.accept(new DeclarationVisitorImpl());
- assertEquals("Expect one visitor", 1, declarationsVisited.size());
- assertEquals("Expected InterfaceDeclaration visitor", "InterfaceDeclarationImpl", declarationsVisited.get(0).getClass().getSimpleName());
- break;
-
- case AnnotationTypeDeclaration :
- for(TypeDeclaration tempDecl : nestedTypes) {
- if(tempDecl.getSimpleName().equals("A")) {
- annoTypeDecl = (AnnotationTypeDeclaration)tempDecl;
- }
- }
- annoTypeDecl.accept(new DeclarationVisitorImpl());
- assertEquals("Expect one visitor", 1, declarationsVisited.size());
- assertEquals("Expected AnnotationTypeDeclaration visitor", "AnnotationDeclarationImpl", declarationsVisited.get(0).getClass().getSimpleName());
- break;
-
- case FieldDeclaration :
- FieldDeclaration fieldDecl = typeDecl.getFields().iterator().next();
- fieldDecl.accept(new DeclarationVisitorImpl());
- assertEquals("Expect one visitor", 1, declarationsVisited.size());
- assertEquals("Expected FieldDeclaration visitor", "FieldDeclarationImpl", declarationsVisited.get(0).getClass().getSimpleName());
- break;
-
- case EnumConstantDeclaration :
- for(TypeDeclaration tempDecl : nestedTypes) {
- if(tempDecl.getSimpleName().equals("E")) {
- enumDecl = (EnumDeclaration)tempDecl;
- }
- }
- enumConstantDecl = enumDecl.getEnumConstants().iterator().next();
- enumConstantDecl.accept(new DeclarationVisitorImpl());
- assertEquals("Expect one visitor", 1, declarationsVisited.size());
- assertEquals("Expected EnumConstantDeclaration visitor", "EnumConstantDeclarationImpl", declarationsVisited.get(0).getClass().getSimpleName());
- break;
-
- case ConstructorDeclaration :
- for(TypeDeclaration tempDecl : nestedTypes) {
- if(tempDecl.getSimpleName().equals("C")) {
- classDecl = (ClassDeclaration)tempDecl;
- }
- }
- ConstructorDeclaration constructorDecl = classDecl.getConstructors().iterator().next();
- constructorDecl.accept(new DeclarationVisitorImpl());
- assertEquals("Expect one visitor", 1, declarationsVisited.size());
- assertEquals("Expected ConstructorDeclaration visitor", "ConstructorDeclarationImpl", declarationsVisited.get(0).getClass().getSimpleName());
- break;
-
- case MethodDeclaration :
- methodDecl = typeDecl.getMethods().iterator().next();
- methodDecl.accept(new DeclarationVisitorImpl());
- assertEquals("Expect one visitor", 1, declarationsVisited.size());
- assertEquals("Expected MethodDeclaration visitor", "MethodDeclarationImpl", declarationsVisited.get(0).getClass().getSimpleName());
- break;
-
- case AnnotationTypeElementDeclaration :
- for(TypeDeclaration tempDecl : nestedTypes) {
- if(tempDecl.getSimpleName().equals("A")) {
- annoTypeDecl = (AnnotationTypeDeclaration)tempDecl;
- }
- }
- AnnotationTypeElementDeclaration annoTypeElementDecl = annoTypeDecl.getMethods().iterator().next();
- annoTypeElementDecl.accept(new DeclarationVisitorImpl());
- assertEquals("Expect one visitor", 1, declarationsVisited.size());
- assertEquals("Expected AnnotationTypeElementDeclaration visitor", "AnnotationElementDeclarationImpl", declarationsVisited.get(0).getClass().getSimpleName());
- break;
-
- case ParameterDeclaration :
- methodDecl = typeDecl.getMethods().iterator().next();
- ParameterDeclaration paramDecl = methodDecl.getParameters().iterator().next();
- paramDecl.accept(new DeclarationVisitorImpl());
- assertEquals("Expect one visitor", 1, declarationsVisited.size());
- assertEquals("Expected ParameterDeclaration visitor", "SourceParameterDeclarationImpl", declarationsVisited.get(0).getClass().getSimpleName());
- break;
-
- case TypeParameterDeclaration :
- for(TypeDeclaration tempDecl : nestedTypes) {
- if(tempDecl.getSimpleName().equals("P")) {
- classDecl = (ClassDeclaration)tempDecl;
- }
- }
- TypeParameterDeclaration typeParamDecl = classDecl.getFormalTypeParameters().iterator().next();
- typeParamDecl.accept(new DeclarationVisitorImpl());
- assertEquals("Expect one visitor", 1, declarationsVisited.size());
- assertEquals("Expected TypeParameterDeclaration visitor", "TypeParameterDeclarationImpl", declarationsVisited.get(0).getClass().getSimpleName());
- break;
- }
-
- }
-
- }
-
-
- /**
- * DeclarationVisitor implementation for the purposes of these tests
- */
- class DeclarationVisitorImpl implements DeclarationVisitor {
-
- public void visitDeclaration(Declaration d) {
- fail("Should never visit a Declaration, only a subclass: " + d);
- }
-
- public void visitPackageDeclaration(PackageDeclaration d) {
- declarationVisited(d);
- }
-
- public void visitMemberDeclaration(MemberDeclaration d) {
- fail("Should never visit a Member, only a subclass: " + d);
- }
-
- public void visitTypeDeclaration(TypeDeclaration d) {
- fail("Should never visit a Type, only a subclass: " + d);
- }
-
- public void visitClassDeclaration(ClassDeclaration d) {
- declarationVisited(d);
- }
-
- public void visitEnumDeclaration(EnumDeclaration d) {
- declarationVisited(d);
- }
-
- public void visitInterfaceDeclaration(InterfaceDeclaration d) {
- declarationVisited(d);
- }
-
- public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {
- declarationVisited(d);
- }
-
- public void visitFieldDeclaration(FieldDeclaration d) {
- declarationVisited(d);
- }
-
- public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {
- declarationVisited(d);
- }
-
- public void visitExecutableDeclaration(ExecutableDeclaration d) {
- fail("Should never visit an ExecutableDeclaration, only a subclass: " + d);
- }
-
- public void visitConstructorDeclaration(ConstructorDeclaration d) {
- declarationVisited(d);
- }
-
- public void visitMethodDeclaration(MethodDeclaration d) {
- declarationVisited(d);
- }
-
- public void visitAnnotationTypeElementDeclaration(AnnotationTypeElementDeclaration d) {
- declarationVisited(d);
- }
-
- public void visitParameterDeclaration(ParameterDeclaration d) {
- declarationVisited(d);
- }
-
- public void visitTypeParameterDeclaration(TypeParameterDeclaration d) {
- declarationVisited(d);
- }
- }
-
-
- /*
- * Utilities for running the DeclarationVisitor tests
- */
-
- enum Cases {
- PackageDeclaration,
- ClassDeclaration,
- EnumDeclaration,
- InterfaceDeclaration,
- AnnotationTypeDeclaration,
- FieldDeclaration,
- EnumConstantDeclaration,
- ConstructorDeclaration,
- MethodDeclaration,
- AnnotationTypeElementDeclaration,
- ParameterDeclaration,
- TypeParameterDeclaration
- }
-
- Cases testCaseIdentifier;
-
- ArrayList<Declaration> declarationsVisited = new ArrayList<Declaration>();
-
- void declarationVisited(Declaration d) {
- declarationsVisited.add(d);
- }
-
- void initDeclVisitList() {
- if(declarationsVisited.size() > 0) {
- declarationsVisited.clear();
- }
- }
-
- final String code =
- "package test;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.generic.*;" + "\n" +
- "@GenericAnnotation public class Test" + "\n" +
- "{" + "\n" +
- " Test() {}" + "\n" +
- " String s;" + "\n" +
- " class C {}" + "\n" +
- " class P<T> {}" + "\n" +
- " interface I {}" + "\n" +
- " void m(int i) {}" + "\n" +
- " enum E { elephant }" + "\n" +
- " @interface A { String strValue() default \"\"; }" + "\n" +
- "}";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ExceptionHandlingTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ExceptionHandlingTests.java
deleted file mode 100644
index d1122aecc1..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ExceptionHandlingTests.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 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:
- * sbandow@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.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-
-public class ExceptionHandlingTests extends APTTestBase {
-
- public ExceptionHandlingTests(final String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(ExceptionHandlingTests.class);
- }
-
- /**
- * Annotation that expects a primitive but gets its wrapper class should not throw a ClassCastException
- */
- public void testWrapperClassForPrimitiveValue() throws Exception {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- IPath testPath = env.addClass(srcRoot, "test", "Test", getCodeForTest("booleanValue = new Boolean(true)"));
-
- fullBuild( project.getFullPath() );
- expectingOnlySpecificProblemFor(testPath, new ExpectedProblem("Test", "Type mismatch: cannot convert from Boolean to boolean", testPath));
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Annotation that expects one primitive but gets another should not throw a ClassCastException
- */
- public void testOtherPrimitiveForBooleanValue() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- IPath testPath = env.addClass(srcRoot, "test", "Test", getCodeForTest("booleanValue = 2"));
-
- fullBuild( project.getFullPath() );
- expectingOnlySpecificProblemFor(testPath, new ExpectedProblem("Test", "Type mismatch: cannot convert from int to boolean", testPath));
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Annotation that expects a primitive but gets a String should not throw a ClassCastException
- */
- public void testStringForBooleanValue() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- IPath testPath = env.addClass(srcRoot, "test", "Test", getCodeForTest("booleanValue = \"not a boolean\""));
-
- fullBuild( project.getFullPath() );
- expectingOnlySpecificProblemFor(testPath, new ExpectedProblem("Test", "Type mismatch: cannot convert from String to boolean", testPath));
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Annotation that expects a primitive but gets an array should not throw a ClassCastException
- */
- public void testArrayForBooleanValue() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- IPath testPath = env.addClass(srcRoot, "test", "Test", getCodeForTest("booleanValue = {}"));
-
- fullBuild( project.getFullPath() );
- ExpectedProblem ep = new ExpectedProblem("Test", "Type mismatch: cannot convert from Object[] to boolean", testPath);
- expectingOnlySpecificProblemFor(testPath, ep);
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Annotation that expects a String but gets a primitive should not throw a ClassCastException
- */
- public void testPrimitiveForStringValue() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- IPath testPath = env.addClass(srcRoot, "test", "Test", getCodeForTest("strValue = true"));
-
- fullBuild( project.getFullPath() );
- expectingOnlySpecificProblemFor(testPath, new ExpectedProblem("Test", "Type mismatch: cannot convert from boolean to String", testPath));
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Annotation that expects a String but gets another class should not throw a ClassCastException
- */
- public void testOtherClassForStringValue() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- IPath testPath = env.addClass(srcRoot, "test", "Test", getCodeForTest("strValue = new Object()"));
-
- fullBuild( project.getFullPath() );
- expectingOnlySpecificProblemFor(testPath, new ExpectedProblem("Test", "Type mismatch: cannot convert from Object to String", testPath));
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Annotation that expects a String but gets an array should not throw a ClassCastException
- */
- public void testArrayForStringValue() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- IPath testPath = env.addClass(srcRoot, "test", "Test", getCodeForTest("strValue = {}"));
-
- fullBuild( project.getFullPath() );
- ExpectedProblem ep = new ExpectedProblem("Test", "Type mismatch: cannot convert from Object[] to String", testPath);
- expectingOnlySpecificProblemFor(testPath, ep);
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Annotation that expects an array but gets a primitive should not throw a ClassCastException
- */
- public void testPrimitiveForArrayValue() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- IPath testPath = env.addClass(srcRoot, "test", "Test", getCodeForTest("arrValue = 'c'"));
-
- fullBuild( project.getFullPath() );
- expectingOnlySpecificProblemFor(testPath, new ExpectedProblem("Test", "Type mismatch: cannot convert from char to String[]", testPath));
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Annotation that expects an array but gets an object should not throw a ClassCastException
- */
- public void testNonArrayForArrayValue() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- IPath testPath = env.addClass(srcRoot, "test", "Test", getCodeForTest("arrValue = new Object()"));
-
- fullBuild( project.getFullPath() );
- expectingOnlySpecificProblemFor(testPath, new ExpectedProblem("Test", "Type mismatch: cannot convert from Object to String[]", testPath));
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Annotation that expects an array of enums but gets an annotation should not throw a ClassCastException
- */
- public void testAnnotationForEnumArrayValue() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- IPath testPath = env.addClass(srcRoot, "test", "Test", getCodeForTest("enumsValue = @ExceptionHandlingAnnotation()"));
-
- fullBuild( project.getFullPath() );
- expectingOnlySpecificProblemFor(testPath, new ExpectedProblem("Test", "Type mismatch: cannot convert from ExceptionHandlingAnnotation to ExceptionHandlingAnnotation.EHAEnum[]", testPath));
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Set up the test code for APT exception handling tests
- * @param annoValue attribute values to pass to ExceptionHandlingAnnotation
- * @return complete test code
- */
- private static String getCodeForTest(String annoValue) {
- return "package test;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.exceptionhandling.ExceptionHandlingAnnotation;" + "\n" +
- "@ExceptionHandlingAnnotation(" +
- annoValue +
- ")" + "\n" +
- "public class Test" + "\n" +
- "{" + "\n" +
- "}";
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ExpectedProblem.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ExpectedProblem.java
deleted file mode 100644
index 19e4048351..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ExpectedProblem.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.tests.builder.Problem;
-
-/**
- * Represents a problem expected to be found by the test.
- * Similar to an IProblem, but allows skipping of offset and category
- *
- */
-public class ExpectedProblem {
-
- private final String _location;
- private final String _message;
- private final IPath _resourcePath;
- private final int _start;
- private final int _end;
-
- public ExpectedProblem(String location, String message, IPath resourcePath) {
- this (location, message, resourcePath, -1, -1);
- }
-
- public ExpectedProblem(String location,
- String message,
- IPath resourcePath,
- int start,
- int end)
- {
- _location = location;
- _message = message;
- _resourcePath = resourcePath;
- _start = start;
- _end = end;
- }
-
- public String getLocation() {
- return _location;
- }
-
- public boolean equalsProblem(final Problem problem) {
- if (problem == null)
- return false;
-
- // Ignore the location, as this is what Problem.equals does as well
- //if (!_location.equals(problem.getLocation())) return false;
- if (!_message.equals(problem.getMessage())) return false;
- if (!_resourcePath.equals(problem.getResourcePath())) return false;
- if (_start != -1 && _start != problem.getStart()) return false;
- if (_end != -1 && _end != problem.getEnd()) return false;
-
- return true;
- }
-
- public String toString(){
- return
- "Problem : "
- + _message
- + " [ resource : <"
- + _resourcePath
- + ">"
- + (" range : <" + _start + "," + _end + ">")
- + "]";
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/FactoryLoaderTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/FactoryLoaderTests.java
deleted file mode 100644
index b1f7bbf5f7..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/FactoryLoaderTests.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 - 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.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.apt.core.util.IFactoryPath;
-import org.eclipse.jdt.apt.tests.external.annotations.classloader.ColorAnnotationProcessor;
-import org.eclipse.jdt.apt.tests.external.annotations.classloader.ColorTestCodeExample;
-import org.eclipse.jdt.apt.tests.external.annotations.loadertest.LoaderTestAnnotationProcessor;
-import org.eclipse.jdt.apt.tests.external.annotations.loadertest.LoaderTestCodeExample;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-
-/**
- *
- */
-public class FactoryLoaderTests extends APTTestBase {
-
- private File _extJar; // external annotation jar
- private IPath _extVarJar; // external annotation jar, as a classpath-var-relative path
- private IPath _projectPath; // initialized in setUp(), cleared in tearDown()
-
- private final static String TEMPJARDIR_CPVAR = "FACTORYLOADERTEST_TEMP"; //$NON-NLS-1$
-
- public FactoryLoaderTests(String name)
- {
- super( name );
- }
-
- public static Test suite() {
- return new TestSuite( FactoryLoaderTests.class );
- }
-
- public void setUp() throws Exception {
- super.setUp();
-
- _projectPath = env.getProject( getProjectName() ).getFullPath();
- _extJar = TestUtil.createAndAddExternalAnnotationJar(
- env.getJavaProject( _projectPath ));
-
- // Create a classpath variable for the same jar file, so we can
- // refer to it that way.
- File canonicalJar = _extJar.getCanonicalFile();
- IPath jarDir = new Path( canonicalJar.getParent() );
- String extJarName = canonicalJar.getName();
- IPath varPath = new Path( TEMPJARDIR_CPVAR );
- _extVarJar = varPath.append( extJarName );
- JavaCore.setClasspathVariable( TEMPJARDIR_CPVAR, jarDir, null );
-
- IPath srcRoot = getSourcePath();
- String code = LoaderTestCodeExample.CODE;
- env.addClass(srcRoot, LoaderTestCodeExample.CODE_PACKAGE, LoaderTestCodeExample.CODE_CLASS_NAME, code);
-
- code = ColorTestCodeExample.CODE;
- env.addClass(srcRoot, ColorTestCodeExample.CODE_PACKAGE, ColorTestCodeExample.CODE_CLASS_NAME, code);
- }
-
- public void testExternalJarLoader() throws Exception {
- LoaderTestAnnotationProcessor.clearLoaded();
- IProject project = env.getProject( getProjectName() );
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- assertFalse(LoaderTestAnnotationProcessor.isLoaded());
-
- IJavaProject jproj = env.getJavaProject( getProjectName() );
- IFactoryPath ifp = AptConfig.getFactoryPath(jproj);
-
- // add _extJar to the factory list as an external jar, and rebuild.
- ifp.addExternalJar(_extJar);
- AptConfig.setFactoryPath(jproj, ifp);
-
- // rebuild and verify that the processor was loaded
- LoaderTestAnnotationProcessor.clearLoaded();
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- assertTrue(LoaderTestAnnotationProcessor.isLoaded());
-
- // Verify that we were able to run the ColorAnnotationProcessor successfully
- assertTrue(ColorAnnotationProcessor.wasSuccessful());
-
- // restore to the original
- ifp.removeExternalJar(_extJar);
- AptConfig.setFactoryPath(jproj, ifp);
-
- // rebuild and verify that the processor was not loaded.
- LoaderTestAnnotationProcessor.clearLoaded();
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- assertFalse(LoaderTestAnnotationProcessor.isLoaded());
-
- // add _extJar to the factory list as a class-path-relative jar, and rebuild.
- ifp.addVarJar(_extVarJar);
- AptConfig.setFactoryPath(jproj, ifp);
-
- // rebuild and verify that the processor was loaded
- LoaderTestAnnotationProcessor.clearLoaded();
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- assertTrue(LoaderTestAnnotationProcessor.isLoaded());
-
- // restore to the original
- ifp.removeVarJar(_extVarJar);
- AptConfig.setFactoryPath(jproj, ifp);
-
- // rebuild and verify that the processor was not loaded.
- LoaderTestAnnotationProcessor.clearLoaded();
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- assertFalse(LoaderTestAnnotationProcessor.isLoaded());
- }
-
- // Test what happens when the factory path contains a jar file that can't be found.
- public void testNonexistentEntry() throws Exception {
- LoaderTestAnnotationProcessor.clearLoaded();
- IProject project = env.getProject( getProjectName() );
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- assertFalse(LoaderTestAnnotationProcessor.isLoaded());
-
- IJavaProject jproj = env.getJavaProject( getProjectName() );
- IFactoryPath ifp = AptConfig.getFactoryPath(jproj);
-
- // add bogus entry to factory list, and rebuild.
- File bogusJar = new File("bogusJar.jar"); // assumed to not exist
- ifp.addExternalJar(bogusJar);
-
- // verify that a problem marker was added.
- AptConfig.setFactoryPath(jproj, ifp);
- fullBuild( project.getFullPath() );
- IMarker[] markers = getAllAPTMarkers(_projectPath);
- assertEquals(1, markers.length);
- assertEquals(AptPlugin.APT_LOADER_PROBLEM_MARKER, markers[0].getType());
- String message = markers[0].getAttribute(IMarker.MESSAGE, "");
- assertTrue(message.contains("bogusJar.jar"));
-
- // remove bogus entry, add _extJar to the factory list as an external jar, and rebuild.
- ifp.removeExternalJar(bogusJar);
- ifp.addExternalJar(_extJar);
- AptConfig.setFactoryPath(jproj, ifp);
-
- // rebuild and verify that the processor was loaded and the problems were removed.
- LoaderTestAnnotationProcessor.clearLoaded();
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- assertTrue(LoaderTestAnnotationProcessor.isLoaded());
-
- // Verify that we were able to run the ColorAnnotationProcessor successfully
- assertTrue(ColorAnnotationProcessor.wasSuccessful());
-
- // restore to the original
- AptConfig.setFactoryPath(jproj, ifp);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.core.tests.builder.Tests#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- JavaCore.removeClasspathVariable( TEMPJARDIR_CPVAR, null );
- _extJar = null;
- _extVarJar = null;
- _projectPath = null;
- super.tearDown();
- }
-
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/FileGenerationTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/FileGenerationTests.java
deleted file mode 100644
index 9078503f56..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/FileGenerationTests.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests;
-
-import java.io.File;
-import java.util.Map;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.core.internal.AptProject;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedFileManager;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-import org.eclipse.jdt.apt.tests.annotations.filegen.TextGenAnnotationProcessor;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-
-public class FileGenerationTests extends APTTestBase {
-
- public FileGenerationTests(final String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return new TestSuite(FileGenerationTests.class);
- }
-
- public void testSourceGenPackages() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code =
- "package test;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.filegen.FileGenLocationAnnotation;" + "\n" +
- "@FileGenLocationAnnotation" + "\n" +
- "public class Test" + "\n" +
- "{" + "\n" +
- "}";
-
- env.addClass(srcRoot, "test", "Test", code);
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- public void testSourceGenOverwrite() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code =
- "package test;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.filegen.FirstGenAnnotation;" + "\n" +
- "@FirstGenAnnotation" + "\n" +
- "public class Test" + "\n" +
- "{" + "\n" +
- "}";
-
- env.addClass(srcRoot, "test", "Test", code);
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- public void testSourceGenAfterDirChange() throws Exception
- {
- IJavaProject jproj = env.getJavaProject( getProjectName() );
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code =
- "package test;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;" + "\n" +
- "@HelloWorldAnnotation" + "\n" +
- "public class Test" + "\n" +
- "{" + "\n" +
- " generatedfilepackage.GeneratedFileTest gft;" + "\n" +
- "}";
-
- AptConfig.setGenSrcDir(jproj, "__foo_src");
-
- env.addClass(srcRoot, "test", "Test", code);
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- Map<String,String> options = AptConfig.getProcessorOptions(jproj);
- String sourcepath = options.get("-sourcepath");
-
- assertTrue(sourcepath.contains("__foo_src"));
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- public void testSourceGenSubDir() throws Exception
- {
- IJavaProject jproj = env.getJavaProject( getProjectName() );
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code =
- "package test;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;" + "\n" +
- "@HelloWorldAnnotation" + "\n" +
- "public class Test" + "\n" +
- "{" + "\n" +
- " generatedfilepackage.GeneratedFileTest gft;" + "\n" +
- "}";
-
- AptConfig.setGenSrcDir(jproj, "gen/foo");
- env.addClass(srcRoot, "test", "Test", code);
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- public void testTextFileGen() throws Exception {
- // enable the test only on windows for now
- if (System.getProperty("os.name").indexOf("Windows") == -1) return;
- final String TEXT_FILE_NAME = "TextFile.txt";
-
- clearProcessorResult(TextGenAnnotationProcessor.class);
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code =
- "package test;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.filegen.TextGenAnnotation;" + "\n" +
- "@TextGenAnnotation(\"" + TEXT_FILE_NAME + "\")" + "\n" +
- "public class Test" + "\n" +
- "{" + "\n" +
- "}";
-
- env.addClass(srcRoot, "test", "Test", code);
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- // Look for the file
- Map<String,String> options = AptConfig.getProcessorOptions(JavaCore.create(project));
- // We'll find it in the binary output directory
- String outputRootPath = options.get("-d");
- File theFile = new File(new File(outputRootPath), TEXT_FILE_NAME);
-
- assertTrue("File was not found: " + theFile.getAbsolutePath(), theFile.exists());
-
- incrementalBuild( project.getFullPath() );
- expectingNoProblems();
- checkProcessorResult(TextGenAnnotationProcessor.class);
- assertTrue("File was not found: " + theFile.getAbsolutePath(), theFile.exists());
-
- // Change the annotation to specify an illegal filename, and an exception should be thrown
- code =
- "package test;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.filegen.TextGenAnnotation;" + "\n" +
- "@TextGenAnnotation(\">.txt\")" + "\n" +
- "public class Test" + "\n" +
- "{" + "\n" +
- "}";
- env.addClass(srcRoot, "test", "Test", code);
-
- incrementalBuild( project.getFullPath() );
- expectingNoProblems();
- assertEquals("Could not generate text file due to IOException", getProcessorResult(TextGenAnnotationProcessor.class));
- assertTrue("File was found, but should be deleted: " + theFile.getAbsolutePath(), !theFile.exists());
-
- // remove the annotation, and the file should be deleted and processor should not run
- code =
- "package test;" + "\n" +
- "public class Test" + "\n" +
- "{" + "\n" +
- "}";
- env.addClass(srcRoot, "test", "Test", code);
-
- incrementalBuild( project.getFullPath() );
- expectingNoProblems();
- assertEquals(null, getProcessorResult(TextGenAnnotationProcessor.class));
- assertTrue("File was found, but should be deleted: " + theFile.getAbsolutePath(), !theFile.exists());
- }
-
- public void testIsGeneratedOrParentFile() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code =
- "package test;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.filegen.FileGenLocationAnnotation;" + "\n" +
- "@FileGenLocationAnnotation" + "\n" +
- "public class Test" + "\n" +
- "{" + "\n" +
- "}";
-
- env.addClass(srcRoot, "test", "Test", code);
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- AptProject aptProj = new AptProject(env.getJavaProject(getProjectName()));
- GeneratedFileManager gfm = aptProj.getGeneratedFileManager();
- String genSrcDir = AptConfig.getGenSrcDir(env.getJavaProject(getProjectName()));
- String P = File.separator;
-
- IFile parentFile = project.getFile("src" + P + "test" + P + "Test.java");
- IFile generatedFile = project.getFile(genSrcDir + P + "test" + P + "A.java");
-
- assertTrue("expected src/test/Test.java to be designated as parent file", gfm.isParentFile(parentFile));
- assertTrue("expected .apt_generated/test/A.java to be designated as generated file", gfm.isGeneratedFile(generatedFile));
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/JavaVersionTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/JavaVersionTests.java
deleted file mode 100644
index efe6350937..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/JavaVersionTests.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.ProcessorTestStatus;
-import org.eclipse.jdt.apt.tests.annotations.mirrortest.CodeExample;
-import org.eclipse.jdt.core.tests.builder.BuilderTests;
-import org.eclipse.jdt.core.tests.util.Util;
-
-/**
- * Test that processors do not get invoked on pre-1.5 projects
- */
-public class JavaVersionTests extends BuilderTests {
-
- public JavaVersionTests(final String name) {
- super( name );
- }
-
- public static Test suite() {
- return new TestSuite( JavaVersionTests.class );
- }
-
- public void setUp() throws Exception {
- super.setUp();
-
- // project will be deleted by super-class's tearDown() method
- IPath projectPath = env.addProject( getProjectName(), "1.4" ); //$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 JavaVersionTests.class.getName() + "Project"; //$NON-NLS-1$
- }
-
- public IPath getSourcePath() {
- IProject project = env.getProject( getProjectName() );
- IFolder srcFolder = project.getFolder( "src" ); //$NON-NLS-1$
- IPath srcRoot = srcFolder.getFullPath();
- return srcRoot;
- }
-
- /**
- * Runs the MirrorTestAnnotationProcessor, which contains
- * the actual tests
- */
- public void testMirror() throws Exception {
- ProcessorTestStatus.reset();
-
- 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() );
-
- assertFalse("Processor was run", ProcessorTestStatus.processorRan()); //$NON-NLS-1$
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ListenerTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ListenerTests.java
deleted file mode 100644
index f1ca01255b..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ListenerTests.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.TestSuite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.tests.annotations.listener.ListenerProcessor;
-
-/**
- *
- */
-public class ListenerTests extends APTTestBase
-{
-
- public ListenerTests(String name) {
- super(name);
- }
-
- public static Test suite()
- {
- return new TestSuite(ListenerTests.class);
- }
-
- public void testListenerCalled() throws Exception
- {
- clearProcessorResult(ListenerProcessor.class);
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code =
- "package test;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.listener.ListenerAnnotation;" + "\n" +
- "@ListenerAnnotation" + "\n" +
- "public class Test" + "\n" +
- "{" + "\n" +
- "}";
-
- env.addClass(srcRoot, "test", "Test", code);
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- checkProcessorResult(ListenerProcessor.class);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorDeclarationTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorDeclarationTests.java
deleted file mode 100644
index 145546a655..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorDeclarationTests.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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:
- * sbandow@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.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.core.env.EnvironmentFactory;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-import org.eclipse.jdt.apt.tests.annotations.generic.AbstractGenericProcessor;
-import org.eclipse.jdt.apt.tests.annotations.generic.GenericFactory;
-import org.eclipse.jdt.apt.tests.annotations.mirrortest.MirrorDeclarationCodeExample;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.util.SourcePosition;
-
-public class MirrorDeclarationTests extends APTTestBase {
-
- public MirrorDeclarationTests(final String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return new TestSuite(MirrorDeclarationTests.class);
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
-
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
- String code = MirrorDeclarationCodeExample.CODE;
- env.addClass(srcRoot, MirrorDeclarationCodeExample.CODE_PACKAGE, MirrorDeclarationCodeExample.CODE_CLASS_NAME, code);
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- }
-
- public void testMirrorDeclaration() throws Exception
- {
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- public void testFieldConstant() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
- String codeTrigger =
- "package test;\n" +
- "public @interface Trigger{}";
-
- env.addClass(srcRoot, "test", "Trigger", codeTrigger);
-
- String codeEntryPoint = "package test;\n" +
- "@Trigger\n" +
- "public class EntryPoint {\n" +
- " ClassWithNestedAnnotation nestedAnno;\n}";
-
- env.addClass(srcRoot, "test", "EntryPoint", codeEntryPoint);
-
- String codeClassWithNestedAnnotation =
- "package test; \n" +
- "public class ClassWithNestedAnnotation {\n" +
- " public final int FOUR = 4; \n " +
- "}";
-
- env.addClass(srcRoot, "test", "ClassWithNestedAnnotation", codeClassWithNestedAnnotation);
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- }
-
- // TODO: Disabled due to Bugzilla 124388 -theodora
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=124388
- public void DISABLED_testDefault() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
- String codeTrigger =
- "package test;\n" +
- "public @interface Trigger{}";
-
- env.addClass(srcRoot, "test", "Trigger", codeTrigger);
-
- String codeEntryPoint = "package test;\n" +
- "@Trigger\n" +
- "public class EntryPoint {\n" +
- " ClassWithNestedAnnotation nestedAnno;\n}";
-
- env.addClass(srcRoot, "test", "EntryPoint", codeEntryPoint);
-
- String codeClassWithNestedAnnotation =
- "package test; \n" +
- "public class ClassWithNestedAnnotation {\n" +
- " public @interface NestedAnnotation{\n" +
- " public enum Character{ \n" +
- " Winnie, Tiger, Piglet, Eore; \n" +
- " }\n"+
- " Character value() default Character.Eore; \n" +
- " }\n" +
- "}";
-
- env.addClass(srcRoot, "test", "ClassWithNestedAnnotation", codeClassWithNestedAnnotation);
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- }
-
- /**
- * Test AST based mirror implementation and binding based mirror implementation.
- * Specifically,
- * (i) method declaration with unresolvable return type.
- * (ii) constructor declaration with unresolvable parameter
- * (iii) field declaration with unresolvable type.
- *
- * This test focus on declarations from file in context.
- *
- * @throws Exception
- */
- public void testUnresolvableDeclarations0()
- throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
- String declAnno =
- "package test;\n" +
- "public @interface DeclarationAnno{}";
-
- env.addClass(srcRoot, "test", "DeclarationAnno", declAnno);
-
- String codeFoo =
- "package test;\n" +
- "@DeclarationAnno\n" +
- "public class Foo {\n" +
- " int field0;\n " +
- " UnknownType field1;\n " +
- " public Foo(UnknownType type){} \n" +
- " public void voidMethod(){} \n " +
- " public UnknownType getType(){}\n " +
- " public class Inner{} \n" +
- "}";
-
- final IPath fooPath = env.addClass(srcRoot, "test", "Foo", codeFoo);
- fullBuild( project.getFullPath() );
-
- expectingOnlySpecificProblemsFor(fooPath, new ExpectedProblem[]{
- new ExpectedProblem("", "UnknownType cannot be resolved to a type", fooPath),
- new ExpectedProblem("", "UnknownType cannot be resolved to a type", fooPath),
- new ExpectedProblem("", "UnknownType cannot be resolved to a type", fooPath)}
- );
- }
-
- /**
- * Test AST based mirror implementation and binding based mirror implementation.
- * Specifically,
- * (i) method declaration with unresolvable return type.
- * (ii) constructor declaration with unresolvable parameter
- * (iii) field declaration with unresolvable type.
- *
- * This test focus on declarations from file outside of processor
- * environment context.
- *
- * @throws Exception
- */
- public void testUnresolvableDeclarations1()
- throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
- String declAnno =
- "package test;\n" +
- "public @interface DeclarationAnno{}";
-
- env.addClass(srcRoot, "test", "DeclarationAnno", declAnno);
-
- String codeBar =
- "package test;\n" +
- "@DeclarationAnno\n" +
- "public class Bar {}";
- env.addClass(srcRoot, "test", "Bar", codeBar);
-
- String codeFoo =
- "package test;\n" +
- "@DeclarationAnno\n" +
- "public class Foo {\n" +
- " int field0;\n " +
- " UnknownType field1;\n " +
- " public Foo(UnknownType type){} \n" +
- " public void voidMethod(){} \n " +
- " public UnknownType getType(){}\n " +
- " public class Inner{} \n" +
- "}";
-
- final IPath fooPath = env.addClass(srcRoot, "test", "Foo", codeFoo);
-
- fullBuild( project.getFullPath() );
- expectingOnlySpecificProblemsFor(fooPath, new ExpectedProblem[]{
- new ExpectedProblem("", "UnknownType cannot be resolved to a type", fooPath),
- new ExpectedProblem("", "UnknownType cannot be resolved to a type", fooPath),
- new ExpectedProblem("", "UnknownType cannot be resolved to a type", fooPath)}
- );
- }
-
- public void testLocation() {
-
- TestLocationProc p = new TestLocationProc();
- GenericFactory.setProcessor(p);
-
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
- String x =
- "package test;\n" +
- "import org.eclipse.jdt.apt.tests.annotations.generic.*;\n" +
- "@GenericAnnotation public class X {}";
-
- env.addClass(srcRoot, "test", "X", x);
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- assertTrue("Processor not invoked", p.called);
- }
-
- static class TestLocationProc extends AbstractGenericProcessor {
-
- boolean called;
-
- public void _process() {
- called = true;
- assertTrue(decls.size() == 1);
-
- Declaration d = decls.iterator().next();
- SourcePosition p = d.getPosition();
-
- assertTrue(p.column() == 32);
- assertTrue(p.line() == 3);
- }
- }
-
- public void testEnvFactory() throws JavaModelException {
-
- IProject project = env.getProject(getProjectName());
- IPath srcRoot = getSourcePath();
- String x = "package test;\n" + "import org.eclipse.jdt.apt.tests.annotations.generic.*;\n"
- + "@GenericAnnotation public class X {}";
-
- IPath path = env.addClass(srcRoot, "test", "X", x);
- IPath tail = path.removeFirstSegments(2);
- IJavaProject p = JavaCore.create(project);
- ICompilationUnit cu = (ICompilationUnit) p.findElement(tail);
- assertTrue("Could not find cu", cu != null);
-
- AnnotationProcessorEnvironment env = EnvironmentFactory.getEnvironment(cu, p);
- TypeDeclaration t = env.getTypeDeclaration("test.X");
-
- SourcePosition pos = t.getPosition();
-
- assertTrue(pos.column() == 32);
- assertTrue(pos.line() == 3);
- }
-
-}
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 c935c59ec9..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorTests.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.core.util.AptConfig;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-import org.eclipse.jdt.apt.tests.annotations.mirrortest.CodeExample;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.tests.util.Util;
-
-public class MirrorTests extends APTTestBase {
-
- public MirrorTests(final String name) {
- super( name );
- }
-
- public static Test suite() {
- return new TestSuite( MirrorTests.class );
- }
-
- /**
- * Runs the MirrorTestAnnotationProcessor, which contains
- * the actual tests
- */
- public void testMirror() throws Exception {
- ProcessorTestStatus.reset();
-
- 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();
-
- assertTrue("Processor was not run", ProcessorTestStatus.processorRan()); //$NON-NLS-1$
-
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- public void testTypeParmaterAPI() throws Exception{
- final String projName = MirrorTests.class.getName() + "TypeParameter.Project"; //$NON-NLS-1$
- IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$
- env.addExternalJars( projectPath, Util.getJavaClassLibs() );
-
- 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 ) );
- IProject project = env.getProject( projName );
- IFolder srcFolder = project.getFolder( "src" );
- IPath srcRoot = srcFolder.getFullPath();
-
- String a1Code = "package pkg;\n" +
- "import org.eclipse.jdt.apt.tests.annotations.apitest.Common;\n" +
- "import java.lang.annotation.Annotation;\n" +
- "@Common\n" +
- "public class A1<T> {\n " +
- " @Common\n" +
- " <A extends Annotation> A get(A a){ return a;}\n" +
- "}\n";
-
- final IPath a1Path = env.addClass( srcRoot, "pkg", "A1", a1Code ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // Set some per-project preferences
- IJavaProject jproj = env.getJavaProject( projName );
- AptConfig.setEnabled(jproj, true);
- fullBuild( project.getFullPath() );
- expectingNoMarkers();
- expectingSpecificProblemsFor(a1Path, new ExpectedProblem[]{
- new ExpectedProblem("", "Type parameter 'T' belongs to org.eclipse.jdt.apt.core.internal.declaration.ClassDeclarationImpl A1", a1Path),
- new ExpectedProblem("", "Type parameter 'A' belongs to org.eclipse.jdt.apt.core.internal.declaration.MethodDeclarationImpl get", a1Path)
- }
- );
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorUtilTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorUtilTests.java
deleted file mode 100644
index 640768f56c..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MirrorUtilTests.java
+++ /dev/null
@@ -1,83 +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:
- * sbandow@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.IProject;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-import org.eclipse.jdt.apt.tests.annotations.mirrortest.MirrorUtilTestAnnotationProcessor;
-import org.eclipse.jdt.apt.tests.annotations.mirrortest.MirrorUtilTestCodeExample;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.tests.builder.Problem;
-
-public class MirrorUtilTests extends APTTestBase {
-
- public MirrorUtilTests(final String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return new TestSuite(MirrorUtilTests.class);
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
-
- IProject project = env.getProject( getProjectName() );
- IJavaProject jproj = env.getJavaProject(project.getFullPath());
- addEnvOptions(jproj);
- IPath srcRoot = getSourcePath();
- String code = MirrorUtilTestCodeExample.CODE;
- env.addClass(srcRoot, MirrorUtilTestCodeExample.CODE_PACKAGE, MirrorUtilTestCodeExample.CODE_CLASS_NAME, code);
- fullBuild( project.getFullPath() );
- assertNoUnexpectedProblems();
- }
-
- /**
- * Add options which the AnnotationProcessorEnvironment should see.
- * The options will be verified within the processor code.
- */
- private void addEnvOptions(IJavaProject jproj) {
- for (int i = 0; i < MirrorUtilTestAnnotationProcessor.ENV_KEYS.length; ++i) {
- AptConfig.addProcessorOption(jproj,
- MirrorUtilTestAnnotationProcessor.ENV_KEYS[i],
- MirrorUtilTestAnnotationProcessor.ENV_VALUES[i]);
- }
- }
-
- /**
- *
- */
- private void assertNoUnexpectedProblems() {
- Problem[] problems = env.getProblems();
- for (Problem problem : problems) {
- if (problem.getMessage().startsWith("The field DeclarationsTestClass")) { //$NON-NLS-1$
- continue;
- }
- fail("Found unexpected problem: " + problem); //$NON-NLS-1$
- }
- }
-
- public void testMirrorUtils() throws Exception
- {
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MixedModeTesting.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MixedModeTesting.java
deleted file mode 100644
index 708727c621..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/MixedModeTesting.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.tests;
-
-import java.io.File;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPathUtil;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.core.IJavaProject;
-
-public class MixedModeTesting extends APTTestBase{
-
- private File _extJar; // external annotation jar
-
- public MixedModeTesting(String name){
- super(name);
- }
-
-
- public static Test suite()
- {
- return new TestSuite( MixedModeTesting.class );
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
- IJavaProject javaProj = env.getJavaProject( getProjectName() );
- _extJar = TestUtil.createAndAddExternalAnnotationJar(javaProj);
-
- FactoryPath fp = (FactoryPath)AptConfig.getFactoryPath(javaProj);
- FactoryContainer fc = FactoryPathUtil.newExtJarFactoryContainer(_extJar);
- fp.addEntryToHead(fc, /*isEnabled=*/ true, /*runInBatchMode=*/ true);
- AptConfig.setFactoryPath(javaProj, fp);
- }
-
- /**
- * Only one batch processor is involved
- * This test the processor environment and that it returns the correct
- * set of declared types.
- */
- public void testSimpleBatchProcessing() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String codeA = "package p1;\n"
- + "\n import org.eclipse.jdt.apt.tests.external.annotations.batch.*;"
- + "\n@Batch\n"
- + "public class A {}\n";
-
- env.addClass( srcRoot, "p1", "A", codeA );
-
- String codeB = "package p1;\n"
- + "\n@Deprecated\n"
- + "public class B {}\n";
-
- env.addClass( srcRoot, "p1", "B", codeB );
-
- String codeC = "package p1;\n"
- + "\n import org.eclipse.jdt.apt.tests.external.annotations.batch.*;"
- + "\n@Batch\n"
- + "public class C {}\n";
-
- env.addClass( srcRoot, "p1", "C", codeC );
-
- // This one doesn't have annotations.
- String codeD = "package p1; public class D{}";
- env.addClass( srcRoot, "p1", "D", codeD );
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- expectingMarkers(new String[]{"CompletedSuccessfully"});
- }
-
- /**
- * What this tests test.
- * This makes sure the internal apt rounding occurs correctly in batch mode.
- * @throws CoreException
- */
- public void testAPTRoundingInMixedMode0()
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String codeX = "package p1;\n"
- + "\n import org.eclipse.jdt.apt.tests.annotations.aptrounding.*;"
- + "\n@GenBean\n"
- + "public class X {}\n";
-
- env.addClass( srcRoot, "p1", "X", codeX );
-
- String codeY = "package p1;\n"
- + "\n import org.eclipse.jdt.apt.tests.annotations.aptrounding.*;"
- + "public class Y { @GenBean2 test.Bean _bean = null; }\n";
-
- env.addClass( srcRoot, "p1", "Y", codeY );
-
- String codeA = "package p1;\n"
- + "\n import org.eclipse.jdt.apt.tests.external.annotations.batch.*;"
- + "\n@Batch\n"
- + "public class A {}\n";
-
- env.addClass( srcRoot, "p1", "A", codeA );
-
- String codeB = "package p1;\n"
- + "\n@Deprecated\n"
- + "public class B {}\n";
-
- env.addClass( srcRoot, "p1", "B", codeB );
-
- String codeC = "package p1;\n"
- + "\n import org.eclipse.jdt.apt.tests.external.annotations.batch.*;"
- + "\n@Batch\n"
- + "public class C {}\n";
-
- env.addClass( srcRoot, "p1", "C", codeC );
-
- // This one doesn't have annotations.
- String codeD = "package p1; public class D{}";
- env.addClass( srcRoot, "p1", "D", codeD );
-
- fullBuild( project.getFullPath() );
- expectingMarkers(new String[]{"CompletedSuccessfully", "Called 2 times."});
-
- expectingNoProblems();
-
- // Now run it again to verify that the classloader was successfully bounced
- fullBuild( project.getFullPath() );
- expectingMarkers(new String[]{"CompletedSuccessfully", "Called 2 times."});
-
- expectingNoProblems();
- }
-
- /*
- * What this test tests.
- * There should be a total of 3 rounds.
- * -The first round starts because of the "BatchGen" annotations.
- * This round creates the gen.Class0 type
- * -The second round starts because of a batch processor being dispatched in a previous round
- * and a new type is generated.
- * This round creates the gen.Class1 type
- * -The third round starts for the exact same reason as round 2.
- * This is a no-op round.
- */
-
- public void testAPTRoundingInMixedMode1()
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String codeA = "package p1;\n"
- + "\n import org.eclipse.jdt.apt.tests.external.annotations.batch.*;"
- + "\n import gen.*;"
- + "\n@BatchGen\n"
- + "public class A {"
- + " Class0 clazz0;\n"
- + " Class1 clazz1;\n"
- + "}\n";
-
- env.addClass( srcRoot, "p1", "A", codeA );
-
- // drop something to possibily fire off an incremental build
- String codeB = "package p1;\n"
- + "public class B {}\n";
-
- env.addClass( srcRoot, "p1", "B", codeB );
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- expectingMarkers(new String[]{"Called the third time."});
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PerfTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PerfTests.java
deleted file mode 100644
index 63b97b8977..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PerfTests.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 java.io.FileInputStream;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.zip.ZipInputStream;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.tests.builder.Problem;
-import org.eclipse.jdt.core.tests.builder.BuilderTests;
-
-public class PerfTests extends BuilderTests
-{
-
- private IPath projectPath;
-
- public PerfTests(String name)
- {
- super( name );
- }
-
- public static Test suite()
- {
- return new TestSuite( PerfTests.class );
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
-
- IWorkspace ws = env.getWorkspace();
- IWorkspaceRoot root = ws.getRoot();
- IPath path = root.getLocation();
- File destRoot = path.toFile();
-
- URL platformURL = Platform.getBundle("org.eclipse.jdt.apt.tests").getEntry("/"); //$NON-NLS-1$//$NON-NLS-2$
- File f = new File(FileLocator.toFileURL(platformURL).getFile());
- f = new File(f, "perf-test-project.zip"); //$NON-NLS-1$
-
-
- //InputStream in = PerfTests.class.getClassLoader().getResourceAsStream("perf-test-project.zip");
- InputStream in = new FileInputStream(f);
- ZipInputStream zipIn = new ZipInputStream(in);
- try {
- TestUtil.unzip(zipIn, destRoot);
- }
- finally {
- zipIn.close();
- }
-
- // project will be deleted by super-class's tearDown() method
- projectPath = env.addProject( "org.eclipse.jdt.core", "1.4" ); //$NON-NLS-1$ //$NON-NLS-2$
-
- System.out.println("Performing full build..."); //$NON-NLS-1$
- fullBuild( projectPath );
- System.out.println("Completed build."); //$NON-NLS-1$
-
- assertNoUnexpectedProblems();
-
- }
-
- /**
- * JDT Core has one warning on the use of IWorkingCopy, and a number
- * of TODOs, XXXs and FIXMEs.
- */
- private void assertNoUnexpectedProblems() {
- Problem[] problems = env.getProblems();
- for (Problem problem : problems) {
- if (problem.getMessage().startsWith("TODO") ||
- problem.getMessage().startsWith("XXX") ||
- problem.getMessage().startsWith("FIXME")) {
- continue;
- }
- else {
- if (problem.getMessage().equals("The type IWorkingCopy is deprecated"))
- continue;
- }
- fail("Found unexpected problem: " + problem);
- }
- }
-
- public static String getProjectName()
- {
- return PerfTests.class.getName() + "Project"; //$NON-NLS-1$
- }
-
- public IPath getSourcePath()
- {
- IProject project = env.getProject( getProjectName() );
- IFolder srcFolder = project.getFolder( "src" ); //$NON-NLS-1$
- IPath srcRoot = srcFolder.getFullPath();
- return srcRoot;
- }
-
- public void testBuilding() throws Throwable {
- IProject proj = env.getProject(projectPath);
- IJavaProject jproj = JavaCore.create(proj); // doesn't actually create anything
-
- assertNoUnexpectedProblems();
-
- // Start with APT turned off
- AptConfig.setEnabled(jproj, false);
- proj.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
-
- assertNoUnexpectedProblems();
-
- System.out.println("Performing full build without apt...");
- long start = System.currentTimeMillis();
- proj.build(IncrementalProjectBuilder.FULL_BUILD, null);
- long totalWithoutAPT = System.currentTimeMillis() - start;
- System.out.println("Completed full build without APT in " + totalWithoutAPT + "ms.");
-
- assertNoUnexpectedProblems();
-
- // Now turn on APT
- AptConfig.setEnabled(jproj, true);
- proj.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
-
- assertNoUnexpectedProblems();
-
- System.out.println("Performing full build with apt...");
- start = System.currentTimeMillis();
- proj.build(IncrementalProjectBuilder.FULL_BUILD, null);
- long totalWithAPT = System.currentTimeMillis() - start;
- System.out.println("Completed full build with APT in " + totalWithAPT + "ms.");
-
- assertNoUnexpectedProblems();
-
- if (totalWithAPT > totalWithoutAPT * 1.15) {
- fail("APT performance degradation greater than 15%");
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PreferencesTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PreferencesTests.java
deleted file mode 100644
index ff4ded6041..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/PreferencesTests.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.FactoryPluginManager;
-import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager;
-import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPathUtil;
-import org.eclipse.jdt.apt.core.internal.util.FactoryContainer.FactoryType;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.apt.core.util.AptPreferenceConstants;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.tests.util.Util;
-
-public class PreferencesTests extends APTTestBase {
-
- public PreferencesTests(final String name) {
- super( name );
- }
-
- public static Test suite() {
- return new TestSuite( PreferencesTests.class );
- }
-
- public void testFactoryPathEncodingAndDecoding() throws Exception {
- //encode
- Map<FactoryContainer, FactoryPath.Attributes> factories = new LinkedHashMap<FactoryContainer, FactoryPath.Attributes>();
- FactoryContainer jarFactory1 = FactoryPathUtil.newExtJarFactoryContainer(new File(JAR_PATH_1)); //$NON-NLS-1$
- FactoryPath.Attributes jarFPA1 = new FactoryPath.Attributes(true, false);
- FactoryContainer jarFactory2 = FactoryPathUtil.newExtJarFactoryContainer(new File(JAR_PATH_2)); //$NON-NLS-1$
- FactoryPath.Attributes jarFPA2 = new FactoryPath.Attributes(true, true);
- FactoryContainer pluginFactory = FactoryPluginManager.getPluginFactoryContainer("org.eclipse.jdt.apt.tests"); //$NON-NLS-1$
- FactoryPath.Attributes pluginFPA = new FactoryPath.Attributes(false, false);
- factories.put(jarFactory1, jarFPA1);
- factories.put(jarFactory2, jarFPA2);
- factories.put(pluginFactory, pluginFPA);
- String xml = FactoryPathUtil.encodeFactoryPath(factories);
- assertEquals(serializedFactories, xml);
-
- // decode
- factories = FactoryPathUtil.decodeFactoryPath(xml);
- assertEquals(3, factories.size());
-
- int index=0;
- for (Map.Entry<FactoryContainer, FactoryPath.Attributes> entry : factories.entrySet()) {
- FactoryContainer container = entry.getKey();
- switch (index) {
- case 0:
- // jar1
- assertEquals(FactoryType.EXTJAR, container.getType());
- assertTrue(entry.getValue().isEnabled());
- assertFalse(entry.getValue().runInBatchMode());
- break;
- case 1:
- // jar2
- assertEquals(FactoryType.EXTJAR, container.getType());
- assertTrue(entry.getValue().isEnabled());
- assertTrue(entry.getValue().runInBatchMode());
- break;
- case 2:
- // plugin
- assertEquals(FactoryType.PLUGIN, container.getType());
- assertFalse(entry.getValue().isEnabled());
- assertEquals("org.eclipse.jdt.apt.tests", container.getId()); //$NON-NLS-1$
- break;
- default:
- fail("FactoryPath had an unexpected number of entries: " + (index + 1));
- }
-
- index++;
- }
- }
-
- // Need to use temp files to get path to external jars.
- // Platform differences prevent us from hard-coding a string here
- private static final String JAR_PATH_1;
- private static final String JAR_PATH_2;
-
- static {
- File jar1 = null;
- File jar2 = null;
- try {
- jar1 = File.createTempFile("test1", "jar");
- jar2 = File.createTempFile("test2", "jar");
- JAR_PATH_1 = jar1.getAbsolutePath();
- JAR_PATH_2 = jar2.getAbsolutePath();
- }
- catch (IOException ioe) {
- throw new RuntimeException("Could not create temp jar files", ioe);
- }
- finally {
- if (jar1 != null) jar1.delete();
- if (jar2 != null) jar2.delete();
- }
- }
-
- private static final String serializedFactories =
- "<factorypath>\n" +
- " <factorypathentry kind=\"EXTJAR\" id=\"" + JAR_PATH_1 + "\" enabled=\"true\" runInBatchMode=\"false\"/>\n" +
- " <factorypathentry kind=\"EXTJAR\" id=\"" + JAR_PATH_2 + "\" enabled=\"true\" runInBatchMode=\"true\"/>\n" +
- " <factorypathentry kind=\"PLUGIN\" id=\"org.eclipse.jdt.apt.tests\" enabled=\"false\" runInBatchMode=\"false\"/>\n" +
- "</factorypath>\n";
-
- /**
- * Test the config API for settings other than factory path
- * @throws Exception
- */
- public void testSimpleConfigApi() throws Exception {
- IJavaProject jproj = env.getJavaProject( getProjectName() );
-
- // aptEnabled
- AptConfig.setEnabled(jproj, false);
- assertFalse(AptConfig.isEnabled(jproj));
- assertFalse(AptConfig.isEnabled(null));
- AptConfig.setEnabled(jproj, true);
- assertTrue(AptConfig.isEnabled(jproj));
- assertFalse(AptConfig.isEnabled(null));
-
- // processorOptions
- Map<String, String> wkspOpts = new HashMap<String, String>(3);
- wkspOpts.put("b", "bVal");
- wkspOpts.put("another option", "and\\more \"punctuation!\"");
- AptConfig.setProcessorOptions(wkspOpts, null);
- Map<String, String> retrievedWkspOpts = AptConfig.getRawProcessorOptions(null);
- assertTrue("getRawProcessorOptions() should return the values set in setProcessorOptions()",
- wkspOpts.equals(retrievedWkspOpts));
-
- Map<String, String> projOpts = new HashMap<String, String>(3);
- projOpts.put("a", "aVal");
- projOpts.put("with spaces", "value also has spaces");
- projOpts.put("foo", "bar");
- AptConfig.setProcessorOptions(projOpts, jproj);
- Map<String, String> retrievedProjOpts = AptConfig.getRawProcessorOptions(jproj);
- assertTrue("getRawProcessorOptions() should return the values set in setProcessorOptions()",
- projOpts.equals(retrievedProjOpts));
-
- wkspOpts.clear();
- wkspOpts.put("noodle", "nubble");
- wkspOpts.put("spoo/mack", "wumpus");
- AptConfig.setProcessorOptions(wkspOpts, null);
- retrievedWkspOpts = AptConfig.getRawProcessorOptions(null);
- assertTrue("getRawProcessorOptions() should return the values set in setProcessorOptions()",
- wkspOpts.equals(retrievedWkspOpts));
-
- projOpts.clear();
- projOpts.put("smurf", "more smurfs\\=bad");
- projOpts.put("baz/quack", "quux");
- AptConfig.setProcessorOptions(projOpts, jproj);
- retrievedProjOpts = AptConfig.getRawProcessorOptions(jproj);
- assertTrue("getRawProcessorOptions() should return the values set in setProcessorOptions()",
- projOpts.equals(retrievedProjOpts));
-
- AptConfig.addProcessorOption(jproj, "foo", "bar");
- AptConfig.addProcessorOption(jproj, "space", "\"text with spaces\"");
- AptConfig.addProcessorOption(jproj, "quux", null);
- AptConfig.addProcessorOption(jproj, "quux", null); // adding twice should have no effect
- Map<String, String> options = AptConfig.getProcessorOptions(jproj);
- String val = options.get("foo");
- assertEquals(val, "bar");
- val = options.get("quux");
- assertNull(val);
- val = options.get("space");
- assertEquals(val, "\"text with spaces\"");
- AptConfig.removeProcessorOption(jproj, "foo");
- options = AptConfig.getProcessorOptions(jproj);
- assertFalse(options.containsKey("foo"));
- assertTrue(options.containsKey("quux"));
- AptConfig.removeProcessorOption(jproj, "quux");
- AptConfig.removeProcessorOption(jproj, "anOptionThatDoesn'tExist");
-
- AptConfig.addProcessorOption(null, "workspace option", "corresponding value");
- AptConfig.addProcessorOption(null, "foo", "whatever");
- AptConfig.removeProcessorOption(null, "foo");
- options = AptConfig.getProcessorOptions(null);
- assertFalse(options.containsKey("foo"));
- assertTrue(options.containsKey("workspace option"));
- AptConfig.removeProcessorOption(null, "workspace option");
- }
-
- /**
- * Test the config API for automatically generated options.
- */
- public void testAutomaticOptions() throws Exception {
- IJavaProject jproj = env.getJavaProject( getProjectName() );
- Map<String,String> options = AptConfig.getProcessorOptions(jproj);
-
- String classpath = options.get("-classpath");
- assertNotNull(classpath);
- assertTrue(classpath.length() > 0);
-
- String sourcepath = options.get("-sourcepath");
- assertNotNull(sourcepath);
- assertTrue(sourcepath.length() > 0);
-
- String target = options.get("-target");
- assertEquals(target, "1.5");
-
- String source = options.get("-source");
- assertEquals(source, "1.5");
-
- String bindir = options.get("-d");
- assertNotNull(bindir);
- assertTrue(bindir.length() > 0);
-
- String gensrcdirAuto = options.get("-s");
- assertNotNull(gensrcdirAuto);
- assertTrue(gensrcdirAuto.length() > 0);
- }
-
- public void testGenSrcDir() throws Exception {
- IJavaProject jproj = env.getJavaProject( getProjectName() );
- String genSrcDir = AptConfig.getGenSrcDir(jproj);
- assertEquals(AptPreferenceConstants.DEFAULT_GENERATED_SOURCE_FOLDER_NAME, genSrcDir);
-
- final String newDir = "gen/src";
- AptConfig.setGenSrcDir(jproj, newDir);
- genSrcDir = AptConfig.getGenSrcDir(jproj);
-
- assertEquals(newDir, genSrcDir);
-
- }
-
- /**
- * Test a series of configuration and make sure the GeneratedFileManager and
- * the classpath reflecting the setup. Configuration setting includes
- * enabling and disabling apt and configure the generated source folder
- * with and without apt enabled.
- *
- * See comments in method body for detail testing scenarios
- * @throws Exception
- */
- public void testConfigGenSrcDir() throws Exception {
-
- final String projectName = "ConfigTestProj";
- IPath projectPath = env.addProject( projectName, "1.5" );
- env.addExternalJars( projectPath, Util.getJavaClassLibs() );
- final IJavaProject javaProj = env.getJavaProject(projectName);
- // APT is not enabled
- boolean aptEnabled = AptConfig.isEnabled(javaProj);
- // test 1: make sure apt is disabled by default
- assertEquals(false, aptEnabled);
- final GeneratedSourceFolderManager gsfm = AptPlugin.getAptProject(javaProj).getGeneratedSourceFolderManager();
- IFolder srcFolder = gsfm.getFolder();
- String folderName = srcFolder.getProjectRelativePath().toOSString();
- // test 2: apt is disabled, then folder should not exists
- assertEquals(srcFolder.exists(), false);
- // test 3: folder name has not been configured, then it should be the default.
- // folder name should be the default name.
- assertEquals(folderName, AptPreferenceConstants.DEFAULT_GENERATED_SOURCE_FOLDER_NAME);
-
- // set folder name while apt is disabled
- String newName = ".gensrcdir";
- AptConfig.setGenSrcDir(javaProj, newName);
- srcFolder = gsfm.getFolder();
- folderName = srcFolder.getProjectRelativePath().toOSString();
- // test 4: apt still disabled but folder name changed, make sure the folder is not on disk.
- assertEquals(false, srcFolder.exists());
- // test 5: make sure we got the new name
- assertEquals(newName, folderName);
- // test 6: make sure the source folder is not on the classpath.
- assertEquals( false, isOnClasspath(javaProj, srcFolder.getFullPath()) );
-
- // enable apt
- AptConfig.setEnabled(javaProj, true);
- aptEnabled = AptConfig.isEnabled(javaProj);
- // test 7: make sure it's enabled after we called the API to enable it.
- assertEquals(true, aptEnabled);
- srcFolder = gsfm.getFolder();
- folderName = srcFolder.getProjectRelativePath().toOSString();
- // test 8: apt enabled, the source folder should be on disk
- assertEquals(true, srcFolder.exists());
- // test 9: make sure the name matches
- assertEquals(newName, folderName);
- // test 10: apt is enabled, folder must be on classpath.
- assertEquals( true, isOnClasspath(javaProj, srcFolder.getFullPath()) );
-
- // now disable apt.
- AptConfig.setEnabled(javaProj, false);
- aptEnabled = AptConfig.isEnabled(javaProj);
- // test 11: make sure it's disabled.
- assertEquals(false, aptEnabled);
- srcFolder = gsfm.getFolder();
- folderName = srcFolder.getProjectRelativePath().toOSString();
- // test 12: make sure we deleted the source folder when we disable apt
- assertEquals(false, srcFolder.exists());
- // test 13: make sure we didn't overwrite the configure folder name
- assertEquals(newName, folderName);
- // test 14: make sure we cleaned up the classpath.
- assertEquals( false, isOnClasspath(javaProj, srcFolder.getFullPath()) );
- }
-
- private boolean isOnClasspath(IJavaProject javaProj, IPath path)
- throws JavaModelException
- {
- final IClasspathEntry[] cp = javaProj.getRawClasspath();
- for (int i = 0; i < cp.length; i++)
- {
- if (cp[i].getPath().equals( path ))
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests.java
deleted file mode 100644
index b52285147d..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.tests;
-
-import java.io.File;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-import org.eclipse.jdt.apt.tests.annotations.readannotation.CodeExample;
-import org.eclipse.jdt.apt.tests.plugin.AptTestsPlugin;
-import org.eclipse.jdt.core.IJavaProject;
-
-public class ReadAnnotationTests extends APTTestBase
-{
- public ReadAnnotationTests(final String name) {
- super( name );
- }
-
- public static Test suite() {
- return new TestSuite( ReadAnnotationTests.class );
- }
-
- private void addAllSources()
- {
- addQuestionSources();
- addTriggerSource();
- addNoTypeSources();
- }
-
- private void addQuestionSources()
- {
- IPath srcRoot = getSourcePath();
- // SimpleAnnotation.java
- env.addClass(
- srcRoot,
- CodeExample.PACKAGE_QUESTION,
- CodeExample.SIMPLE_ANNOTATION_CLASS,
- CodeExample.SIMPLE_ANNOTATION_CODE );
-
- // RTVisibleAnnotation.java
- env.addClass(
- srcRoot,
- CodeExample.PACKAGE_QUESTION,
- CodeExample.RTVISIBLE_CLASS,
- CodeExample.RTVISIBLE_ANNOTATION_CODE);
-
- // RTInvisibleAnnotation.java
- env.addClass(
- srcRoot,
- CodeExample.PACKAGE_QUESTION,
- CodeExample.RTINVISIBLE_CLASS,
- CodeExample.RTINVISIBLE_ANNOTATION_CODE);
-
- // package-info.java
- env.addClass(
- srcRoot,
- CodeExample.PACKAGE_QUESTION,
- CodeExample.PACKAGE_INFO_CLASS,
- CodeExample.PACKAGE_INFO_CODE);
-
- // Color.java
- env.addClass(
- srcRoot,
- CodeExample.PACKAGE_QUESTION,
- CodeExample.COLOR_CLASS,
- CodeExample.COLOR_CODE);
-
- // AnnotationTest.java
- env.addClass(
- srcRoot,
- CodeExample.PACKAGE_QUESTION,
- CodeExample.ANNOTATION_TEST_CLASS,
- CodeExample.ANNOTATION_TEST_CODE);
- }
-
- private void addNoTypeSources()
- {
- IPath srcRoot = getSourcePath();
- // package-info.java
- env.addClass(srcRoot,
- CodeExample.PACKAGE_NOTYPES,
- CodeExample.PACKAGE_INFO_NOTYPES_CLASS,
- CodeExample.PACKAGE_INFO_NOTYPES_CODE);
- }
-
- private void addTriggerSource()
- {
- IPath srcRoot = getSourcePath();
- // MyMarkerAnnotation.java
- env.addClass(srcRoot,
- CodeExample.PACKAGE_TRIGGER,
- CodeExample.MYMARKERANNOTATION_CLASS,
- CodeExample.MYMARKERANNOTATION_CODE);
-
- // Trigger.java
- env.addClass(srcRoot,
- CodeExample.PACKAGE_TRIGGER,
- CodeExample.TRIGGER_CLASS,
- CodeExample.TRIGGER_CODE);
- }
-
- private IProject setupTest() throws Exception
- {
- // This should not be necessary, but see https://bugs.eclipse.org/bugs/show_bug.cgi?id=99638
- IJavaProject jproj = getCurrentJavaProject();
- jproj.setOption("org.eclipse.jdt.core.compiler.problem.deprecation", "ignore");
- return jproj.getProject();
- }
-
- /**
- * Set up all the source files for testing.
- * Runs the ReadAnnotationProcessor, which contains
- * the actual testing.
- */
-
- public void test0() throws Exception {
- // reset the error reset the error;
- IProject project = setupTest();
- addAllSources();
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- assertTrue(ProcessorTestStatus.processorRan());
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-
- /**
- * Set up the jar file for testing.
- * Runs the ReadAnnotationProcessor, which contains
- * the actual testing.
- */
- public void test1() throws Exception
- {
- IProject project = setupTest();
- final File jar =
- TestUtil.getFileInPlugin(AptTestsPlugin.getDefault(),
- new Path("/resources/question.jar")); //$NON-NLS-1$
- final String path = jar.getAbsolutePath();
- env.addExternalJar(project.getFullPath(), path);
-
- addTriggerSource();
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- assertTrue(ProcessorTestStatus.processorRan());
- assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java
deleted file mode 100644
index 7da3d6d6f3..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ReadAnnotationTests2.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.tests;
-
-import java.io.File;
-import java.util.HashSet;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-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.core.runtime.Path;
-import org.eclipse.jdt.apt.tests.annotations.readannotation.CodeExample;
-import org.eclipse.jdt.apt.tests.plugin.AptTestsPlugin;
-import org.eclipse.jdt.core.BindingKey;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTParser;
-import org.eclipse.jdt.core.dom.ASTRequestor;
-import org.eclipse.jdt.core.dom.IAnnotationBinding;
-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;
-import org.eclipse.jdt.core.tests.builder.BuilderTests;
-import org.eclipse.jdt.core.tests.util.Util;
-
-/**
- * This test the dom layer of annotation support. No APT involved.
- * @author tyeung
- */
-public class ReadAnnotationTests2 extends BuilderTests {
-
- private String[] NO_ANNOTATIONS = new String[0];
- private ICompilationUnit[] NO_UNIT = new ICompilationUnit[0];
- private int counter = 0;
- private String projectName = null;
- public ReadAnnotationTests2(final String name) {
- super( name );
- }
-
- public static Test suite() {
- return new TestSuite( ReadAnnotationTests2.class );
- }
-
- public String getProjectName() {
- return projectName;
- }
-
- public String getUniqueProjectName(){
- projectName = ReadAnnotationTests.class.getName() + "Project" + counter; //$NON-NLS-1$
- counter ++;
- return projectName;
- }
-
-
- public IPath getSourcePath() {
- IProject project = env.getProject( getProjectName() );
- IFolder srcFolder = project.getFolder( "src" ); //$NON-NLS-1$
- IPath srcRoot = srcFolder.getFullPath();
- return srcRoot;
- }
-
- public IPath getBinaryPath(){
- IProject project = env.getProject( getProjectName() );
- IFolder srcFolder = project.getFolder( "binary" ); //$NON-NLS-1$
- IPath lib = srcFolder.getFullPath();
- return lib;
- }
-
- public IPath getOutputPath(){
- IProject project = env.getProject( getProjectName() );
- IFolder binFolder = project.getFolder( "bin" ); //$NON-NLS-1$
- IPath bin = binFolder.getFullPath();
- return bin;
- }
-
- private void addAllSources()
- {
- IPath srcRoot = getSourcePath();
- // SimpleAnnotation.java
- env.addClass(
- srcRoot,
- CodeExample.PACKAGE_QUESTION,
- CodeExample.SIMPLE_ANNOTATION_CLASS,
- CodeExample.SIMPLE_ANNOTATION_CODE );
-
- // RTVisibleAnnotation.java
- env.addClass(
- srcRoot,
- CodeExample.PACKAGE_QUESTION,
- CodeExample.RTVISIBLE_CLASS,
- CodeExample.RTVISIBLE_ANNOTATION_CODE);
-
- // RTInvisibleAnnotation.java
- env.addClass(
- srcRoot,
- CodeExample.PACKAGE_QUESTION,
- CodeExample.RTINVISIBLE_CLASS,
- CodeExample.RTINVISIBLE_ANNOTATION_CODE);
-
- // package-info.java
- env.addClass(
- srcRoot,
- CodeExample.PACKAGE_QUESTION,
- CodeExample.PACKAGE_INFO_CLASS,
- CodeExample.PACKAGE_INFO_CODE);
-
- // Color.java
- env.addClass(
- srcRoot,
- CodeExample.PACKAGE_QUESTION,
- CodeExample.COLOR_CLASS,
- CodeExample.COLOR_CODE);
-
- // AnnotationTest.java
- env.addClass(
- srcRoot,
- CodeExample.PACKAGE_QUESTION,
- CodeExample.ANNOTATION_TEST_CLASS,
- CodeExample.ANNOTATION_TEST_CODE);
- }
-
- private IProject setupTest() throws Exception
- {
- // project will be deleted by super-class's tearDown() method
- IPath projectPath = env.addProject( getUniqueProjectName(), "1.5" ); //$NON-NLS-1$
- env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$
- env.addExternalJars( projectPath, Util.getJavaClassLibs() );
-
- IJavaProject jproj = env.getJavaProject(projectPath);
- jproj.setOption("org.eclipse.jdt.core.compiler.problem.deprecation", "ignore");
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$
-
- env.addPackageFragmentRoot( projectPath, "src" ); //$NON-NLS-1$
- return env.getProject(getProjectName());
- }
-
- public void testSourceAnnotation() throws Exception {
- // reset the error reset the error;
- IProject project = setupTest();
- addAllSources();
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- _testAnnotations();
- }
-
- public void testBinaryAnnotation() throws Exception
- {
- IProject project = setupTest();
- final File jar =
- TestUtil.getFileInPlugin(AptTestsPlugin.getDefault(),
- new Path("/resources/question.jar")); //$NON-NLS-1$
- final String path = jar.getAbsolutePath();
- env.addExternalJar(project.getFullPath(), path);
- fullBuild( project.getFullPath() );
- expectingNoProblems();
- _testAnnotations();
- }
-
- private ITypeBinding getTypeBinding(final String key, final IJavaProject javaProj)
- {
- 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(javaProj);
- parser.createASTs(NO_UNIT, new String[]{key}, requestor, null);
- return requestor._result;
- }
-
- public void _testAnnotations()
- {
- final String typeKey = BindingKey.createTypeBindingKey("question.AnnotationTest");
- final ITypeBinding typeBinding = getTypeBinding(typeKey, env.getJavaProject(getProjectName()));
-
- TestCase.assertNotNull("failed to locate 'question.AnnotationTest'", typeBinding);
- TestCase.assertEquals("Type name mismatch", "question.AnnotationTest", typeBinding.getQualifiedName());
-
- // test package annotation
- final String[] expectedPkgAnnos = new String[]{ "@Deprecated()" };
- assertAnnotation(expectedPkgAnnos, typeBinding.getPackage().getAnnotations() );
-
- // test annotation on type.
- final String[] expectedTypeAnnos = new String[]{ "@Deprecated()",
- "@RTVisibleAnno(anno = @SimpleAnnotation(value = test), clazzes = {})",
- "@RTInvisibleAnno(value = question)" };
-
- assertAnnotation(expectedTypeAnnos, typeBinding.getAnnotations());
-
- final IVariableBinding[] fieldBindings = typeBinding.getDeclaredFields();
- int counter = 0;
- TestCase.assertEquals(5, fieldBindings.length);
- for(IVariableBinding fieldDecl : fieldBindings ){
- final String name = "field" + counter;
-
- TestCase.assertEquals("field name mismatch", name, fieldDecl.getName());
- final String[] expected;
- switch(counter){
- case 0:
- expected = new String[] { "@RTVisibleAnno(name = Foundation, boolValue = false, byteValue = 16, charValue = c, doubleValue = 99.0, floatValue = 9.0, intValue = 999, longValue = 3333, shortValue = 3, colors = {question.Color RED, question.Color BLUE}, anno = @SimpleAnnotation(value = core), simpleAnnos = {@SimpleAnnotation(value = org), @SimpleAnnotation(value = eclipse), @SimpleAnnotation(value = jdt)}, clazzes = {Object.class, String.class}, clazz = Object.class)",
- "@RTInvisibleAnno(value = org.eclipse.jdt.core)",
- "@Deprecated()" };
- break;
- case 1:
- expected = new String[] { "@Deprecated()" };
- break;
- case 2:
- expected = new String[] { "@RTVisibleAnno(anno = @SimpleAnnotation(value = field), clazzes = {})",
- "@RTInvisibleAnno(value = 2)" };
- break;
- case 3:
- expected = new String[] { "@RTInvisibleAnno(value = 3)" };
- break;
- case 4:
- expected = new String[] { "@SimpleAnnotation(value = 4)" };
- break;
- default:
- expected = NO_ANNOTATIONS;
- }
-
- assertAnnotation(expected, fieldDecl.getAnnotations());
- counter ++;
- }
-
-
- final IMethodBinding[] methodBindings = typeBinding.getDeclaredMethods();
- counter = 0;
- TestCase.assertEquals(7, methodBindings.length);
- for(IMethodBinding methodDecl : methodBindings ){
- final String name = "method" + counter;
-
- TestCase.assertEquals("method name mismatch", name, methodDecl.getName());
- final String[] expected;
- switch(counter)
- {
- case 0:
- expected = new String[] { "@RTVisibleAnno(anno = @SimpleAnnotation(value = method0), clazzes = {})",
- "@RTInvisibleAnno(value = 0)",
- "@Deprecated()" };
- break;
- case 1:
- expected = new String[] { "@Deprecated()" };
- break;
- case 2:
- expected = new String[] { "@RTVisibleAnno(anno = @SimpleAnnotation(value = method2), clazzes = {})",
- "@RTInvisibleAnno(value = 2)" };
- break;
- case 3:
- expected = new String[] { "@RTInvisibleAnno(value = 3)" };
- break;
- case 4:
- expected = new String[] { "@SimpleAnnotation(value = method4)" };
- break;
- case 5:
- case 6:
- default:
- expected = NO_ANNOTATIONS;
- }
-
- assertAnnotation(expected, methodDecl.getAnnotations());
-
- if( counter == 5 ){
- final int numParameters = methodDecl.getParameterTypes().length;
- for( int pCounter=0; pCounter<numParameters; pCounter++ ){
- final String[] expectedParamAnnotations;
- switch( pCounter )
- {
- case 1:
- expectedParamAnnotations = new String[] { "@Deprecated()" };
- break;
- case 2:
- expectedParamAnnotations = new String[] { "@RTVisibleAnno(anno = @SimpleAnnotation(value = param2), clazzes = {})",
- "@RTInvisibleAnno(value = 2)" };
- break;
- default:
- expectedParamAnnotations = NO_ANNOTATIONS;
- }
- assertAnnotation(expectedParamAnnotations, methodDecl.getParameterAnnotations(pCounter));
- }
-
- }
- counter ++;
- }
- }
-
- private void assertAnnotation(final String[] expected, IAnnotationBinding[] annotations)
- {
- final int expectedLen = expected.length;
- TestCase.assertEquals("annotation number mismatch", expected.length, annotations.length); //$NON-NLS-1$
-
- final HashSet<String> expectedSet = new HashSet<String>(expectedLen * 4 / 3 + 1);
- for( int i=0; i<expectedLen; i++ )
- expectedSet.add(expected[i]);
-
- int counter = 0;
- for( IAnnotationBinding mirror : annotations ){
- if( counter >= expectedLen )
- TestCase.assertEquals("", mirror.toString()); //$NON-NLS-1$
- else{
- final String mirrorToString = mirror.toString();
- final boolean contains = expectedSet.contains(mirrorToString);
- if( !contains ){
- System.err.println(mirrorToString);
- System.err.println(expectedSet);
- }
- TestCase.assertTrue("unexpected annotation " + mirrorToString, contains); //$NON-NLS-1$
- expectedSet.remove(mirrorToString);
- }
- counter ++;
- }
- }
-
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/RegressionTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/RegressionTests.java
deleted file mode 100644
index 3bd5c207b5..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/RegressionTests.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.TestSuite;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.tests.util.Util;
-
-/**
- *
- */
-public class RegressionTests extends APTTestBase {
-
- public RegressionTests(String name) {
- super(name);
- }
-
- public static Test suite()
- {
- return new TestSuite( RegressionTests.class );
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
- }
-
- /**
- * Bugzilla 104032: NPE when deleting project that has APT settings.
- */
- public void testBugzilla104032() throws Exception
- {
- // set up project with unique name
- final String projName = RegressionTests.class.getName() + "104032.Project"; //$NON-NLS-1$
- IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$
- env.addExternalJars( projectPath, Util.getJavaClassLibs() );
-
- 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 ) );
- IProject project = env.getProject( projName );
- IFolder srcFolder = project.getFolder( "src" );
- IPath srcRoot = srcFolder.getFullPath();
-
- 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; }";
- env.addClass( srcRoot, "p1", "A1", a1Code ); //$NON-NLS-1$ //$NON-NLS-2$
- env.addClass( srcRoot, "p1", "A2", a2Code ); //$NON-NLS-1$ //$NON-NLS-2$
- env.addClass( srcRoot, "p1", "B", bCode ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // Set some per-project preferences
- IJavaProject jproj = env.getJavaProject( projName );
- AptConfig.addProcessorOption(jproj, "test.104032.a", "foo");
- AptConfig.setEnabled(jproj, true);
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- // Now delete the project!
- ResourcesPlugin.getWorkspace().delete(new IResource[] { project }, true, null);
-
- }
-
- /**
- * Tests annotation proxies
- */
- public void testBugzilla106541() throws Exception
- {
- final String projName = RegressionTests.class.getName() + "104032.Project"; //$NON-NLS-1$
- IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$
- env.addExternalJars( projectPath, Util.getJavaClassLibs() );
-
- env.removePackageFragmentRoot( projectPath, "" ); //$NON-NLS-1$
- env.addPackageFragmentRoot( projectPath, "src" ); //$NON-NLS-1$
- env.setOutputFolder( projectPath, "bin" ); //$NON-NLS-1$
-
- IJavaProject javaProject = env.getJavaProject( projectPath ) ;
- AptConfig.setEnabled(javaProject, true);
- TestUtil.createAndAddAnnotationJar(javaProject);
- IProject project = env.getProject( projName );
- IFolder srcFolder = project.getFolder( "src" );
- IPath srcRoot = srcFolder.getFullPath();
-
- String code = "package p1; " + "\n"
- + "import org.eclipse.jdt.apt.tests.annotations.readAnnotationType.SimpleAnnotation;" + "\n"
- + "@SimpleAnnotation(SimpleAnnotation.Name.HELLO)" + "\n"
- + "public class MyClass { \n"
- + " public test.HELLOGen _gen;"
- + " }";
-
- env.addClass( srcRoot, "p1", "MyClass", code );
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- // Now delete the project!
- ResourcesPlugin.getWorkspace().delete(new IResource[] { project }, true, null);
-
- }
-
- // doesn't work because of a jdt.core type system universe problem.
- public void testBugzilla120255() throws Exception{
- final String projName = RegressionTests.class.getName() + "120255.Project"; //$NON-NLS-1$
- IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$
- env.addExternalJars( projectPath, Util.getJavaClassLibs() );
-
- 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 ) );
- IProject project = env.getProject( projName );
- IFolder srcFolder = project.getFolder( "src" );
- IPath srcRoot = srcFolder.getFullPath();
-
- String a1Code = "package pkg; " + "\n"
- + "import org.eclipse.jdt.apt.tests.annotations.apitest.Common;\n"
- + "import java.util.*;\n\n"
- + "@Common\n"
- + "public class A1<T> {\n "
- + " @Common\n"
- + " Collection<String> collectionOfString;\n\n"
- + " @Common\n"
- + " Collection<List> collectionOfList;\n"
- + " public static class inner{}"
- + "}";
-
- final IPath a1Path = env.addClass( srcRoot, "pkg", "A1", a1Code ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // Set some per-project preferences
- IJavaProject jproj = env.getJavaProject( projName );
- AptConfig.setEnabled(jproj, true);
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(a1Path, new ExpectedProblem[]{
- new ExpectedProblem("", "java.util.List is assignable to java.util.Collection", a1Path),
- new ExpectedProblem("", "java.lang.String is not assignable to java.util.Collection", a1Path),
- new ExpectedProblem("", "Type parameter 'T' belongs to org.eclipse.jdt.apt.core.internal.declaration.ClassDeclarationImpl A1", a1Path)
- }
- );
- }
-
- /**
- * Test the Types.isSubtype() API, in various inheritance scenarios
- */
- public void testBugzilla206591A() throws Exception {
- final String projName = RegressionTests.class.getName() + "206591.Project"; //$NON-NLS-1$
- IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$
- env.addExternalJars( projectPath, Util.getJavaClassLibs() );
-
- 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 ) );
- IProject project = env.getProject( projName );
- IFolder srcFolder = project.getFolder( "src" );
- IPath srcRoot = srcFolder.getFullPath();
-
- String a1Code = "package pkg; " + "\n"
- + "import org.eclipse.jdt.apt.tests.annotations.apitest.SubtypeOf;\n"
- + "public interface A1 {\n "
- + "}\n"
- + "class A2 implements A1 {\n"
- + "}\n"
- + "class A3 extends A2 {\n"
- + " @SubtypeOf(A1.class) // yes\n"
- + " A2 _foo;\n"
- + " @SubtypeOf(A1.class) // yes\n"
- + " A3 _bar;\n"
- + " @SubtypeOf(A2.class) // yes\n"
- + " A3 _baz;\n"
- + " @SubtypeOf(A1.class) // yes\n"
- + " A1 _quux;\n"
- + " @SubtypeOf(A2.class) // no\n"
- + " A1 _yuzz;\n"
- + " @SubtypeOf(String.class) // no\n"
- + " A2 _wum;\n"
- + "}\n"
- + "class A4 extends A2 implements A1 {\n"
- + " @SubtypeOf(A1.class) // yes\n"
- + " A4 _humpf;\n"
- + " @SubtypeOf(A2.class) // yes\n"
- + " A4 _fuddle;\n"
- + " @SubtypeOf(A5.class) // no\n"
- + " A4 _snee;\n"
- + "}\n"
- + "class A5 {\n"
- + "}\n";
-
- final IPath a1Path = env.addClass( srcRoot, "pkg", "A1", a1Code ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // Set some per-project preferences
- IJavaProject jproj = env.getJavaProject( projName );
- AptConfig.setEnabled(jproj, true);
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(a1Path, new ExpectedProblem[]{
- new ExpectedProblem("", "pkg.A2 is a subtype of pkg.A1", a1Path),
- new ExpectedProblem("", "pkg.A3 is a subtype of pkg.A1", a1Path),
- new ExpectedProblem("", "pkg.A3 is a subtype of pkg.A2", a1Path),
- new ExpectedProblem("", "pkg.A1 is a subtype of pkg.A1", a1Path),
- new ExpectedProblem("", "pkg.A1 is not a subtype of pkg.A2", a1Path),
- new ExpectedProblem("", "pkg.A2 is not a subtype of java.lang.String", a1Path),
- new ExpectedProblem("", "pkg.A4 is a subtype of pkg.A1", a1Path),
- new ExpectedProblem("", "pkg.A4 is a subtype of pkg.A2", a1Path),
- new ExpectedProblem("", "pkg.A4 is not a subtype of pkg.A5", a1Path),
- }
- );
- }
-
- /**
- * Test the Types.isAssignable() API, in various inheritance scenarios
- * @throws Exception
- */
- public void testBugzilla206591B() throws Exception {
- final String projName = RegressionTests.class.getName() + "206591.Project"; //$NON-NLS-1$
- IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$
- env.addExternalJars( projectPath, Util.getJavaClassLibs() );
-
- 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 ) );
- IProject project = env.getProject( projName );
- IFolder srcFolder = project.getFolder( "src" );
- IPath srcRoot = srcFolder.getFullPath();
-
- String a1Code = "package pkg; " + "\n"
- + "import org.eclipse.jdt.apt.tests.annotations.apitest.AssignableTo;\n"
- + "public interface A1 {\n "
- + "}\n"
- + "class A2 implements A1 {\n"
- + "}\n"
- + "class A3 extends A2 {\n"
- + " @AssignableTo(A1.class) // yes\n"
- + " A2 _foo;\n"
- + " @AssignableTo(int.class) // yes\n"
- + " byte _bar;\n"
- + " @AssignableTo(A1.class) // yes\n"
- + " A3 _baz;\n"
- + " @AssignableTo(A2.class) // no\n"
- + " A1 _quux;\n"
- + "}";
-
- final IPath a1Path = env.addClass( srcRoot, "pkg", "A1", a1Code ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // Set some per-project preferences
- IJavaProject jproj = env.getJavaProject( projName );
- AptConfig.setEnabled(jproj, true);
- fullBuild( project.getFullPath() );
- expectingSpecificProblemsFor(a1Path, new ExpectedProblem[]{
- new ExpectedProblem("", "pkg.A2 is assignable to pkg.A1", a1Path),
- new ExpectedProblem("", "byte is assignable to int", a1Path),
- new ExpectedProblem("", "pkg.A3 is assignable to pkg.A1", a1Path),
- new ExpectedProblem("", "pkg.A1 is not assignable to pkg.A2", a1Path),
- }
- );
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ScalingTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ScalingTests.java
deleted file mode 100644
index 2f43ef14de..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ScalingTests.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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 java.io.File;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.tests.util.Util;
-
-/**
- *
- * @since 3.3
- */
-public class ScalingTests extends APTTestBase {
- private final boolean VERBOSE = true;
-
- public ScalingTests(String name) {
- super(name);
- }
-
- public static Test suite()
- {
- return new TestSuite( ScalingTests.class );
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
- }
-
- /**
- * A customer reports that projects with ~2000 files abort generation.
- * Note, this test will take quite a long time to run.
- */
- public void testGeneratingLotsOfFiles() throws Exception
- {
- final int FILES_TO_GENERATE = 4000; // total number of files to create
- final int PAUSE_EVERY = 200; // wait for indexer to catch up after creating this many files
- final int PAUSE_TIME = 2000; // milliseconds to wait for indexer
-
- // set up project with unique name
- final String projName = ScalingTests.class.getName() + "LotsOfFilesProject"; //$NON-NLS-1$
- IPath projectPath = env.addProject( projName, "1.5" ); //$NON-NLS-1$
- env.addExternalJars( projectPath, Util.getJavaClassLibs() );
-
- 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 ) );
- IProject project = env.getProject( projName );
- IFolder srcFolder = project.getFolder( "src" );
- IPath srcRoot = srcFolder.getFullPath();
-
- String template =
- "package p;\n" +
- "import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;\n" +
- "@HelloWorldAnnotation(\"Generated%05d\")\n" +
- "public class Test%05d { generatedfilepackage.Generated%05d _t; }";
- for (int i = 1; i <= FILES_TO_GENERATE; ++i) {
- String name = String.format("Test%05d", i);
- String contents = String.format(template, i, i, FILES_TO_GENERATE - i + 1);
- env.addClass( srcRoot, "p", name, contents ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // pause to let indexer catch up
- if (i % PAUSE_EVERY == 0) {
- if (VERBOSE)
- System.out.println("Created " + i + " files; pausing for indexer");
- Thread.sleep(PAUSE_TIME);
- }
- }
-
- if (VERBOSE)
- System.out.println("Done creating source files");
-
- // Set some per-project preferences
- IJavaProject jproj = env.getJavaProject( projName );
- AptConfig.setEnabled(jproj, true);
-
- long start = System.currentTimeMillis();
- fullBuild( project.getFullPath() );
- if (VERBOSE)
- System.out.println("Done with build after " + ((System.currentTimeMillis() - start)/1000L) + " sec");
-
- expectingNoProblems();
-
- IPath projPath = jproj.getProject().getLocation();
- for (int i = 1; i <= FILES_TO_GENERATE; ++i) {
- // check that file was generated
- String genFileName = String.format(".apt_generated/generatedfilepackage/Generated%05d.java", i);
- File genFile = new File(projPath.append(genFileName).toOSString());
- assertTrue("Expected generated source file " + genFileName + " was not found", genFile != null && genFile.exists());
- // check that generated file was compiled
- String genClassName = String.format("bin/generatedfilepackage/Generated%05d.class", i);
- File genClass = new File(projPath.append(genClassName).toOSString());
- assertTrue("Compiled file " + genClassName + " was not found", genClass != null && genClass.exists());
- }
-
- if (VERBOSE)
- System.out.println("Done checking output");
-
- // Now delete the project!
- ResourcesPlugin.getWorkspace().delete(new IResource[] { project }, true, null);
-
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ScannerTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ScannerTests.java
deleted file mode 100644
index 5b65090ffe..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/ScannerTests.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 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:
- * sbandow@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.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.core.internal.util.ScannerUtil;
-
-public class ScannerTests extends APTTestBase {
-
- public ScannerTests(final String name) {
- super( name );
- }
-
- public static Test suite() {
- return new TestSuite( ScannerTests.class );
- }
-
- public void testHasAnnotation() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code =
- "package test;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.noop.NoOpAnnotation;" + "\n" +
- "@NoOpAnnotation" + "\n" +
- "public class Has" + "\n" +
- "{" + "\n" +
- "}";
-
- env.addClass(srcRoot, "test", "Has", code);
-
- IFile file = project.getFile(P + "src" + P + "test" + P + "Has.java");
-
- assertTrue("Expected annotation instance", ScannerUtil.hasAnnotationInstance(file));
- assertTrue("Expected annotation instance", ScannerUtil.hasAnnotationInstance(code.toCharArray()));
- }
-
- public void testHasNoAnnotation() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code =
- "package test;" + "\n" +
- "public class No" + "\n" +
- "{" + "\n" +
- "}";
-
- env.addClass(srcRoot, "test", "No", code);
-
- IFile file = project.getFile(P + "src" + P + "test" + P + "No.java");
-
- assertFalse("Expected no annotation instance", ScannerUtil.hasAnnotationInstance(file));
- assertFalse("Expected no annotation instance", ScannerUtil.hasAnnotationInstance(code.toCharArray()));
- }
-
- public void testHasAnnotationInComment() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code =
- "package test;" + "\n" +
- "/**" + "\n" +
- " * @author Joe Bob" + "\n" +
- " */" + "\n" +
- "public class Comments" + "\n" +
- "{" + "\n" +
- " // @Foo" + "\n" +
- " /* @Bar */" + "\n" +
- "}";
-
- env.addClass(srcRoot, "test", "Comments", code);
-
- IFile file = project.getFile(P + "src" + P + "test" + P + "Comments.java");
-
- assertFalse("Expected no annotation instance", ScannerUtil.hasAnnotationInstance(file));
- assertFalse("Expected no annotation instance", ScannerUtil.hasAnnotationInstance(code.toCharArray()));
- }
-
-
- /*
- * Test currently disabled due to Bugzilla 140232
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=140232
- */
- public void _testHasAnnotationDeclaration() throws Exception
- {
- IProject project = env.getProject( getProjectName() );
- IPath srcRoot = getSourcePath();
-
- String code =
- "package test;" + "\n" +
- "public @interface AnnoDecl" + "\n" +
- "{" + "\n" +
- "}";
-
- env.addClass(srcRoot, "test", "AnnoDecl", code);
-
- IFile file = project.getFile(P + "src" + P + "test" + P + "AnnoDecl.java");
-
- assertFalse("Expected no annotation instance", ScannerUtil.hasAnnotationInstance(file));
- assertFalse("Expected no annotation instance", ScannerUtil.hasAnnotationInstance(code.toCharArray()));
- }
-
- private String P = File.separator;
-
-}
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 fe2dfbcb80..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestAll.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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(APITests.suite());
- suite.addTest(MirrorTests.suite());
- suite.addTest(ReadAnnotationTests.suite());
- suite.addTest(PreferencesTests.suite());
- suite.addTest(FactoryLoaderTests.suite());
- suite.addTest(ListenerTests.suite());
- suite.addTest(MirrorDeclarationTests.suite());
- suite.addTest(MirrorUtilTests.suite());
- suite.addTest(AnnotationValueConversionTests.suite());
- suite.addTest(JavaVersionTests.suite());
- suite.addTest(RegressionTests.suite());
- suite.addTest(FileGenerationTests.suite());
- suite.addTest(MixedModeTesting.suite());
- suite.addTest(ExceptionHandlingTests.suite());
- suite.addTest(ScannerTests.suite());
- suite.addTest(DeclarationVisitorTests.suite());
- suite.addTest(TypeVisitorTests.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 c469598378..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TestUtil.java
+++ /dev/null
@@ -1,462 +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.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.util.FileSystemUtil;
-import org.eclipse.jdt.apt.tests.plugin.AptTestsPlugin;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-
-public class TestUtil
-{
-
- private static File ANNO_JAR = null;
-
- /**
- * Returns the annotation jar, creating it if it hasn't already been created.
- * @return the java.io.File of the jar that was created.
- */
- public static File createAndAddAnnotationJar( IJavaProject project )
- throws IOException, JavaModelException
- {
- if (ANNO_JAR == null) {
- // The jar file will be created in the state location, e.g., .metadata/
- IPath statePath = AptPlugin.getPlugin().getStateLocation();
- IPath jarPath = statePath.append("org.eclipse.jdt.apt.tests.TestUtil.jar");
- ANNO_JAR = new File(jarPath.toOSString());
- String classesJarPath = ANNO_JAR.getAbsolutePath();
-
- if (null != getFileInPlugin( AptTestsPlugin.getDefault(), new Path("/bin") )) {
- // We're in a dev environment, where we jar up the classes from the plugin project
- FileFilter filter = new PackageFileFilter(
- ANNOTATIONS_PKG, getPluginClassesDir());
- Map<File, FileFilter> files = Collections.singletonMap(
- new File(getPluginClassesDir()), filter);
- zip( classesJarPath, files );
- }
- else {
- // We're in a releng environment, where we copy the already-built jar
- File aptJarFile = getFileInPlugin( AptTestsPlugin.getDefault(), new Path("/apt.jar"));
- if(null == aptJarFile) {
- throw new FileNotFoundException("Could not find apt.jar file in org.eclipse.jdt.apt.tests plugin");
- }
- moveFile(aptJarFile, classesJarPath);
- }
-
- ANNO_JAR.deleteOnExit();
- }
-
- addLibraryEntry( project, new Path(ANNO_JAR.getAbsolutePath()), null /*srcAttachmentPath*/,
- null /*srcAttachmentPathRoot*/, true );
-
- return ANNO_JAR;
- }
-
- /**
- * Looks for the apt.jar that is defined in the build.properties
- * and available when the plugin is built deployed.
- * (currently when the plugin is built using releng the /bin directory classes are not available)
- *
- * else it creates an annotation jar containing annotations and processors
- * from the "external.annotations" package, and adds it to the project.
- * Classes will be found under [project]/binext, and manifest will be
- * drawn from [project]/srcext/META-INF.
- * This jar is meant to represent an annotation jar file not
- * wrapped within a plugin. Note that adding a jar to a project makes
- * its classes visible to the compiler but does NOT automatically cause
- * its annotation processors to be loaded.
- * @return the java.io.File of the jar that was created.
- */
- public static File createAndAddExternalAnnotationJar(
- IJavaProject project )
- throws IOException, JavaModelException
- {
- // create temporary file
- File jarFile = File.createTempFile("org.eclipse.jdt.apt.tests.TestUtil", ".jar"); //$NON-NLS-1$//$NON-NLS-2$
- String classesJarPath = jarFile.getAbsolutePath();
-
- File extBinDir = getFileInPlugin( AptTestsPlugin.getDefault(), new Path("/binext"));
- if(null != extBinDir) {
-
- //create zip file in temp file location
- FileFilter classFilter = new PackageFileFilter(
- EXTANNOTATIONS_PKG, getPluginExtClassesDir());
- FileFilter manifestFilter = new PackageFileFilter(
- "META-INF", getPluginExtSrcDir()); //$NON-NLS-1$
- Map<File, FileFilter> files = new HashMap<File, FileFilter>(2);
- files.put(new File( getPluginExtClassesDir() ), classFilter);
- files.put(new File( getPluginExtSrcDir() ), manifestFilter);
- zip( classesJarPath, files );
-
- } else {
-
- File extJarFile = getFileInPlugin( AptTestsPlugin.getDefault(), new Path("/aptext.jar"));
- if(null != extJarFile) {
-
- // move extapt.jar to classesJarPath file
- moveFile(extJarFile, classesJarPath);
-
- } else {
-
- throw new FileNotFoundException("Could not find aptext.jar file in org.eclipse.jdt.apt.tests plugin");
- }
-
- }
-
- addLibraryEntry( project, new Path(classesJarPath), null /*srcAttachmentPath*/,
- null /*srcAttachmentPathRoot*/, true );
-
-
- // This file will be locked until GC takes care of unloading the
- // annotation processor classes, so we can't delete it ourselves.
- jarFile.deleteOnExit();
- return jarFile;
-
- }
-
- /**
- * Set the autobuild to the value of the parameter and
- * return the old one. This is a workaround for a synchronization
- * problem: thread A creates a project, thus spawning thread B to
- * do an autobuild. Thread A goes on to configure the project's
- * classpath; at the same time, thread B calls APT, which configures
- * the project's classpath. Access to the classpath is not
- * synchronized, so there's a race for which thread's modification
- * wins. We work around this by disabling autobuild.
- *
- * @param state the value to be set for autobuilding.
- * @return the old value of the autobuild state
- */
- public static boolean enableAutoBuild(boolean state) {
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- IWorkspaceDescription desc= workspace.getDescription();
- boolean isAutoBuilding= desc.isAutoBuilding();
- if (isAutoBuilding != state) {
- desc.setAutoBuilding(state);
- try {
- workspace.setDescription(desc);
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
- return isAutoBuilding;
- }
-
- public static IPath getProjectPath( IJavaProject project )
- {
- return project.getResource().getLocation();
- }
-
- public static String getPluginClassesDir()
- {
- return getFileInPlugin( AptTestsPlugin.getDefault(), new Path( "/bin" ) ) //$NON-NLS-1$
- .getAbsolutePath();
- }
-
- public static String getPluginExtClassesDir()
- {
- return getFileInPlugin( AptTestsPlugin.getDefault(), new Path( "/binext" ) ) //$NON-NLS-1$
- .getAbsolutePath();
- }
-
- public static String getPluginExtSrcDir()
- {
- return getFileInPlugin( AptTestsPlugin.getDefault(), new Path( "/srcext" ) ) //$NON-NLS-1$
- .getAbsolutePath();
- }
-
- /**
- *
- * @param plugin The Plugin to get file from
- * @param path The path to the file in the Plugin
- * @return File object if found, null otherwise
- */
- public static java.io.File getFileInPlugin(Plugin plugin, IPath path)
- {
- try
- {
- URL installURL = plugin.getBundle().getEntry( path.toString() );
- if(null == installURL)
- return null; // File Not found
-
- URL localURL = FileLocator.toFileURL( installURL );
- return new java.io.File( localURL.getFile() );
- }
- catch( IOException e )
- {
- return null;
- }
- }
-
- /**
- * Could use File.renameTo(File) but it's platform dependant.
- *
- * @param from - The file to move
- * @param path - The path to move it to
- */
- public static void moveFile(File from , String toPath)
- throws FileNotFoundException, IOException {
-
- FileInputStream fis = null;
- FileOutputStream fos = null;
- try
- {
- fis = new FileInputStream( from );
- fos = new FileOutputStream(new File(toPath));
- int b;
- while ( ( b = fis.read() ) != -1)
- fos.write( b );
- }
- finally
- {
- if ( fis != null ) fis.close();
- if ( fos != null ) fos.close();
- }
- }
-
- /**
- * Create a zip file and add contents.
- * @param zipPath the zip file
- * @param input a map of root directories and corresponding filters. Each
- * root directory will be searched, and any files that pass the filter will
- * be added to the zip file.
- * @throws IOException
- */
- public static void zip(String zipPath, Map<File, FileFilter> input)
- throws IOException
- {
- ZipOutputStream zip = null;
- try
- {
- zip = new ZipOutputStream( new FileOutputStream( zipPath ) );
- // +1 for last slash
- for (Map.Entry<File, FileFilter> e : input.entrySet()) {
- zip( zip, e.getKey(), e.getKey().getPath().length() + 1, e.getValue() );
- }
- }
- finally
- {
- if( zip != null )
- {
- zip.close();
- }
- }
- }
-
- private static void zip(ZipOutputStream zip, File dir, 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( zip, file, rootPathLength, filter );
- }
- else
- {
- String path = file.getPath();
- path = path.substring( rootPathLength );
- ZipEntry entry = new ZipEntry( path.replace( '\\', '/' ) );
- zip.putNextEntry( entry );
- zip.write( getBytesFromFile( file ) );
- zip.closeEntry();
- }
- }
- }
- }
- }
-
- private static byte[] getBytesFromFile( File f )
- throws IOException
- {
- FileInputStream fis = null;
- ByteArrayOutputStream baos = null;
- byte[] rtrn = new byte[0];
- try
- {
- fis = new FileInputStream( f );
- baos = new ByteArrayOutputStream();
- int b;
- while ( ( b = fis.read() ) != -1)
- baos.write( b );
- rtrn = baos.toByteArray();
- }
- finally
- {
- if ( fis != null ) fis.close();
- if ( baos != null ) baos.close();
- }
- return rtrn;
-
- }
-
- public static void unzip (File srcZip, File destDir) throws IOException {
- ZipFile zf = new ZipFile(srcZip);
- for (Enumeration<? extends ZipEntry> entries = zf.entries(); entries.hasMoreElements();) {
- ZipEntry entry = entries.nextElement();
- String name = entry.getName();
- File dest = new File(destDir, name);
- if (entry.isDirectory()) {
- FileSystemUtil.mkdirs(dest);
- }
- else {
- File parent = dest.getParentFile();
- FileSystemUtil.mkdirs(parent);
- InputStream from = null;
- OutputStream to = null;
- try {
- from = zf.getInputStream(entry);
- to = new FileOutputStream(dest);
- byte[] buffer = new byte[4096];
- int bytesRead;
- while ((bytesRead = from.read(buffer)) != -1) {
- to.write(buffer, 0, bytesRead);
- }
- }
- finally {
- if (from != null) try {from.close();} catch (IOException ioe){}
- if (to != null) try {to.close();} catch (IOException ioe) {}
- }
- }
- }
- }
-
- public static void unzip (ZipInputStream srcZip, File destDir) throws IOException {
- ZipEntry entry;
- while ((entry = srcZip.getNextEntry()) != null) {
- String name = entry.getName();
- File dest = new File(destDir, name);
- if (entry.isDirectory()) {
- FileSystemUtil.mkdirs(dest);
- }
- else {
- File parent = dest.getParentFile();
- FileSystemUtil.mkdirs(parent);
- OutputStream to = null;
- try {
- to = new FileOutputStream(dest);
- byte[] buffer = new byte[4096];
- int bytesRead;
- while ((bytesRead = srcZip.read(buffer)) != -1) {
- to.write(buffer, 0, bytesRead);
- }
- }
- finally {
- srcZip.closeEntry();
- if (to != null) try {to.close();} catch (IOException ioe) {}
- }
- }
- }
- }
-
-
- public static void addLibraryEntry(IJavaProject project, IPath path, IPath srcAttachmentPath, IPath srcAttachmentPathRoot, boolean exported) throws JavaModelException{
- IClasspathEntry[] entries = project.getRawClasspath();
- int length = entries.length;
- IClasspathEntry newPathEntry = JavaCore.newLibraryEntry(
- path,
- srcAttachmentPath,
- srcAttachmentPathRoot,
- exported);
- for(int i = 0; i < length; i++) {
- //check for duplicates (Causes JavaModelException) - return if path already exists
- if(newPathEntry.equals(entries[i]))
- return;
- }
- System.arraycopy(entries, 0, entries = new IClasspathEntry[length + 1], 1, length);
- entries[0] = newPathEntry;
- project.setRawClasspath(entries, null);
- }
-
-
- private static class PackageFileFilter implements FileFilter {
- private final String[] _packageParts;
- private final Path _binDir;
-
- /**
- * Select only those files under a certain package.
- * @param packageSubset a partial package name, such as
- * "org.eclipse.jdt.apt.tests.annotations".
- * @param binDir the absolute path of the directory
- * in which the compiled classes are to be found.
- */
- public PackageFileFilter(String packageSubset, String binDir) {
- _packageParts = packageSubset.split("\\."); //$NON-NLS-1$
- _binDir = new Path(binDir);
- }
-
- public boolean accept(File pathname)
- {
- IPath f = new Path( pathname.getAbsolutePath() );
-
- int nsegments = f.matchingFirstSegments( _binDir );
- boolean ok = true;
- int min = Math.min( f.segmentCount() - nsegments,
- _packageParts.length );
- for( int i = nsegments, j = 0; j < min; i++, j++ )
- {
- if( !f.segment( i ).equals( _packageParts[j] ) )
- {
- ok = false;
- break;
- }
- }
- return ok;
- }
- }
-
- public static final String ANNOTATIONS_PKG =
- "org.eclipse.jdt.apt.tests.annotations"; //$NON-NLS-1$
-
- public static final String EXTANNOTATIONS_PKG =
- "org.eclipse.jdt.apt.tests.external.annotations"; //$NON-NLS-1$
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TypeVisitorTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TypeVisitorTests.java
deleted file mode 100644
index d66338f3a9..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/TypeVisitorTests.java
+++ /dev/null
@@ -1,363 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.apt.tests.annotations.generic.AbstractGenericProcessor;
-import org.eclipse.jdt.apt.tests.annotations.generic.GenericFactory;
-
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.ClassDeclaration;
-import com.sun.mirror.declaration.FieldDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.declaration.TypeParameterDeclaration;
-import com.sun.mirror.type.AnnotationType;
-import com.sun.mirror.type.ArrayType;
-import com.sun.mirror.type.ClassType;
-import com.sun.mirror.type.DeclaredType;
-import com.sun.mirror.type.EnumType;
-import com.sun.mirror.type.InterfaceType;
-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.TypeVisitor;
-import com.sun.mirror.util.Types;
-
-/**
- * Tests for the JDT-APT implementation of Type Visitors
- */
-public class TypeVisitorTests extends APTTestBase {
-
- public TypeVisitorTests(final String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(TypeVisitorTests.class);
- }
-
- public void testPrimitiveTypeVisitor() {
- testCaseIdentifier = Cases.PrimitiveType;
- runProcessorBasedTest();
- }
-
- public void testVoidTypeVisitor() {
- testCaseIdentifier = Cases.VoidType;
- runProcessorBasedTest();
- }
-
- public void testClassTypeVisitor() {
- testCaseIdentifier = Cases.ClassType;
- runProcessorBasedTest();
- }
-
- public void testEnumTypeVisitor() {
- testCaseIdentifier = Cases.EnumType;
- runProcessorBasedTest();
- }
-
- public void testInterfaceTypeVisitor() {
- testCaseIdentifier = Cases.InterfaceType;
- runProcessorBasedTest();
- }
-
- public void testAnnotationTypeVisitor() {
- testCaseIdentifier = Cases.AnnotationType;
- runProcessorBasedTest();
- }
-
- public void testArrayTypeVisitor() {
- testCaseIdentifier = Cases.ArrayType;
- runProcessorBasedTest();
- }
-
- public void testTypeVariableVisitor() {
- testCaseIdentifier = Cases.TypeVariable;
- runProcessorBasedTest();
- }
-
- public void testWildcardTypeVisitor() {
- testCaseIdentifier = Cases.WildcardType;
- runProcessorBasedTest();
- }
-
-
- /**
- * Instantiate the AnnotationProcessor to run the actual tests
- */
- void runProcessorBasedTest() {
- TypeVisitorProc p = new TypeVisitorProc();
- GenericFactory.PROCESSOR = p;
-
- IProject project = env.getProject(getProjectName());
- IPath srcRoot = getSourcePath();
-
- env.addClass(srcRoot, "test", "Test", code);
-
- fullBuild( project.getFullPath() );
- expectingNoProblems();
-
- assertTrue("Processor not invoked", p.called);
- }
-
-
- /**
- * Annotation Processor containing the actual tests
- */
- class TypeVisitorProc extends AbstractGenericProcessor {
- boolean called;
-
- public void _process() {
- called = true;
- assertTrue(decls.size() == 1);
-
- initTypeVisitList();
-
- TypeDeclaration typeDecl = env.getTypeDeclarations().iterator().next();
- Collection<TypeDeclaration> nestedTypes = typeDecl.getNestedTypes();
- Collection<FieldDeclaration> fieldDecls = typeDecl.getFields();
- ClassDeclaration classDecl = null;
- FieldDeclaration fieldDecl = null;
- PrimitiveType primitiveType = null;
- AnnotationMirror annoMirror = null;
- Types typesUtil = env.getTypeUtils();
-
- switch (testCaseIdentifier) {
-
- case PrimitiveType :
- for(FieldDeclaration tempDecl : fieldDecls) {
- if(tempDecl.getSimpleName().equals("j")) {
- fieldDecl = tempDecl;
- }
- }
- primitiveType = (PrimitiveType)fieldDecl.getType();
- primitiveType.accept(new TypeVisitorImpl());
- assertEquals("Expect one visitor", 1, typesVisited.size());
- assertEquals("Expected PrimitiveType visitor", "PrimitiveTypeImpl", typesVisited.get(0).getClass().getSimpleName());
- break;
-
- case VoidType :
- MethodDeclaration methodDecl = typeDecl.getMethods().iterator().next();
- VoidType voidType = (VoidType)methodDecl.getReturnType();
- voidType.accept(new TypeVisitorImpl());
- assertEquals("Expect one visitor", 1, typesVisited.size());
- assertEquals("Expected VoidType visitor", "VoidTypeImpl", typesVisited.get(0).getClass().getSimpleName());
- break;
-
- case ClassType :
- for(TypeDeclaration tempDecl : nestedTypes) {
- if(tempDecl.getSimpleName().equals("C")) {
- classDecl = (ClassDeclaration)tempDecl;
- }
- }
- ClassType classType = classDecl.getSuperclass();
- classType.accept(new TypeVisitorImpl());
- assertEquals("Expect one visitor", 1, typesVisited.size());
- assertEquals("Expected ClassType visitor", "ClassDeclarationImpl", typesVisited.get(0).getClass().getSimpleName());
- break;
-
- case EnumType :
- for(FieldDeclaration tempDecl : fieldDecls) {
- if(tempDecl.getSimpleName().equals("s")) {
- fieldDecl = tempDecl;
- }
- }
- annoMirror = fieldDecl.getAnnotationMirrors().iterator().next();
- EnumType enumType = (EnumType)annoMirror.getElementValues().keySet().iterator().next().getReturnType();
- enumType.accept(new TypeVisitorImpl());
- assertEquals("Expect one visitor", 1, typesVisited.size());
- assertEquals("Expected EnumType visitor", "EnumDeclarationImpl", typesVisited.get(0).getClass().getSimpleName());
- break;
-
- case InterfaceType :
- for(TypeDeclaration tempDecl : nestedTypes) {
- if(tempDecl.getSimpleName().equals("D")) {
- classDecl = (ClassDeclaration)tempDecl;
- }
- }
- InterfaceType interfaceType = classDecl.getSuperinterfaces().iterator().next();
- interfaceType.accept(new TypeVisitorImpl());
- assertEquals("Expect one visitor", 1, typesVisited.size());
- assertEquals("Expected InterfaceType visitor", "InterfaceDeclarationImpl", typesVisited.get(0).getClass().getSimpleName());
- break;
-
- case AnnotationType :
- for(FieldDeclaration tempDecl : fieldDecls) {
- if(tempDecl.getSimpleName().equals("s")) {
- fieldDecl = tempDecl;
- }
- }
- annoMirror = fieldDecl.getAnnotationMirrors().iterator().next();
- AnnotationType annoType = annoMirror.getAnnotationType();
- annoType.accept(new TypeVisitorImpl());
- assertEquals("Expect one visitor", 1, typesVisited.size());
- assertEquals("Expected AnnotationType visitor", "AnnotationDeclarationImpl", typesVisited.get(0).getClass().getSimpleName());
- break;
-
- case ArrayType :
- for(FieldDeclaration tempDecl : fieldDecls) {
- if(tempDecl.getSimpleName().equals("k")) {
- fieldDecl = tempDecl;
- }
- }
- ArrayType arrayType = (ArrayType)fieldDecl.getType();
- arrayType.accept(new TypeVisitorImpl());
- assertEquals("Expect one visitor", 1, typesVisited.size());
- assertEquals("Expected ArrayType visitor", "ArrayTypeImpl", typesVisited.get(0).getClass().getSimpleName());
- break;
-
- case TypeVariable :
- for(TypeDeclaration tempDecl : nestedTypes) {
- if(tempDecl.getSimpleName().equals("P")) {
- classDecl = (ClassDeclaration)tempDecl;
- }
- }
- TypeParameterDeclaration typeParamDecl = classDecl.getFormalTypeParameters().iterator().next();
- TypeVariable typeVariable = typesUtil.getTypeVariable(typeParamDecl);
- typeVariable.accept(new TypeVisitorImpl());
- assertEquals("Expect one visitor", 1, typesVisited.size());
- assertEquals("Expected TypeVariable visitor", "TypeParameterDeclarationImpl", typesVisited.get(0).getClass().getSimpleName());
- break;
-
- case WildcardType :
- for(FieldDeclaration tempDecl : fieldDecls) {
- if(tempDecl.getSimpleName().equals("ln")) {
- fieldDecl = tempDecl;
- }
- }
- InterfaceType wildcardList = (InterfaceType)fieldDecl.getType();
- WildcardType wildcardType = (WildcardType)wildcardList.getActualTypeArguments().iterator().next();
- wildcardType.accept(new TypeVisitorImpl());
- assertEquals("Expect one visitor", 1, typesVisited.size());
- assertEquals("Expected WildcardType visitor", "WildcardTypeImpl", typesVisited.get(0).getClass().getSimpleName());
- break;
- }
- }
- }
-
-
- /**
- * TypeVisitor implementation for the purposes of these tests
- */
- class TypeVisitorImpl implements TypeVisitor {
-
- public void visitTypeMirror(TypeMirror t) {
- fail("Should never visit a TypeMirror, only a subclass: " + t);
- }
-
- public void visitPrimitiveType(PrimitiveType t) {
- typeVisited(t);
- }
-
- public void visitVoidType(VoidType t) {
- typeVisited(t);
- }
-
- public void visitReferenceType(ReferenceType t) {
- fail("Should never visit a ReferenceType, only a subclass: " + t);
- }
-
- public void visitDeclaredType(DeclaredType t) {
- fail("Should never visit a DeclaredType, only a subclass: " + t);
- }
-
- public void visitClassType(ClassType t) {
- typeVisited(t);
- }
-
- public void visitEnumType(EnumType t) {
- typeVisited(t);
- }
-
- public void visitInterfaceType(InterfaceType t) {
- typeVisited(t);
- }
-
- public void visitAnnotationType(AnnotationType t) {
- typeVisited(t);
- }
-
- public void visitArrayType(ArrayType t) {
- typeVisited(t);
- }
-
- public void visitTypeVariable(TypeVariable t) {
- typeVisited(t);
- }
-
- public void visitWildcardType(WildcardType t) {
- typeVisited(t);
- }
- }
-
-
- /*
- * Utilities for running the TypeVisitor tests
- */
-
- enum Cases {
- PrimitiveType,
- VoidType,
- ClassType,
- EnumType,
- InterfaceType,
- AnnotationType,
- ArrayType,
- TypeVariable,
- WildcardType
- }
-
- Cases testCaseIdentifier;
-
- ArrayList<TypeMirror> typesVisited = new ArrayList<TypeMirror>();
-
- void typeVisited(TypeMirror t) {
- typesVisited.add(t);
- }
-
- void initTypeVisitList() {
- if(typesVisited.size() > 0) {
- typesVisited.clear();
- }
- }
-
- final String code =
- "package test;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.generic.*;" + "\n" +
- "import java.util.List;" + "\n" +
- "@GenericAnnotation public class Test" + "\n" +
- "{" + "\n" +
- " int j;" + "\n" +
- " int k[];" + "\n" +
- " List<? extends Number> ln;" + "\n" +
- " class C {}" + "\n" +
- " class P<T> { }" + "\n" +
- " class D implements Runnable { public void run () {} }" + "\n" +
- " void m() {}" + "\n" +
- " enum E { elephant }" + "\n" +
- " @interface B { E e(); }" + "\n" +
- " @B(e = E.elephant)" + "\n" +
- " String s;" + "\n" +
- "}";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/BaseFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/BaseFactory.java
deleted file mode 100644
index 209ca39edb..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/BaseFactory.java
+++ /dev/null
@@ -1,52 +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;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-
-/**
- * Base class for annotation factories. Takes care of supported
- * annotations and supported options.
- */
-public abstract class BaseFactory implements AnnotationProcessorFactory {
-
- private final Collection<String> _supportedAnnotations;
-
- /**
- * Pass in supported annotations. At least one is required,
- * the rest are optional.
- *
- * @param anno main annotation
- * @param otherAnnos other supported annotations. Not necessary if
- * no extra annotations are supported.
- */
- public BaseFactory(String anno, String... otherAnnos) {
- _supportedAnnotations = new ArrayList<String>(1 + otherAnnos.length);
- _supportedAnnotations.add(anno);
- for (String s : otherAnnos) {
- _supportedAnnotations.add(s);
- }
- }
-
- public Collection<String> supportedOptions() {
- return Collections.emptyList();
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return _supportedAnnotations;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/BaseProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/BaseProcessor.java
deleted file mode 100644
index 8ef9caebe0..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/BaseProcessor.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
-
- * Copyright (c) 2005, 2007 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;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Messager;
-
-public abstract class BaseProcessor implements AnnotationProcessor {
-
- public static final String SUCCESS = "succeeded";
-
- public static String getPropertyName(Class<? extends AnnotationProcessor> processor) {
- return processor.getName() + ".result";
- }
-
- protected void reportSuccess(Class<? extends AnnotationProcessor> processor) {
- System.setProperty(getPropertyName(processor), SUCCESS);
- }
-
- protected void reportError(Class<? extends AnnotationProcessor> processor, String msg) {
- System.setProperty(getPropertyName(processor), msg);
- }
-
- protected final AnnotationProcessorEnvironment _env;
-
- public BaseProcessor(final AnnotationProcessorEnvironment env) {
- _env = env;
- }
-
- protected void assertEqual(final int expected, final int actual, final String message){
- if(expected != actual){
- final Messager msgr = _env.getMessager();
- msgr.printError(message + " expected: " + expected + " actual: " + actual );
- }
- }
-
- protected void assertEqual(final Object expected, final Object actual, final String message) {
- if( expected == null ){
- final Messager msgr = _env.getMessager();
- msgr.printError(message + " actual: " + actual );
- }
- else if( actual == null ){
- final Messager msgr = _env.getMessager();
- msgr.printError(message + "expected " + expected );
- }
- else if( !expected.equals(actual) ){
- final Messager msgr = _env.getMessager();
- msgr.printError(message + " expected: " + expected + " actual: " + actual );
- }
- }
-
- protected void assertEqual(final String expected, final String actual, final String message){
- if( expected == null ){
- final Messager msgr = _env.getMessager();
- msgr.printError(message + " actual: " + actual );
- }
- else if( actual == null ){
- final Messager msgr = _env.getMessager();
- msgr.printError(message + "expected " + expected );
- }
- else if( !expected.equals(actual) ){
- final Messager msgr = _env.getMessager();
- msgr.printError(message + " expected: " + expected + " actual: " + actual );
- }
- }
-
- protected void assertNonNull(final Object obj, final String message){
- if( obj == null ){
- final Messager msgr = _env.getMessager();
- msgr.printError(message);
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/ProcessorTestStatus.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/ProcessorTestStatus.java
deleted file mode 100644
index 142e42b509..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/ProcessorTestStatus.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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;
-
-/**
- * Utility class to hold results of processor-based tests.
- * All methods are static.
- */
-public final class ProcessorTestStatus {
-
- /**
- * Marker string to indicate that no errors were encountered.
- */
- public static final String NO_ERRORS = "NO ERRORS";
-
- /**
- * Marker string to indicate processor never ran.
- */
- public static final String NOT_RUN = "NOT RUN";
-
- /** Error status. Will be == NO_ERRORS if no errors were encountered **/
- private static String s_errorStatus = NOT_RUN;
-
- /**
- * Was a processor run at all?
- */
- private static boolean s_processorRan = false;
-
- /** An expected condition failed. Record the error **/
- public static void failWithoutException(final String error) {
- s_errorStatus = error;
- }
-
- /** Returns true if any errors were encountered **/
- public static boolean hasErrors() {
- return s_errorStatus != NO_ERRORS;
- }
-
- /** Get the error string. Will be NO_ERRORS if none were encountered **/
- public static String getErrors() {
- return s_errorStatus;
- }
-
- /** Reset the status. Needs to be called before each set of tests that could fail **/
- public static void reset() {
- s_errorStatus = NOT_RUN;
- s_processorRan = false;
- }
-
- /** Did a processor call the setProcessorRan() method since the last reset()? */
- public static boolean processorRan() {
- return s_processorRan;
- }
-
- /** A processor can call this to indicate that it has run (with or without errors) */
- public static void setProcessorRan() {
- s_processorRan = true;
- if (NOT_RUN.equals(s_errorStatus))
- s_errorStatus = NO_ERRORS;
- }
-
- // Private c-tor to prevent construction
- private ProcessorTestStatus() {}
-
- public static void assertEquals(String reason, Object expected, Object actual) {
- if (expected == actual)
- return;
- if (expected != null && expected.equals(actual))
- return;
- ProcessorTestStatus.fail("Expected " + expected + ", but saw " + actual + ". Reason: " + reason);
- }
-
- public static void assertEquals(String reason, String expected, String actual) {
- if (expected == actual)
- return;
- if (expected != null && expected.equals(actual))
- return;
- ProcessorTestStatus.fail("Expected " + expected + ", but saw " + actual + ". Reason: " + reason);
- }
-
- public static void assertEquals(String reason, int expected, int actual) {
- if (expected == actual)
- return;
- ProcessorTestStatus.fail("Expected " + expected + ", but saw " + actual + ". Reason: " + reason);
- }
-
- public static void assertTrue(String reason, boolean expected) {
- if (!expected)
- ProcessorTestStatus.fail(reason);
- }
-
- public static void fail(final String reason) {
- failWithoutException(reason);
- throw new IllegalStateException("Failed during test: " + reason);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/ProcessorUtil.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/ProcessorUtil.java
deleted file mode 100644
index e1b21d2294..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/ProcessorUtil.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.annotations;
-
-import java.util.Collection;
-import java.util.Map;
-
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
-import com.sun.mirror.declaration.AnnotationValue;
-import com.sun.mirror.declaration.EnumConstantDeclaration;
-import com.sun.mirror.type.AnnotationType;
-import com.sun.mirror.type.TypeMirror;
-
-/**
- * Utilities for use by APT test processors
- * @since 3.4
- */
-public final class ProcessorUtil
-{
- /**
- * Represent an annotation mirror and its explicit values as a String. Use this,
- * rather than toString(), in order to have reliable and stable results.
- */
- public static String annoMirrorToString(AnnotationMirror mirror) {
- AnnotationType type = mirror.getAnnotationType();
- if (type == null) {
- return "[Annotation of unknown (null) type]";
- }
- AnnotationTypeDeclaration decl = type.getDeclaration();
- if (decl == null) {
- return "[Annotation with null type declaration]";
- }
- StringBuilder sb = new StringBuilder();
- sb.append('@');
- sb.append(decl.getSimpleName());
- sb.append('(');
- Map<AnnotationTypeElementDeclaration, AnnotationValue> values = mirror.getElementValues();
- boolean first = true;
- for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> entry : values.entrySet()) {
- if (!first) {
- sb.append(", ");
- }
- first = false;
- sb.append(annoValuePairToString(entry.getKey(), entry.getValue()));
- }
- sb.append(')');
- return sb.toString();
- }
-
- public static String annoValuePairToString(AnnotationTypeElementDeclaration key, AnnotationValue value)
- {
- if (key == null) {
- return "[Null annotation value declaration]";
- }
- StringBuilder sb = new StringBuilder();
- sb.append(key.getSimpleName());
- sb.append(" = ");
- sb.append(annoValueToString(value));
- return sb.toString();
- }
-
- private static String annoValueToString(AnnotationValue value) {
- if (value == null) {
- return "null";
- }
- Object v = value.getValue();
- if (v == null) {
- return "null";
- }
- if (v instanceof EnumConstantDeclaration) {
- return ((EnumConstantDeclaration)v).getSimpleName();
- }
- else if (v instanceof TypeMirror) {
- // TODO: clearly we also need a typeMirrorToString utility function
- return ((TypeMirror)v).toString();
- }
- else if (v instanceof AnnotationMirror) {
- return annoMirrorToString((AnnotationMirror)v);
- }
- else if (v instanceof Collection) {
- // Collection<AnnotationValue>, for an array value
- StringBuilder sb = new StringBuilder();
- sb.append('{');
- boolean first = true;
- for (Object item : (Collection<?>)v) {
- if (!first) {
- sb.append(", ");
- }
- first = false;
- sb.append(annoValueToString((AnnotationValue)item));
- }
- sb.append('}');
- return sb.toString();
- }
- // boxed primitive or String
- return value.toString();
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/APIAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/APIAnnotationProcessorFactory.java
deleted file mode 100644
index 0ff313140a..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/APIAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.tests.annotations.apitest;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Messager;
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
-import com.sun.mirror.declaration.AnnotationValue;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.FieldDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.declaration.TypeParameterDeclaration;
-import com.sun.mirror.type.DeclaredType;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.util.Types;
-
-
-public class APIAnnotationProcessorFactory extends BaseFactory {
-
- public APIAnnotationProcessorFactory(){
- super(Common.class.getName(), SubtypeOf.class.getName(), AssignableTo.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> decls,
- AnnotationProcessorEnvironment env) {
- return new APIAnnotationProcessor(env);
- }
-
- public static class APIAnnotationProcessor extends BaseProcessor{
-
- private Messager _msgr;
- private Types _types;
-
- public APIAnnotationProcessor(AnnotationProcessorEnvironment env){
- super(env);
- }
-
- public void process() {
- _msgr = _env.getMessager();
- _types = _env.getTypeUtils();
- checkCommon();
- checkSubtypeOf();
- checkAssignableTo();
- }
-
- /**
- * validate instances of the Common annotation
- */
- private void checkCommon()
- {
- final AnnotationTypeDeclaration commonAnnoType =
- (AnnotationTypeDeclaration)_env.getTypeDeclaration(Common.class.getName());
- final Collection<Declaration> decls =
- _env.getDeclarationsAnnotatedWith(commonAnnoType);
- for( Declaration decl : decls ){
- if(decl instanceof FieldDeclaration ){
- final FieldDeclaration field = (FieldDeclaration)decl;
- final TypeMirror type = field.getType();
- if( type instanceof DeclaredType ){
- final TypeMirror collectionType =
- _env.getTypeUtils().getDeclaredType(_env.getTypeDeclaration(Collection.class.getName()));
- final Collection<TypeMirror> typeVars =
- ((DeclaredType)type).getActualTypeArguments();
- if(typeVars.size() == 1 ){
- TypeMirror typeVar = typeVars.iterator().next();
- boolean assignable = _env.getTypeUtils().isAssignable(typeVar, collectionType);
- if( assignable )
- _msgr.printError(typeVar + " is assignable to " + collectionType );
- else
- _msgr.printError(typeVar + " is not assignable to " + collectionType );
- }
- }
- }else if(decl instanceof TypeDeclaration){
- final TypeDeclaration typeDecl = (TypeDeclaration)decl;
- final Collection<TypeParameterDeclaration> typeParams =
- typeDecl.getFormalTypeParameters();
- for(TypeParameterDeclaration typeParam : typeParams){
- Declaration owner = typeParam.getOwner();
- _msgr.printError("Type parameter '" + typeParam + "' belongs to " + owner.getClass().getName() + " " + owner.getSimpleName() );
- }
- }
- else if( decl instanceof MethodDeclaration ){
- final MethodDeclaration methodDecl = (MethodDeclaration)decl;
- final Collection<TypeParameterDeclaration> typeParams =
- methodDecl.getFormalTypeParameters();
- for(TypeParameterDeclaration typeParam : typeParams){
- Declaration owner = typeParam.getOwner();
- _msgr.printError("Type parameter '" + typeParam + "' belongs to " + owner.getClass().getName() + " " + owner.getSimpleName() );
- }
- }
- }
- }
-
- /**
- * Validate all the fields annotated with @SubtypeOf, in order to test
- * the Types.subtypeOf() method.
- * We ignore anything but fields, out of laziness.
- */
- private void checkSubtypeOf() {
- final AnnotationTypeDeclaration annoType =
- (AnnotationTypeDeclaration)_env.getTypeDeclaration(SubtypeOf.class.getName());
- final Collection<Declaration> decls =
- _env.getDeclarationsAnnotatedWith(annoType);
- for( Declaration decl : decls ){
- if(decl instanceof FieldDeclaration ) {
- AnnotationMirror mirror = findMirror(decl, annoType);
- if (mirror == null) {
- return;
- }
- TypeMirror valueType = getTypeValue(mirror);
- final FieldDeclaration field = (FieldDeclaration)decl;
- final TypeMirror fieldType = field.getType();
- boolean isSubtype = _types.isSubtype(fieldType, valueType);
- if( isSubtype )
- _msgr.printError(fieldType + " is a subtype of " + valueType );
- else
- _msgr.printError(fieldType + " is not a subtype of " + valueType );
- }
- }
- }
-
- /**
- * Validate all the fields annotated with @AssignableTo.
- * We ignore anything but fields, out of laziness.
- */
- private void checkAssignableTo() {
- final AnnotationTypeDeclaration annoType =
- (AnnotationTypeDeclaration)_env.getTypeDeclaration(AssignableTo.class.getName());
- final Collection<Declaration> decls =
- _env.getDeclarationsAnnotatedWith(annoType);
- for( Declaration decl : decls ){
- if(decl instanceof FieldDeclaration ) {
- AnnotationMirror mirror = findMirror(decl, annoType);
- if (mirror == null) {
- return;
- }
- TypeMirror valueType = getTypeValue(mirror);
- final FieldDeclaration field = (FieldDeclaration)decl;
- final TypeMirror fieldType = field.getType();
- boolean isAssignableTo = _types.isAssignable(fieldType, valueType);
- if( isAssignableTo )
- _msgr.printError(fieldType + " is assignable to " + valueType );
- else
- _msgr.printError(fieldType + " is not assignable to " + valueType );
- }
- }
- }
-
- /**
- * @return a mirror for the instance of the specified annotation on the specified
- * declaration, or null if one is not present.
- */
- private AnnotationMirror findMirror(Declaration decl, AnnotationTypeDeclaration at) {
- for (AnnotationMirror mirror : decl.getAnnotationMirrors()) {
- if (mirror.getAnnotationType().equals(at)) {
- return mirror;
- }
- }
- return null;
- }
-
- /**
- * @return the value() of an annotation instance <code>mirror</code>, if it is a
- * class value, or null if not.
- */
- private TypeMirror getTypeValue(AnnotationMirror mirror) {
- Map<AnnotationTypeElementDeclaration, AnnotationValue> values = mirror.getElementValues();
- for (Entry<AnnotationTypeElementDeclaration, AnnotationValue> entry : values.entrySet()) {
- if ("value".equals(entry.getKey().getSimpleName())) {
- if (entry.getValue().getValue() instanceof TypeMirror)
- return (TypeMirror)entry.getValue().getValue();
- else
- return null;
- }
- }
- return null;
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/AssignableTo.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/AssignableTo.java
deleted file mode 100644
index 4c87f8cec2..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/AssignableTo.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.annotations.apitest;
-
-/**
- * Triggers the APIAnnotationProcessor, which will verify that the annotated object
- * is assignable to an object of the specified type.
- */
-public @interface AssignableTo
-{
- Class<?> value();
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/Common.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/Common.java
deleted file mode 100644
index b84d031f1c..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/Common.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.tests.annotations.apitest;
-
-/**
- * This annotation will trigger the {@link APIAnnotationProcessorFactory}
- */
-public @interface Common {
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/SubtypeOf.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/SubtypeOf.java
deleted file mode 100644
index 1d527cb698..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/apitest/SubtypeOf.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.annotations.apitest;
-
-/**
- * Triggers the APIAnnotationProcessor, which will validate that the annotated object
- * is of a type that is a subtype of the specified value.
- */
-public @interface SubtypeOf
-{
- Class<?> value();
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/GenBean.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/GenBean.java
deleted file mode 100644
index 27ab60cc6a..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/GenBean.java
+++ /dev/null
@@ -1,15 +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.tests.annotations.aptrounding;
-
-public @interface GenBean {
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/GenBean2.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/GenBean2.java
deleted file mode 100644
index 8ce17ecc70..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/GenBean2.java
+++ /dev/null
@@ -1,15 +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.tests.annotations.aptrounding;
-
-public @interface GenBean2 {
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round1GenAnnotationFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round1GenAnnotationFactory.java
deleted file mode 100644
index 0a7fd81848..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round1GenAnnotationFactory.java
+++ /dev/null
@@ -1,44 +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.tests.annotations.aptrounding;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-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 Round1GenAnnotationFactory implements AnnotationProcessorFactory{
-
- public static final List<String> SUPPORTED_TYPES;
-
- static{
- SUPPORTED_TYPES = new ArrayList<String>();
- SUPPORTED_TYPES.add(GenBean.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> decls, AnnotationProcessorEnvironment env) {
- return new Round1GenAnnotationProcessor(env);
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return SUPPORTED_TYPES;
- }
-
- public Collection<String> supportedOptions() {
- return Collections.emptyList();
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round1GenAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round1GenAnnotationProcessor.java
deleted file mode 100644
index 322ea74637..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round1GenAnnotationProcessor.java
+++ /dev/null
@@ -1,53 +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.tests.annotations.aptrounding;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Collection;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Filer;
-import com.sun.mirror.apt.Messager;
-import com.sun.mirror.declaration.TypeDeclaration;
-
-public class Round1GenAnnotationProcessor implements AnnotationProcessor{
-
- private final AnnotationProcessorEnvironment _env;
- Round1GenAnnotationProcessor(AnnotationProcessorEnvironment env)
- {
- _env = env;
- }
-
- public void process() {
- final TypeDeclaration beanType = _env.getTypeDeclaration("test.Bean");
- final Filer filer = _env.getFiler();
- if( beanType == null ){
- try{
- PrintWriter writer = filer.createSourceFile("test.Bean");
- writer.print("package test;\n");
- writer.print("public class Bean{}\n");
- writer.close();
- }
- catch(IOException io){}
- }
-
- final Collection<TypeDeclaration> typeDecls = _env.getTypeDeclarations();
- final Messager msger = _env.getMessager();
- if( typeDecls.size() == 1 ){
- final TypeDeclaration type = typeDecls.iterator().next();
- if( !type.getQualifiedName().equals( "p1.X") )
- msger.printError("Expected to find p1.X but got " + type.getQualifiedName() );
- }
- else
- msger.printError("expected one type declaration but got " + typeDecls );
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round2GenAnnotationFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round2GenAnnotationFactory.java
deleted file mode 100644
index 724f21bf5c..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round2GenAnnotationFactory.java
+++ /dev/null
@@ -1,44 +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.tests.annotations.aptrounding;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-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 Round2GenAnnotationFactory implements AnnotationProcessorFactory{
-
- public static final List<String> SUPPORTED_TYPES;
-
- static{
- SUPPORTED_TYPES = new ArrayList<String>();
- SUPPORTED_TYPES.add(GenBean2.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> decls, AnnotationProcessorEnvironment env) {
- return new Round2GenAnnotationProcessor(env);
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return SUPPORTED_TYPES;
- }
-
- public Collection<String> supportedOptions() {
- return Collections.emptyList();
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round2GenAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round2GenAnnotationProcessor.java
deleted file mode 100644
index 743fa7affb..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/aptrounding/Round2GenAnnotationProcessor.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 and implementation
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.aptrounding;
-
-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;
-import com.sun.mirror.declaration.TypeDeclaration;
-
-public class Round2GenAnnotationProcessor implements AnnotationProcessor {
- private final AnnotationProcessorEnvironment _env;
- Round2GenAnnotationProcessor(AnnotationProcessorEnvironment env)
- {
- _env = env;
- }
-
- public void process() {
- final TypeDeclaration beanType = _env.getTypeDeclaration("test.Bean");
- final Filer filer = _env.getFiler();
- if( beanType != null ){
- try{
- PrintWriter writer = filer.createSourceFile("test.BeanBean");
- writer.print("package test;\n");
- writer.print("public class BeanBean{ public Bean bean = null; }\n");
- writer.close();
- }
- catch(IOException io){}
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/exceptionhandling/ExceptionHandlingAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/exceptionhandling/ExceptionHandlingAnnotation.java
deleted file mode 100644
index d3b94e2ffe..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/exceptionhandling/ExceptionHandlingAnnotation.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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:
- * sbandow@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.exceptionhandling;
-
-public @interface ExceptionHandlingAnnotation {
- public enum EHAEnum { A, B }
- EHAEnum[] enumsValue() default { EHAEnum.A };
- boolean booleanValue() default false;
- String strValue() default "";
- String[] arrValue () default {""};
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/exceptionhandling/ExceptionHandlingProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/exceptionhandling/ExceptionHandlingProcessor.java
deleted file mode 100644
index e7294bb39e..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/exceptionhandling/ExceptionHandlingProcessor.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 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:
- * sbandow@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.exceptionhandling;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.Declaration;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-import org.eclipse.jdt.apt.tests.annotations.exceptionhandling.ExceptionHandlingAnnotation.EHAEnum;
-
-public class ExceptionHandlingProcessor extends BaseProcessor {
-
- private AnnotationTypeDeclaration _annotationType;
-
- public ExceptionHandlingProcessor(Set<AnnotationTypeDeclaration> declarationTypes, AnnotationProcessorEnvironment env) {
- super(env);
- assert declarationTypes.size() == 1;
- _annotationType = declarationTypes.iterator().next();
- }
-
- @SuppressWarnings("unused")
- public void process() {
- ProcessorTestStatus.setProcessorRan();
- Collection<Declaration> declarations = _env.getDeclarationsAnnotatedWith(_annotationType);
- assert declarations.size() == 1;
- for (Declaration dec : declarations) {
- ExceptionHandlingAnnotation annotation = dec.getAnnotation(ExceptionHandlingAnnotation.class);
- boolean booleanValue = annotation.booleanValue();
- String strValue = annotation.strValue();
- String[] arrValue = annotation.arrValue();
- EHAEnum[] enumsValue = annotation.enumsValue();
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/exceptionhandling/ExceptionHandlingProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/exceptionhandling/ExceptionHandlingProcessorFactory.java
deleted file mode 100644
index 3f40d5b19d..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/exceptionhandling/ExceptionHandlingProcessorFactory.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.exceptionhandling;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-
-public class ExceptionHandlingProcessorFactory extends BaseFactory
-{
-
- public ExceptionHandlingProcessorFactory() {
- super(ExceptionHandlingAnnotation.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> declarations, AnnotationProcessorEnvironment env) {
- return new ExceptionHandlingProcessor(declarations, env);
- }
-}
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 0a7a1d2579..0000000000
--- 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 ""; //$NON-NLS-1$
-}
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 15c8affdf1..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotationProcessor.java
+++ /dev/null
@@ -1,28 +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 org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-
-public class ExtraDependencyAnnotationProcessor extends BaseProcessor {
-
- public ExtraDependencyAnnotationProcessor(AnnotationProcessorEnvironment env) {
- super(env);
- }
-
- public void process() {
- _env.getTypeDeclaration( "p1.p2.p3.p4.C" ); //$NON-NLS-1$
- }
-}
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 dd80009ef3..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/extradependency/ExtraDependencyAnnotationProcessorFactory.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:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.extradependency;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class ExtraDependencyAnnotationProcessorFactory extends BaseFactory {
-
- public ExtraDependencyAnnotationProcessorFactory() {
- super(ExtraDependencyAnnotation.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env) {
-
- return new ExtraDependencyAnnotationProcessor( env );
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FileGenLocationAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FileGenLocationAnnotation.java
deleted file mode 100644
index aaf337a29a..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FileGenLocationAnnotation.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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.filegen;
-
-public @interface FileGenLocationAnnotation
-{
- String value() default ""; //$NON-NLS-1$
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FileGenLocationAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FileGenLocationAnnotationProcessor.java
deleted file mode 100644
index b039c62d2c..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FileGenLocationAnnotationProcessor.java
+++ /dev/null
@@ -1,63 +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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.filegen;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Filer;
-
-public class FileGenLocationAnnotationProcessor extends BaseProcessor {
-
- public FileGenLocationAnnotationProcessor(AnnotationProcessorEnvironment env) {
- super(env);
- }
-
- public void process()
- {
- ProcessorTestStatus.setProcessorRan();
- try
- {
- Filer f = _env.getFiler();
-
- PrintWriter pwa = f.createSourceFile("test.A"); //$NON-NLS-1$
- pwa.print(CODE_GEN_IN_PKG);
- pwa.close();
-
- PrintWriter pwb = f.createSourceFile("B"); //$NON-NLS-1$
- pwb.print(CODE_GEN_AT_PROJ_ROOT);
- pwb.close();
-
- }
- catch( IOException ioe )
- {
- ioe.printStackTrace();
- }
- }
-
- protected String CODE_GEN_IN_PKG =
- "package test;" + "\n" +
- "public class A" + "\n" +
- "{" + "\n" +
- "}";
-
- protected String CODE_GEN_AT_PROJ_ROOT =
- "public class B" + "\n" +
- "{" + "\n" +
- " test.A a;" + "\n" +
- "}";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FileGenLocationAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FileGenLocationAnnotationProcessorFactory.java
deleted file mode 100644
index 9363c2992d..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FileGenLocationAnnotationProcessorFactory.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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.filegen;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class FileGenLocationAnnotationProcessorFactory extends BaseFactory {
-
- public FileGenLocationAnnotationProcessorFactory() {
- super(FileGenLocationAnnotation.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env)
- {
- return new FileGenLocationAnnotationProcessor( env );
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FirstGenAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FirstGenAnnotation.java
deleted file mode 100644
index a2906fa49b..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FirstGenAnnotation.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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.filegen;
-
-public @interface FirstGenAnnotation
-{
- String value() default ""; //$NON-NLS-1$
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FirstGenAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FirstGenAnnotationProcessor.java
deleted file mode 100644
index 291d8522c5..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FirstGenAnnotationProcessor.java
+++ /dev/null
@@ -1,53 +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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.filegen;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Filer;
-
-public class FirstGenAnnotationProcessor extends BaseProcessor {
-
- public FirstGenAnnotationProcessor(AnnotationProcessorEnvironment env) {
- super(env);
- }
-
- public void process()
- {
- ProcessorTestStatus.setProcessorRan();
- try
- {
- Filer f = _env.getFiler();
- PrintWriter pw = f.createSourceFile("duptest.DupFile"); //$NON-NLS-1$
- pw.print(CODE);
- pw.close();
- }
- catch( IOException e )
- {
- e.printStackTrace();
- }
- }
-
- protected String CODE =
- "package duptest;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.filegen.SecondGenAnnotation;" + "\n" +
- "@SecondGenAnnotation" + "\n" +
- "public class DupFile" + "\n" +
- "{" + "\n" +
- "}";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FirstGenAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FirstGenAnnotationProcessorFactory.java
deleted file mode 100644
index 1f06bf90da..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/FirstGenAnnotationProcessorFactory.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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.filegen;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class FirstGenAnnotationProcessorFactory extends BaseFactory {
-
- public FirstGenAnnotationProcessorFactory() {
- super(FirstGenAnnotation.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env)
- {
- return new FirstGenAnnotationProcessor( env );
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/SecondGenAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/SecondGenAnnotation.java
deleted file mode 100644
index a8fbd21f67..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/SecondGenAnnotation.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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.filegen;
-
-public @interface SecondGenAnnotation
-{
- String value() default ""; //$NON-NLS-1$
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/SecondGenAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/SecondGenAnnotationProcessor.java
deleted file mode 100644
index 31ca208eb9..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/SecondGenAnnotationProcessor.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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.filegen;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Filer;
-
-public class SecondGenAnnotationProcessor extends BaseProcessor {
-
- public SecondGenAnnotationProcessor(AnnotationProcessorEnvironment env) {
- super(env);
- }
-
- public void process()
- {
- ProcessorTestStatus.setProcessorRan();
- try
- {
- Filer f = _env.getFiler();
- PrintWriter pw = f.createSourceFile("duptest.DupFile"); //$NON-NLS-1$
- pw.print(CODE_OVERWRITE);
- pw.close();
-
- Filer fr = _env.getFiler();
- PrintWriter pwr = fr.createSourceFile("reftest.RefFile"); //$NON-NLS-1$
- pwr.print(CODE_REF);
- pwr.close();
- }
- catch( IOException e )
- {
- e.printStackTrace();
- }
- }
-
- protected String CODE_OVERWRITE =
- "package duptest;" + "\n" +
- "public class DupFile" + "\n" +
- "{" + "\n" +
- " public class Inner" + "\n" +
- " {" + "\n" +
- " }" + "\n" +
- "}";
-
- protected String CODE_REF =
- "package reftest;" + "\n" +
- "public class RefFile" + "\n" +
- "{" + "\n" +
- " duptest.DupFile.Inner i;" + "\n" +
- "}";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/SecondGenAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/SecondGenAnnotationProcessorFactory.java
deleted file mode 100644
index 0560ed4caf..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/SecondGenAnnotationProcessorFactory.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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.filegen;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class SecondGenAnnotationProcessorFactory extends BaseFactory {
-
- public SecondGenAnnotationProcessorFactory() {
- super(SecondGenAnnotation.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env)
- {
- return new SecondGenAnnotationProcessor( env );
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/TextGenAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/TextGenAnnotation.java
deleted file mode 100644
index d5bd9b3df7..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/TextGenAnnotation.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.filegen;
-
-public @interface TextGenAnnotation {
-
- String value(); // name of file to generate
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/TextGenAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/TextGenAnnotationProcessor.java
deleted file mode 100644
index 1c57a6c5f1..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/TextGenAnnotationProcessor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.filegen;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Collection;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Filer;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.Declaration;
-
-public class TextGenAnnotationProcessor extends BaseProcessor {
-
- public TextGenAnnotationProcessor(AnnotationProcessorEnvironment env) {
- super(env);
- }
-
- public void process() {
- ProcessorTestStatus.setProcessorRan();
- Filer f = _env.getFiler();
- AnnotationTypeDeclaration annoDecl = (AnnotationTypeDeclaration) _env.getTypeDeclaration(TextGenAnnotation.class.getName());
- Collection<Declaration> annotatedDecls = _env.getDeclarationsAnnotatedWith(annoDecl);
- try {
- for (Declaration annotatedDecl : annotatedDecls) {
- TextGenAnnotation tganno = annotatedDecl.getAnnotation(TextGenAnnotation.class);
- String fileName = tganno.value();
- PrintWriter writer = f.createTextFile(
- Filer.Location.CLASS_TREE,
- "",
- new File(fileName),
- null);
- writer.print(TEXT);
- writer.close();
- }
- reportSuccess(this.getClass());
- }
- catch (NullPointerException npe) {
- reportError(this.getClass(), "Could not read annotation in order to generate text file");
- }
- catch (IOException ioe) {
- reportError(this.getClass(), "Could not generate text file due to IOException");
- }
- }
-
- private static final String TEXT = "This is some text generated by an annotation processor";
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/TextGenAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/TextGenAnnotationProcessorFactory.java
deleted file mode 100644
index 357d0b303e..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/filegen/TextGenAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 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.filegen;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class TextGenAnnotationProcessorFactory extends BaseFactory {
-
- public TextGenAnnotationProcessorFactory() {
- super(TextGenAnnotation.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> decls,
- AnnotationProcessorEnvironment env) {
- return new TextGenAnnotationProcessor(env);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/generic/AbstractGenericProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/generic/AbstractGenericProcessor.java
deleted file mode 100644
index 00e96000e9..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/generic/AbstractGenericProcessor.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.generic;
-
-import java.util.Collection;
-
-import junit.framework.AssertionFailedError;
-
-import com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-
-public abstract class AbstractGenericProcessor implements AnnotationProcessor {
- protected AnnotationProcessorEnvironment env;
- protected AnnotationTypeDeclaration genericAnnotation;
- protected Collection<Declaration> decls;
-
- public void setEnv(AnnotationProcessorEnvironment env) {
- this.env = env;
- genericAnnotation = (AnnotationTypeDeclaration) env.getTypeDeclaration(GenericAnnotation.class.getName());
- decls = env.getDeclarationsAnnotatedWith(genericAnnotation);
- }
-
- public abstract void _process();
-
- /**
- * This method is abstract, so that subclasses need to implement
- * _process. We'll handle catching any errant throwables
- * and fail any junit tests.
- */
- public final void process() {
- try {
- _process();
- }
- catch (Throwable t) {
- t.printStackTrace();
- throw new AssertionFailedError("Processor threw an exception during processing");
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/generic/GenericAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/generic/GenericAnnotation.java
deleted file mode 100644
index ddf48d606a..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/generic/GenericAnnotation.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.generic;
-
-public @interface GenericAnnotation {
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/generic/GenericFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/generic/GenericFactory.java
deleted file mode 100644
index 0efb47745a..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/generic/GenericFactory.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.generic;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class GenericFactory extends BaseFactory {
- public static AbstractGenericProcessor PROCESSOR;
- public static AnnotationProcessor fact;
-
- public static void setProcessor(AbstractGenericProcessor p) {
- PROCESSOR = p;
- }
-
- public GenericFactory() {
- super(GenericAnnotation.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> arg0, AnnotationProcessorEnvironment env) {
- PROCESSOR.setEnv(env);
- return PROCESSOR;
- }
-
-}
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 68c27aee1f..0000000000
--- 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, 2007 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 "GeneratedFileTest"; //$NON-NLS-1$
-}
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 02ccdfc858..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotationProcessor.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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 java.util.Collection;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Filer;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.Declaration;
-
-/**
- * A processor that looks for HelloWorldAnnotation, and in response
- * generates a type named in the value of the annotation, containing code
- * specified in getCode().
- */
-public class HelloWorldAnnotationProcessor extends BaseProcessor {
-
- private final static String PACKAGENAME = "generatedfilepackage"; //$NON-NLS-1$
-
- public HelloWorldAnnotationProcessor(AnnotationProcessorEnvironment env) {
- super(env);
- }
-
- public void process()
- {
- ProcessorTestStatus.setProcessorRan();
- Filer f = _env.getFiler();
- AnnotationTypeDeclaration annoDecl = (AnnotationTypeDeclaration) _env.getTypeDeclaration(HelloWorldAnnotation.class.getName());
- Collection<Declaration> annotatedDecls = _env.getDeclarationsAnnotatedWith(annoDecl);
- try {
- for (Declaration annotatedDecl : annotatedDecls) {
- String typeName = getTypeName(annotatedDecl);
- PrintWriter writer = f.createSourceFile(
- PACKAGENAME + "." + typeName);
- writer.print(getCode(typeName));
- writer.close();
- }
- reportSuccess(this.getClass());
- }
- catch (NullPointerException npe) {
- reportError(this.getClass(), "Could not read annotation in order to generate text file");
- }
- catch (IOException ioe) {
- reportError(this.getClass(), "Could not generate text file due to IOException");
- }
- }
-
- private String getTypeName(Declaration annotatedDecl) {
- HelloWorldAnnotation tganno = annotatedDecl.getAnnotation(HelloWorldAnnotation.class);
- return tganno.value();
- }
-
- private String getCode(String typeName) {
- return "package " + PACKAGENAME + ";" + "\n"
- + "public class "+ typeName + "\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 342f1ff2bc..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldAnnotationProcessorFactory.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:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.helloworld;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-import org.eclipse.jdt.apt.core.util.AptPreferenceConstants;
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class HelloWorldAnnotationProcessorFactory extends BaseFactory {
-
- public HelloWorldAnnotationProcessorFactory() {
- super(HelloWorldAnnotation.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env)
- {
- return new HelloWorldAnnotationProcessor( env );
- }
-
- public Collection<String> supportedOptions() {
- return Collections.singletonList(AptPreferenceConstants.RTTG_ENABLED_OPTION);
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldWildcardAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldWildcardAnnotationProcessorFactory.java
deleted file mode 100644
index c73101fe59..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/helloworld/HelloWorldWildcardAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.helloworld;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * Processor factory that claims annotations with a wildcard
- * ("org.eclipse.jdt.apt.tests.annotations.helloworld.*")
- */
-public class HelloWorldWildcardAnnotationProcessorFactory extends
- HelloWorldAnnotationProcessorFactory {
-
- public static volatile boolean CLAIM_ALL_ANNOTATIONS;
-
-
- public Collection<String> supportedAnnotationTypes() {
-
- // We need to swap behavior because always claiming "*" will cause
- // other processors normally called after us to be prevented from running,
- // as we have claimed everything
- if (CLAIM_ALL_ANNOTATIONS) {
- return Collections.singletonList("*");
- }
- else {
- return Collections.singletonList("org.eclipse.jdt.apt.tests.annotations.helloworld.*"); //$NON-NLS-1$
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/listener/ListenerAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/listener/ListenerAnnotation.java
deleted file mode 100644
index 8003f19d94..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/listener/ListenerAnnotation.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.annotations.listener;
-
-/**
- * Used to test AnnotationProcessorListener implementation.
- */
-public @interface ListenerAnnotation
-{
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/listener/ListenerAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/listener/ListenerAnnotationProcessorFactory.java
deleted file mode 100644
index cd66e90b3e..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/listener/ListenerAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.annotations.listener;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-/**
- *
- */
-public class ListenerAnnotationProcessorFactory extends BaseFactory
-{
-
- public ListenerAnnotationProcessorFactory() {
- super(ListenerAnnotation.class.getName());
- }
-
- /* (non-Javadoc)
- * @see com.sun.mirror.apt.AnnotationProcessorFactory#getProcessorFor(java.util.Set, com.sun.mirror.apt.AnnotationProcessorEnvironment)
- */
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env)
- {
- return new ListenerProcessor(env);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/listener/ListenerProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/listener/ListenerProcessor.java
deleted file mode 100644
index 803bb0442c..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/listener/ListenerProcessor.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.annotations.listener;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.RoundCompleteEvent;
-import com.sun.mirror.apt.RoundCompleteListener;
-
-/**
- * Ensure that the RoundCompleteListener does get called, and that it is possible
- * to modify the listener list from within the callback (see bug 180595).
- */
-public class ListenerProcessor extends BaseProcessor
-{
- private static int _calls = 0;
-
- private class Listener implements RoundCompleteListener {
- public void roundComplete(RoundCompleteEvent event) {
- if (event.getRoundState().finalRound()) {
- ++_calls;
- _env.removeListener(this);
- // Only report success if we make it this far on both listeners
- if (2 == _calls) {
- ListenerProcessor.this.reportSuccess(ListenerProcessor.class);
- }
- }
- }
- }
-
- public ListenerProcessor(AnnotationProcessorEnvironment env) {
- super(env);
- env.addListener(new Listener());
- env.addListener(new Listener());
- }
-
- /* (non-Javadoc)
- * @see com.sun.mirror.apt.AnnotationProcessor#process()
- */
- public void process()
- {
- // do nothing
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerAnnotation.java
deleted file mode 100644
index d6d74ff7b6..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerAnnotation.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.annotations.messager;
-
-/**
- *
- */
-public @interface MessagerAnnotation {
- enum Severity { ERROR, WARNING, INFO, OK }
-
- Severity severity();
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerAnnotationProcessor.java
deleted file mode 100644
index e1a1b0943f..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerAnnotationProcessor.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.annotations.messager;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Messager;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.util.SourcePosition;
-
-/**
- * Used to test the Messager interface. Processing @MessagerAnnotation
- * causes messages to be posted.
- */
-public class MessagerAnnotationProcessor extends BaseProcessor {
-
- private final AnnotationTypeDeclaration _annotationDecl;
-
- // Text of problems created
- public static final String PROBLEM_TEXT_INFO = "Annotated with MessagerAnnotation(INFO)"; //$NON-NLS-1$
- public static final String PROBLEM_TEXT_WARNING = "Annotated with MessagerAnnotation(WARNING)"; //$NON-NLS-1$
- public static final String PROBLEM_TEXT_ERROR = "Annotated with MessagerAnnotation(ERROR)"; //$NON-NLS-1$
-
- public MessagerAnnotationProcessor(
- Set<AnnotationTypeDeclaration> decls, AnnotationProcessorEnvironment env) {
- super(env);
- assert decls.size() == 1;
- _annotationDecl = decls.iterator().next();
- }
-
- /* (non-Javadoc)
- * @see com.sun.mirror.apt.AnnotationProcessor#process()
- */
- public void process() {
- Collection<Declaration> annotatedDecls = _env.getDeclarationsAnnotatedWith(_annotationDecl);
- Messager m = _env.getMessager();
- for (Declaration decl : annotatedDecls) {
- MessagerAnnotation a = decl.getAnnotation(MessagerAnnotation.class);
- SourcePosition sp = decl.getPosition();
- MessagerAnnotation.Severity sev = a.severity();
- switch (sev) {
- case ERROR :
- m.printError(sp, PROBLEM_TEXT_ERROR);
- break;
- case WARNING :
- m.printWarning(sp, PROBLEM_TEXT_WARNING);
- break;
- case INFO :
- m.printNotice(sp, PROBLEM_TEXT_INFO);
- break;
- }
- }
- reportSuccess(this.getClass());
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerAnnotationProcessorFactory.java
deleted file mode 100644
index 1b3f279bb1..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerAnnotationProcessorFactory.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:
- * wharley@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.messager;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class MessagerAnnotationProcessorFactory extends BaseFactory {
-
- private final static String annotationName = "org.eclipse.jdt.apt.tests.annotations.messager.MessagerAnnotation";
- public MessagerAnnotationProcessorFactory() {
- super(annotationName);
- }
-
- /* (non-Javadoc)
- * @see com.sun.mirror.apt.AnnotationProcessorFactory#getProcessorFor(java.util.Set, com.sun.mirror.apt.AnnotationProcessorEnvironment)
- */
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> decls,
- AnnotationProcessorEnvironment env) {
- return new MessagerAnnotationProcessor(decls, env);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerCodeExample.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerCodeExample.java
deleted file mode 100644
index 3d94843f99..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/messager/MessagerCodeExample.java
+++ /dev/null
@@ -1,83 +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.annotations.messager;
-
-
-/**
- * Code examples for tests of Messager interface
- */
-public class MessagerCodeExample {
-
- public static final String CODE_PACKAGE = "messagertestpackage";
- public static final String CODE_CLASS_NAME = "MessagerTestClass";
- public static final String CODE_FULL_NAME = CODE_PACKAGE + "." + CODE_CLASS_NAME;
-
- // These offsets work for each code example, as long as the examples are cumulative
- public static final int INFO_START = 219;
- public static final int INFO_END = 222;
- public static final int WARNING_START = 319;
- public static final int WARNING_END = 322;
- public static final int ERROR_START = 417;
- public static final int ERROR_END = 421;
-
- private static final String HEADER_CHUNK =
- "package messagertestpackage;\n" +
- "import org.eclipse.jdt.apt.tests.annotations.messager.MessagerAnnotation;" + "\n" +
- "public class MessagerTestClass {" + "\n";
-
- private static final String INFO_CHUNK =
- " @MessagerAnnotation(severity=MessagerAnnotation.Severity.INFO)" + "\n" +
- " public void Foo() {" + "\n" +
- " }" + "\n";
-
- private static final String WARNING_CHUNK =
- " @MessagerAnnotation(severity=MessagerAnnotation.Severity.WARNING)" + "\n" +
- " public void Bar() {" + "\n" +
- " }" + "\n";
-
- private static final String ERROR_CHUNK =
- " @MessagerAnnotation(severity=MessagerAnnotation.Severity.ERROR)" + "\n" +
- " public void Quux() {" + "\n" +
- " }" + "\n";
-
- private static final String OK_CHUNK =
- " @MessagerAnnotation(severity=MessagerAnnotation.Severity.OK)" + "\n" +
- " public void Foo() {" + "\n" +
- " }" + "\n";
-
- /** Code example with INFO, WARNING, and ERROR severities */
- public static final String CODE1 =
- HEADER_CHUNK +
- INFO_CHUNK +
- WARNING_CHUNK +
- ERROR_CHUNK +
- "}";
-
- /** Code example with INFO and WARNING severities */
- public static final String CODE2 =
- HEADER_CHUNK +
- INFO_CHUNK +
- WARNING_CHUNK +
- "}";
-
- /** Code example with INFO severity only */
- public static final String CODE3 =
- HEADER_CHUNK +
- INFO_CHUNK +
- "}";
-
- /** Code example with INFO severity only */
- public static final String CODE4 =
- HEADER_CHUNK +
- OK_CHUNK +
- "}";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/ASTBasedMirrorDeclarationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/ASTBasedMirrorDeclarationProcessorFactory.java
deleted file mode 100644
index 78a01ac78d..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/ASTBasedMirrorDeclarationProcessorFactory.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.mirrortest;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.ClassDeclaration;
-import com.sun.mirror.declaration.ConstructorDeclaration;
-import com.sun.mirror.declaration.FieldDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-
-public class ASTBasedMirrorDeclarationProcessorFactory
- extends BaseFactory
-{
- public ASTBasedMirrorDeclarationProcessorFactory(){
- super("test.DeclarationAnno");
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> arg0,
- AnnotationProcessorEnvironment env) {
- return new ASTBasedMirrorDeclarationProcessor(env);
- }
-
- public static final class ASTBasedMirrorDeclarationProcessor
- extends BaseProcessor{
-
- public ASTBasedMirrorDeclarationProcessor(AnnotationProcessorEnvironment env){
- super(env);
- }
- public void process() {
- final Collection<TypeDeclaration> typeDecls = _env.getTypeDeclarations();
- boolean done = false;
- for( TypeDeclaration typeDecl : typeDecls ){
- if(typeDecl instanceof ClassDeclaration ){
- examineClass( (ClassDeclaration)typeDecl );
- if( typeDecl.getQualifiedName().equals("test.Foo") )
- done = true;
- }
- }
- // if the current file does not contain "test.Foo",
- // look for it by name and run the same tests.
- if( !done ){
- final ClassDeclaration fooDecl = (ClassDeclaration)_env.getTypeDeclaration("test.Foo");
- examineClass(fooDecl);
- final ClassDeclaration innerTypeDecl = (ClassDeclaration)_env.getTypeDeclaration("test.Foo$Inner");
- examineClass(innerTypeDecl);
- }
- }
-
- private void examineClass(ClassDeclaration typeDecl ){
-
- assertNonNull(typeDecl, "missing type declaration");
- if( typeDecl != null ){
- final String typename = typeDecl.getSimpleName();
- if(typename.equals("Foo")){
- final Collection<? extends MethodDeclaration> methods = typeDecl.getMethods();
- assertEqual(2, methods.size(), "number of methods do not match ");
- for(MethodDeclaration method : methods ){
- final String name = method.getSimpleName();
- if( name.equals("getType") ){
- final String methodString = method.toString();
- final String expectedString = "UnknownType getType()";
- assertEqual(expectedString, methodString, "signature mismatch");
- }
- else if( name.equals("voidMethod")){
- final String methodString = method.toString();
- final String expectedString = "void voidMethod()";
- assertEqual(expectedString, methodString, "signature mismatch");
- }
- else{
- assertEqual(null, method.toString(), "unexpected method");
- }
- }
-
- final Collection<ConstructorDeclaration> constructors =
- typeDecl.getConstructors();
- assertEqual(1, constructors.size(), "number of constructors do not match");
- for( ConstructorDeclaration constructor : constructors ){
- final String constructorString = constructor.toString();
- final String expectedString = "Foo(UnknownType type)";
- assertEqual(expectedString, constructorString, "signature mismatch");
- }
- final Collection<FieldDeclaration> fields =
- typeDecl.getFields();
- assertEqual(2, fields.size(), "number of fields do not match");
- for( FieldDeclaration field : fields ){
- final String name = field.getSimpleName();
- if( "field0".equals(name) || "field1".equals(name) ){
- continue;
- }
- assertEqual(null, name, "unexpected field");
- }
- }
- else if(typename.equals("Inner")){
- final Collection<? extends MethodDeclaration> methods =
- typeDecl.getMethods();
- assertEqual(0, methods.size(), "number of methods do not match ");
-
- final Collection<ConstructorDeclaration> constructors =
- typeDecl.getConstructors();
- assertEqual(1, constructors.size(), "number of constructors do not match");
- for( ConstructorDeclaration constructor : constructors ){
- final String constructorString = constructor.toString();
- final String expectedString = "Inner()";
- assertEqual(expectedString, constructorString, "signature mismatch");
- }
- final Collection<FieldDeclaration> fields =
- typeDecl.getFields();
- assertEqual(0, fields.size(), "number of fields do not match");
- }
- }
- }
- }
-}
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 1b7337aca5..0000000000
--- 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" +
- " public static final String STATIC_FIELD = \"Static Field\";\n" +
- "\n" +
- " private static final long serialVersionUID = 42L;\n" +
- "\n" +
- " public 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" +
- " public 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/DefaultConstantAnnotationFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/DefaultConstantAnnotationFactory.java
deleted file mode 100644
index 8321617072..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/DefaultConstantAnnotationFactory.java
+++ /dev/null
@@ -1,30 +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.tests.annotations.mirrortest;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class DefaultConstantAnnotationFactory extends BaseFactory{
-
- public DefaultConstantAnnotationFactory(){
- super("test.Trigger");
- }
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> decls, AnnotationProcessorEnvironment env) {
- return new DefaultConstantProcessor(env);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/DefaultConstantProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/DefaultConstantProcessor.java
deleted file mode 100644
index 9484dc342b..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/DefaultConstantProcessor.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.tests.annotations.mirrortest;
-
-import java.util.Collection;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Messager;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.FieldDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.type.DeclaredType;
-
-public class DefaultConstantProcessor extends BaseProcessor {
- public DefaultConstantProcessor(AnnotationProcessorEnvironment env){
- super(env);
- }
- public void process() {
- final AnnotationTypeDeclaration trigger = (AnnotationTypeDeclaration)_env.getTypeDeclaration("test.Trigger");
-
- final Messager msger = _env.getMessager();
- if( trigger == null)
- msger.printError("cannot find test.Trigger");
-
- final Collection<Declaration> decls = _env.getDeclarationsAnnotatedWith(trigger);
- for(Declaration decl : decls ){
- if( decl instanceof TypeDeclaration ){
- final TypeDeclaration typeDecl = (TypeDeclaration)decl;
- if( "test.EntryPoint".equals(typeDecl.getQualifiedName()) ){
- final Collection<FieldDeclaration> fields = typeDecl.getFields();
- for( FieldDeclaration field : fields ){
- final String name = field.getSimpleName();
- if( "nestedAnno".equals(name)){
- final DeclaredType fieldType = (DeclaredType)field.getType();
- final Collection<TypeDeclaration> nestedTypes = fieldType.getDeclaration().getNestedTypes();
- for(TypeDeclaration nestedType : nestedTypes ){
- if( "NestedAnnotation".equals(nestedType.getSimpleName()) ){
- final Collection<? extends MethodDeclaration> annotationMethods = nestedType.getMethods();
- for( MethodDeclaration annotationMethod : annotationMethods ){
- if( "value".equals(annotationMethod.getSimpleName()) ){
- final AnnotationTypeElementDeclaration value =
- (AnnotationTypeElementDeclaration)annotationMethod;
- final String defaultString = value.getDefaultValue() == null ? "" :
- value.getDefaultValue().toString();
- final String expected = "Eore";
- if(!defaultString.equals(expected) )
- msger.printError("expecting default=" + expected + " but got " +defaultString);
- }
- }
- }
- }
-
- final Collection<FieldDeclaration> nestedAnnoFields = fieldType.getDeclaration().getFields();
- for(FieldDeclaration nestedAnnoField : nestedAnnoFields ){
- if(nestedAnnoField.getSimpleName().equals("FOUR")){
- final Object constant = nestedAnnoField.getConstantValue();
- final String expected = "4";
- final String constantStr = constant == null ? "" : constant.toString();
- if(!constantStr.equals(expected) )
- msger.printError("expecting constant=" + expected + " but got " + constantStr);
- }
- }
- continue;
- }
- else{
- msger.printError("found unexpected field " + field );
- }
-
- }
-
- continue;
- }
- }
- msger.printError("found unexpected declaration " + decl );
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationCodeExample.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationCodeExample.java
deleted file mode 100644
index 0e54016730..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationCodeExample.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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.mirrortest;
-
-public class MirrorDeclarationCodeExample
-{
- public static final String CODE_PACKAGE = "mirrortestpackage";
- public static final String CODE_CLASS_NAME = "DeclarationTestClass";
- public static final String CODE_FULL_NAME = CODE_PACKAGE + "." + CODE_CLASS_NAME;
-
- public static final String CODE =
- "package mirrortestpackage;\n" +
- "import org.eclipse.jdt.apt.tests.annotations.mirrortest.MirrorDeclarationTestAnnotation;" + "\n" +
- "@MirrorDeclarationTestAnnotation(s=\"fred\", value=5)" + "\n" +
- "public class DeclarationTestClass {" + "\n" +
- " public class ClassDec {" + "\n" +
- " public ClassDec() {}" + "\n" +
- " public ClassDec(int j) {}" + "\n" +
- " public static final int i = 1;" + "\n" +
- " public float f;" + "\n" +
- " public static final String s = \"hello\";" + "\n" +
- " public java.util.GregorianCalendar gc;" + "\n" +
- " public void methodDec(int k, String... t) throws Exception {}" + "\n" +
- " public void methodDecNoArg(){}" + "\n" +
- " @MirrorDeclarationTestAnnotation() public Object foo(Object o) throws Exception {\n" +
- " return null;\n" +
- " }\n" +
- " @MirrorDeclarationTestAnnotation() public Object foo2(Object o) throws Exception {\n" +
- " return null;\n" +
- " }\n" +
- " @MirrorDeclarationTestAnnotation() public Object foo3(Object o) throws Exception {\n" +
- " return null;\n" +
- " }\n" +
- " }" + "\n" +
- " public enum EnumDec {" + "\n" +
- " aardvark, anteater" + "\n" +
- " }" + "\n" +
- "}";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationTestAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationTestAnnotation.java
deleted file mode 100644
index 2ae16c4f59..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationTestAnnotation.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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.mirrortest;
-
-public @interface MirrorDeclarationTestAnnotation {
- String s() default "bob"; //$NON-NLS-1$
- int value() default 3;
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationTestAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationTestAnnotationProcessor.java
deleted file mode 100644
index a47fe814ea..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationTestAnnotationProcessor.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-//TODO AnnotationMirror.ElementValues()
-//TODO AnnotationMirror.getPosition()
-//TODO AnnotationValue.getPosition()
-//TODO AnnotationValue.toString()
-//TODO Declaration
-//TODO ExecutableDeclaration
-//TODO TypeDeclaration
-//TODO InterfaceDeclaration
-//TODO MemberDeclaration
-//TODO MethodDeclaration.getFormalTypeParameters()
-//TODO PackageDeclaration
-//TODO TypeParameterDeclaration
-
-package org.eclipse.jdt.apt.tests.annotations.mirrortest;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
-import com.sun.mirror.declaration.AnnotationValue;
-import com.sun.mirror.declaration.ClassDeclaration;
-import com.sun.mirror.declaration.ConstructorDeclaration;
-import com.sun.mirror.declaration.EnumConstantDeclaration;
-import com.sun.mirror.declaration.EnumDeclaration;
-import com.sun.mirror.declaration.FieldDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.Modifier;
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.type.AnnotationType;
-import com.sun.mirror.type.ClassType;
-import com.sun.mirror.type.ReferenceType;
-
-public class MirrorDeclarationTestAnnotationProcessor extends BaseProcessor {
-
- public MirrorDeclarationTestAnnotationProcessor(AnnotationProcessorEnvironment env) {
- super(env);
- }
-
- public void process() {
- ProcessorTestStatus.setProcessorRan();
- try {
- Collection<TypeDeclaration> decls = _env.getSpecifiedTypeDeclarations();
- TypeDeclaration testClass = null;
- ClassDeclaration testClassDec = null;
- for(TypeDeclaration decl : decls) {
- if(decl.toString().endsWith("DeclarationTestClass")) { //$NON-NLS-1$
- testClass = decl;
- }
- if(decl.toString().endsWith("ClassDec")) { //$NON-NLS-1$
- testClassDec = (ClassDeclaration)decl;
- }
- }
-
- testAnnotationImplementations(testClass);
- testClassDeclaration(testClassDec);
- testEnumImplementations(testClass);
- testFieldDeclaration(testClassDec);
- testMethodDeclaration(testClassDec);
- }
- catch (Throwable t) {
- if (!ProcessorTestStatus.hasErrors()) {
- ProcessorTestStatus.failWithoutException(t.toString());
- }
- t.printStackTrace();
- }
- }
-
-
- /**
- * Tests for:
- * Annotation Mirror
- * AnnotationTypeDeclaration
- * AnnotationTypeElementDeclaration
- * AnnotationValue
- *
- * @param testClass TypeDeclaration
- *
- */
- private void testAnnotationImplementations(TypeDeclaration testClass) {
-
- //AnnotationMirror tests
- Collection<AnnotationMirror> annoMirrors = testClass.getAnnotationMirrors();
- ProcessorTestStatus.assertEquals("Number of annotation mirrors", 1, annoMirrors.size());
-
- AnnotationMirror annoMirror = annoMirrors.iterator().next();
- ProcessorTestStatus.assertTrue("Annotation mirror contents", annoMirror.toString().startsWith("@MirrorDeclarationTestAnnotation"));
-
- AnnotationType annoType = annoMirror.getAnnotationType();
- ProcessorTestStatus.assertTrue("AnnotationType name", annoType.toString().endsWith("mirrortest.MirrorDeclarationTestAnnotation"));
-
-
- //AnnotationTypeDeclaration tests
- AnnotationTypeDeclaration annoTypeDecl = annoType.getDeclaration();
- ProcessorTestStatus.assertEquals("AnnotationTypeDeclaration same as AnnotationType", annoType, annoTypeDecl);
-
-
- //AnnotationTypeElementDeclaration and AnnotationValue tests
- Collection<AnnotationTypeElementDeclaration> elementDeclarations = annoTypeDecl.getMethods();
- ProcessorTestStatus.assertEquals("Number of methods on annotation", 2, elementDeclarations.size());
-
- AnnotationTypeElementDeclaration elementString = null;
- AnnotationTypeElementDeclaration elementInt = null;
- for(AnnotationTypeElementDeclaration ated : elementDeclarations) {
- if(ated.toString().startsWith("S"))
- elementString = ated;
- if(ated.toString().startsWith("i"))
- elementInt = ated;
- }
- ProcessorTestStatus.assertEquals("declaring type same as AnnotationTypeDeclaration", annoTypeDecl, elementString.getDeclaringType());
- ProcessorTestStatus.assertEquals("declaring type same as AnnotationTypeDeclaration", annoTypeDecl, elementInt.getDeclaringType());
-
- AnnotationValue valueString = elementString.getDefaultValue();
- AnnotationValue valueInt = elementInt.getDefaultValue();
- ProcessorTestStatus.assertEquals("", "bob", valueString.getValue());
- ProcessorTestStatus.assertEquals("", new Integer(3), valueInt.getValue());
- ProcessorTestStatus.assertEquals("", "bob", valueString.toString());
- ProcessorTestStatus.assertEquals("", "3", valueInt.toString());
- }
-
- /**
- * Tests for:
- * ClassDeclaration
- * ConstructorDeclaration
- *
- * @param testClass
- */
- private void testClassDeclaration(ClassDeclaration testClassDec) {
-
- //ClassDeclaration tests
- Collection<ConstructorDeclaration> constructDecls = testClassDec.getConstructors();
- ProcessorTestStatus.assertEquals("Number of constructors", 2, constructDecls.size());
-
- ConstructorDeclaration constructNoArg = null;
- ConstructorDeclaration constructIntArg = null;
- for(ConstructorDeclaration construct : constructDecls) {
- if(construct.toString().endsWith("()"))
- constructNoArg = construct;
- if(construct.toString().endsWith("(int j)"))
- constructIntArg = construct;
- }
- ProcessorTestStatus.assertTrue("constructor with no args", constructNoArg != null);
- ProcessorTestStatus.assertTrue("constructor with one (int) arg", constructIntArg != null);
-
- Collection<MethodDeclaration> methodDecls = testClassDec.getMethods();
- ProcessorTestStatus.assertEquals("Number of methods", 5, methodDecls.size());
-
- HashSet<AnnotationMirror> annotationMirrors = new HashSet<AnnotationMirror>();
- for (MethodDeclaration methodDeclaration : methodDecls) {
- Collection<AnnotationMirror> mirrors = methodDeclaration.getAnnotationMirrors();
- annotationMirrors.addAll(mirrors);
- }
- ProcessorTestStatus.assertEquals("Wrong size for annotation mirrors", 3, annotationMirrors.size());
-
- MethodDeclaration methodDecl = null;
- methodDecl = methodDecls.iterator().next();
- ProcessorTestStatus.assertTrue("method declaration exists", methodDecl != null);
-
- ClassType superClass = testClassDec.getSuperclass();
- ProcessorTestStatus.assertEquals("Object is only super", "java.lang.Object", superClass.toString());
- }
-
- /**
- * Tests for:
- * EnumConstantDeclaration
- * EnumDeclaration
- *
- * @param testClass
- */
- private void testEnumImplementations(TypeDeclaration testClass) {
-
- //EnumDeclaration tests
- Collection<TypeDeclaration> nestedTypes = testClass.getNestedTypes();
- EnumDeclaration enumDecl = null;
- for(TypeDeclaration decl : nestedTypes) {
- if(decl.toString().endsWith("EnumDec"))
- enumDecl = (EnumDeclaration)decl;
- }
- ProcessorTestStatus.assertTrue("EnumDeclaration exists", enumDecl != null);
-
- Collection<EnumConstantDeclaration> enumConstDecls = enumDecl.getEnumConstants();
- ProcessorTestStatus.assertEquals("Number of enum constants", 2, enumConstDecls.size());
- EnumConstantDeclaration enumConstAardvark = null;
- EnumConstantDeclaration enumConstAnteater = null;
- for(EnumConstantDeclaration enumConst : enumConstDecls) {
- if(enumConst.toString().equals("aardvark"))
- enumConstAardvark = enumConst;
- if(enumConst.toString().equals("anteater"))
- enumConstAnteater = enumConst;
- }
- ProcessorTestStatus.assertTrue("enum constant \"aardvark\" exists", enumConstAardvark != null);
- ProcessorTestStatus.assertTrue("enum constant \"anteater\" exists", enumConstAnteater != null);
-
- //EnumConstantDeclaration tests
- EnumDeclaration declaringTypeAardvark = enumConstAardvark.getDeclaringType();
- EnumDeclaration declaringTypeAnteater = enumConstAnteater.getDeclaringType();
- ProcessorTestStatus.assertEquals("Declaring type is EnumDec", "mirrortestpackage.DeclarationTestClass.EnumDec", declaringTypeAardvark.toString());
- ProcessorTestStatus.assertEquals("Declaring type is EnumDec", "mirrortestpackage.DeclarationTestClass.EnumDec", declaringTypeAnteater.toString());
-
-
- //Modifier tests
- Modifier[] valuesArray = Modifier.values();
- int valuesArrayLength = valuesArray.length;
- ProcessorTestStatus.assertEquals("Modifier.values() array length", 11, valuesArrayLength);
-
- ProcessorTestStatus.assertEquals("Modifier.ABSTRACT", "abstract", Modifier.ABSTRACT.toString());
- ProcessorTestStatus.assertEquals("Modifier.FINAL", "final", Modifier.FINAL.toString());
- ProcessorTestStatus.assertEquals("Modifier.NATIVE", "native", Modifier.NATIVE.toString());
- ProcessorTestStatus.assertEquals("Modifier.PRIVATE", "private", Modifier.PRIVATE.toString());
- ProcessorTestStatus.assertEquals("Modifier.PROTECTED", "protected", Modifier.PROTECTED.toString());
- ProcessorTestStatus.assertEquals("Modifier.PUBLIC", "public", Modifier.PUBLIC.toString());
- ProcessorTestStatus.assertEquals("Modifier.STATIC", "static", Modifier.STATIC.toString());
- ProcessorTestStatus.assertEquals("Modifier.STRICTFP", "strictfp", Modifier.STRICTFP.toString());
- ProcessorTestStatus.assertEquals("Modifier.SYNCHRONIZED", "synchronized", Modifier.SYNCHRONIZED.toString());
- ProcessorTestStatus.assertEquals("Modifier.TRANSIENT", "transient", Modifier.TRANSIENT.toString());
- ProcessorTestStatus.assertEquals("Modifier.VOLATILE", "volatile", Modifier.VOLATILE.toString());
- ProcessorTestStatus.assertEquals("Modifier.valueOf(\"PUBLIC\")", Modifier.PUBLIC, Modifier.valueOf("PUBLIC"));
- }
-
- /**
- * Tests for:
- * FieldDeclaration
- *
- * @param testClassDec
- */
- private void testFieldDeclaration(ClassDeclaration testClassDec) {
-
- //FieldDeclaration tests
- Collection<FieldDeclaration> fieldDecls = testClassDec.getFields();
- ProcessorTestStatus.assertEquals("Number of fields", 4, fieldDecls.size());
- FieldDeclaration fieldI = null;
- FieldDeclaration fieldF = null;
- FieldDeclaration fieldS = null;
- FieldDeclaration fieldGC = null;
- for(FieldDeclaration field : fieldDecls) {
- if(field.toString().equals("i"))
- fieldI = field;
- if(field.toString().equals("f"))
- fieldF = field;
- if(field.toString().equals("s"))
- fieldS = field;
- if(field.toString().equals("gc"))
- fieldGC = field;
- }
- ProcessorTestStatus.assertTrue("Field i exists", fieldI != null);
- ProcessorTestStatus.assertEquals("Field i constant expression is 1", "1", fieldI.getConstantExpression());
- ProcessorTestStatus.assertEquals("Field i constant value is 1", "1", fieldI.getConstantValue().toString());
- ProcessorTestStatus.assertEquals("Field i type is int", "int", fieldI.getType().toString());
- ProcessorTestStatus.assertTrue("Field f exists", fieldF != null);
- ProcessorTestStatus.assertEquals("Field f constant expression is null", null, fieldF.getConstantExpression());
- ProcessorTestStatus.assertEquals("Field f constant value is null", null, fieldF.getConstantValue());
- ProcessorTestStatus.assertEquals("Field f type is float", "float", fieldF.getType().toString());
- ProcessorTestStatus.assertTrue("Field s exists", fieldS != null);
- ProcessorTestStatus.assertEquals("Field s constant expression is hello", "hello", fieldS.getConstantExpression());
- ProcessorTestStatus.assertEquals("Field s constant value is hello", "hello", fieldS.getConstantValue().toString());
- ProcessorTestStatus.assertEquals("Field s type is java.lang.String", "java.lang.String", fieldS.getType().toString());
- ProcessorTestStatus.assertTrue("Field gc exists", fieldGC != null);
- ProcessorTestStatus.assertEquals("Field gc constant expression is null", null, fieldGC.getConstantExpression());
- ProcessorTestStatus.assertEquals("Field gc constant value is null", null, fieldGC.getConstantValue());
- ProcessorTestStatus.assertEquals("Field gc type is java.util.GregorianCalendar", "java.util.GregorianCalendar", fieldGC.getType().toString());
- }
-
- /**
- * Tests for:
- * MethodDeclaration
- * ParameterDeclaration
- *
- * @param testClassDec
- */
- private void testMethodDeclaration(ClassDeclaration testClassDec) {
-
- //Tests for MethodDeclaration
- Collection<MethodDeclaration> methodDecls = testClassDec.getMethods();
- MethodDeclaration methodDec = null;
- MethodDeclaration methodDecNoArg = null;
- for(MethodDeclaration method : methodDecls) {
- if(method.toString().endsWith("methodDec(int k, String... t)"))
- methodDec = method;
- if(method.toString().endsWith("methodDecNoArg()"))
- methodDecNoArg = method;
- }
- ProcessorTestStatus.assertTrue("Method methodDec exists", methodDec != null);
-
- Collection<ReferenceType> thrownTypes = methodDec.getThrownTypes();
- ProcessorTestStatus.assertEquals("Number of types thrown", 1, thrownTypes.size());
-
- ReferenceType thrownType = thrownTypes.iterator().next();
- ProcessorTestStatus.assertEquals("methodDec throws Exception", "java.lang.Exception", thrownType.toString());
- ProcessorTestStatus.assertTrue("methodDec is varargs", methodDec.isVarArgs());
- ProcessorTestStatus.assertTrue("Method methodDecNoArg exists", methodDecNoArg != null);
- ProcessorTestStatus.assertEquals("Number of types thrown", 0, methodDecNoArg.getThrownTypes().size());
- ProcessorTestStatus.assertTrue("methodDecNoArg is not varargs", !methodDecNoArg.isVarArgs());
-
-
- //Tests for ParameterDeclaration
- Collection<ParameterDeclaration> paramDecls = methodDec.getParameters();
- ParameterDeclaration paramDeclInt = null;
- ParameterDeclaration paramDeclString = null;
- for(ParameterDeclaration param : paramDecls) {
- if(param.toString().startsWith("int"))
- paramDeclInt = param;
- if(param.toString().startsWith("String..."))
- paramDeclString = param;
- }
- ProcessorTestStatus.assertTrue("int parameter exists", paramDeclInt != null);
- ProcessorTestStatus.assertEquals("Parameter type is int", "int", paramDeclInt.getType().toString());
- ProcessorTestStatus.assertTrue("String... parameter exists", paramDeclString != null);
- ProcessorTestStatus.assertEquals("Parameter type is String[]", "java.lang.String[]", paramDeclString.getType().toString());
- ProcessorTestStatus.assertEquals("Number of parameters in methodDecNoArg", 0, methodDecNoArg.getParameters().size());
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationTestAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationTestAnnotationProcessorFactory.java
deleted file mode 100644
index db5b08b1bf..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorDeclarationTestAnnotationProcessorFactory.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:
- * jgarms@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.mirrortest;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class MirrorDeclarationTestAnnotationProcessorFactory extends BaseFactory
-{
-
- public MirrorDeclarationTestAnnotationProcessorFactory() {
- super(MirrorDeclarationTestAnnotation.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env)
- {
- return new MirrorDeclarationTestAnnotationProcessor(env);
- }
-
-
-}
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 ecb1e72612..0000000000
--- 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 ""; //$NON-NLS-1$
-}
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 e699e7a5f6..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotationProcessor.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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 org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-
-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 extends BaseProcessor {
-
- public MirrorTestAnnotationProcessor(AnnotationProcessorEnvironment env) {
- super(env);
- }
-
- public void process() {
- ProcessorTestStatus.setProcessorRan();
- 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 (!ProcessorTestStatus.hasErrors()) {
- ProcessorTestStatus.failWithoutException(t.toString());
- }
- t.printStackTrace();
- }
- }
-
- private void testTypeDecl(TypeDeclaration typeDecl) {
- ProcessorTestStatus.assertEquals("Type name",
- CodeExample.CODE_PACKAGE + "." + CodeExample.CODE_CLASS_NAME,
- typeDecl.getQualifiedName());
-
- PackageDeclaration pkg = typeDecl.getPackage();
- ProcessorTestStatus.assertEquals("Package", CodeExample.CODE_PACKAGE, pkg.getQualifiedName());
-
- Collection<FieldDeclaration> fields = typeDecl.getFields();
- ProcessorTestStatus.assertEquals("Number of fields: " + fields, 3, fields.size());
-
- Collection<TypeParameterDeclaration> typeParams = typeDecl.getFormalTypeParameters();
- ProcessorTestStatus.assertEquals("Number of type params", 0, typeParams.size());
-
- Collection<? extends MethodDeclaration> methods = typeDecl.getMethods();
- ProcessorTestStatus.assertEquals("Number of methods", 3, methods.size());
-
- Collection<TypeDeclaration> nestedTypes = typeDecl.getNestedTypes();
- ProcessorTestStatus.assertEquals("Number of nested types", 1, nestedTypes.size());
-
- Collection<InterfaceType> supers = typeDecl.getSuperinterfaces();
- ProcessorTestStatus.assertEquals("Number of supers", 1, supers.size());
- }
-
- private void testPackageImpl() {
- PackageDeclaration pkg = _env.getPackage("org.eclipse.jdt.apt.tests.annotations.mirrortest");
- ProcessorTestStatus.assertEquals("Package name", "org.eclipse.jdt.apt.tests.annotations.mirrortest", pkg.getQualifiedName());
- // We used to test by counting the number of elements returned by the various calls,
- // but that is not stable between different JDKs.
-
- pkg = _env.getPackage("java");
- ProcessorTestStatus.assertEquals("Package name", "java", pkg.getQualifiedName());
- ProcessorTestStatus.assertEquals("Number of classes in java", 0, pkg.getClasses().size());
-
- pkg = _env.getPackage("java.util");
- ProcessorTestStatus.assertEquals("Package name", "java.util", pkg.getQualifiedName());
-
- Collection<ClassDeclaration> classes = pkg.getClasses();
- TypeDeclaration stringDecl = _env.getTypeDeclaration("java.util.Collections");
- ProcessorTestStatus.assertTrue("java.util contains String", classes.contains(stringDecl));
-
- Collection<EnumDeclaration> enums = pkg.getEnums();
- ProcessorTestStatus.assertEquals("Number of enums in java.util", 0, enums.size());
-
- TypeDeclaration iteratorDecl = _env.getTypeDeclaration("java.util.Iterator");
- Collection<InterfaceDeclaration> interfaces = pkg.getInterfaces();
- ProcessorTestStatus.assertTrue("java.util contains Iterator", interfaces.contains(iteratorDecl));
- }
-
- private void testDeclarationsUtil(TypeDeclaration typeDecl) {
- Declarations utils = _env.getDeclarationUtils();
- TypeDeclaration objType = _env.getTypeDeclaration("java.lang.Object");
-
- // Test negative case
- ProcessorTestStatus.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;
- }
- }
- ProcessorTestStatus.assertTrue("inner's staticMethod() should hide MirrorTestClass'", utils.hides(innerMethod, outerMethod));
- }
-}
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 f40b7826d0..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorTestAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,34 +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.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class MirrorTestAnnotationProcessorFactory extends BaseFactory {
-
- public MirrorTestAnnotationProcessorFactory() {
- super(MirrorTestAnnotation.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> typeDecls, AnnotationProcessorEnvironment env) {
- return new MirrorTestAnnotationProcessor(env);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestAnnotation.java
deleted file mode 100644
index 02d45143fe..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestAnnotation.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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:
- * sbandow@bea.com - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.mirrortest;
-
-public @interface MirrorUtilTestAnnotation
-{
- String value() default ""; //$NON-NLS-1$
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestAnnotationProcessor.java
deleted file mode 100644
index b3120198bc..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestAnnotationProcessor.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.mirrortest;
-
-import java.io.File;
-import java.util.Map;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.FieldDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-
-public class MirrorUtilTestAnnotationProcessor extends BaseProcessor
-{
-
- // Environment options test cases
- // no-translation cases
- public static final int EC_NORMAL = 0;
- public static final int EC_NORMALPATH = 1;
- public static final int EC_BOGUSCPVAR = 2;
- public static final int EC_BADPROJ = 3;
- // end of no-translation cases
- public static final int EC_NUM_NOTRANSLATIONCASES = 4;
- // expected-translation cases
- public static final int EC_CPVAR = 4;
- public static final int EC_CPVARPATH = 5;
- public static final int EC_CPVARFILE = 6;
- public static final int EC_PROJ = 7;
- public static final int EC_PROJFILE = 8;
- public static final int EC_PROJDIRFILE = 9;
-
- private static final String ENVPREFIX = "apt.tests.annotations.mirrortest.";
- public static final String[] ENV_KEYS = {
- // no-translation
- ENVPREFIX + "normal",
- ENVPREFIX + "normalPath",
- ENVPREFIX + "boguscpvar",
- ENVPREFIX + "badProj",
- // expected-translation
- ENVPREFIX + "cpvar",
- ENVPREFIX + "cpvarPath",
- ENVPREFIX + "cpvarFile",
- ENVPREFIX + "proj",
- ENVPREFIX + "projFile",
- ENVPREFIX + "projdirFile"
- };
- public static final String[] ENV_VALUES = {
- // no-translation
- "normal",
- "normal/foo.bar",
- "%NOSUCH/VARNAME%",
- "%ROOT%/someOtherProject/foo/nonexistent.txt",
- // expected-translation
- "%ECLIPSE_HOME%",
- "%ECLIPSE_HOME%/plugins",
- "%ECLIPSE_HOME%/notice.html",
- "%ROOT%/org.eclipse.jdt.apt.tests.MirrorUtilTestsProject",
- "%ROOT%/org.eclipse.jdt.apt.tests.MirrorUtilTestsProject/.classpath",
- "%PROJECT.DIR%/.classpath"
- };
-
- public MirrorUtilTestAnnotationProcessor(AnnotationProcessorEnvironment env)
- {
- super(env);
- }
-
- public void process()
- {
- ProcessorTestStatus.setProcessorRan();
- testHidesOverrides();
- testEnvOptions();
- }
-
-
- @SuppressWarnings("unused")
- private void testHidesOverrides()
- {
- //set the type declarations
- TypeDeclaration type_EnvTestClass = null;
- TypeDeclaration type_A = null;
- TypeDeclaration type_B = null;
- TypeDeclaration type_C = null;
- TypeDeclaration type_D = null;
- TypeDeclaration type_I = null;
- TypeDeclaration type_J = null;
- TypeDeclaration type_K = null;
- for(TypeDeclaration type : _env.getTypeDeclarations())
- {
- if(type.toString().endsWith("EnvTestClass"))
- type_EnvTestClass = type;
- if(type.toString().endsWith("A"))
- type_A = type;
- if(type.toString().endsWith("B"))
- type_B = type;
- if(type.toString().endsWith("C"))
- type_C = type;
- if(type.toString().endsWith("D"))
- type_D = type;
- if(type.toString().endsWith("I"))
- type_I = type;
- if(type.toString().endsWith("J"))
- type_J = type;
- if(type.toString().endsWith("K"))
- type_K = type;
- }
-
- //set the method declarations
- MethodDeclaration method_A = type_A.getMethods().iterator().next();
- MethodDeclaration method_B = type_B.getMethods().iterator().next();
- MethodDeclaration method_C = type_C.getMethods().iterator().next();
- MethodDeclaration method_D = type_D.getMethods().iterator().next();
- MethodDeclaration method_I = type_I.getMethods().iterator().next();
- MethodDeclaration method_K = type_K.getMethods().iterator().next();
-
- //set the field declarations
- FieldDeclaration field_A = type_A.getFields().iterator().next();
- FieldDeclaration field_B = type_B.getFields().iterator().next();
- FieldDeclaration field_C = type_C.getFields().iterator().next();
- FieldDeclaration field_D = type_D.getFields().iterator().next();
- FieldDeclaration field_I = type_I.getFields().iterator().next();
- FieldDeclaration field_K = type_K.getFields().iterator().next();
-
- //overrides positive tests
- ProcessorTestStatus.assertTrue("Expect B.method() to override A.method()", _env.getDeclarationUtils().overrides(method_B, method_A));
- ProcessorTestStatus.assertTrue("Expect K.method() to override I.method()", _env.getDeclarationUtils().overrides(method_K, method_I));
-
- //overrides negative tests
- ProcessorTestStatus.assertTrue("Expect B.method() to not override C.method()", !_env.getDeclarationUtils().overrides(method_B, method_C));
- ProcessorTestStatus.assertTrue("Expect D.method(String s) to not override A.method()", !_env.getDeclarationUtils().overrides(method_D, method_A));
-
- //hides positive tests
- ProcessorTestStatus.assertTrue("Expect B.field to hide A.field", _env.getDeclarationUtils().hides(field_B, field_A));
- ProcessorTestStatus.assertTrue("Expect D.field to hide A.field", _env.getDeclarationUtils().hides(field_D, field_A));
- ProcessorTestStatus.assertTrue("Expect K.field to hide I.field", _env.getDeclarationUtils().hides(field_K, field_I));
-
- //hides negative test
- ProcessorTestStatus.assertTrue("Expect B.field to not hide C.field", !_env.getDeclarationUtils().hides(field_B, field_C));
- }
-
- private void testEnvOptions() {
- Map<String, String> options = _env.getOptions();
- // no-translation cases should be unchanged
- for (int i = 0; i < EC_NUM_NOTRANSLATIONCASES; ++i) {
- ProcessorTestStatus.assertEquals(ENV_KEYS[i], options.get(ENV_KEYS[i]), ENV_VALUES[i]);
- }
- // translation cases should be changed
- for (int i = EC_NUM_NOTRANSLATIONCASES; i < ENV_KEYS.length; ++i) {
- ProcessorTestStatus.assertTrue(ENV_KEYS[i], !ENV_VALUES[i].equals(options.get(ENV_KEYS[i])) );
- }
- // the files should exist at the specified absolute location
- String name = options.get(ENV_KEYS[EC_CPVARFILE]);
- File file;
- if (name == null) {
- ProcessorTestStatus.fail(ENV_KEYS[EC_CPVARFILE] + " was not in options map");
- } else {
- file = new File(name);
- ProcessorTestStatus.assertTrue(ENV_KEYS[EC_CPVARFILE] + " was not found", file != null && file.exists());
- }
-
- name = options.get(ENV_KEYS[EC_PROJFILE]);
- if (name == null) {
- ProcessorTestStatus.fail(ENV_KEYS[EC_PROJFILE] + " was not in options map");
- } else {
- file = new File(name);
- ProcessorTestStatus.assertTrue(ENV_KEYS[EC_PROJFILE] + " was not found", file != null && file.exists());
- }
-
- name = options.get(ENV_KEYS[EC_PROJDIRFILE]);
- if (name == null) {
- ProcessorTestStatus.fail(ENV_KEYS[EC_PROJDIRFILE] + " was not in options map");
- } else {
- file = new File(name);
- ProcessorTestStatus.assertTrue(ENV_KEYS[EC_PROJDIRFILE] + " was not found", file != null && file.exists());
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestAnnotationProcessorFactory.java
deleted file mode 100644
index a10bc2a1ba..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,35 +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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.mirrortest;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class MirrorUtilTestAnnotationProcessorFactory extends BaseFactory
-{
-
- public MirrorUtilTestAnnotationProcessorFactory() {
- super(MirrorUtilTestAnnotation.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env)
- {
- return new MirrorUtilTestAnnotationProcessor(env);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestCodeExample.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestCodeExample.java
deleted file mode 100644
index 319c4f3cea..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/mirrortest/MirrorUtilTestCodeExample.java
+++ /dev/null
@@ -1,68 +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:
- * sbandow@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.mirrortest;
-
-/**
- * Holds information for the mirror tests.
- */
-public class MirrorUtilTestCodeExample {
-
- public static final String CODE_PACKAGE = "testpackage";
-
- public static final String CODE_CLASS_NAME = "DeclarationsTestClass";
-
- public static final String CODE_FULL_NAME = CODE_PACKAGE + "." + CODE_CLASS_NAME;
-
- public static final String CODE =
- "package testpackage;" + "\n" +
- "import org.eclipse.jdt.apt.tests.annotations.mirrortest.MirrorUtilTestAnnotation;" + "\n" +
- "@MirrorUtilTestAnnotation" + "\n" +
- "public class DeclarationsTestClass" + "\n" +
- "{" + "\n" +
- " public class A" + "\n" +
- " {" + "\n" +
- " public int field; " + "\n" +
- " public void method(){}" + "\n" +
- " }" + "\n" +
- " public class B extends A" + "\n" +
- " {" + "\n" +
- " public int field; " + "\n" +
- " public void method(){}" + "\n" +
- " }" + "\n" +
- " public class C" + "\n" +
- " {" + "\n" +
- " public int field; " + "\n" +
- " public void method(){}" + "\n" +
- " }" + "\n" +
- " public class D extends A" + "\n" +
- " {" + "\n" +
- " public Object field;" + "\n" +
- " public void method(String s){}" + "\n" +
- " }" + "\n" +
- " public interface I" + "\n" +
- " {" + "\n" +
- " public int field = 1;" + "\n" +
- " public void method();" + "\n" +
- " }" + "\n" +
- " public interface J" + "\n" +
- " {" + "\n" +
- " public int field = 2;" + "\n" +
- " }" + "\n" +
- " public class K implements I, J" + "\n" +
- " {" + "\n" +
- " public int field;" + "\n" +
- " public void method(){}" + "\n" +
- " }" + "\n" +
- "}";
-
-}
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 3b267ed452..0000000000
--- 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 ""; //$NON-NLS-1$
-}
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 4d11699b01..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotationProcessor.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.io.IOException;
-import java.io.PrintWriter;
-import java.util.Collection;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotation;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Filer;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.Declaration;
-
-
-public class NestedHelloWorldAnnotationProcessor extends
- BaseProcessor {
-
- public NestedHelloWorldAnnotationProcessor(AnnotationProcessorEnvironment env)
- {
- super( env );
- }
-
- // Code is annotated with HelloWorldAnnotation, so it will cause another round of processing
- public String getCode() {
- return "package " + PACKAGENAME + ";" + "\n" +
- "@" + HelloWorldAnnotation.class.getName() + "\n" +
- "public class " + TYPENAME + "\n" +
- "{ }";
- }
-
- private final static String PACKAGENAME = "nested.hello.world.generatedclass.pkg"; //$NON-NLS-1$
- private final static String TYPENAME = "NestedHelloWorldAnnotationGeneratedClass"; //$NON-NLS-1$
-
- @SuppressWarnings("unused")
- public void process()
- {
- Filer f = _env.getFiler();
- AnnotationTypeDeclaration annoDecl = (AnnotationTypeDeclaration) _env.getTypeDeclaration(NestedHelloWorldAnnotation.class.getName());
- Collection<Declaration> annotatedDecls = _env.getDeclarationsAnnotatedWith(annoDecl);
- try {
- for (Declaration annotatedDecl : annotatedDecls) {
- String typeName = TYPENAME;
- PrintWriter writer = f.createSourceFile(
- PACKAGENAME + "." + typeName);
- writer.print(getCode());
- writer.close();
- }
- reportSuccess(this.getClass());
- }
- catch (NullPointerException npe) {
- reportError(this.getClass(), "Could not read annotation in order to generate text file");
- }
- catch (IOException ioe) {
- reportError(this.getClass(), "Could not generate text file due to IOException");
- }
- }
-}
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 5d32b9eacc..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/nestedhelloworld/NestedHelloWorldAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,44 +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.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-import org.eclipse.jdt.apt.core.util.AptPreferenceConstants;
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class NestedHelloWorldAnnotationProcessorFactory extends BaseFactory
-{
- public NestedHelloWorldAnnotationProcessorFactory() {
- super(NestedHelloWorldAnnotation.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env)
- {
- return new NestedHelloWorldAnnotationProcessor( env );
- }
-
- public Collection<String> supportedOptions() {
- return Collections.singletonList(AptPreferenceConstants.RTTG_ENABLED_OPTION);
- }
-
-}
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 80e807f96d..0000000000
--- 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 ""; //$NON-NLS-1$
-}
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 33cdb62a84..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotationProcessor.java
+++ /dev/null
@@ -1,20 +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;
-
-public class NoOpAnnotationProcessor implements AnnotationProcessor
-{
- public void process(){}
-}
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 ea5b98aa42..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/noop/NoOpAnnotationProcessorFactory.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:
- * mkaufman@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.annotations.noop;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class NoOpAnnotationProcessorFactory extends BaseFactory
-{
-
- public NoOpAnnotationProcessorFactory() {
- super(NoOpAnnotation.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env)
- {
- return new NoOpAnnotationProcessor();
- }
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/Pause.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/Pause.java
deleted file mode 100644
index 0d9406f39c..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/Pause.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.annotations.pause;
-
-/**
- * Processing this annotation causes a delay proportional to the
- * value specified.
- */
-public @interface Pause {
- int value() default 500;
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessor.java
deleted file mode 100644
index bab18368ea..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.annotations.pause;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.Declaration;
-
-/**
- * Used to test performance in the IDE. Processing @Pause
- * causes the processor to pause for a defined interval.
- */
-public class PauseAnnotationProcessor extends BaseProcessor {
-
- private final AnnotationTypeDeclaration _annotationDecl;
-
- public PauseAnnotationProcessor(
- Set<AnnotationTypeDeclaration> decls, AnnotationProcessorEnvironment env) {
- super(env);
- assert decls.size() == 1;
- _annotationDecl = decls.iterator().next();
- }
-
- /* (non-Javadoc)
- * @see com.sun.mirror.apt.AnnotationProcessor#process()
- */
- public void process() {
- String phase = _env.getOptions().get("phase");
- Collection<Declaration> annotatedDecls = _env.getDeclarationsAnnotatedWith(_annotationDecl);
- for (Declaration decl : annotatedDecls) {
- Pause a = decl.getAnnotation(Pause.class);
- int pause = a.value();
- System.out.println(phase + " pausing for " + pause + " to process " + decl.getSimpleName() + "...");
- // busy sleep
- long end = System.currentTimeMillis() + pause;
- while (System.currentTimeMillis() < end)
- for (int i = 0; i < 100000; ++i) {
- /* pausing */
- }
- System.out.println(phase + " finished pausing");
- }
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessorFactory.java
deleted file mode 100644
index 4d264f5895..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.annotations.pause;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class PauseAnnotationProcessorFactory extends BaseFactory {
-
- private final static String annotationName = "org.eclipse.jdt.apt.tests.annotations.pause.Pause";
- public PauseAnnotationProcessorFactory() {
- super(annotationName);
- }
-
- /* (non-Javadoc)
- * @see com.sun.mirror.apt.AnnotationProcessorFactory#getProcessorFor(java.util.Set, com.sun.mirror.apt.AnnotationProcessorEnvironment)
- */
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> decls,
- AnnotationProcessorEnvironment env) {
- return new PauseAnnotationProcessor(decls, env);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/AnnotationReader.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/AnnotationReader.java
deleted file mode 100644
index 06181b421c..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/AnnotationReader.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.readAnnotationType;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Collection;
-
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.Declaration;
-
-public class AnnotationReader {
- public void createClassFilesForAnnotatedDeclarations(
- Collection<Declaration> declarations,
- AnnotationProcessorEnvironment env) throws IOException {
- assert declarations.size() == 1;
- for (Declaration dec : declarations) {
-
- PrintWriter writer = null;
- try {
- SimpleAnnotation annotation = dec
- .getAnnotation(SimpleAnnotation.class);
- String value = annotation.value().name();
- //Class annotationType = annotation.annotationType();
- String className = value + "Gen";
- writer = env.getFiler().createSourceFile("test." + className);
- writer.println("package test;");
- writer.println("public class " + className);
- writer.println("{}");
- } finally {
- if (writer != null) {
- writer.close();
- }
- }
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/ReadAnnotationTypeProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/ReadAnnotationTypeProcessor.java
deleted file mode 100644
index 4ec2a3bad0..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/ReadAnnotationTypeProcessor.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.readAnnotationType;
-
-import java.io.PrintWriter;
-import java.util.Collection;
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.Declaration;
-
-public class ReadAnnotationTypeProcessor extends BaseProcessor {
-
- private AnnotationTypeDeclaration _annotationType;
-
- public ReadAnnotationTypeProcessor(Set<AnnotationTypeDeclaration> declarationTypes, AnnotationProcessorEnvironment env) {
- super(env);
- assert declarationTypes.size() == 1;
- _annotationType = declarationTypes.iterator().next();
- }
-
- public void process() {
- PrintWriter writer = null;
- try
- {
- Collection<Declaration> declarations = _env.getDeclarationsAnnotatedWith(_annotationType);
- assert declarations.size() == 1;
- new AnnotationReader().createClassFilesForAnnotatedDeclarations(declarations, _env);
- } catch (Throwable e)
- {
- e.printStackTrace();
- _env.getMessager().printError(e.getMessage());
- } finally
- {
- if (writer != null)
- {
- writer.close();
- }
- }
- }
-
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/ReadAnnotationTypeProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/ReadAnnotationTypeProcessorFactory.java
deleted file mode 100644
index 22ba7f58f0..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/ReadAnnotationTypeProcessorFactory.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.readAnnotationType;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class ReadAnnotationTypeProcessorFactory extends BaseFactory {
-
- public ReadAnnotationTypeProcessorFactory() {
- super(SimpleAnnotation.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> declarations, AnnotationProcessorEnvironment env) {
- return new ReadAnnotationTypeProcessor(declarations, env);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/SimpleAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/SimpleAnnotation.java
deleted file mode 100644
index 2685a266f4..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readAnnotationType/SimpleAnnotation.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.readAnnotationType;
-
-public @interface SimpleAnnotation {
-
- enum Name
- {
- HELLO, GOOD_BYE
- }
-
- public Name value();
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readannotation/CodeExample.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readannotation/CodeExample.java
deleted file mode 100644
index 8845013440..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readannotation/CodeExample.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.tests.annotations.readannotation;
-
-public class CodeExample {
-
- public static final String PACKAGE_QUESTION = "question";
-
- public static final String ANNOTATION_TEST_CLASS = "AnnotationTest";
- public static final String ANNOTATION_TEST_CODE =
- "package question;\n" +
- "\n" +
- "@Deprecated\n" +
- "@RTVisibleAnno(anno=@SimpleAnnotation(\"test\"), clazzes={})\n" +
- "@RTInvisibleAnno(\"question\")\n" +
- "public interface AnnotationTest{\n" +
- "\n" +
- " @RTVisibleAnno(name = \"Foundation\",\n" +
- " boolValue = false, \n" +
- " byteValue = 0x10, \n" +
- " charValue = 'c', \n" +
- " doubleValue = 99.0, \n" +
- " floatValue = (float)9.0, \n" +
- " intValue = 999, \n" +
- " longValue = 3333, \n" +
- " shortValue = 3, \n" +
- " colors ={ Color.RED, Color.BLUE }, \n" +
- " anno = @SimpleAnnotation(\"core\"),\n" +
- " simpleAnnos = {@SimpleAnnotation(\"org\"), \n" +
- " @SimpleAnnotation(\"eclipse\"),\n" +
- " @SimpleAnnotation(\"jdt\") }, \n" +
- " clazzes = {Object.class, String.class},\n " +
- " clazz = Object.class)\n " +
- " @RTInvisibleAnno(\"org.eclipse.jdt.core\")\n " +
- " @Deprecated \n " +
- " public int field0 = 0; \n" +
- "\n" +
- " @Deprecated \n" +
- " public int field1 = 1; \n" +
- "\n" +
- " @RTVisibleAnno(anno=@SimpleAnnotation(\"field\"), clazzes={})\n " +
- " @RTInvisibleAnno(\"2\") \n " +
- " public int field2 = 2; \n" +
- "\n" +
- " @RTInvisibleAnno(\"3\") \n" +
- " public int field3 = 3; \n" +
- "\n" +
- " @SimpleAnnotation(\"4\") \n" +
- " public int field4 = 4; \n" +
- "\n" +
- " @RTVisibleAnno(anno=@SimpleAnnotation(\"method0\"), clazzes={}) \n" +
- " @RTInvisibleAnno(\"0\") \n" +
- " @Deprecated \n " +
- " public int method0(); \n " +
- "\n" +
- " @Deprecated \n " +
- " public int method1(); \n " +
- "\n" +
- " @RTVisibleAnno(anno=@SimpleAnnotation(\"method2\"), clazzes={}) \n " +
- " @RTInvisibleAnno(\"2\") \n" +
- " public int method2(); \n" +
- "\n" +
- " @RTInvisibleAnno(\"3\") \n" +
- " public int method3(); \n" +
- "\n" +
- " @SimpleAnnotation(\"method4\") \n" +
- " public int method4(); \n" +
- "\n" +
- " public int method5(int p0, \n" +
- " @Deprecated \n" +
- " int p1, \n" +
- " @RTVisibleAnno(anno=@SimpleAnnotation(\"param2\"), clazzes={}) \n" +
- " @RTInvisibleAnno(\"2\") \n" +
- " int p2); \n" +
- "\n" +
- " public int method6(int p0, int p1, int p2); \n" +
- "\n }";
-
- public static final String COLOR_CLASS = "Color";
- public static final String COLOR_CODE =
- "package question;\n" +
- "\n" +
- "public enum Color { RED, WHITE, BLUE; } ";
-
- public static final String PACKAGE_INFO_CLASS = "package-info";
- public static final String PACKAGE_INFO_CODE =
- "@Deprecated package question; ";
-
- public static final String RTINVISIBLE_CLASS = "RTInvisibleAnno";
- public static final String RTINVISIBLE_ANNOTATION_CODE =
- "package question; \n" +
- "\n" +
- " public @interface RTInvisibleAnno{ \n" +
- " String value(); \n" +
- " }";
-
- public static final String RTVISIBLE_CLASS = "RTVisibleAnno";
- public static final String RTVISIBLE_ANNOTATION_CODE =
- "package question; \n" +
- "\n" +
- "import java.lang.annotation.*; \n" +
- "\n" +
- "@Retention(value=RetentionPolicy.RUNTIME) \n" +
- "public @interface RTVisibleAnno \n" +
- "{ \n" +
- " String name() default \"eclipse\"; \n" +
- " boolean boolValue() default true; \n" +
- " byte byteValue() default 0x0001; \n" +
- " char charValue() default 'e'; \n" +
- " double doubleValue() default 0.0; \n" +
- " float floatValue() default 0; \n" +
- " int intValue() default 17; \n" +
- " long longValue() default 43; \n" +
- " short shortValue() default 1; \n" +
- " Color[] colors() default {Color.RED, Color.WHITE, Color.BLUE}; \n" +
- " SimpleAnnotation anno(); \n" +
- " SimpleAnnotation[] simpleAnnos() default { @SimpleAnnotation(\"org.eclipse.org\") }; \n" +
- " Class<?>[] clazzes(); \n" +
- " Class<?> clazz() default java.lang.String.class; \n" +
- "\n }";
-
- public static final String SIMPLE_ANNOTATION_CLASS = "SimpleAnnotation";
- public static final String SIMPLE_ANNOTATION_CODE =
- "package question; \n" +
- "\n" +
- "import java.lang.annotation.Retention; \n" +
- "import java.lang.annotation.RetentionPolicy; \n" +
- "\n" +
- "@Retention(value=RetentionPolicy.RUNTIME) \n" +
- "public @interface SimpleAnnotation { \n" +
- "\n" +
- " String value(); \n" +
- "}";
-
- public static final String PACKAGE_TRIGGER = "trigger";
- public static final String TRIGGER_CLASS = "Trigger";
- public static final String TRIGGER_CODE =
- "package trigger; \n" +
- "\n" +
- "@MyMarkerAnnotation \n" +
- "public class Trigger {}";
-
- public static final String MYMARKERANNOTATION_CLASS = "MyMarkerAnnotation";
- public static final String MYMARKERANNOTATION_CODE =
- "package trigger; \n" +
- "\n" +
- "public @interface MyMarkerAnnotation {}";
-
- public static final String PACKAGE_NOTYPES = "notypes";
- public static final String PACKAGE_INFO_NOTYPES_CLASS = "package-info";
- public static final String PACKAGE_INFO_NOTYPES_CODE =
- "@question.SimpleAnnotation(\"foo\") package notypes;\n";
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readannotation/ReadAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readannotation/ReadAnnotationProcessor.java
deleted file mode 100644
index 96cca7398b..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readannotation/ReadAnnotationProcessor.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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.tests.annotations.readannotation;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import junit.framework.ComparisonFailure;
-import junit.framework.TestCase;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorUtil;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.FieldDeclaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.declaration.ParameterDeclaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-
-public class ReadAnnotationProcessor extends BaseProcessor
-{
- private static final String[] NO_ANNOTATIONS = new String[0];
-
- public ReadAnnotationProcessor(AnnotationProcessorEnvironment env)
- {
- super(env);
- }
-
- public void process()
- {
- ProcessorTestStatus.setProcessorRan();
- try{
- TypeDeclaration typeDecl = _env.getTypeDeclaration("question.AnnotationTest");
- TestCase.assertNotNull("failed to locate type 'question.AnnotationTest'", typeDecl);
- if( typeDecl != null){
- TestCase.assertEquals("Type name mismatch", "question.AnnotationTest", typeDecl.getQualifiedName());
-
- final String[] expectedPkgAnnos = new String[]{ "@Deprecated()" };
- assertAnnotation(expectedPkgAnnos, typeDecl.getPackage().getAnnotationMirrors() );
- assertAnnotation(expectedPkgAnnos, _env.getPackage("question").getAnnotationMirrors() );
-
- final String[] expectedNoTypeAnnos = new String[]{ "@SimpleAnnotation(value = foo)" };
- assertAnnotation(expectedNoTypeAnnos, _env.getPackage("notypes").getAnnotationMirrors());
-
- final String[] expectedTypeAnnos = new String[]{ "@Deprecated()",
- "@RTVisibleAnno(anno = @SimpleAnnotation(value = test), clazzes = {})",
- "@RTInvisibleAnno(value = question)" };
- assertAnnotation(expectedTypeAnnos, typeDecl.getAnnotationMirrors());
-
- final Collection<FieldDeclaration> fieldDecls = typeDecl.getFields();
-
- int counter = 0;
- TestCase.assertEquals(5, fieldDecls.size());
- for(FieldDeclaration fieldDecl : fieldDecls ){
- final String name = "field" + counter;
-
- TestCase.assertEquals("field name mismatch", name, fieldDecl.getSimpleName());
- final String[] expected;
- switch(counter){
- case 0:
- expected = new String[] { "@RTVisibleAnno(name = Foundation, boolValue = false, byteValue = 16, charValue = c, doubleValue = 99.0, floatValue = 9.0, intValue = 999, longValue = 3333, shortValue = 3, colors = {RED, BLUE}, anno = @SimpleAnnotation(value = core), simpleAnnos = {@SimpleAnnotation(value = org), @SimpleAnnotation(value = eclipse), @SimpleAnnotation(value = jdt)}, clazzes = {java.lang.Object, java.lang.String}, clazz = java.lang.Object)",
- "@RTInvisibleAnno(value = org.eclipse.jdt.core)",
- "@Deprecated()" };
- break;
- case 1:
- expected = new String[] { "@Deprecated()" };
- break;
- case 2:
- expected = new String[] { "@RTVisibleAnno(anno = @SimpleAnnotation(value = field), clazzes = {})",
- "@RTInvisibleAnno(value = 2)" };
- break;
- case 3:
- expected = new String[] { "@RTInvisibleAnno(value = 3)" };
- break;
- case 4:
- expected = new String[] { "@SimpleAnnotation(value = 4)" };
- break;
- default:
- expected = NO_ANNOTATIONS;
- }
-
- assertAnnotation(expected, fieldDecl.getAnnotationMirrors());
- counter ++;
- }
-
- final Collection<? extends MethodDeclaration> methodDecls = typeDecl.getMethods();
- counter = 0;
- TestCase.assertEquals(7, methodDecls.size());
- for(MethodDeclaration methodDecl : methodDecls ){
- final String name = "method" + counter;
-
- TestCase.assertEquals("method name mismatch", name, methodDecl.getSimpleName());
- final String[] expected;
- switch(counter)
- {
- case 0:
- expected = new String[] { "@RTVisibleAnno(anno = @SimpleAnnotation(value = method0), clazzes = {})",
- "@RTInvisibleAnno(value = 0)",
- "@Deprecated()" };
- break;
- case 1:
- expected = new String[] { "@Deprecated()" };
- break;
- case 2:
- expected = new String[] { "@RTVisibleAnno(anno = @SimpleAnnotation(value = method2), clazzes = {})",
- "@RTInvisibleAnno(value = 2)" };
- break;
- case 3:
- expected = new String[] { "@RTInvisibleAnno(value = 3)" };
- break;
- case 4:
- expected = new String[] { "@SimpleAnnotation(value = method4)" };
- break;
- case 5:
- case 6:
- default:
- expected = NO_ANNOTATIONS;
- }
-
- assertAnnotation(expected, methodDecl.getAnnotationMirrors());
-
- if( counter == 5 ){
- Collection<ParameterDeclaration> paramDecls = methodDecl.getParameters();
- int pCounter = 0;
- for( ParameterDeclaration paramDecl : paramDecls ){
- final String[] expectedParamAnnotations;
- switch( pCounter )
- {
- case 1:
- expectedParamAnnotations = new String[] { "@Deprecated()" };
- break;
- case 2:
- expectedParamAnnotations = new String[] { "@RTVisibleAnno(anno = @SimpleAnnotation(value = param2), clazzes = {})",
- "@RTInvisibleAnno(value = 2)" };
- break;
- default:
- expectedParamAnnotations = NO_ANNOTATIONS;
- }
- assertAnnotation(expectedParamAnnotations, paramDecl.getAnnotationMirrors());
- pCounter ++;
- }
-
- }
- counter ++;
- }
- }
- }
- catch( ComparisonFailure failure ){
- if (!ProcessorTestStatus.hasErrors()) {
- ProcessorTestStatus.failWithoutException(failure.toString());
- }
- throw failure;
- }
- catch( junit.framework.AssertionFailedError error ){
- if (!ProcessorTestStatus.hasErrors()) {
- ProcessorTestStatus.failWithoutException(error.toString());
- }
- throw error;
- }
- }
-
- private void assertAnnotation(final String[] expected, Collection<AnnotationMirror> annotations)
- {
- final int expectedLen = expected.length;
- TestCase.assertEquals("annotation number mismatch", expected.length, annotations.size()); //$NON-NLS-1$
-
- final HashSet<String> expectedSet = new HashSet<String>(expectedLen * 4 / 3 + 1);
- for( int i=0; i<expectedLen; i++ )
- expectedSet.add(expected[i]);
-
- int counter = 0;
- for( AnnotationMirror mirror : annotations ){
- String mirrorString = ProcessorUtil.annoMirrorToString(mirror);
- if( counter >= expectedLen )
- TestCase.assertEquals("", mirrorString); //$NON-NLS-1$
- else{
- final boolean contains = expectedSet.contains(mirrorString);
- if( !contains ){
- System.err.println("found unexpected: " + mirrorString);
- System.err.println("expected set: " + expectedSet);
- }
- TestCase.assertTrue("unexpected annotation " + mirrorString, contains); //$NON-NLS-1$
- expectedSet.remove(mirrorString);
- }
- counter ++;
- }
- }
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readannotation/ReadAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readannotation/ReadAnnotationProcessorFactory.java
deleted file mode 100644
index 1639d77ff6..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/readannotation/ReadAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,35 +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.tests.annotations.readannotation;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class ReadAnnotationProcessorFactory extends BaseFactory
-{
-
- public ReadAnnotationProcessorFactory() {
- super("trigger.MyMarkerAnnotation"); //$NON-NLS-1$
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env)
- {
- return new ReadAnnotationProcessor( env );
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/Annotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/Annotation.java
deleted file mode 100644
index f39027f154..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/Annotation.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.valueconversion;
-
-public @interface Annotation {
- boolean z();
- char c();
- byte b();
- short s();
- int i();
- long l();
- float f();
- double d();
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/AnnotationWithArray.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/AnnotationWithArray.java
deleted file mode 100644
index 21031807b0..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/AnnotationWithArray.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.valueconversion;
-
-public @interface AnnotationWithArray {
- boolean[] booleans();
- byte[] bytes();
- short[] shorts();
- int[] ints();
- long[] longs();
- float[] floats();
- double[] doubles();
- char[] chars();
- String str() default "some string";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/RefAnnotation.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/RefAnnotation.java
deleted file mode 100644
index 0f8da54694..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/RefAnnotation.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.valueconversion;
-
-public @interface RefAnnotation {
- boolean z();
- char c();
- byte b();
- short s();
- int i();
- long l();
- float f();
- double d();
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/RefAnnotationWithArray.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/RefAnnotationWithArray.java
deleted file mode 100644
index c13c9e13f6..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/RefAnnotationWithArray.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.annotations.valueconversion;
-
-public @interface RefAnnotationWithArray {
- boolean[] booleans();
- byte[] bytes();
- short[] shorts();
- int[] ints();
- long[] longs();
- float[] floats();
- double[] doubles();
- char[] chars();
- String str() default "string";
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/ValueConversionProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/ValueConversionProcessor.java
deleted file mode 100644
index 88f6654069..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/ValueConversionProcessor.java
+++ /dev/null
@@ -1,463 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.tests.annotations.valueconversion;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
-import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Messager;
-import com.sun.mirror.declaration.AnnotationMirror;
-import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
-import com.sun.mirror.declaration.AnnotationValue;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.type.AnnotationType;
-
-public class ValueConversionProcessor extends BaseProcessor {
-
- public static final Byte BYTE_49 = 49;
- public static final Byte BYTE_50 = 50;
- public static final Character CHAR_ONE = '1';
- public static final Character CHAR_TWO = '2';
- public static final Double DOUBLE_49 = 49d;
- public static final Double DOUBLE_50 = 50d;
- public static final Float FLOAT_49 = 49f;
- public static final Float FLOAT_50 = 50f;
- public static final Integer INTEGER_49 = 49;
- public static final Integer INTEGER_50 = 50;
- public static final Long LONG_49 = 49l;
- public static final Long LONG_50 = 50l;
- public static final Short SHORT_49 = 49;
- public static final Short SHORT_50 = 50;
-
- public ValueConversionProcessor(AnnotationProcessorEnvironment env)
- {
- super(env);
- }
-
- public void process()
- {
- ProcessorTestStatus.setProcessorRan();
- final TypeDeclaration test = _env.getTypeDeclaration("sample.Test");
- if( test == null )
- TestCase.assertNotNull("failed to locate type 'sample.Test'", test);
-
- testCompilerAPIPath(test);
- testReflectionPath(test);
- }
-
- private void testCompilerAPIPath(TypeDeclaration test){
- final Collection<AnnotationMirror> annotations = test.getAnnotationMirrors();
- final int numAnnotations = annotations == null ? 0 : annotations.size();
- TestCase.assertEquals("annotation number mismatch", 1, numAnnotations);
-
- final AnnotationMirror annotation = annotations.iterator().next();
- final AnnotationType annotationType = annotation.getAnnotationType();
- final String annoTypeName = annotationType.getDeclaration().getQualifiedName();
- if( !Annotation.class.getName().equals( annoTypeName ) &&
- !AnnotationWithArray.class.getName().equals( annoTypeName ))
- return;
-
- final Map<AnnotationTypeElementDeclaration, AnnotationValue> elementValues =
- annotation.getElementValues();
-
- for( Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> entry :
- elementValues.entrySet() ){
- AnnotationTypeElementDeclaration elementDecl = entry.getKey();
- final String name = elementDecl.getSimpleName();
- final AnnotationValue value = entry.getValue();
- compare(name, value.getValue());
- }
- }
-
- private void testReflectionPath(TypeDeclaration test){
- final RefAnnotation refAnno = test.getAnnotation(RefAnnotation.class);
- if( refAnno != null ){
- assertValueMatch("z", refAnno.z(), true);
- assertValueMatch("b", refAnno.b(), (byte)49);
- assertValueMatch("c", refAnno.c(), '1');
- assertValueMatch("d", refAnno.d(), 49);
- assertValueMatch("f", refAnno.f(), 49);
- assertValueMatch("i", refAnno.i(), 49);
- assertValueMatch("l", refAnno.l(), 49);
- assertValueMatch("s", refAnno.s(), (short)49);
- }
- final RefAnnotationWithArray refAnnoArray = test.getAnnotation(RefAnnotationWithArray.class);
- if( refAnnoArray != null ){
- assertArrayValueMatch("booleans", refAnnoArray.booleans(), new boolean[]{true, true});
- assertArrayValueMatch("bytes", refAnnoArray.bytes(), new byte[]{49, 50} );
- assertArrayValueMatch("chars", refAnnoArray.chars(), new char[]{'1', '2'});
- assertArrayValueMatch("doubles", refAnnoArray.doubles(), new double[]{49d, 50d});
- assertArrayValueMatch("floats", refAnnoArray.floats(), new float[]{49f, 50f});
- assertArrayValueMatch("ints", refAnnoArray.ints(), new int[]{49, 50});
- assertArrayValueMatch("longs", refAnnoArray.longs(), new long[]{49l, 50l});
- assertArrayValueMatch("shorts", refAnnoArray.shorts(), new short[]{49, 50});
- compare("str", refAnnoArray.str());
- }
- }
-
- private void compare(final String name, final Object actualValue){
- if( name.length() == 1 )
- {
- final Class<?> expectedType;
- final Object expectedValue;
- switch(name.charAt(0))
- {
- case 'z':
- expectedType = Boolean.class;
- expectedValue = Boolean.TRUE;
- break;
- case 'b':
- expectedType = Byte.class;
- expectedValue = BYTE_49;
- break;
- case 'c':
- expectedType = Character.class;
- expectedValue = CHAR_ONE;
- break;
- case 's':
- expectedType = Short.class;
- expectedValue = SHORT_49;
- break;
- case 'i':
- expectedType = Integer.class;
- expectedValue = INTEGER_49;
- break;
- case 'l':
- expectedType = Long.class;
- expectedValue = LONG_49;
- break;
- case 'f':
- expectedType = Float.class;
- expectedValue = FLOAT_49;
- break;
- case 'd':
- expectedType = Double.class;
- expectedValue = DOUBLE_49;
- break;
- default:
- TestCase.assertNotNull("unexpected member " + name, null);
- throw new IllegalStateException(); // won't get here.
- }
- assertValueTypeMatch(name, actualValue, expectedType, expectedValue);
- }
- else{
- final Class<?> expectedElementType;
- final Object[] expectedElementValues;
- if( "booleans".equals(name) ){
- expectedElementType = Boolean.class;
- expectedElementValues = new Object[]{Boolean.TRUE, Boolean.TRUE};
- }
- else if( "chars".equals(name) ){
- expectedElementType = Character.class;
- expectedElementValues = new Object[]{CHAR_ONE, CHAR_TWO};
- }
- else if( "bytes".equals(name) ){
- expectedElementType = Byte.class;
- expectedElementValues = new Object[]{BYTE_49, BYTE_50};
- }
- else if( "shorts".equals(name) ){
- expectedElementType = Short.class;
- expectedElementValues = new Object[]{SHORT_49, SHORT_50};
- }
- else if( "ints".equals(name) ){
- expectedElementType = Integer.class;
- expectedElementValues = new Object[]{INTEGER_49, INTEGER_50};
- }
- else if( "longs".equals(name) ){
- expectedElementType = Long.class;
- expectedElementValues = new Object[]{LONG_49, LONG_50};
- }
- else if( "floats".equals(name) ){
- expectedElementType = Float.class;
- expectedElementValues = new Object[]{FLOAT_49, FLOAT_50};
-
- }
- else if( "doubles".equals(name) ){
- expectedElementType = Double.class;
- expectedElementValues = new Object[]{DOUBLE_49, DOUBLE_50};
- }
- else if( "str".equals(name) ){
- assertValueTypeMatch(name, actualValue, String.class, "string");
- return;
- }
- else{
- TestCase.assertNotNull("unexpected member " + name, null);
- throw new IllegalStateException(); // won't get here.
- }
- @SuppressWarnings("unchecked")
- List<AnnotationValue> actualList = (List<AnnotationValue>)actualValue;
- assertArrayValueTypeMatch(name, actualList, expectedElementType, expectedElementValues);
- }
- }
-
- private void assertValueTypeMatch(
- final String name,
- final Object actualValue,
- final Class<?> expectedType,
- final Object expectedValue)
- {
- if( actualValue != null && expectedType != actualValue.getClass() ){
- final Messager msgr = _env.getMessager();
- msgr.printError("type mismatch for member " + name +
- " expected " + expectedType.getName() + " but got " + actualValue.getClass().getName());
- }
- else if( !expectedValue.equals(actualValue) ){
- final Messager msgr = _env.getMessager();
- msgr.printError("value mismatch for member " + name +
- " expected " + expectedValue + " but got " + actualValue);
- }
- }
-
- private void assertArrayValueTypeMatch(
- final String name,
- final List<AnnotationValue> actualValues,
- final Class<?> expectedElementType,
- final Object[] expectedValues)
- {
- int i=0;
- for( AnnotationValue av : actualValues ){
- assertValueTypeMatch(name, av.getValue(), expectedElementType, expectedValues[i] );
- i++;
- }
- }
-
- private void assertValueMatch(
- final String name,
- final boolean actual,
- final boolean expected){
-
- if( actual != expected ){
- final Messager msgr = _env.getMessager();
- msgr.printError("value mismatch for member " + name +
- " expected " + expected + " but got " + actual);
- }
- }
-
- private void assertValueMatch(
- final String name,
- final byte actual,
- final byte expected){
-
- if( actual != expected ){
- final Messager msgr = _env.getMessager();
- msgr.printError("value mismatch for member " + name +
- " expected " + expected + " but got " + actual);
- }
- }
-
- private void assertValueMatch(
- final String name,
- final char actual,
- final char expected){
-
- if( actual != expected ){
- final Messager msgr = _env.getMessager();
- msgr.printError("value mismatch for member " + name +
- " expected " + expected + " but got " + actual);
- }
- }
-
- private void assertValueMatch(
- final String name,
- final double actual,
- final double expected){
-
- if( actual != expected ){
- final Messager msgr = _env.getMessager();
- msgr.printError("value mismatch for member " + name +
- " expected " + expected + " but got " + actual);
- }
- }
-
- private void assertValueMatch(
- final String name,
- final float actual,
- final float expected){
-
- if( actual != expected ){
- final Messager msgr = _env.getMessager();
- msgr.printError("value mismatch for member " + name +
- " expected " + expected + " but got " + actual);
- }
- }
-
- private void assertValueMatch(
- final String name,
- final int actual,
- final int expected){
-
- if( actual != expected ){
- final Messager msgr = _env.getMessager();
- msgr.printError("value mismatch for member " + name +
- " expected " + expected + " but got " + actual);
- }
- }
-
- private void assertValueMatch(
- final String name,
- final long actual,
- final long expected){
-
- if( actual != expected ){
- final Messager msgr = _env.getMessager();
- msgr.printError("value mismatch for member " + name +
- " expected " + expected + " but got " + actual);
- }
- }
-
- private void assertValueMatch(
- final String name,
- final short actual,
- final short expected){
-
- if( actual != expected ){
- final Messager msgr = _env.getMessager();
- msgr.printError("value mismatch for member " + name +
- " expected " + expected + " but got " + actual);
- }
- }
-
-
- private void assertArrayValueMatch(
- final String name,
- final boolean[] actual,
- final boolean[] expected){
-
- int i=0;
- final Messager msgr = _env.getMessager();
- for( boolean a : actual ){
- if( a != expected[i] ){
- msgr.printError("value mismatch for member " + name +
- " expected " + expected[i] + " but got " + a);
- }
- i++;
- }
- }
-
- private void assertArrayValueMatch(
- final String name,
- final byte[] actual,
- final byte[] expected){
-
- int i=0;
- final Messager msgr = _env.getMessager();
- for( byte a : actual ){
- if( a != expected[i] ){
- msgr.printError("value mismatch for member " + name +
- " expected " + expected[i] + " but got " + a);
- }
- i++;
- }
- }
-
- private void assertArrayValueMatch(
- final String name,
- final char[] actual,
- final char[] expected){
-
- int i=0;
- final Messager msgr = _env.getMessager();
- for( char a : actual ){
- if( a != expected[i] ){
- msgr.printError("value mismatch for member " + name +
- " expected " + expected[i] + " but got " + a);
- }
- i++;
- }
- }
-
- private void assertArrayValueMatch(
- final String name,
- final double[] actual,
- final double[] expected){
-
- int i=0;
- final Messager msgr = _env.getMessager();
- for( double a : actual ){
- if( a != expected[i] ){
- msgr.printError("value mismatch for member " + name +
- " expected " + expected[i] + " but got " + a);
- }
- i++;
- }
- }
-
- private void assertArrayValueMatch(
- final String name,
- final float[] actual,
- final float[] expected){
-
- int i=0;
- final Messager msgr = _env.getMessager();
- for( float a : actual ){
- if( a != expected[i] ){
- msgr.printError("value mismatch for member " + name +
- " expected " + expected[i] + " but got " + a);
- }
- i++;
- }
- }
-
- private void assertArrayValueMatch(
- final String name,
- final int[] actual,
- final int[] expected){
-
- int i=0;
- final Messager msgr = _env.getMessager();
- for( int a : actual ){
- if( a != expected[i] ){
- msgr.printError("value mismatch for member " + name +
- " expected " + expected[i] + " but got " + a);
- }
- i++;
- }
- }
-
- private void assertArrayValueMatch(
- final String name,
- final long[] actual,
- final long[] expected){
-
- int i=0;
- final Messager msgr = _env.getMessager();
- for( long a : actual ){
- if( a != expected[i] ){
- msgr.printError("value mismatch for member " + name +
- " expected " + expected[i] + " but got " + a);
- }
- i++;
- }
- }
-
- private void assertArrayValueMatch(
- final String name,
- final short[] actual,
- final short[] expected){
-
- int i=0;
- final Messager msgr = _env.getMessager();
- for( short a : actual ){
- if( a != expected[i] ){
- msgr.printError("value mismatch for member " + name +
- " expected " + expected[i] + " but got " + a);
- }
- i++;
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/ValueConversionProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/ValueConversionProcessorFactory.java
deleted file mode 100644
index 3ca6ae21ec..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/valueconversion/ValueConversionProcessorFactory.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.tests.annotations.valueconversion;
-
-import java.util.Set;
-
-import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class ValueConversionProcessorFactory extends BaseFactory {
-
- public ValueConversionProcessorFactory() {
- super(Annotation.class.getName(),
- RefAnnotation.class.getName(),
- AnnotationWithArray.class.getName(),
- RefAnnotationWithArray.class.getName());
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env)
- {
- return new ValueConversionProcessor( env );
- }
-}
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 3bb339e551..0000000000
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/jdtcoretests/AllJdtCoreTests.java
+++ /dev/null
@@ -1,47 +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;
-
-
-public class AllJdtCoreTests extends org.eclipse.jdt.core.tests.RunJDTCoreTests {
-
- public AllJdtCoreTests(String testName) { super(testName); }
- }
-
-/*
- * NOTE - sometimes, we have observed failures that were resolved by changing
- * the order in which the jdt-core tests are run. If you ever get weird errors
- * in the jdt-core tests, then you may want to experiment with changing this class
- * to be something like the following.
- *
- *
-public class AllJdtCoreTests extends TestCase {
-
- public AllJdtCoreTests(String testName)
- {
- super(testName);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(RunJDTCoreTests.class.getName());
- suite.addTest(RunModelTests.suite());
- suite.addTest(RunBuilderTests.suite());
- suite.addTest(RunCompilerTests.suite());
- suite.addTest(RunDOMTests.suite());
- suite.addTest(RunFormatterTests.suite());
-
- return suite;
- }
-}
- */
-
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 07847e8aac..0000000000
--- 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.apt.tests/srcext/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory b/org.eclipse.jdt.apt.tests/srcext/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
deleted file mode 100644
index 1a676f0353..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
+++ /dev/null
@@ -1,4 +0,0 @@
-org.eclipse.jdt.apt.tests.external.annotations.loadertest.LoaderTestAnnotationProcessorFactory
-org.eclipse.jdt.apt.tests.external.annotations.classloader.ColorAnnotationProcessorFactory
-org.eclipse.jdt.apt.tests.external.annotations.batch.BatchAnnotationFactory
-org.eclipse.jdt.apt.tests.external.annotations.batch.BatchGenAnnotationFactory \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/Batch.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/Batch.java
deleted file mode 100644
index 92bc9e18a5..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/Batch.java
+++ /dev/null
@@ -1,15 +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.tests.external.annotations.batch;
-
-public @interface Batch {
-
-}
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchAnnotationFactory.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchAnnotationFactory.java
deleted file mode 100644
index 524ecdc434..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchAnnotationFactory.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 and implementation
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.external.annotations.batch;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-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 BatchAnnotationFactory implements AnnotationProcessorFactory{
-
- private static final List<String> SUPPORTED_TYPES =
- Collections.singletonList(Batch.class.getName());
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> decls,
- AnnotationProcessorEnvironment env) {
- return new BatchProcessor(env);
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return SUPPORTED_TYPES;
- }
- public Collection<String> supportedOptions() {
- return Collections.emptyList();
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchGen.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchGen.java
deleted file mode 100644
index 6dc81a4196..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchGen.java
+++ /dev/null
@@ -1,15 +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.tests.external.annotations.batch;
-
-public @interface BatchGen {
-
-}
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchGenAnnotationFactory.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchGenAnnotationFactory.java
deleted file mode 100644
index 70bc7355e6..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchGenAnnotationFactory.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:
- * tyeung@bea.com - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.external.annotations.batch;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-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 BatchGenAnnotationFactory implements AnnotationProcessorFactory {
-
- private static int ROUND = 0;
- private static final List<String> SUPPORTED_TYPES =
- Collections.singletonList(BatchGen.class.getName());
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> decls,
- AnnotationProcessorEnvironment env) {
- if( ROUND == 0 ){
- ROUND ++;
- return new BatchGen0AnnotationProcessor(env);
- }
- else if( ROUND == 1){
- ROUND ++;
- if( !decls.isEmpty() )
- env.getMessager().printError("Expecting empty set but got " + decls );
-
- return new BatchGen1AnnotationProcessor(env);
- }
- else if( ROUND == 2 ){ // NO-OP
- env.getMessager().printError("Called the third time.");
- return null;
- }
- // This is to make sure we aren't bouncing the class loader without a full build.
- else
- env.getMessager().printError("Calling BatchGenAnnotionFactory too many times. Round=" + ROUND );
- return null;
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return SUPPORTED_TYPES;
- }
- public Collection<String> supportedOptions() {
- return Collections.emptyList();
- }
-
- static class BatchGen0AnnotationProcessor implements AnnotationProcessor {
-
- final AnnotationProcessorEnvironment _env;
- BatchGen0AnnotationProcessor(AnnotationProcessorEnvironment env){
- _env = env;
- }
- public void process() {
- // a generated file will cause BatchGenAnnotationFactory to be
- // called again.
- try{
- final PrintWriter writer = _env.getFiler().createSourceFile("gen.Class0");
- writer.print("package gen;\n");
- writer.print("public class Class0{}");
- writer.close();
- }
- catch(IOException e){
- _env.getMessager().printError(e.getMessage());
- }
- }
- }
-
- static class BatchGen1AnnotationProcessor implements AnnotationProcessor {
- final AnnotationProcessorEnvironment _env;
- BatchGen1AnnotationProcessor(AnnotationProcessorEnvironment env){
- _env = env;
- }
- public void process(){
- try{
- final PrintWriter writer = _env.getFiler().createSourceFile("gen.Class1");
- writer.print("package gen;\n");
- writer.print("public class Class1{}");
- writer.close();
- }
- catch(IOException e){
- _env.getMessager().printError(e.getMessage());
- }
- }
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchProcessor.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchProcessor.java
deleted file mode 100644
index 1bb3ec554b..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/batch/BatchProcessor.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.tests.external.annotations.batch;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.Messager;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-
-public class BatchProcessor implements AnnotationProcessor {
-
- // Store how often we've been called in order to
- // test classloader resetting
- private static int TIMES_CALLED = 0;
-
- private final AnnotationProcessorEnvironment _env;
- BatchProcessor(AnnotationProcessorEnvironment env){
- _env = env;
- }
- public void process() {
-
- final Messager msger = _env.getMessager();
- if( TIMES_CALLED == 0 ){
-
- final Collection<String> expectedList = new HashSet<String>();
- expectedList.add("p1.A");
- expectedList.add("p1.B");
- expectedList.add("p1.C");
- expectedList.add("p1.D");
- final Collection<TypeDeclaration> allTypes = _env.getSpecifiedTypeDeclarations();
- for( TypeDeclaration type : allTypes ){
- expectedList.remove(type.getQualifiedName());
- }
-
- if( !expectedList.isEmpty() ){
- msger.printError("failed to find type " + expectedList);
- }
-
- final Collection<String> expectedAnnotated = new HashSet<String>();
- expectedList.add("p1.A");
- expectedList.add("p1.C");
- final AnnotationTypeDeclaration batchAnnoDecl =
- (AnnotationTypeDeclaration)_env.getTypeDeclaration(Batch.class.getName());
- final Collection<Declaration> decls = _env.getDeclarationsAnnotatedWith(batchAnnoDecl);
- for( Declaration decl : decls ){
- if( decl instanceof TypeDeclaration )
- expectedAnnotated.remove( ((TypeDeclaration)decl).getQualifiedName() );
- }
- if( !expectedAnnotated.isEmpty() ){
- msger.printError("failed to find annotated type " + expectedAnnotated );
- }
-
- msger.printWarning("CompletedSuccessfully");
- }
- else{
- msger.printWarning("Called " + (TIMES_CALLED + 1) + " times.");
- }
-
- TIMES_CALLED++;
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/Color.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/Color.java
deleted file mode 100644
index b91b3ec25c..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/Color.java
+++ /dev/null
@@ -1,16 +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.external.annotations.classloader;
-
-public enum Color {
- RED, GREEN, BLUE;
-}
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorAnnotation.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorAnnotation.java
deleted file mode 100644
index 1f0962611d..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorAnnotation.java
+++ /dev/null
@@ -1,17 +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.external.annotations.classloader;
-
-
-public @interface ColorAnnotation {
- Color color();
-}
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorAnnotationProcessor.java
deleted file mode 100644
index 9201ec1e98..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorAnnotationProcessor.java
+++ /dev/null
@@ -1,62 +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.external.annotations.classloader;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.TypeDeclaration;
-
-public class ColorAnnotationProcessor implements AnnotationProcessor {
-
- public static final String PROP_KEY = "ColorAnnotationProcessor";
- public static final String SUCCESS_VALUE = "success";
-
- private final AnnotationProcessorEnvironment _env;
-
- public ColorAnnotationProcessor(AnnotationProcessorEnvironment env) {
- _env = env;
- }
-
- public void process() {
- System.setProperty(PROP_KEY, "Beginning processing");
- try {
- TypeDeclaration typeDecl = _env.getTypeDeclaration("colortestpackage.ColorTest");
-
- ColorAnnotation colorAnno = typeDecl.getAnnotation(ColorAnnotation.class);
-
- Color color = colorAnno.color();
-
- if (color != Color.RED)
- throw new IllegalStateException("Expecting red, but got: " + color);
-
- ColorWrapper colorWrapper = typeDecl.getAnnotation(ColorWrapper.class);
- ColorAnnotation[] colorAnnoArray = colorWrapper.colors();
-
- if (colorAnnoArray[0].color() != Color.GREEN)
- throw new IllegalStateException("Expecting green, but got: " + color);
-
- if (colorAnnoArray[1].color() != Color.BLUE)
- throw new IllegalStateException("Expecting blue, but got: " + color);
- }
- catch (Throwable t) {
- t.printStackTrace();
- System.setProperty(PROP_KEY, "Failed");
- }
- System.setProperty(PROP_KEY, SUCCESS_VALUE);
-
- }
-
- public static boolean wasSuccessful() {
- return SUCCESS_VALUE.equals(System.getProperty(PROP_KEY));
- }
-
-}
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorAnnotationProcessorFactory.java
deleted file mode 100644
index b186274079..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorAnnotationProcessorFactory.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:
- * jgarms@bea.com - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.external.annotations.classloader;
-
-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 ColorAnnotationProcessorFactory implements AnnotationProcessorFactory {
-
- public Collection<String> supportedOptions() {
- return Collections.emptyList();
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return Collections.singleton("org.eclipse.jdt.apt.tests.external.annotations.classloader.ColorAnnotation");
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> decls, AnnotationProcessorEnvironment env) {
- return new ColorAnnotationProcessor(env);
- }
-
-
-}
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorTestCodeExample.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorTestCodeExample.java
deleted file mode 100644
index 2ecf456950..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorTestCodeExample.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:
- * jgarms@bea.com - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.jdt.apt.tests.external.annotations.classloader;
-
-public class ColorTestCodeExample {
-
- public static final String CODE_PACKAGE = "colortestpackage";
- public static final String CODE_CLASS_NAME = "ColorTest";
- public static final String CODE_FULL_NAME = CODE_PACKAGE + "." + CODE_CLASS_NAME;
-
- public static final String CODE =
- "package colortestpackage;\r\n" +
- "\r\n" +
- "import org.eclipse.jdt.apt.tests.external.annotations.classloader.Color;\r\n" +
- "import org.eclipse.jdt.apt.tests.external.annotations.classloader.ColorAnnotation;\r\n" +
- "import org.eclipse.jdt.apt.tests.external.annotations.classloader.ColorWrapper;\r\n" +
- "\r\n" +
- "@ColorAnnotation(color = Color.RED)\r\n" +
- "@ColorWrapper(colors = {@ColorAnnotation(color = Color.GREEN), @ColorAnnotation(color = Color.BLUE)})\r\n" +
- "public class ColorTest {\r\n" +
- "\r\n" +
- "}";
-}
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorWrapper.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorWrapper.java
deleted file mode 100644
index 0116becf97..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/classloader/ColorWrapper.java
+++ /dev/null
@@ -1,16 +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.external.annotations.classloader;
-
-public @interface ColorWrapper {
- ColorAnnotation[] colors();
-}
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestAnnotation.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestAnnotation.java
deleted file mode 100644
index 83aa06cc34..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestAnnotation.java
+++ /dev/null
@@ -1,19 +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 - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.external.annotations.loadertest;
-
-/**
- * Used to test whether this annotation processor is successfully loaded.
- */
-public @interface LoaderTestAnnotation {
- String value() default ""; //$NON-NLS-1$
-}
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestAnnotationProcessor.java
deleted file mode 100644
index a09bb12190..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestAnnotationProcessor.java
+++ /dev/null
@@ -1,94 +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 - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.external.annotations.loadertest;
-
-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;
-
-/**
- * Used to test loading an annotation processor from a jar file.
- */
-public class LoaderTestAnnotationProcessor implements AnnotationProcessor {
-
- private static String getClassName() {
- return getPackageName() + "." + getTypeName(); //$NON-NLS-1$
- }
-
- private final AnnotationProcessorEnvironment _env;
-
- /**
- * Has an instance of this class been constructed in this VM?
- * This is implemented in such a way that the answer does not
- * depend on sharing a classloader.
- */
- public static boolean isLoaded() {
- return "loaded".equals(System.getProperty(getClassName())); //$NON-NLS-1$
- }
-
- /**
- * Clear the "isLoaded" setting. After this, isLoaded() will
- * return false until the next time an instance is constructed.
- */
- public static void clearLoaded() {
- System.clearProperty(getClassName());
- }
-
- public LoaderTestAnnotationProcessor(AnnotationProcessorEnvironment env) {
- System.setProperty(getClassName(), "loaded"); //$NON-NLS-1$
- _env = env;
- }
-
- public void process() {
- try
- {
- Filer f = getEnvironment().getFiler();
- PrintWriter pw = f
- .createSourceFile( getClassName() );
- pw.print( getCode() );
- pw.close();
- }
- catch( IOException ioe )
- {
- ioe.printStackTrace();
- }
- }
-
- public AnnotationProcessorEnvironment getEnvironment()
- {
- return _env;
- }
-
- protected static String getCode() {
- return CODE;
- }
-
- protected static String getPackageName() {
- return "generatedfilepackage"; //$NON-NLS-1$
- }
-
- protected static String getTypeName() {
- return "LoadFactoryFromJarTest"; //$NON-NLS-1$
- }
-
- protected final static String CODE =
- "package " + getPackageName() + ";\n" +
- "public class " + getTypeName() + "\n" +
- "{\n" +
- " public static void helloWorld() {\n" +
- " System.out.println( \"Hello, world! I am a generated file!\" ); \n" +
- " }\n" +
- "}\n";
-}
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestAnnotationProcessorFactory.java
deleted file mode 100644
index d117276a29..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestAnnotationProcessorFactory.java
+++ /dev/null
@@ -1,50 +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 - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.external.annotations.loadertest;
-
-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;
-
-/**
- * Used to test loading an annotation processor from a jar file.
- */
-public class LoaderTestAnnotationProcessorFactory implements
- AnnotationProcessorFactory {
-
- private static ArrayList<String> annotations = new ArrayList<String>();
-
- {
- annotations.add( LoaderTestAnnotation.class.getName() );
- }
-
- public Collection<String> supportedOptions() {
- return Collections.emptyList();
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return annotations;
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env) {
- return new LoaderTestAnnotationProcessor( env );
- }
-}
diff --git a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestCodeExample.java b/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestCodeExample.java
deleted file mode 100644
index 9b8a842cca..0000000000
--- a/org.eclipse.jdt.apt.tests/srcext/org/eclipse/jdt/apt/tests/external/annotations/loadertest/LoaderTestCodeExample.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:
- * wharley - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.tests.external.annotations.loadertest;
-
-/**
- * Code example used to test the annotation processor factory loader.
- */
-public class LoaderTestCodeExample {
- public static final String CODE_PACKAGE = "loadertestpackage";
- public static final String CODE_CLASS_NAME = "LoaderTestClass";
- public static final String CODE_FULL_NAME = CODE_PACKAGE + "." + CODE_CLASS_NAME;
-
- public static final String CODE =
- "package loadertestpackage;\n" +
- "import org.eclipse.jdt.apt.tests.external.annotations.loadertest.LoaderTestAnnotation;" + "\n" +
- "@LoaderTestAnnotation" + "\n" +
- "public class LoaderTestClass {" + "\n" +
- " public static void SayHello() {" + "\n" +
- " System.out.println(\"hello\");" + "\n" +
- " }" + "\n" +
- "}";
-}
diff --git a/org.eclipse.jdt.apt.tests/test.xml b/org.eclipse.jdt.apt.tests/test.xml
deleted file mode 100644
index f2b7258971..0000000000
--- a/org.eclipse.jdt.apt.tests/test.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0"?>
-
-<project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <property name="eclipse-home" value="${basedir}\..\.."/>
-
- <!-- sets the properties eclipse-home, and library-file -->
- <property name="plugin-name" value="org.eclipse.jdt.apt.tests"/>
- <property name="library-file"
- value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/>
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- <delete>
- <fileset dir="${eclipse-home}" includes="org*.xml"/>
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
-
- <property name="apt-folder" value="${eclipse-home}/apt_folder"/>
- <delete dir="${apt-folder}" quiet="true"/>
-
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${apt-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname" value="org.eclipse.jdt.apt.tests.TestAll"/>
- </ant>
-
- </target>
-
- <!-- This target holds code to cleanup the testing environment after -->
- <!-- after all of the tests have been run. You can use this target to -->
- <!-- delete temporary files that have been created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen -->
- <!-- after all the tests have been run should go here. -->
- <target name="run" depends="init,suite,cleanup">
- <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
- <property name="includes" value="org*.xml"/>
- <property name="output-file" value="${plugin-name}.xml"/>
- </ant>
- </target>
-
- <!-- This target runs the performance test suites. -->
- <target name="performance">
- </target>
-
-</project>
diff --git a/org.eclipse.jdt.apt.ui/.classpath b/org.eclipse.jdt.apt.ui/.classpath
deleted file mode 100644
index 304e86186a..0000000000
--- a/org.eclipse.jdt.apt.ui/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jdt.apt.ui/.cvsignore b/org.eclipse.jdt.apt.ui/.cvsignore
deleted file mode 100644
index ba077a4031..0000000000
--- a/org.eclipse.jdt.apt.ui/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/org.eclipse.jdt.apt.ui/.project b/org.eclipse.jdt.apt.ui/.project
deleted file mode 100644
index ce8878df09..0000000000
--- a/org.eclipse.jdt.apt.ui/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.apt.ui</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.ui/.settings/org.eclipse.core.resources.prefs b/org.eclipse.jdt.apt.ui/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index c1226369fa..0000000000
--- a/org.eclipse.jdt.apt.ui/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,5 +0,0 @@
-#Mon Mar 20 23:59:29 PST 2006
-eclipse.preferences.version=1
-encoding//src/org/eclipse/jdt/apt/ui/internal/messages.properties=8859_1
-encoding//src/org/eclipse/jdt/apt/ui/internal/preferences/messages.properties=8859_1
-encoding//src/org/eclipse/jdt/apt/ui/internal/util/messages.properties=8859_1
diff --git a/org.eclipse.jdt.apt.ui/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jdt.apt.ui/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 0146e7d230..0000000000
--- a/org.eclipse.jdt.apt.ui/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,69 +0,0 @@
-#Mon Mar 20 23:34:15 PST 2006
-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.doc.comment.support=enabled
-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.discouragedReference=ignore
-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.forbiddenReference=error
-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.invalidJavadoc=warning
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected
-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.missingJavadocComments=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected
-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=warning
-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.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-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=warning
-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.ui/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.jdt.apt.ui/.settings/org.eclipse.jdt.ui.prefs
deleted file mode 100644
index 328c856e72..0000000000
--- a/org.eclipse.jdt.apt.ui/.settings/org.eclipse.jdt.ui.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Wed Jun 22 17:00:28 PDT 2005
-eclipse.preferences.version=1
-internal.default.compliance=default
diff --git a/org.eclipse.jdt.apt.ui/META-INF/MANIFEST.MF b/org.eclipse.jdt.apt.ui/META-INF/MANIFEST.MF
deleted file mode 100644
index 035ba23467..0000000000
--- a/org.eclipse.jdt.apt.ui/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,20 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jdt.apt.ui; singleton:=true
-Bundle-Version: 3.3.100.qualifier
-Bundle-Activator: org.eclipse.jdt.apt.ui.internal.AptUIPlugin
-Bundle-Localization: plugin
-Require-Bundle: org.eclipse.jdt.apt.core;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.jdt.ui;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)"
-Bundle-ActivationPolicy: lazy
-Bundle-Vendor: Eclipse.org
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Export-Package: org.eclipse.jdt.apt.ui.internal;x-internal:=true,
- org.eclipse.jdt.apt.ui.internal.preferences;x-internal:=true,
- org.eclipse.jdt.apt.ui.internal.util;x-internal:=true
diff --git a/org.eclipse.jdt.apt.ui/about.html b/org.eclipse.jdt.apt.ui/about.html
deleted file mode 100644
index 460233046e..0000000000
--- a/org.eclipse.jdt.apt.ui/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 2, 2006</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.ui/build.properties b/org.eclipse.jdt.apt.ui/build.properties
deleted file mode 100644
index 0cd9ecb41d..0000000000
--- a/org.eclipse.jdt.apt.ui/build.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 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
-###############################################################################
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.xml,\
- about.html,\
- plugin.properties
-src.includes = about.html
diff --git a/org.eclipse.jdt.apt.ui/plugin.properties b/org.eclipse.jdt.apt.ui/plugin.properties
deleted file mode 100644
index 4b61be465d..0000000000
--- a/org.eclipse.jdt.apt.ui/plugin.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 BEA Systems Inc. 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:
-# BEA Systems Inc. - initial implementation
-###############################################################################
-providerName=Eclipse.org
-pluginName=Java Annotation Processing UI
-aptQuickFixProviderName=APT Quick Fix Provider
-aptQuickFixProcessorName=APTQuickFixProcessor
-annotationProcessingName=Annotation Processing
-factoryPathName=Factory Path
-natureName=nature
-markerCategory.problem=APT Problems \ No newline at end of file
diff --git a/org.eclipse.jdt.apt.ui/plugin.xml b/org.eclipse.jdt.apt.ui/plugin.xml
deleted file mode 100644
index bd7907d785..0000000000
--- a/org.eclipse.jdt.apt.ui/plugin.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin>
-
-<!-- =================================================================================== -->
-<!-- Extension: Preferences -->
-<!-- =================================================================================== -->
- <!-- Disabled: see Bugzilla 136498
- extension
- point="org.eclipse.ui.preferencePages">
- <page
- category="org.eclipse.jdt.ui.preferences.CompliancePreferencePage"
- class="org.eclipse.jdt.apt.ui.internal.preferences.AptPreferencePage"
- id="org.eclipse.jdt.apt.ui.preferences.aptPreferences"
- name="%annotationProcessingName"/>
- <page
- category="org.eclipse.jdt.apt.ui.preferences.aptPreferences"
- class="org.eclipse.jdt.apt.ui.internal.preferences.FactoryPathPreferencePage"
- id="org.eclipse.jdt.apt.ui.preferences.factoryPathPreferences"
- name="%factoryPathName"/>
- </extension -->
- <extension
- point="org.eclipse.ui.propertyPages">
- <page
- category="org.eclipse.jdt.ui.propertyPages.CompliancePreferencePage"
- class="org.eclipse.jdt.apt.ui.internal.preferences.AptPreferencePage"
- id="org.eclipse.jdt.apt.ui.propertyPages.aptPreferences"
- name="%annotationProcessingName">
- <enabledWhen>
- <adapt type="org.eclipse.core.resources.IProject">
- <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.jdt.core.javanature"/>
- </adapt>
- </enabledWhen>
- </page>
- <page
- category="org.eclipse.jdt.apt.ui.propertyPages.aptPreferences"
- class="org.eclipse.jdt.apt.ui.internal.preferences.FactoryPathPreferencePage"
- id="org.eclipse.jdt.apt.ui.propertyPages.factoryPathPreferences"
- name="%factoryPathName">
- <enabledWhen>
- <adapt type="org.eclipse.core.resources.IProject">
- <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.jdt.core.javanature"/>
- </adapt>
- </enabledWhen>
- </page>
- </extension>
- <extension
- point="org.eclipse.ui.ide.markerSupport">
- <markerTypeCategory name="%markerCategory.problem">
- <markerTypeReference id="org.eclipse.jdt.apt.core.buildproblem"/>
- <markerTypeReference id="org.eclipse.jdt.apt.core.compile.problem"/>
- <markerTypeReference id="org.eclipse.jdt.apt.core.configproblem"/>
- <markerTypeReference id="org.eclipse.jdt.apt.core.nonreconcile.compile.problem"/>
- <markerTypeReference id="org.eclipse.jdt.apt.pluggable.core.compileProblem"/>
- </markerTypeCategory>
- </extension>
-
-
-</plugin>
diff --git a/org.eclipse.jdt.apt.ui/scripts/exportplugin.xml b/org.eclipse.jdt.apt.ui/scripts/exportplugin.xml
deleted file mode 100644
index 4db455a9be..0000000000
--- a/org.eclipse.jdt.apt.ui/scripts/exportplugin.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Build script to create the apt.ui plugin.
- This script assumes that the classes have already been compiled,
- and exist in the 'bin' subdirectory of the plugin project.
- The directory structure assumed by this script is as follows:
- [dev root]/
- [workspace]/
- [plugins]/
- org.eclipse.jdt.apt.ui/
- bin/
- src/
- scripts/ // contains this script
- plugin-export/ // will be created if necessary
- org.eclipse.jdt.apt.cui_[version]/
- org.eclipse.jdt.apt.ui_[version].zip // will be created
-
--->
-
-<project name="${plugin}" default="export plug-in [_1.0.0]" basedir="..">
-
-<target name="export plug-in [_1.0.0]">
- <antcall target="zz_internal_export">
- <param name="plugin_version" value="3.2.0.qualifier"/>
- </antcall>
-</target>
-
-<target name="zz_internal_export">
-
- <tstamp/>
- <property name="export-dir" value="../../plugin-export" />
- <property name="plugin" value="org.eclipse.jdt.apt.ui" />
- <property name="plugin-dir" value="${export-dir}/${plugin}_${plugin_version}"/>
-
- <echo message="TARGET: ${export-dir}" />
- <mkdir dir="${export-dir}" />
- <delete dir="${plugin-dir}" />
- <mkdir dir="${plugin-dir}" />
-
- <echo message="UPDATE ${plugin}_${plugin_version}.jar" />
- <zip zipfile="${plugin-dir}/${plugin}_${plugin_version}.jar">
- <fileset dir=".">
- <include name="plugin.xml" />
- <include name="plugin.properties" />
- <include name="META-INF/**" />
- </fileset>
- <fileset dir="bin" />
- </zip>
-
- <echo message="UPDATE aptui src.zip" />
- <zip zipfile="${plugin-dir}/src.zip">
- <fileset dir="src" />
- </zip>
-
- <echo message="UPDATE ${export-dir}/../${plugin}_${plugin_version}.zip" />
- <zip zipfile="${export-dir}/../${plugin}_${plugin_version}.zip"
- basedir="${export-dir}"
- includes="${plugin}_${plugin_version}/**" />
-</target>
-
-</project>
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/AptUIPlugin.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/AptUIPlugin.java
deleted file mode 100644
index a370af411f..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/AptUIPlugin.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.ui.internal;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class AptUIPlugin extends AbstractUIPlugin {
-
- //The shared instance.
- private static AptUIPlugin plugin;
-
- // The plugin ID
- public static final String PLUGIN_ID = "org.eclipse.jdt.apt.ui"; //$NON-NLS-1$
-
- /**
- * Status IDs for system log entries. Must be unique per plugin.
- */
- public static final int STATUS_EXCEPTION = 1;
- public static final int INTERNAL_ERROR = 2;
-
- /**
- * The constructor.
- */
- public AptUIPlugin() {
- plugin = this;
- }
-
- /**
- * This method is called upon plug-in activation
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- }
-
- /**
- * This method is called when the plug-in is stopped
- */
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- plugin = null;
- }
-
- /**
- * Returns the shared instance.
- */
- public static AptUIPlugin getDefault() {
- return plugin;
- }
-
- public static IWorkbenchWindow getActiveWorkbenchWindow() {
- return getDefault().getWorkbench().getActiveWorkbenchWindow();
- }
-
- public static Shell getActiveWorkbenchShell() {
- IWorkbenchWindow window= getActiveWorkbenchWindow();
- if (window != null) {
- return window.getShell();
- }
- return null;
- }
-
- /**
- * Returns an image descriptor for the image file at the given
- * plug-in relative path.
- *
- * @param path the path
- * @return the image descriptor
- */
- public static ImageDescriptor getImageDescriptor(String path) {
- return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
-
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
-
- public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, STATUS_EXCEPTION, Messages.AptUIPlugin_exceptionThrown, e));
- }
-
-}
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/Messages.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/Messages.java
deleted file mode 100644
index 9c7abfcb6c..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/Messages.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.ui.internal;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- *
- */
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.jdt.apt.ui.messages"; //$NON-NLS-1$
-
- private Messages() {
- }
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- public static String AptUIPlugin_exceptionThrown;
-}
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/messages.properties b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/messages.properties
deleted file mode 100644
index eb276582e3..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/messages.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 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
-###############################################################################
-AptUIPlugin_exceptionThrown=An exception was thrown
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AdvancedFactoryPathOptionsDialog.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AdvancedFactoryPathOptionsDialog.java
deleted file mode 100644
index f99b848286..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AdvancedFactoryPathOptionsDialog.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.ui.internal.preferences;
-
-import java.io.IOException;
-import java.util.Map.Entry;
-
-import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
-import org.eclipse.jdt.apt.ui.internal.util.ExceptionHandler;
-import org.eclipse.jdt.apt.ui.internal.util.IAptHelpContextIds;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Dialog to display "advanced options" on a FactoryPathEntry,
- * typically in the context of the factory path config UI.
- * Advanced options are those which do not normally need to
- * be configured, and which may require deeper-than-usual
- * understanding of the annotation processing architecture.
- */
-public class AdvancedFactoryPathOptionsDialog extends Dialog {
-
- private final static int LIST_WIDTH= 70; // width (in chars) of factory list
- private final static int LIST_HEIGHT= 10; // number of lines in factory list
-
- private class FieldAdapter implements IDialogFieldListener {
- public void dialogFieldChanged(DialogField field) {
- }
- }
-
- // shallow copies, because they are not changed by this code
- private final FactoryContainer _fc;
- private final FactoryPath.Attributes _attr;
-
- // Dialog controls
- private SelectionButtonDialogField _batchModeField;
- private ListViewer _contentsField;
-
- public AdvancedFactoryPathOptionsDialog(
- Shell parent, FactoryContainer fc, FactoryPath.Attributes attr) {
- super(parent);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- _fc= fc;
- _attr= attr;
- }
-
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(Messages.AdvancedFactoryPathOptionsDialog_advancedOptions);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IAptHelpContextIds.ADVANCED_FACTORYPATH_OPTIONS_DIALOG);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dlgArea= (Composite) super.createDialogArea(parent);
-
- // Set up "batch mode" checkbox.
- FieldAdapter adapter = new FieldAdapter();
- _batchModeField = new SelectionButtonDialogField(SWT.CHECK);
- _batchModeField.setSelection(_attr.runInBatchMode());
- _batchModeField.setLabelText(Messages.AdvancedFactoryPathOptionsDialog_batchMode);
- _batchModeField.setDialogFieldListener(adapter);
- _batchModeField.doFillIntoGrid(dlgArea, 2);
- // Plugins can't run in APT compatibility mode.
- boolean isPlugin = _fc.getType() == FactoryContainer.FactoryType.PLUGIN;
- _batchModeField.setEnabled(!isPlugin);
-
- DialogField.createEmptySpace(dlgArea, 1);
-
- // Set up label for processor contents list
- Label description= new Label(dlgArea, SWT.WRAP);
- description.setText(Messages.AdvancedFactoryPathOptionsDialog_label_processorsInThisContainer);
- GridData gdLabel= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gdLabel.horizontalSpan= 2;
- description.setLayoutData(gdLabel);
-
- // Set up processor contents list
- _contentsField= new ListViewer(dlgArea, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
- data.heightHint = convertHeightInCharsToPixels(LIST_HEIGHT);
- data.widthHint = convertWidthInCharsToPixels(LIST_WIDTH);
- _contentsField.getList().setLayoutData(data);
- _contentsField.getList().setFont(parent.getFont());
- try {
- for (Entry<String, String> entry : _fc.getFactoryNames().entrySet()) {
- String name = entry.getKey();
- _contentsField.add(name);
- //TODO: display the processor type (i.e., entry.getValue())
- }
- }
- catch (IOException e) {
- final String message = "Unable to load factory names from container [" + _fc.getId() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- ExceptionHandler.log(e, message);
- }
- _contentsField.setSelection(null, false);
-
- applyDialogFont(dlgArea);
- return dlgArea;
- }
-
- /**
- * Return a new Attributes representing the original value updated
- * with any changes made by the user. Changes will be included even
- * if the dialog was cancelled, so this should only be called if the
- * dialog returned OK.
- */
- public FactoryPath.Attributes getResult() {
- boolean batchMode = _batchModeField.isSelected();
- return new FactoryPath.Attributes(_attr.isEnabled(), batchMode);
- }
-}
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AptConfigurationBlock.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AptConfigurationBlock.java
deleted file mode 100644
index 87074a9471..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AptConfigurationBlock.java
+++ /dev/null
@@ -1,600 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 BEA Systems, Inc. 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:
- * BEA Systems Inc. - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.ui.internal.preferences;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.apt.core.util.AptPreferenceConstants;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.jdt.internal.ui.util.PixelConverter;
-import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringDialogField;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * Preference pane for most APT (Java annotation processing) settings.
- * see org.eclipse.jdt.ui.internal.preferences.TodoTaskConfigurationBlock
- * for the conceptual source of some of this code.
- * <p>
- *
- */
-public class AptConfigurationBlock extends BaseConfigurationBlock {
-
- private static final Key KEY_APTENABLED= getKey(AptPlugin.PLUGIN_ID, AptPreferenceConstants.APT_ENABLED);
- private static final Key KEY_RECONCILEENABLED= getKey(AptPlugin.PLUGIN_ID, AptPreferenceConstants.APT_RECONCILEENABLED);
- private static final Key KEY_GENSRCDIR= getKey(AptPlugin.PLUGIN_ID, AptPreferenceConstants.APT_GENSRCDIR);
-
- private static Key[] getAllKeys() {
- return new Key[] {
- KEY_APTENABLED, KEY_RECONCILEENABLED, KEY_GENSRCDIR
- };
- }
-
- private static final int IDX_ADD= 0;
- private static final int IDX_EDIT= 1;
- private static final int IDX_REMOVE= 2;
-
- private final IJavaProject fJProj;
-
- private SelectionButtonDialogField fAptEnabledField;
- private SelectionButtonDialogField fReconcileEnabledField;
- private StringDialogField fGenSrcDirField;
- private ListDialogField fProcessorOptionsField;
-
- private PixelConverter fPixelConverter;
- private Composite fBlockControl;
-
- private Map<String, String> fOriginalProcOptions; // cache of saved values
- private String fOriginalGenSrcDir;
- private boolean fOriginalAptEnabled;
- private boolean fOriginalReconcileEnabled;
-
- // used to distinguish actual changes from re-setting of same value - see useProjectSpecificSettings()
- private boolean fPerProjSettingsEnabled;
-
- /**
- * Event handler for Processor Options list control.
- */
- private class ProcessorOptionsAdapter implements IListAdapter, IDialogFieldListener {
-
- public void customButtonPressed(ListDialogField field, int index) {
- switch (index) {
- case IDX_ADD:
- editOrAddProcessorOption(null);
- break;
- case IDX_EDIT:
- tryToEdit(field);
- break;
- }
- }
-
- @SuppressWarnings("unchecked")
- public void selectionChanged(ListDialogField field) {
- List selectedElements= field.getSelectedElements();
- field.enableButton(IDX_EDIT, canEdit(field, selectedElements));
- }
-
- public void doubleClicked(ListDialogField field) {
- tryToEdit(field);
- }
-
- public void dialogFieldChanged(DialogField field) {
- updateModel(field);
- }
-
- @SuppressWarnings("unchecked")
- private boolean canEdit(DialogField field, List selectedElements) {
- if (!field.isEnabled())
- return false;
- return selectedElements.size() == 1;
- }
-
- private void tryToEdit(ListDialogField field) {
- List<ProcessorOption> selection= getListSelection();
- if (canEdit(field, selection)) {
- editOrAddProcessorOption(selection.get(0));
- }
- }
- }
-
- /**
- * An entry in the Processor Options list control.
- */
- public static class ProcessorOption {
- public String key;
- public String value;
- }
-
- /**
- * Sorts items in the Processor Options list control.
- */
- private static class ProcessorOptionSorter extends ViewerComparator {
- @SuppressWarnings("unchecked") // getComparator() returns a raw Comparator rather than a Comparator<T>
- public int compare(Viewer viewer, Object e1, Object e2) {
- return getComparator().compare(((ProcessorOption) e1).key, ((ProcessorOption) e2).key);
- }
- }
-
- /**
- * Controls display of items in the Processor Options list control.
- */
- private class ProcessorOptionsLabelProvider extends LabelProvider implements ITableLabelProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- */
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- public String getColumnText(Object element, int columnIndex) {
- ProcessorOption o = (ProcessorOption) element;
- if (columnIndex == 0) {
- return o.key;
- }
- else if (columnIndex == 1) {
- return o.value;
- }
- else {
- return ""; //$NON-NLS-1$
- }
- }
- }
-
- public AptConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
- super(context, project, getAllKeys(), container);
-
- fJProj = JavaCore.create(project);
-
- UpdateAdapter adapter= new UpdateAdapter();
-
- if (fJProj != null) {
- fAptEnabledField= new SelectionButtonDialogField(SWT.CHECK);
- fAptEnabledField.setDialogFieldListener(adapter);
- fAptEnabledField.setLabelText(Messages.AptConfigurationBlock_enable);
- }
- else {
- fAptEnabledField = null;
- }
-
- fReconcileEnabledField= new SelectionButtonDialogField(SWT.CHECK);
- fReconcileEnabledField.setDialogFieldListener(adapter);
- fReconcileEnabledField.setLabelText(Messages.AptConfigurationBlock_enableReconcileProcessing);
-
- fGenSrcDirField = new StringDialogField();
- fGenSrcDirField.setDialogFieldListener(adapter);
- fGenSrcDirField.setLabelText(Messages.AptConfigurationBlock_generatedSrcDir);
-
- String[] buttons= new String[] {
- Messages.AptConfigurationBlock_add,
- Messages.AptConfigurationBlock_edit,
- Messages.AptConfigurationBlock_remove
- };
- ProcessorOptionsAdapter optionsAdapter = new ProcessorOptionsAdapter();
- fProcessorOptionsField = new ListDialogField(optionsAdapter, buttons, new ProcessorOptionsLabelProvider());
- fProcessorOptionsField.setDialogFieldListener(optionsAdapter);
- fProcessorOptionsField.setRemoveButtonIndex(IDX_REMOVE);
- String[] columnHeaders= new String[] {
- Messages.AptConfigurationBlock_key,
- Messages.AptConfigurationBlock_value
- };
- fProcessorOptionsField.setTableColumns(new ListDialogField.ColumnsDescription(columnHeaders, true));
- fProcessorOptionsField.setViewerComparator(new ProcessorOptionSorter());
- fProcessorOptionsField.setLabelText(Messages.AptConfigurationBlock_options);
-
- updateControls();
-
- if (fProcessorOptionsField.getSize() > 0) {
- fProcessorOptionsField.selectFirstElement();
- } else {
- fProcessorOptionsField.enableButton(IDX_EDIT, false);
- }
-
- }
-
- /*
- * At workspace level, don't ask for a rebuild.
- */
- @Override
- protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
- if (workspaceSettings)
- return null;
- // if the only thing that changed was the reconcile setting, return null: a rebuild is not necessary
- if (fOriginalGenSrcDir.equals(fGenSrcDirField.getText())) {
- if (fOriginalAptEnabled == fAptEnabledField.isSelected()) {
- if (!procOptionsChanged()) {
- return null;
- }
- }
- }
- return super.getFullBuildDialogStrings(workspaceSettings);
- }
-
- /*
- * Helper to eliminate unchecked-conversion warning
- */
- @SuppressWarnings("unchecked")
- private List<ProcessorOption> getListElements() {
- return fProcessorOptionsField.getElements();
- }
-
- /*
- * Helper to eliminate unchecked-conversion warning
- */
- @SuppressWarnings("unchecked")
- private List<ProcessorOption> getListSelection() {
- return fProcessorOptionsField.getSelectedElements();
- }
-
- private void editOrAddProcessorOption(ProcessorOption original) {
- ProcessorOptionInputDialog dialog= new ProcessorOptionInputDialog(getShell(), original, getListElements());
- if (dialog.open() == Window.OK) {
- if (original != null) {
- fProcessorOptionsField.replaceElement(original, dialog.getResult());
- } else {
- fProcessorOptionsField.addElement(dialog.getResult());
- }
- }
- }
-
- @Override
- protected Control createContents(Composite parent) {
- setShell(parent.getShell());
-
- fPixelConverter= new PixelConverter(parent);
- int indent= fPixelConverter.convertWidthInCharsToPixels(4);
-
- fBlockControl = new Composite(parent, SWT.NONE);
- fBlockControl.setFont(parent.getFont());
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
-
- fBlockControl.setLayout(layout);
-
- DialogField[] fields = fAptEnabledField != null ?
- new DialogField[] {
- fAptEnabledField,
- fReconcileEnabledField,
- fGenSrcDirField,
- fProcessorOptionsField,
- } :
- new DialogField[] {
- fReconcileEnabledField,
- fGenSrcDirField,
- fProcessorOptionsField,
- };
- LayoutUtil.doDefaultLayout(fBlockControl, fields, true, SWT.DEFAULT, SWT.DEFAULT);
- LayoutUtil.setHorizontalGrabbing(fProcessorOptionsField.getListControl(null));
-
- GridData reconcileGD= (GridData)fReconcileEnabledField.getSelectionButton(parent).getLayoutData();
- reconcileGD.horizontalIndent = indent;
- fReconcileEnabledField.getSelectionButton(parent).setLayoutData(reconcileGD);
-
- Label description= new Label(fBlockControl, SWT.WRAP);
- description.setText(Messages.AptConfigurationBlock_classpathAddedAutomaticallyNote);
- GridData gdLabel= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gdLabel.horizontalSpan= 2;
- gdLabel.widthHint= fPixelConverter.convertWidthInCharsToPixels(60);
- description.setLayoutData(gdLabel);
-
- Dialog.applyDialogFont(fBlockControl);
-
- validateSettings(null, null, null);
-
- return fBlockControl;
- }
-
- @Override
- protected void cacheOriginalValues() {
- super.cacheOriginalValues();
- fOriginalProcOptions= AptConfig.getRawProcessorOptions(fJProj);
- fOriginalGenSrcDir = AptConfig.getGenSrcDir(fJProj);
- fOriginalAptEnabled = AptConfig.isEnabled(fJProj);
- fOriginalReconcileEnabled = AptConfig.shouldProcessDuringReconcile(fJProj);
- fPerProjSettingsEnabled = hasProjectSpecificOptionsNoCache(fProject);
- }
-
- protected void initContents() {
- loadProcessorOptions(fJProj);
- }
-
- @Override
- protected void saveSettings() {
- List<ProcessorOption> elements;
- boolean isProjSpecificDisabled = (fJProj != null) && !fBlockControl.isEnabled();
- if (isProjSpecificDisabled) {
- // We're in a project properties pane but the entire configuration
- // block control is disabled. That means the per-project settings checkbox
- // is unchecked. To save that state, we'll clear the proc options map.
- elements = Collections.<ProcessorOption>emptyList();
- }
- else {
- elements = getListElements();
- }
- saveProcessorOptions(elements);
- super.saveSettings();
- if (null != fAptProject) {
- if (isProjSpecificDisabled) { // compare against workspace defaults
- if (!fOriginalGenSrcDir.equals(AptConfig.getGenSrcDir(null))) {
- fAptProject.preferenceChanged(AptPreferenceConstants.APT_GENSRCDIR);
- }
- if (fOriginalAptEnabled != AptConfig.isEnabled(null)) {
- // make JDT "processingEnabled" setting track APT "enabled" setting.
- setJDTProcessAnnotationsSetting(fAptEnabledField.isSelected());
-
- fAptProject.preferenceChanged(AptPreferenceConstants.APT_ENABLED);
- }
- if (fOriginalReconcileEnabled != AptConfig.shouldProcessDuringReconcile(null)) {
- fAptProject.preferenceChanged(AptPreferenceConstants.APT_RECONCILEENABLED);
- }
- }
- else { // compare against current settings
- if (!fOriginalGenSrcDir.equals(fGenSrcDirField.getText()))
- fAptProject.preferenceChanged(AptPreferenceConstants.APT_GENSRCDIR);
- boolean isAptEnabled = fAptEnabledField.isSelected();
- if (fOriginalAptEnabled != isAptEnabled) {
- // make JDT "processingEnabled" setting track APT "enabled" setting.
- setJDTProcessAnnotationsSetting(isAptEnabled);
-
- fAptProject.preferenceChanged(AptPreferenceConstants.APT_ENABLED);
- }
- if (fOriginalReconcileEnabled != fReconcileEnabledField.isSelected())
- fAptProject.preferenceChanged(AptPreferenceConstants.APT_RECONCILEENABLED);
- }
- }
- }
-
- /**
- * Set the org.eclipse.jdt.core.compiler.processAnnotations setting.
- * In Eclipse 3.3, this value replaces org.eclipse.jdt.apt.aptEnabled,
- * but we continue to set both values in order to ensure backward
- * compatibility with prior versions.
- * the aptEnabled setting.
- * @param enable
- */
- private void setJDTProcessAnnotationsSetting(boolean enable) {
- IScopeContext context = (null != fJProj) ?
- new ProjectScope(fJProj.getProject()) : new InstanceScope();
- IEclipsePreferences node = context.getNode(JavaCore.PLUGIN_ID);
- final String value = enable ? AptPreferenceConstants.ENABLED : AptPreferenceConstants.DISABLED;
- node.put(AptPreferenceConstants.APT_PROCESSANNOTATIONS, value);
- try {
- node.flush();
- }
- catch (BackingStoreException e){
- AptPlugin.log(e, "Failed to save preference: " + AptPreferenceConstants.APT_PROCESSANNOTATIONS); //$NON-NLS-1$
- }
- }
-
- /**
- * Check whether any processor options have changed.
- * @return true if they did.
- */
- private boolean procOptionsChanged() {
- Map<String, String> savedProcOptions = new HashMap<String, String>(fOriginalProcOptions);
- for (ProcessorOption o : getListElements()) {
- final String savedVal = savedProcOptions.get(o.key);
- if (savedVal != null && savedVal.equals(o.value)) {
- savedProcOptions.remove(o.key);
- }
- else {
- // found an unsaved option in the list
- return true;
- }
- }
- if (!savedProcOptions.isEmpty()) {
- // found a saved option that has been removed
- return true;
- }
- return false;
- }
-
- /**
- * Check whether any processor options have changed, as well as
- * any of the settings tracked in the "normal" way (as Keys).
- */
- @Override
- protected boolean settingsChanged(IScopeContext currContext) {
- if (procOptionsChanged())
- return true;
- else
- return super.settingsChanged(currContext);
- }
-
- /**
- * Call after updating key values, to warn user if new values are invalid.
- * @param changedKey may be null, e.g. if called from createContents.
- * @param oldValue may be null
- * @param newValue may be null
- */
- @Override
- protected void validateSettings(Key changedKey, String oldValue, String newValue) {
- IStatus status = null;
-
- status = validateGenSrcDir();
- if (status.getSeverity() == IStatus.OK) {
- status = validateProcessorOptions();
- }
-
- fContext.statusChanged(status);
- }
-
- /**
- * Validate "generated source directory" setting. It must be a valid
- * pathname relative to a project, and must not be a source directory.
- * @return true if current field value is valid
- */
- private IStatus validateGenSrcDir() {
- String dirName = fGenSrcDirField.getText();
- if (!AptConfig.validateGenSrcDir(fJProj, dirName)) {
- return new StatusInfo(IStatus.ERROR, Messages.AptConfigurationBlock_genSrcDirMustBeValidRelativePath);
- }
- if (fJProj != null && !dirName.equals(fOriginalGenSrcDir)) {
- IFolder folder = fJProj.getProject().getFolder( dirName );
- if (folder != null && folder.exists() && !folder.isDerived()) {
- return new StatusInfo(IStatus.WARNING, Messages.AptConfigurationBlock_warningContentsMayBeDeleted);
- }
- }
- return new StatusInfo();
- }
-
- /**
- * Validate the currently set processor options. We do this by
- * looking at the table contents rather than the packed string,
- * just because it's easier.
- * @return a StatusInfo containing a warning if appropriate.
- */
- private IStatus validateProcessorOptions() {
- List<ProcessorOption> elements = getListElements();
- for (ProcessorOption o : elements) {
- if (AptConfig.isAutomaticProcessorOption(o.key)) {
- return new StatusInfo(IStatus.WARNING,
- Messages.AptConfigurationBlock_warningIgnoredOptions + ": " + o.key); //$NON-NLS-1$
- }
- }
- return new StatusInfo();
- }
-
- /**
- * Update the UI based on the values presently stored in the keys.
- */
- @Override
- protected void updateControls() {
- if (fAptEnabledField != null) {
- boolean aptEnabled= Boolean.valueOf(getValue(KEY_APTENABLED)).booleanValue();
- fAptEnabledField.setSelection(aptEnabled);
- }
- boolean reconcileEnabled= Boolean.valueOf(getValue(KEY_RECONCILEENABLED)).booleanValue();
- fReconcileEnabledField.setSelection(reconcileEnabled);
- String str= getValue(KEY_GENSRCDIR);
- fGenSrcDirField.setText(str == null ? "" : str); //$NON-NLS-1$
- }
-
- /**
- * Update the values stored in the keys based on the UI.
- */
- protected final void updateModel(DialogField field) {
-
- if (fAptEnabledField != null && field == fAptEnabledField) {
- String newVal = String.valueOf(fAptEnabledField.isSelected());
- setValue(KEY_APTENABLED, newVal);
- } else if (field == fGenSrcDirField) {
- String newVal = fGenSrcDirField.getText();
- setValue(KEY_GENSRCDIR, newVal);
- } else if (field == fReconcileEnabledField) {
- String newVal = String.valueOf(fReconcileEnabledField.isSelected());
- setValue(KEY_RECONCILEENABLED, newVal);
- }
- validateSettings(null, null, null); // params are ignored
- }
-
- /**
- * Bugzilla 136498: when project-specific settings are enabled, force APT to be enabled.
- */
- @Override
- public void useProjectSpecificSettings(boolean enable) {
- super.useProjectSpecificSettings(enable);
- if (enable ^ fPerProjSettingsEnabled) {
- fAptEnabledField.setSelection(enable);
- fPerProjSettingsEnabled = enable;
- }
- }
-
- /**
- * Save the contents of the options list.
- */
- private void saveProcessorOptions(List<ProcessorOption> elements) {
- Map<String, String> map = new LinkedHashMap<String, String>(elements.size());
- for (ProcessorOption o : elements) {
- map.put(o.key, (o.value.length() > 0) ? o.value : null);
- }
- AptConfig.setProcessorOptions(map, fJProj);
- }
-
- /**
- * Set the processor options list contents
- */
- private void loadProcessorOptions(IJavaProject jproj) {
- List<ProcessorOption> options= new ArrayList<ProcessorOption>();
- Map<String, String> parsedOptions = AptConfig.getRawProcessorOptions(jproj);
- for (Map.Entry<String, String> entry : parsedOptions.entrySet()) {
- ProcessorOption o = new ProcessorOption();
- o.key = entry.getKey();
- if (o.key == null || o.key.length() < 1) {
- // Don't allow defective entries
- continue;
- }
- o.value = (entry.getValue() == null) ? "" : entry.getValue(); //$NON-NLS-1$
- options.add(o);
- }
- fProcessorOptionsField.setElements(options);
- }
-
- @Override
- public void performDefaults() {
- fPerProjSettingsEnabled = false;
- if (fJProj != null) {
- // If project-specific, load workspace settings
- loadProcessorOptions(null);
- }
- else {
- // If workspace, load "factory default," which is empty.
- fProcessorOptionsField.removeAllElements();
- }
- super.performDefaults();
- }
-
-}
-
-
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AptPreferencePage.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AptPreferencePage.java
deleted file mode 100644
index 49d65035a2..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AptPreferencePage.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 BEA Systems, Inc. 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:
- * BEA Systems Inc. - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.ui.internal.preferences;
-
-import org.eclipse.jdt.apt.ui.internal.AptUIPlugin;
-import org.eclipse.jdt.apt.ui.internal.util.IAptHelpContextIds;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-
-/*
- * The page to configure the naming style options.
- */
-public class AptPreferencePage extends BasePreferencePage {
-
- private static final String PREF_ID= "org.eclipse.jdt.apt.ui.preferences.aptPreferences"; //$NON-NLS-1$
- private static final String PROP_ID= "org.eclipse.jdt.apt.ui.propertyPages.aptPreferences"; //$NON-NLS-1$
-
- public AptPreferencePage() {
- setPreferenceStore(AptUIPlugin.getDefault().getPreferenceStore());
-
- // only shown for workspace preferences
- setDescription(Messages.AptPreferencePage_preferences);
-
- // only used when page is shown programatically
- setTitle(Messages.AptPreferencePage_preferencesTitle);
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- setConfigurationBlock(new AptConfigurationBlock(getNewStatusChangedListener(), getProject(), container));
-
- super.createControl(parent);
- }
-
- @Override
- protected String getContextHelpId() {
- return IAptHelpContextIds.APTCONFIGURATION_PREFERENCE_PAGE;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
- */
- protected String getPreferencePageID() {
- return PREF_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
- */
- protected String getPropertyPageID() {
- return PROP_ID;
- }
-
-
-
-}
-
-
-
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/BaseConfigurationBlock.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/BaseConfigurationBlock.java
deleted file mode 100644
index fe3e961ff2..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/BaseConfigurationBlock.java
+++ /dev/null
@@ -1,936 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.ui.internal.preferences;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jdt.apt.core.internal.AptPlugin;
-import org.eclipse.jdt.apt.core.internal.AptProject;
-import org.eclipse.jdt.apt.ui.internal.util.ExceptionHandler;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jdt.internal.ui.preferences.ScrolledPageContent;
-import org.eclipse.jdt.internal.ui.util.CoreUtility;
-import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Scrollable;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.forms.events.ExpansionAdapter;
-import org.eclipse.ui.forms.events.ExpansionEvent;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.preferences.WorkingCopyManager;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.ui.preferences.IWorkingCopyManager;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * The ConfigurationBlock hierarchy is used to organize controls and keys
- * within a property/preference page. The implementor derives from this
- * class and creates dialog controls, layout, and response code.
- * <p>
- * This code is largely a copy of OptionsConfigurationBlock (JDT UI), modified
- * to fix bugs and to improve extensibility for preference pages that contain
- * a mix of preference-based and externally serialized data.
- */
-public abstract class BaseConfigurationBlock {
-
- protected static class ControlData {
- private Key fKey;
- private String[] fValues;
-
- public ControlData(Key key, String[] values) {
- fKey= key;
- fValues= values;
- }
-
- public Key getKey() {
- return fKey;
- }
-
- public int getSelection(String value) {
- if (value != null) {
- for (int i= 0; i < fValues.length; i++) {
- if (value.equals(fValues[i])) {
- return i;
- }
- }
- }
- return fValues.length -1; // assume the last option is the least severe
- }
-
- public String getValue(boolean selection) {
- int index= selection ? 0 : 1;
- return fValues[index];
- }
-
- public String getValue(int index) {
- return fValues[index];
- }
- }
-
- public static final class Key {
-
- private String fKey;
- private String fQualifier;
-
- public Key(String qualifier, String key) {
- fQualifier= qualifier;
- fKey= key;
- }
-
- public String getName() {
- return fKey;
- }
-
- private IEclipsePreferences getNode(IScopeContext context, IWorkingCopyManager manager) {
- IEclipsePreferences node= context.getNode(fQualifier);
- if (manager != null) {
- return manager.getWorkingCopy(node);
- }
- return node;
- }
-
- public String getQualifier() {
- return fQualifier;
- }
-
- public String getStoredValue(IScopeContext context, IWorkingCopyManager manager) {
- return getNode(context, manager).get(fKey, null);
- }
-
- public String getStoredValue(IScopeContext[] lookupOrder, boolean ignoreTopScope, IWorkingCopyManager manager) {
- for (int i= ignoreTopScope ? 1 : 0; i < lookupOrder.length; i++) {
- String value= getStoredValue(lookupOrder[i], manager);
- if (value != null) {
- return value;
- }
- }
- return null;
- }
-
- public void setStoredValue(IScopeContext context, String value, IWorkingCopyManager manager) {
- if (value != null) {
- getNode(context, manager).put(fKey, value);
- } else {
- getNode(context, manager).remove(fKey);
- }
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return fQualifier + '/' + fKey;
- }
-
- }
-
- protected class UpdateAdapter implements IDialogFieldListener {
-
- public void dialogFieldChanged(DialogField field) {
- updateModel(field);
- }
- }
-
- private static final String SETTINGS_EXPANDED= "expanded"; //$NON-NLS-1$
-
- protected final Key[] fAllKeys;
- private boolean fOriginallyHadProjectSettings; // updated in cacheOriginalValues
- private Map<Key, String> fDisabledProjectSettings; // null when project specific settings are turned off
- protected IScopeContext[] fLookupOrder;
- protected final IWorkingCopyManager fManager;
-
- protected final ArrayList<Button> fCheckBoxes;
- protected final ArrayList<Combo> fComboBoxes;
- protected final ArrayList<ExpandableComposite> fExpandedComposites;
- protected final HashMap<Scrollable, Label> fLabels;
- protected final ArrayList<Text> fTextBoxes;
-
- private ModifyListener fTextModifyListener;
- protected IStatusChangeListener fContext;
- private SelectionListener fSelectionListener;
-
- protected final IProject fProject; // project or null
- protected final AptProject fAptProject; // null for workspace prefs
-
- private IWorkbenchPreferenceContainer fContainer;
- private Shell fShell;
-
- private Control fBlockControl;
-
- protected static Key getKey(String plugin, String name) {
- return new Key(plugin, name);
- }
-
- public BaseConfigurationBlock(IStatusChangeListener context, IProject project, Key[] keys, IWorkbenchPreferenceContainer container) {
- fContext= context;
- fProject= project;
- fAllKeys= keys;
- fContainer= container;
- /*
- if (container == null) {
- fManager= new WorkingCopyManager();
- } else {
- fManager= container.getWorkingCopyManager();
- }
- */
- // Workaround for Bugzilla 115731 - always use our own WCM.
- fManager = new WorkingCopyManager();
-
- if (fProject != null) {
- fLookupOrder= new IScopeContext[] {
- new ProjectScope(fProject),
- new InstanceScope(),
- new DefaultScope()
- };
- fAptProject = AptPlugin.getAptProject(JavaCore.create(fProject));
- } else {
- fLookupOrder= new IScopeContext[] {
- new InstanceScope(),
- new DefaultScope()
- };
- fAptProject = null;
- }
-
- testIfOptionsComplete(keys);
- if (fProject == null || hasProjectSpecificOptionsNoCache(fProject)) {
- fDisabledProjectSettings= null;
- } else {
- fDisabledProjectSettings= new IdentityHashMap<Key, String>();
- for (int i= 0; i < keys.length; i++) {
- Key curr= keys[i];
- fDisabledProjectSettings.put(curr, curr.getStoredValue(fLookupOrder, false, fManager));
- }
- }
-
- settingsUpdated();
-
- fCheckBoxes= new ArrayList<Button>();
- fComboBoxes= new ArrayList<Combo>();
- fTextBoxes= new ArrayList<Text>(2);
- fLabels= new HashMap<Scrollable, Label>();
- fExpandedComposites= new ArrayList<ExpandableComposite>();
- }
-
- protected Button addCheckBox(Composite parent, String label, Key key, String[] values, int indent) {
- ControlData data= new ControlData(key, values);
-
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 3;
- gd.horizontalIndent= indent;
-
- Button checkBox= new Button(parent, SWT.CHECK);
- checkBox.setFont(JFaceResources.getDialogFont());
- checkBox.setText(label);
- checkBox.setData(data);
- checkBox.setLayoutData(gd);
- checkBox.addSelectionListener(getSelectionListener());
-
- makeScrollableCompositeAware(checkBox);
-
- String currValue= getValue(key);
- checkBox.setSelection(data.getSelection(currValue) == 0);
-
- fCheckBoxes.add(checkBox);
-
- return checkBox;
- }
-
- protected Combo addComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) {
- GridData gd= new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1);
- gd.horizontalIndent= indent;
-
- Label labelControl= new Label(parent, SWT.LEFT);
- labelControl.setFont(JFaceResources.getDialogFont());
- labelControl.setText(label);
- labelControl.setLayoutData(gd);
-
- Combo comboBox= newComboControl(parent, key, values, valueLabels);
- comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
- fLabels.put(comboBox, labelControl);
-
- return comboBox;
- }
-
- protected Combo addInversedComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) {
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indent;
- gd.horizontalSpan= 3;
-
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
- composite.setLayout(layout);
- composite.setLayoutData(gd);
-
- Combo comboBox= newComboControl(composite, key, values, valueLabels);
- comboBox.setFont(JFaceResources.getDialogFont());
- comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
- Label labelControl= new Label(composite, SWT.LEFT | SWT.WRAP);
- labelControl.setText(label);
- labelControl.setLayoutData(new GridData());
-
- fLabels.put(comboBox, labelControl);
- return comboBox;
- }
-
- protected Text addTextField(Composite parent, String label, Key key, int indent, int widthHint) {
- Label labelControl= new Label(parent, SWT.WRAP);
- labelControl.setText(label);
- labelControl.setFont(JFaceResources.getDialogFont());
- labelControl.setLayoutData(new GridData());
-
- Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE);
- textBox.setData(key);
- textBox.setLayoutData(new GridData());
-
- makeScrollableCompositeAware(textBox);
-
- fLabels.put(textBox, labelControl);
-
- String currValue= getValue(key);
- if (currValue != null) {
- textBox.setText(currValue);
- }
- textBox.addModifyListener(getTextModifyListener());
-
- GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- if (widthHint != 0) {
- data.widthHint= widthHint;
- }
- data.horizontalIndent= indent;
- data.horizontalSpan= 2;
- textBox.setLayoutData(data);
-
- fTextBoxes.add(textBox);
- return textBox;
- }
-
- protected boolean checkValue(Key key, String value) {
- return value.equals(getValue(key));
- }
-
- protected void controlChanged(Widget widget) {
- ControlData data= (ControlData) widget.getData();
- String newValue= null;
- if (widget instanceof Button) {
- newValue= data.getValue(((Button)widget).getSelection());
- } else if (widget instanceof Combo) {
- newValue= data.getValue(((Combo)widget).getSelectionIndex());
- } else {
- return;
- }
- String oldValue= setValue(data.getKey(), newValue);
- validateSettings(data.getKey(), oldValue, newValue);
- }
-
- /**
- * Called from BasePreferencePage#createPreferenceContent.
- */
- public final Control createPreferenceContent(Composite parent) {
- fBlockControl = createContents(parent);
- if (fBlockControl != null) {
- cacheOriginalValues();
- initContents();
- }
- return fBlockControl;
- }
-
- /**
- * Derived classes must override this in order to create
- * their visual content. After this is called, initContents()
- * will be called.
- * @return a Composite representing the entire pane.
- */
- protected abstract Control createContents(Composite parent);
-
- /**
- * This will be called when settings are first loaded and
- * whenever changes are applied.
- * Derived classes may use this to cache the saved settings
- * values, for later comparison to see if anything changed.
- */
- protected void cacheOriginalValues() {
- fOriginallyHadProjectSettings= hasProjectSpecificOptionsNoCache(fProject);
- }
-
- /**
- * This will be called exactly once during initialization, after
- * createContents() and cacheOriginalValues().
- * Derived classes may override this to initialize any fields
- * that are not based on a Key.
- */
- protected void initContents() {
- // Base method does nothing.
- }
-
- protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) {
- ExpandableComposite excomposite= new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
- excomposite.setText(label);
- excomposite.setExpanded(false);
- excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
- excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1));
- excomposite.addExpansionListener(new ExpansionAdapter() {
- public void expansionStateChanged(ExpansionEvent e) {
- expandedStateChanged((ExpandableComposite) e.getSource());
- }
- });
- fExpandedComposites.add(excomposite);
- makeScrollableCompositeAware(excomposite);
- return excomposite;
- }
-
- /**
- * Called from BasePreferencePage#dispose().
- * Derived classes may override.
- */
- public void dispose() {
- }
-
- protected final void expandedStateChanged(ExpandableComposite expandable) {
- ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(expandable);
- if (parentScrolledComposite != null) {
- parentScrolledComposite.reflow(true);
- }
- }
-
- protected Control findControl(Key key) {
- Combo comboBox= getComboBox(key);
- if (comboBox != null) {
- return comboBox;
- }
- Button checkBox= getCheckBox(key);
- if (checkBox != null) {
- return checkBox;
- }
- Text text= getTextControl(key);
- if (text != null) {
- return text;
- }
- return null;
- }
-
- protected boolean getBooleanValue(Key key) {
- return Boolean.valueOf(getValue(key)).booleanValue();
- }
-
- protected Button getCheckBox(Key key) {
- for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
- Button curr= fCheckBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
- if (key.equals(data.getKey())) {
- return curr;
- }
- }
- return null;
- }
-
- protected Combo getComboBox(Key key) {
- for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
- Combo curr= fComboBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
- if (key.equals(data.getKey())) {
- return curr;
- }
- }
- return null;
- }
-
- /**
- * Provide the strings needed to ask the user whether to rebuild.
- * Derived classes can override this to change the strings, or to
- * return null, in which case the dialog will not be shown and the
- * rebuild will not be triggered.
- * @param workspaceSettings true if workspace settings have changed,
- * false if only project-specific settings have changed.
- * @return an array whose first entry is the dialog title, and whose
- * second entry is a query asking the user whether to rebuild.
- */
- protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
- String[] strings= new String[2];
- strings[0] = Messages.BaseConfigurationBlock_settingsChanged;
- if (workspaceSettings) {
- strings[1]= Messages.BaseConfigurationBlock_fullRebuildRequired;
- }
- else {
- strings[1]= Messages.BaseConfigurationBlock_rebuildRequired;
- }
- return strings;
- }
-
- protected ExpandableComposite getParentExpandableComposite(Control control) {
- Control parent= control.getParent();
- while (!(parent instanceof ExpandableComposite) && parent != null) {
- parent= parent.getParent();
- }
- if (parent instanceof ExpandableComposite) {
- return (ExpandableComposite) parent;
- }
- return null;
- }
-
- protected ScrolledPageContent getParentScrolledComposite(Control control) {
- Control parent= control.getParent();
- while (!(parent instanceof ScrolledPageContent) && parent != null) {
- parent= parent.getParent();
- }
- if (parent instanceof ScrolledPageContent) {
- return (ScrolledPageContent) parent;
- }
- return null;
- }
-
- protected final IWorkbenchPreferenceContainer getPreferenceContainer() {
- return fContainer;
- }
-
- protected SelectionListener getSelectionListener() {
- if (fSelectionListener == null) {
- fSelectionListener= new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {}
-
- public void widgetSelected(SelectionEvent e) {
- controlChanged(e.widget);
- }
- };
- }
- return fSelectionListener;
- }
-
- protected Shell getShell() {
- return fShell;
- }
-
- /**
- * Retuens the value as actually stored in the preference store.
- * @param key
- * @return the value as actually stored in the preference store.
- */
- protected String getStoredValue(Key key) {
- return key.getStoredValue(fLookupOrder, false, fManager);
- }
-
- protected Text getTextControl(Key key) {
- for (int i= fTextBoxes.size() - 1; i >= 0; i--) {
- Text curr= fTextBoxes.get(i);
- ControlData data= (ControlData) curr.getData();
- if (key.equals(data.getKey())) {
- return curr;
- }
- }
- return null;
- }
-
- protected ModifyListener getTextModifyListener() {
- if (fTextModifyListener == null) {
- fTextModifyListener= new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- textChanged((Text) e.widget);
- }
- };
- }
- return fTextModifyListener;
- }
-
- protected String[] getTokens(String text, String separator) {
- StringTokenizer tok= new StringTokenizer(text, separator);
- int nTokens= tok.countTokens();
- String[] res= new String[nTokens];
- for (int i= 0; i < res.length; i++) {
- res[i]= tok.nextToken().trim();
- }
- return res;
- }
-
- protected String getValue(Key key) {
- if (fDisabledProjectSettings != null) {
- return fDisabledProjectSettings.get(key);
- }
- return key.getStoredValue(fLookupOrder, false, fManager);
- }
-
- /**
- * TODO: this method is a workaround for Bugzilla 111144 and 106111. When
- * 111144 is fixed, remove this method and call hasProjectSpecificOptions()
- * instead. The difference is that this one does not cause project prefs nodes
- * to be cached in the WorkingCopyManager.
- * @return true if the project has project-specific options.
- */
- public boolean hasProjectSpecificOptionsNoCache(IProject project) {
- if (project != null) {
- IScopeContext projectContext= new ProjectScope(project);
- Key[] allKeys= fAllKeys;
- for (int i= 0; i < allKeys.length; i++) {
- if (allKeys[i].getStoredValue(projectContext, null) != null) {
- return true;
- }
- }
- }
- return false;
- }
-
- private void makeScrollableCompositeAware(Control control) {
- ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(control);
- if (parentScrolledComposite != null) {
- parentScrolledComposite.adaptChild(control);
- }
- }
-
- protected Combo newComboControl(Composite composite, Key key, String[] values, String[] valueLabels) {
- ControlData data= new ControlData(key, values);
-
- Combo comboBox= new Combo(composite, SWT.READ_ONLY);
- comboBox.setItems(valueLabels);
- comboBox.setData(data);
- comboBox.addSelectionListener(getSelectionListener());
- comboBox.setFont(JFaceResources.getDialogFont());
-
- makeScrollableCompositeAware(comboBox);
-
- String currValue= getValue(key);
- comboBox.select(data.getSelection(currValue));
-
- fComboBoxes.add(comboBox);
- return comboBox;
- }
-
- public boolean performApply() {
- return processChanges(null); // apply directly
- }
-
-
- public void performDefaults() {
- IScopeContext[] lookupOrder; // not same as fLookupOrder! Starts one layer deeper.
- if (fProject != null) {
- lookupOrder= new IScopeContext[] {
- new InstanceScope(),
- new DefaultScope()
- };
- } else {
- lookupOrder= new IScopeContext[] {
- new DefaultScope()
- };
- }
-
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
- String defValue= curr.getStoredValue(lookupOrder, false, null);
- setValue(curr, defValue);
- }
-
- settingsUpdated();
- updateControls();
- validateSettings(null, null, null);
- }
-
- public boolean performOk() {
- return processChanges(fContainer);
- }
-
- /**
- * @since 3.1
- */
- public void performRevert() {
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
- String origValue= curr.getStoredValue(fLookupOrder, false, null);
- setValue(curr, origValue);
- }
-
- settingsUpdated();
- updateControls();
- validateSettings(null, null, null);
- }
-
- /**
- * If there are changed settings, save them and ask user whether to rebuild.
- * This is called by performOk() and performApply().
- * @param container null when called from performApply().
- * @return false to abort exiting the preference pane.
- */
- protected boolean processChanges(IWorkbenchPreferenceContainer container) {
-
- boolean projectSpecificnessChanged = false;
- boolean isProjectSpecific= (fProject != null) && fBlockControl.getEnabled();
- if (fOriginallyHadProjectSettings ^ isProjectSpecific) {
- // the project-specificness changed.
- projectSpecificnessChanged= true;
- } else if ((fProject != null) && !isProjectSpecific) {
- // no project specific data, and there never was, and this
- // is a project preferences pane, so nothing could have changed.
- return true;
- }
-
- if (!projectSpecificnessChanged && !settingsChanged(fLookupOrder[0])) {
- return true;
- }
-
- int response= 1; // "NO" rebuild unless we put up the dialog.
- String[] strings= getFullBuildDialogStrings(fProject == null);
- if (strings != null) {
- MessageDialog dialog= new MessageDialog(
- getShell(),
- strings[0],
- null,
- strings[1],
- MessageDialog.QUESTION,
- new String[] {
- IDialogConstants.YES_LABEL,
- IDialogConstants.NO_LABEL,
- IDialogConstants.CANCEL_LABEL
- },
- 2);
- response= dialog.open();
- }
- if (response == 0 || response == 1) { // "YES" or "NO" - either way, save.
- saveSettings();
- if (container == null) {
- // we're doing an Apply, so update the reference values.
- cacheOriginalValues();
- }
- }
- if (response == 0) { // "YES", rebuild
- if (container != null) {
- // build after dialog exits
- container.registerUpdateJob(CoreUtility.getBuildJob(fProject));
- } else {
- // build immediately
- CoreUtility.getBuildJob(fProject).schedule();
- }
- } else if (response != 1) { // "CANCEL" - no save, no rebuild.
- return false;
- }
- return true;
- }
-
- /**
- * Save dialog information to persistent storage.
- * Derived classes should override this if they have settings
- * that are managed using means other than the Key infrastructure.
- */
- protected void saveSettings() {
- try {
- fManager.applyChanges();
- } catch (BackingStoreException e) {
- ExceptionHandler.log(e, "Unable to save preferences"); //$NON-NLS-1$
- }
- }
-
- protected void restoreSectionExpansionStates(IDialogSettings settings) {
- for (int i= 0; i < fExpandedComposites.size(); i++) {
- ExpandableComposite excomposite= fExpandedComposites.get(i);
- if (settings == null) {
- excomposite.setExpanded(i == 0); // only expand the first node by default
- } else {
- excomposite.setExpanded(settings.getBoolean(SETTINGS_EXPANDED + String.valueOf(i)));
- }
- }
- }
-
- public void selectOption(Key key) {
- Control control= findControl(key);
- if (control != null) {
- if (!fExpandedComposites.isEmpty()) {
- ExpandableComposite expandable= getParentExpandableComposite(control);
- if (expandable != null) {
- for (int i= 0; i < fExpandedComposites.size(); i++) {
- ExpandableComposite curr= fExpandedComposites.get(i);
- curr.setExpanded(curr == expandable);
- }
- expandedStateChanged(expandable);
- }
- }
- control.setFocus();
- }
- }
-
- public void selectOption(String key, String qualifier) {
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
- if (curr.getName().equals(key) && curr.getQualifier().equals(qualifier)) {
- selectOption(curr);
- }
- }
- }
-
- protected void setComboEnabled(Key key, boolean enabled) {
- Combo combo= getComboBox(key);
- Label label= fLabels.get(combo);
- combo.setEnabled(enabled);
- label.setEnabled(enabled);
- }
-
- protected void setShell(Shell shell) {
- fShell= shell;
- }
-
- /**
- * Checks the state of all Keys in the dialog to see whether there have been changes.
- * Derived classes which include settings managed outside of the Key infrastructure
- * should override this method, in order to check whether the additional settings have changed.
- * @return true if there is anything that needs to be saved.
- */
- protected boolean settingsChanged(IScopeContext currContext) {
- boolean needsBuild= false;
- for (int i= 0; i < fAllKeys.length; i++) {
- Key key= fAllKeys[i];
- String oldVal= key.getStoredValue(currContext, null);
- String val= key.getStoredValue(currContext, fManager);
- if (val == null) {
- if (oldVal != null) {
- needsBuild |= !oldVal.equals(key.getStoredValue(fLookupOrder, true, fManager));
- }
- } else if (!val.equals(oldVal)) {
- needsBuild |= oldVal != null || !val.equals(key.getStoredValue(fLookupOrder, true, fManager));
- }
- }
- return needsBuild;
- }
-
- protected void settingsUpdated() {
- }
-
- protected String setValue(Key key, boolean value) {
- return setValue(key, String.valueOf(value));
- }
-
- protected String setValue(Key key, String value) {
- if (fDisabledProjectSettings != null) {
- return fDisabledProjectSettings.put(key, value);
- }
- String oldValue= getValue(key);
- key.setStoredValue(fLookupOrder[0], value, fManager);
- return oldValue;
- }
-
- protected void storeSectionExpansionStates(IDialogSettings settings) {
- for (int i= 0; i < fExpandedComposites.size(); i++) {
- ExpandableComposite curr= fExpandedComposites.get(i);
- settings.put(SETTINGS_EXPANDED + String.valueOf(i), curr.isExpanded());
- }
- }
-
- private void testIfOptionsComplete(Key[] allKeys) {
- for (int i= 0; i < allKeys.length; i++) {
- if (allKeys[i].getStoredValue(fLookupOrder, false, fManager) == null) {
- JavaPlugin.logErrorMessage("preference option missing: " + allKeys[i] + " (" + this.getClass().getName() +')'); //$NON-NLS-1$//$NON-NLS-2$
- }
- }
- }
-
- protected void textChanged(Text textControl) {
- Key key= (Key) textControl.getData();
- String number= textControl.getText();
- String oldValue= setValue(key, number);
- validateSettings(key, oldValue, number);
- }
-
- protected void updateCheckBox(Button curr) {
- ControlData data= (ControlData) curr.getData();
-
- String currValue= getValue(data.getKey());
- curr.setSelection(data.getSelection(currValue) == 0);
- }
-
- protected void updateCombo(Combo curr) {
- ControlData data= (ControlData) curr.getData();
-
- String currValue= getValue(data.getKey());
- curr.select(data.getSelection(currValue));
- }
-
- protected void updateControls() {
- // update the UI
- for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
- updateCheckBox(fCheckBoxes.get(i));
- }
- for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
- updateCombo(fComboBoxes.get(i));
- }
- for (int i= fTextBoxes.size() - 1; i >= 0; i--) {
- updateText(fTextBoxes.get(i));
- }
- }
-
- protected abstract void updateModel(DialogField field);
-
- protected void updateText(Text curr) {
- Key key= (Key) curr.getData();
-
- String currValue= getValue(key);
- if (currValue != null) {
- curr.setText(currValue);
- }
- }
-
- public void useProjectSpecificSettings(boolean enable) {
- boolean hasProjectSpecificOption= fDisabledProjectSettings == null;
- if (enable != hasProjectSpecificOption && fProject != null) {
- if (enable) {
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
- String val= fDisabledProjectSettings.get(curr);
- curr.setStoredValue(fLookupOrder[0], val, fManager);
- }
- fDisabledProjectSettings= null;
- updateControls();
- } else {
- fDisabledProjectSettings= new IdentityHashMap<Key, String>();
- for (int i= 0; i < fAllKeys.length; i++) {
- Key curr= fAllKeys[i];
- String oldSetting= curr.getStoredValue(fLookupOrder, false, fManager);
- fDisabledProjectSettings.put(curr, oldSetting);
- curr.setStoredValue(fLookupOrder[0], null, fManager); // clear project settings
- }
- }
- }
- }
-
- /* (non-javadoc)
- * Update fields and validate.
- * @param changedKey Key that changed, or null, if all changed.
- */
- protected abstract void validateSettings(Key changedKey, String oldValue, String newValue);
-}
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/BasePreferencePage.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/BasePreferencePage.java
deleted file mode 100644
index 0dc89776db..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/BasePreferencePage.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.ui.internal.preferences;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Base class for APT preference and property pages.
- */
-public abstract class BasePreferencePage extends PropertyAndPreferencePage {
- private BaseConfigurationBlock fConfigurationBlock;
-
- protected Control createPreferenceContent(Composite composite) {
- return getConfigurationBlock().createPreferenceContent(composite);
- }
-
- @Override
- public void createControl(Composite parent) {
- super.createControl(parent);
- String contextId = getContextHelpId();
- if (contextId != null) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), contextId);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#dispose()
- */
- public void dispose() {
- if (getConfigurationBlock() != null) {
- getConfigurationBlock().dispose();
- }
- super.dispose();
- }
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
- */
- protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
- if (getConfigurationBlock() != null) {
- getConfigurationBlock().useProjectSpecificSettings(useProjectSpecificSettings);
- }
- super.enableProjectSpecificSettings(useProjectSpecificSettings);
- }
-
- protected BaseConfigurationBlock getConfigurationBlock() {
- return fConfigurationBlock;
- }
-
- /**
- * Derived classes should override by returning a string that refers
- * to a context topic entry in docs/contexts_APT.xml. The default
- * implementation returns null, which causes context help to be disabled.
- */
- protected String getContextHelpId() {
- return null;
- }
-
- protected boolean hasProjectSpecificOptions(IProject project) {
- // Workaround for bug 106111 / 111144:
- // See BaseConfigurationBlock.hasProjectSpecificOptionsNoCache() for details.
- return getConfigurationBlock().hasProjectSpecificOptionsNoCache(project);
- }
-
- /*
- * See bug 136498: don't show workspace preferences.
- */
- @Override
- protected boolean offerLink() {
- return false;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performApply()
- */
- public void performApply() {
- if (getConfigurationBlock() != null) {
- getConfigurationBlock().performApply();
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- if (getConfigurationBlock() != null) {
- getConfigurationBlock().performDefaults();
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- if (getConfigurationBlock() != null && !getConfigurationBlock().performOk()) {
- return false;
- }
- return super.performOk();
- }
-
- protected void setConfigurationBlock(BaseConfigurationBlock configurationBlock) {
- fConfigurationBlock = configurationBlock;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
- */
- public void setElement(IAdaptable element) {
- super.setElement(element);
- setDescription(null); // no description for property page
- }
-}
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/FactoryPathConfigurationBlock.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/FactoryPathConfigurationBlock.java
deleted file mode 100644
index bc25f4d0c5..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/FactoryPathConfigurationBlock.java
+++ /dev/null
@@ -1,742 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.ui.internal.preferences;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPathUtil;
-import org.eclipse.jdt.apt.core.internal.util.FactoryPath.Attributes;
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.apt.core.util.IFactoryPath;
-import org.eclipse.jdt.apt.ui.internal.util.ExceptionHandler;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.internal.ui.util.PixelConverter;
-import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-
-/**
- * Data and controls for the Java Annotation Factory Path preference page.
- */
-public class FactoryPathConfigurationBlock extends BaseConfigurationBlock {
-
- private static final int IDX_UP= 0;
- private static final int IDX_DOWN= 1;
- // 2
- private static final int IDX_ADDJAR= 3;
- private static final int IDX_ADDEXTJAR= 4;
- private static final int IDX_ADDVAR= 5;
- // 6
- private static final int IDX_EDIT= 7;
- private static final int IDX_ADVANCED= 8;
- private static final int IDX_REMOVE= 9;
- // 10
- private static final int IDX_ENABLEALL= 11;
- private static final int IDX_DISABLEALL= 12;
-
- private final static String[] buttonLabels = {
- Messages.FactoryPathConfigurationBlock_up,
- Messages.FactoryPathConfigurationBlock_down,
- null, // 2
- Messages.FactoryPathConfigurationBlock_addJars,
- Messages.FactoryPathConfigurationBlock_addExternalJars,
- Messages.FactoryPathConfigurationBlock_addVariable,
- null, // 6
- Messages.FactoryPathConfigurationBlock_edit,
- Messages.FactoryPathConfigurationBlock_advanced,
- Messages.FactoryPathConfigurationBlock_remove,
- null, // 10
- Messages.FactoryPathConfigurationBlock_enableAll,
- Messages.FactoryPathConfigurationBlock_disableAll
- };
-
- /**
- * Event handler for factory path list control
- */
- private class FactoryPathAdapter implements IListAdapter, IDialogFieldListener {
- public void customButtonPressed(ListDialogField field, int index) {
- FactoryPathConfigurationBlock.this.customButtonPressed(index);
- }
-
- public void selectionChanged(ListDialogField field) {
- boolean enableRemove = canRemove();
- field.enableButton(IDX_REMOVE, enableRemove);
- boolean enableEdit = canEdit();
- field.enableButton(IDX_EDIT, enableEdit);
- boolean enableAdvanced = canAdvanced();
- field.enableButton(IDX_ADVANCED, enableAdvanced);
- }
-
- /**
- * This method gets called when, among other things, a checkbox is
- * clicked. However, it doesn't get any information about which
- * item it was whose checkbox was clicked. We could hook into the
- * list control's CheckboxTableViewer event listener for changes to
- * individual checkboxes; but that does not get called for enableAll
- * and disableAll events.
- */
- public void dialogFieldChanged(DialogField field) {
- if (!fSettingListContents) {
- updateFactoryPathEntries();
- }
- }
-
- public void doubleClicked(ListDialogField field) {
- if (canEdit()) {
- editSelectedItem();
- }
- }
- }
-
- private class FactoryPathLabelProvider extends LabelProvider implements ITableLabelProvider {
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- if (!(element instanceof FactoryPathEntry)) {
- return ""; //$NON-NLS-1$
- }
- FactoryPathEntry fpe = (FactoryPathEntry)element;
- if (columnIndex == 0) {
- return fpe._fc.toString();
- }
- else {
- return ""; //$NON-NLS-1$
- }
- }
- }
-
- /**
- * The factory path is a list of containers, plus some information about
- * each container. That makes it a list of FactoryPathEntry.
- */
- private static class FactoryPathEntry {
- /* shallow copies - beware! */
- public final FactoryContainer _fc;
- public FactoryPath.Attributes _attr;
-
- // CONSTRUCTORS
- public FactoryPathEntry(FactoryContainer fc, FactoryPath.Attributes attr) {
- _fc = fc;
- _attr = attr;
- }
-
- // CONVERSION TO/FROM INDIVIDUAL ELEMENTS
- public static Map<FactoryContainer, Attributes> pathMapFromList(List<FactoryPathEntry> list) {
- Map<FactoryContainer, FactoryPath.Attributes> map =
- new LinkedHashMap<FactoryContainer, FactoryPath.Attributes>(list.size());
- for (FactoryPathEntry fpe : list) {
- map.put(fpe._fc, fpe._attr);
- }
- return map;
- }
- public static List<FactoryPathEntry> pathListFromMap(Map<FactoryContainer, Attributes> map) {
- List<FactoryPathEntry> list = new ArrayList<FactoryPathEntry>(map.size());
- for (Map.Entry<FactoryContainer, Attributes> entry : map.entrySet()) {
- FactoryPathEntry fpe = new FactoryPathEntry(entry.getKey(), entry.getValue());
- list.add(fpe);
- }
- return list;
- }
-
- // SUPPORT FOR COMPARISON
- public boolean equals(Object obj) {
- if (!(obj instanceof FactoryPathEntry))
- return false;
- FactoryPathEntry fpe = (FactoryPathEntry)obj;
- return _fc.equals(fpe._fc) && _attr.equals(fpe._attr);
- }
- public int hashCode() {
- return _fc.hashCode() ^ _attr.hashCode();
- }
-
- }
-
- private PixelConverter fPixelConverter;
- private Composite fBlockControl; // the control representing the entire configuration block
-
- /**
- * The factory path at the time this pref pane was launched.
- * Use this to see if anything changed at save time.
- */
- private List<FactoryPathEntry> fOriginalPath;
-
- private final IJavaProject fJProj;
-
- /**
- * The GUI control representing the factory path. Its data items
- * are of type FactoryPathEntry.
- */
- private CheckedListDialogField fFactoryPathList;
-
- /**
- * True while inside setListContents(). Used in order to efficiently
- * and correctly add new elements to the factory list: short-circuits
- * the factory list field listener code.
- */
- private boolean fSettingListContents = false;
-
- public FactoryPathConfigurationBlock(IStatusChangeListener context,
- IProject project, IWorkbenchPreferenceContainer container) {
- super(context, project, new Key[] {}, container);
-
- fJProj = JavaCore.create(project);
-
- FactoryPathAdapter adapter= new FactoryPathAdapter();
- FactoryPathLabelProvider labelProvider = new FactoryPathLabelProvider();
-
- fFactoryPathList= new CheckedListDialogField(adapter, buttonLabels, labelProvider);
- fFactoryPathList.setDialogFieldListener(adapter);
- fFactoryPathList.setLabelText(Messages.FactoryPathConfigurationBlock_pluginsAndJars);
- fFactoryPathList.setUpButtonIndex(IDX_UP);
- fFactoryPathList.setDownButtonIndex(IDX_DOWN);
- fFactoryPathList.setRemoveButtonIndex(IDX_REMOVE);
- fFactoryPathList.setCheckAllButtonIndex(IDX_ENABLEALL);
- fFactoryPathList.setUncheckAllButtonIndex(IDX_DISABLEALL);
- }
-
- /**
- * Respond to the user checking the "enabled" checkbox of an entry
- * in the factory path control, by replacing the FactoryPathEntry
- * with a new one with the correct "enabled" value.
- * We don't have information about which entry was changed, so we
- * have to look at all of them. This is inefficient - somewhere
- * around O(n log n) depending on how the list is implemented - but
- * hopefully the list is not so huge that it's a problem.
- */
- private void updateFactoryPathEntries() {
- for (FactoryPathEntry fpe : getListContents()) {
- boolean checked = fFactoryPathList.isChecked(fpe);
- if (checked != fpe._attr.isEnabled()) {
- fpe._attr.setEnabled(checked);
- }
- }
- }
-
- /**
- * Respond to a button in the button bar.
- * Most buttons are handled by code in CheckedListDialogField;
- * this method is for the rest, e.g., Add External Jar.
- * @param index
- */
- public void customButtonPressed(int index) {
- FactoryPathEntry[] newEntries = null;
- switch (index) {
- case IDX_ADDJAR: // add jars in project
- newEntries= openJarFileDialog(null);
- addEntries(newEntries);
- break;
-
- case IDX_ADDEXTJAR: // add external jars
- newEntries= openExtJarFileDialog(null);
- addEntries(newEntries);
- break;
-
- case IDX_ADDVAR: // add jar from classpath variable
- newEntries= openVariableSelectionDialog(null);
- addEntries(newEntries);
- break;
-
- case IDX_EDIT: // edit selected item
- if (canEdit()) {
- editSelectedItem();
- }
- break;
-
- case IDX_ADVANCED: // advanced options
- advancedOptionsDialog();
- break;
- }
-
- }
-
- /**
- * Can't remove a selection that contains a plugin.
- */
- private boolean canRemove() {
- List<FactoryPathEntry> selected= getSelectedListContents();
- boolean containsPlugin= false;
- for (FactoryPathEntry fpe : selected) {
- if (fpe._fc.getType() == FactoryContainer.FactoryType.PLUGIN) {
- containsPlugin = true;
- break;
- }
- }
- return !containsPlugin;
- }
-
- /**
- * Can only edit a single item at a time. Can't edit plugins.
- */
- private boolean canEdit() {
- List<FactoryPathEntry> selected= getSelectedListContents();
- if (selected.size() != 1) {
- return false;
- }
- FactoryContainer fc = selected.get(0)._fc;
- return (fc.getType() != FactoryContainer.FactoryType.PLUGIN);
- }
-
- /**
- * Can only launch the 'advanced' dialog on a single item at a time.
- */
- private boolean canAdvanced() {
- List<FactoryPathEntry> selected= getSelectedListContents();
- return (selected.size() == 1);
- }
-
- /**
- * Edit the item selected.
- * Precondition: exactly one item is selected in the list,
- * and it is an editable item (not a plugin).
- * @param field a listbox of FactoryContainers.
- */
- private void editSelectedItem() {
- List<FactoryPathEntry> selected= getSelectedListContents();
- if (selected.size() != 1) {
- return;
- }
- FactoryPathEntry original = selected.get(0);
- FactoryPathEntry[] edited = null;
- switch (original._fc.getType()) {
- case PLUGIN:
- return;
- case EXTJAR:
- edited= openExtJarFileDialog(original);
- break;
- case VARJAR:
- edited= openVariableSelectionDialog(original);
- break;
- case WKSPJAR:
- edited= openJarFileDialog(original);
- break;
- }
- if (edited != null && edited.length > 0) {
- fFactoryPathList.replaceElement(original, edited[0]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.ui.internal.preferences.BaseConfigurationBlock#createContents(org.eclipse.swt.widgets.Composite)
- */
- protected Control createContents(Composite parent) {
- setShell(parent.getShell());
-
- fPixelConverter= new PixelConverter(parent);
-
- fBlockControl= new Composite(parent, SWT.NONE);
- fBlockControl.setFont(parent.getFont());
-
- Dialog.applyDialogFont(fBlockControl);
-
- LayoutUtil.doDefaultLayout(fBlockControl, new DialogField[] { fFactoryPathList }, true, SWT.DEFAULT, SWT.DEFAULT);
- LayoutUtil.setHorizontalGrabbing(fFactoryPathList.getListControl(null));
-
- fFactoryPathList.enableButton(IDX_ADDJAR, (fJProj != null));
- // bugzilla 139101: only enable Advanced and Edit buttons if there is a selection
- fFactoryPathList.enableButton(IDX_ADVANCED, false);
- fFactoryPathList.enableButton(IDX_EDIT, false);
- int buttonBarWidth= fPixelConverter.convertWidthInCharsToPixels(24);
- fFactoryPathList.setButtonsMinWidth(buttonBarWidth);
-
- return fBlockControl;
- }
-
- @Override
- public boolean hasProjectSpecificOptionsNoCache(IProject project) {
- return (project == null) ? false : AptConfig.hasProjectSpecificFactoryPath(JavaCore.create(project));
- }
-
- /**
- * Initialize the user interface based on the cached original settings.
- */
- @Override
- protected void initContents() {
- setListContents(fOriginalPath);
- }
-
- /**
- * Save reference copies of the settings, so we can see if anything changed.
- * This must stay in sync with the actual saved values for the rebuild logic
- * to work; so be sure to call this any time you save (eg in performApply()).
- */
- @Override
- protected void cacheOriginalValues() {
- IFactoryPath ifp = AptConfig.getFactoryPath(fJProj);
- // we'll risk this downcast because we're such good buddies with apt.core.
- FactoryPath fp = (FactoryPath)ifp;
- Map<FactoryContainer, FactoryPath.Attributes> path = fp.getAllContainers();
- fOriginalPath = FactoryPathEntry.pathListFromMap(path);
- super.cacheOriginalValues();
- }
-
- /*
- * Helper method to get rid of unchecked conversion warning
- */
- @SuppressWarnings("unchecked")
- private List<FactoryPathEntry> getListContents() {
- List<FactoryPathEntry> contents= fFactoryPathList.getElements();
- return contents;
- }
-
- /*
- * Helper method to get rid of unchecked conversion warning
- */
- @SuppressWarnings("unchecked")
- private List<FactoryPathEntry> getSelectedListContents() {
- List<FactoryPathEntry> contents= fFactoryPathList.getSelectedElements();
- return contents;
- }
-
- /**
- * Add new entries to the list control. Differs from setListContents()
- * in that the list is not cleared first, and the entries are not copied
- * before being added to the list.
- * @param entries can be null.
- */
- private void addEntries(FactoryPathEntry[] entries) {
- if (null == entries) {
- return;
- }
- int insertAt;
- List<FactoryPathEntry> selectedElements= getSelectedListContents();
- if (selectedElements.size() == 1) {
- insertAt= fFactoryPathList.getIndexOfElement(selectedElements.get(0)) + 1;
- } else {
- insertAt= fFactoryPathList.getSize();
- }
- try {
- fSettingListContents = true;
- for (int i = 0; i < entries.length; ++i) {
- fFactoryPathList.addElement(entries[i], insertAt + i);
- fFactoryPathList.setChecked(entries[i], entries[i]._attr.isEnabled());
- }
- }
- finally {
- fSettingListContents = false;
- }
- }
-
- /**
- * Set the contents of the list control. The FPEs in the input list
- * will be copied; the originals are left untouched, so that if the
- * list control's contents are modified they can be compared with the
- * original.
- * @param fpeList can be null.
- */
- private void setListContents(List<FactoryPathEntry> fpeList) {
- try {
- fSettingListContents = true;
- fFactoryPathList.removeAllElements();
- if (fpeList == null) {
- return;
- }
- for (FactoryPathEntry originalFpe : fpeList) {
- // clone, because we may later want to compare with the original.
- FactoryPathEntry fpe = new FactoryPathEntry(originalFpe._fc, new Attributes(originalFpe._attr));
- fFactoryPathList.addElement(fpe);
- fFactoryPathList.setChecked(fpe, fpe._attr.isEnabled());
- }
- }
- finally {
- fSettingListContents = false;
- }
- }
-
- /**
- * Get all the containers of a certain type currently on the list.
- * The format of the returned paths will depend on the container type:
- * for EXTJAR it will be an absolute path; for WKSPJAR it will be a
- * path relative to the workspace root; for VARJAR it will be a path
- * whose first segment is the name of a classpath variable.
- * @param type may not be PLUGIN
- * @param ignore null, or an item to not put on the list (used when
- * editing an existing item).
- * @return an array, possibly empty (but never null)
- */
- private IPath[] getExistingPaths(FactoryContainer.FactoryType type, FactoryContainer ignore) {
- if (type == FactoryContainer.FactoryType.PLUGIN) {
- throw new IllegalArgumentException();
- }
- List<FactoryPathEntry> all = getListContents();
- // find out how many entries there are of this type
- int countType = 0;
- for (FactoryPathEntry fpe : all) {
- FactoryContainer fc = fpe._fc;
- if (fc.getType() == type && fc != ignore) {
- ++countType;
- }
- }
- // create an array of paths, one per entry of this type
- IPath[] some = new IPath[countType];
- int i = 0;
- for (FactoryPathEntry fpe : all) {
- FactoryContainer fc = fpe._fc;
- if (fc.getType() == type && fc != ignore) {
- some[i++] = new Path(fc.getId());
- }
- }
- return some;
- }
-
- /**
- * Launch the "advanced options" dialog, which displays the factory classes
- * contained by the selected container and allows the user to specify
- * options that are needed only in certain special cases.
- *
- * We treat advanced options as an attribute of the factory path, not of the
- * container; the same container may have different advanced options in different
- * projects. We treat advanced options the same way as the "enabled" flag.
- */
- private void advancedOptionsDialog() {
- List<FactoryPathEntry> selected= getSelectedListContents();
- if (selected.size() != 1) {
- return;
- }
- FactoryPathEntry original= selected.get(0);
- AdvancedFactoryPathOptionsDialog dialog=
- new AdvancedFactoryPathOptionsDialog(getShell(), original._fc, original._attr);
- if (dialog.open() == Window.OK) {
- original._attr = dialog.getResult();
- // If the dialog could change the enabled attribute, we would also
- // need to update the checkbox in the GUI here. But it doesn't.
- }
- }
-
- /**
- * Add or edit a project-relative jar file. Only possible when editing
- * project properties; this method is disabled in workspace prefs.
- * @param original null, or an existing list entry to be edited
- * @return a list of additional factory path entries to be added
- */
- private FactoryPathEntry[] openJarFileDialog(FactoryPathEntry original) {
- if (fJProj == null) {
- return null;
- }
- IWorkspaceRoot root= fJProj.getProject().getWorkspace().getRoot();
-
- if (original == null) {
- IPath[] results= BuildPathDialogAccess.chooseJAREntries(getShell(), fJProj.getPath(), new IPath[0]);
- if (results == null) {
- return null;
- }
- ArrayList<FactoryPathEntry> res= new ArrayList<FactoryPathEntry>();
- for (int i= 0; i < results.length; i++) {
- IResource resource= root.findMember(results[i]);
- if (resource instanceof IFile) {
- FactoryContainer fc = FactoryPathUtil.newWkspJarFactoryContainer(results[i]);
- // assume defaults of enabled=true, runInAptMode=false
- FactoryPath.Attributes attr = new FactoryPath.Attributes(true, false);
- FactoryPathEntry fpe = new FactoryPathEntry(fc, attr);
- res.add(fpe);
- }
- //TODO: handle missing jars
- }
- return res.toArray(new FactoryPathEntry[res.size()]);
- }
- else {
- IPath[] existingPaths = getExistingPaths(FactoryContainer.FactoryType.WKSPJAR, original._fc);
- IPath result= BuildPathDialogAccess.configureJAREntry(getShell(), new Path(original._fc.getId()), existingPaths);
- if (result == null) {
- return null;
- }
- IResource resource= root.findMember(result);
- if (resource instanceof IFile) {
- FactoryPathEntry[] edited = new FactoryPathEntry[1];
- FactoryContainer fc= FactoryPathUtil.newWkspJarFactoryContainer(result);
- // Use prior value for isEnabled. Assume default of runInAptMode=false
- FactoryPath.Attributes attr = new FactoryPath.Attributes(original._attr.isEnabled(), false);
- edited[0]= new FactoryPathEntry(fc, attr);
- return edited;
- }
- //TODO: handle missing jars
- return null;
- }
- }
-
- /**
- * Add or edit an external (not project-relative) jar file.
- * @param original null, or an existing list entry to be edited
- * @return a list of additional factory path entries to be added
- */
- private FactoryPathEntry[] openExtJarFileDialog(FactoryPathEntry original) {
- if (original == null) {
- IPath[] selected= BuildPathDialogAccess.chooseExternalJAREntries(getShell());
- if (selected == null) {
- return null;
- }
- ArrayList<FactoryPathEntry> res= new ArrayList<FactoryPathEntry>();
- for (int i= 0; i < selected.length; i++) {
- FactoryContainer fc = FactoryPathUtil.newExtJarFactoryContainer(selected[i].toFile());
- // assume defaults of enabled=true, runInAptMode=false
- FactoryPath.Attributes attr = new FactoryPath.Attributes(true, false);
- FactoryPathEntry fpe = new FactoryPathEntry(fc, attr);
- res.add(fpe);
- }
- return res.toArray(new FactoryPathEntry[res.size()]);
- }
- else {
- IPath result= BuildPathDialogAccess.configureExternalJAREntry(getShell(), new Path(original._fc.getId()));
- if (result == null) {
- return null;
- }
- FactoryPathEntry[] edited= new FactoryPathEntry[1];
- FactoryContainer fc= FactoryPathUtil.newExtJarFactoryContainer(result.toFile());
- // Use prior value for isEnabled. Assume default of runInAptMode=false
- FactoryPath.Attributes attr = new FactoryPath.Attributes(original._attr.isEnabled(), false);
- edited[0]= new FactoryPathEntry(fc, attr);
- return edited;
- }
- }
-
- /**
- * Add or edit an external (not project-relative) jar file whose
- * location includes a classpath variable name.
- * @param original null, or an existing list entry to be edited
- * @return a list of additional factory path entries to be added
- */
- private FactoryPathEntry[] openVariableSelectionDialog(FactoryPathEntry original) {
- if (original == null) {
- IPath[] selected= BuildPathDialogAccess.chooseVariableEntries(getShell(), new IPath[0]);
- if (selected == null) {
- return null;
- }
- ArrayList<FactoryPathEntry> res= new ArrayList<FactoryPathEntry>();
- for (int i= 0; i < selected.length; i++) {
- FactoryContainer fc= FactoryPathUtil.newVarJarFactoryContainer(selected[i]);
- // assume defaults of enabled=true, runInAptMode=false
- FactoryPath.Attributes attr = new FactoryPath.Attributes(true, false);
- FactoryPathEntry fpe = new FactoryPathEntry(fc, attr);
- res.add(fpe);
- }
- return res.toArray(new FactoryPathEntry[res.size()]);
- }
- else {
- IPath[] existingPaths = getExistingPaths(FactoryContainer.FactoryType.VARJAR, original._fc);
- IPath result= BuildPathDialogAccess.configureVariableEntry(getShell(), new Path(original._fc.getId()), existingPaths);
- if (result == null) {
- return null;
- }
- FactoryPathEntry[] edited= new FactoryPathEntry[1];
- FactoryContainer fc= FactoryPathUtil.newVarJarFactoryContainer(result);
- // Use prior value for isEnabled. Assume default of runInAptMode=false
- FactoryPath.Attributes attr = new FactoryPath.Attributes(original._attr.isEnabled(), false);
- edited[0]= new FactoryPathEntry(fc, attr);
- return edited;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.ui.internal.preferences.BaseConfigurationBlock#updateModel(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField)
- */
- protected void updateModel(DialogField field) {
- // We don't use IEclipsePreferences for this pane, so no need to do anything.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.apt.ui.internal.preferences.BaseConfigurationBlock#validateSettings(org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock.Key, java.lang.String, java.lang.String)
- */
- protected void validateSettings(Key changedKey, String oldValue, String newValue) {
- // TODO: validate that all the specified factory containers exist?
- }
-
- protected void saveSettings() {
- FactoryPath fp;
- if ((fJProj != null) && !fBlockControl.isEnabled()) {
- // We're in a project properties pane but the entire configuration
- // block control is disabled. That means the per-project settings checkbox
- // is unchecked. To save that state, we'll delete the settings file.
- fp = null;
- }
- else {
- List<FactoryPathEntry> containers;
- Map<FactoryContainer, FactoryPath.Attributes> map;
- containers = getListContents();
- map = FactoryPathEntry.pathMapFromList(containers);
- fp = new FactoryPath();
- fp.setContainers(map);
- }
-
- try {
- AptConfig.setFactoryPath(fJProj, fp);
- }
- catch (CoreException e) {
- final String title = Messages.FactoryPathConfigurationBlock_unableToSaveFactorypath_title;
- final String message = Messages.FactoryPathConfigurationBlock_unableToSaveFactorypath_message;
- ExceptionHandler.handle(e, fBlockControl.getShell(), title, message);
- }
-
- super.saveSettings();
- }
-
- /**
- * If per-project, restore list contents to current workspace settings;
- * the per-project settings checkbox will be cleared for us automatically.
- * If workspace, restore list contents to factory-default settings.
- */
- public void performDefaults() {
- IFactoryPath ifp = AptConfig.getDefaultFactoryPath(fJProj);
- // we'll risk this downcast because we're such good buddies with apt.core.
- FactoryPath fp = (FactoryPath)ifp;
- Map<FactoryContainer, FactoryPath.Attributes> map = fp.getAllContainers();
- List<FactoryPathEntry> defaults = FactoryPathEntry.pathListFromMap(map);
- setListContents(defaults);
- super.performDefaults();
- }
-
- /**
- * @return true if settings or project-specificness changed since
- * the pane was launched - that is, if there is anything to save.
- */
- @Override
- protected boolean settingsChanged(IScopeContext currContext) {
- if (fOriginalPath == null) {
- // shouldn't happen, but just in case it does, consider it a change.
- return true;
- }
- // Is the new path the same size, containing the same items
- // in the same order? We rely on FactoryPathEntry.equals() here.
- List<FactoryPathEntry> newPath = getListContents();
- return !fOriginalPath.equals(newPath);
- }
-
-}
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/FactoryPathPreferencePage.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/FactoryPathPreferencePage.java
deleted file mode 100644
index fda9315303..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/FactoryPathPreferencePage.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.ui.internal.preferences;
-
-import org.eclipse.jdt.apt.ui.internal.AptUIPlugin;
-import org.eclipse.jdt.apt.ui.internal.util.IAptHelpContextIds;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-
-/**
- *
- */
-public class FactoryPathPreferencePage extends BasePreferencePage {
-
- private static final String PREF_ID= "org.eclipse.jdt.apt.ui.preferences.factoryPathPreferences"; //$NON-NLS-1$
- private static final String PROP_ID= "org.eclipse.jdt.apt.ui.propertyPages.factoryPathPreferences"; //$NON-NLS-1$
-
- /**
- *
- */
- public FactoryPathPreferencePage() {
- setPreferenceStore(AptUIPlugin.getDefault().getPreferenceStore());
- //setDescription(Messages.FactoryPathPreferencePage_factoryPath);
-
- // only used when page is shown programatically
- setTitle(Messages.FactoryPathPreferencePage_preferences);
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
- setConfigurationBlock(new FactoryPathConfigurationBlock(getNewStatusChangedListener(), getProject(), container));
-
- super.createControl(parent);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
- */
- protected String getPreferencePageID() {
- return PREF_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
- */
- protected String getPropertyPageID() {
- return PROP_ID;
- }
-
- @Override
- protected String getContextHelpId() {
- return IAptHelpContextIds.FACTORYPATH_PREFERENCE_PAGE;
- }
-
-}
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/Messages.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/Messages.java
deleted file mode 100644
index 73208ff0bf..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/Messages.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.ui.internal.preferences;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.jdt.apt.ui.internal.preferences.messages"; //$NON-NLS-1$
-
- private Messages() {
- }
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- public static String AptConfigurationBlock_enable;
-
- public static String AptConfigurationBlock_enableReconcileProcessing;
-
- public static String AptConfigurationBlock_generatedSrcDir;
-
- public static String AptConfigurationBlock_options;
-
- public static String FactoryPathConfigurationBlock_up;
-
- public static String FactoryPathConfigurationBlock_down;
-
- public static String FactoryPathConfigurationBlock_addJars;
-
- public static String FactoryPathConfigurationBlock_addExternalJars;
-
- public static String FactoryPathConfigurationBlock_addVariable;
-
- public static String FactoryPathConfigurationBlock_remove;
-
- public static String FactoryPathConfigurationBlock_enableAll;
-
- public static String FactoryPathConfigurationBlock_disableAll;
-
- public static String FactoryPathConfigurationBlock_pluginsAndJars;
-
- public static String FactoryPathPreferencePage_factoryPath;
-
- public static String FactoryPathPreferencePage_preferences;
-
- public static String AptPreferencePage_preferences;
-
- public static String AptPreferencePage_preferencesTitle;
-
- public static String BaseConfigurationBlock_settingsChanged;
-
- public static String BaseConfigurationBlock_fullRebuildRequired;
-
- public static String BaseConfigurationBlock_rebuildRequired;
-
- public static String AptConfigurationBlock_classpathAddedAutomaticallyNote;
-
- public static String AptConfigurationBlock_warningIgnoredOptions;
-
- public static String FactoryPathConfigurationBlock_unableToSaveFactorypath_title;
-
- public static String FactoryPathConfigurationBlock_unableToSaveFactorypath_message;
-
- public static String FactoryPathConfigurationBlock_edit;
-
- public static String AptConfigurationBlock_add;
-
- public static String AptConfigurationBlock_edit;
-
- public static String AptConfigurationBlock_remove;
-
- public static String AptConfigurationBlock_key;
-
- public static String AptConfigurationBlock_value;
-
- public static String ProcessorOptionInputDialog_newProcessorOption;
-
- public static String ProcessorOptionInputDialog_editProcessorOption;
-
- public static String ProcessorOptionInputDialog_key;
-
- public static String ProcessorOptionInputDialog_value;
-
- public static String ProcessorOptionInputDialog_emptyKey;
-
- public static String ProcessorOptionInputDialog_keyAlreadyInUse;
-
- public static String ProcessorOptionInputDialog_equalsSignNotValid;
-
- public static String AptConfigurationBlock_genSrcDirMustBeValidRelativePath;
-
- public static String FactoryPathConfigurationBlock_advanced;
-
- public static String AdvancedFactoryPathOptionsDialog_advancedOptions;
-
- public static String AdvancedFactoryPathOptionsDialog_batchMode;
-
- public static String AdvancedFactoryPathOptionsDialog_label_processorsInThisContainer;
-
- public static String AptConfigurationBlock_warningContentsMayBeDeleted;
-}
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/ProcessorOptionInputDialog.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/ProcessorOptionInputDialog.java
deleted file mode 100644
index 5ce4f60b34..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/ProcessorOptionInputDialog.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.ui.internal.preferences;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.apt.ui.internal.preferences.AptConfigurationBlock.ProcessorOption;
-import org.eclipse.jdt.apt.ui.internal.util.IAptHelpContextIds;
-import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringDialogField;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Dialog to edit or add an APT processor option
- */
-public class ProcessorOptionInputDialog extends StatusDialog {
-
- private class FieldAdapter implements IDialogFieldListener {
- public void dialogFieldChanged(DialogField field) {
- doValidation();
- }
- }
-
- private StringDialogField fKeyField;
- private StringDialogField fValueField;
-
- private List<String> fExistingNames;
-
- public ProcessorOptionInputDialog(Shell parent, ProcessorOption option, List<ProcessorOption> existingEntries) {
- super(parent);
-
- fExistingNames= new ArrayList<String>(existingEntries.size());
- for (ProcessorOption o : existingEntries) {
- if (!o.equals(option)) {
- fExistingNames.add(o.key);
- }
- }
-
- if (option == null) {
- setTitle(Messages.ProcessorOptionInputDialog_newProcessorOption);
- } else {
- setTitle(Messages.ProcessorOptionInputDialog_editProcessorOption);
- }
-
- FieldAdapter adapter= new FieldAdapter();
-
- fKeyField= new StringDialogField();
- fKeyField.setLabelText(Messages.ProcessorOptionInputDialog_key);
- fKeyField.setDialogFieldListener(adapter);
-
- fValueField= new StringDialogField();
- fValueField.setLabelText(Messages.ProcessorOptionInputDialog_value);
- fValueField.setDialogFieldListener(adapter);
-
- fKeyField.setText((option != null) ? option.key : ""); //$NON-NLS-1$
- fValueField.setText((option != null) ? option.value : ""); //$NON-NLS-1$
- }
-
- public ProcessorOption getResult() {
- ProcessorOption option = new ProcessorOption();
- option.key= fKeyField.getText().trim();
- option.value= fValueField.getText().trim();
-
- return option;
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
-
- Composite inner= new Composite(composite, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
- inner.setLayout(layout);
-
- fKeyField.doFillIntoGrid(inner, 2);
- fValueField.doFillIntoGrid(inner, 2);
-
- LayoutUtil.setHorizontalGrabbing(fKeyField.getTextControl(null));
- LayoutUtil.setWidthHint(fKeyField.getTextControl(null), convertWidthInCharsToPixels(50));
- LayoutUtil.setHorizontalGrabbing(fValueField.getTextControl(null));
- LayoutUtil.setWidthHint(fValueField.getTextControl(null), convertWidthInCharsToPixels(50));
-
- fKeyField.postSetFocusOnDialogField(parent.getDisplay());
-
- applyDialogFont(composite);
- return composite;
- }
-
- private void doValidation() {
- StatusInfo status= new StatusInfo();
- String newKey= fKeyField.getText();
- String newVal= fValueField.getText();
- // TODO: thorough validation of both key and value
- if (newKey.length() == 0) {
- status.setError(Messages.ProcessorOptionInputDialog_emptyKey);
- } else if (fExistingNames.contains(newKey)) {
- status.setError(Messages.ProcessorOptionInputDialog_keyAlreadyInUse);
- } else if (newVal.indexOf('=') >= 0) {
- status.setError(Messages.ProcessorOptionInputDialog_equalsSignNotValid);
- } else if (AptConfig.isAutomaticProcessorOption(newKey)) {
- status.setWarning(Messages.AptConfigurationBlock_warningIgnoredOptions);
- }
- updateStatus(status);
- }
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IAptHelpContextIds.PROCESSOR_OPTION_INPUT_DIALOG);
- }
-}
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/messages.properties b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/messages.properties
deleted file mode 100644
index 3379f7d517..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/messages.properties
+++ /dev/null
@@ -1,50 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 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
-###############################################################################
-AptConfigurationBlock_enable=Enable annotation &processing
-AptConfigurationBlock_add=&New...
-AptConfigurationBlock_key=Key
-AptConfigurationBlock_edit=&Edit...
-AptConfigurationBlock_remove=&Remove
-AptConfigurationBlock_value=Value
-AptConfigurationBlock_generatedSrcDir=&Generated source directory:
-AptConfigurationBlock_warningIgnoredOptions=An automatically set option will override this option
-AptConfigurationBlock_warningContentsMayBeDeleted=Contents of generated source directory may be deleted
-AptConfigurationBlock_enableReconcileProcessing=Enable processing in edito&r
-AptConfigurationBlock_classpathAddedAutomaticallyNote=Note: options such as \"-classpath\" and \"-sourcepath\" are automatically passed to all processors, with values corresponding to the project's Java settings.
-AptConfigurationBlock_genSrcDirMustBeValidRelativePath=Generated source directory must be a valid relative path
-AptConfigurationBlock_options=Processor options (-Akey=value):
-AptPreferencePage_preferences=Specify the default annotation processor settings for new projects:
-AptPreferencePage_preferencesTitle=Java Annotation Processing Preferences
-FactoryPathConfigurationBlock_up=&Up
-FactoryPathConfigurationBlock_down=Do&wn
-FactoryPathConfigurationBlock_edit=&Edit...
-FactoryPathConfigurationBlock_addJars=Add &JARs...
-FactoryPathConfigurationBlock_advanced=Advan&ced...
-FactoryPathConfigurationBlock_addExternalJars=Add E&xternal JARs...
-FactoryPathConfigurationBlock_unableToSaveFactorypath_title=Save Factory Path
-FactoryPathConfigurationBlock_unableToSaveFactorypath_message=Unable to save factory path.
-FactoryPathConfigurationBlock_addVariable=Add &Variable...
-FactoryPathConfigurationBlock_remove=&Remove
-FactoryPathConfigurationBlock_enableAll=Ena&ble All
-FactoryPathConfigurationBlock_disableAll=Di&sable All
-FactoryPathConfigurationBlock_pluginsAndJars=Plug-ins and JARs that contain annotation processors:
-FactoryPathPreferencePage_factoryPath=Java annotation processor factory path:
-FactoryPathPreferencePage_preferences=Factory Path Preferences
-BaseConfigurationBlock_settingsChanged=Annotation Processing Settings Changed
-BaseConfigurationBlock_fullRebuildRequired=The annotation processing settings have changed. A full rebuild is required for changes to take effect. Do the full build now?
-BaseConfigurationBlock_rebuildRequired=The annotation processing settings have changed. A rebuild of the project is required for changes to take effect. Do the project build now?
-ProcessorOptionInputDialog_newProcessorOption=New Processor Option
-ProcessorOptionInputDialog_keyAlreadyInUse=That key is already in use
-ProcessorOptionInputDialog_editProcessorOption=Edit Processor Option
-ProcessorOptionInputDialog_equalsSignNotValid=The equals sign is not a valid character
-ProcessorOptionInputDialog_key=&Key:
-ProcessorOptionInputDialog_value=&Value:
-ProcessorOptionInputDialog_emptyKey=Please enter a key
-AdvancedFactoryPathOptionsDialog_advancedOptions=Advanced Options
-AdvancedFactoryPathOptionsDialog_label_processorsInThisContainer=Processors in this container:
-AdvancedFactoryPathOptionsDialog_batchMode=&Run this container's processors in batch mode
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/ExceptionHandler.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/ExceptionHandler.java
deleted file mode 100644
index 060c1189f0..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/ExceptionHandler.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation, BEA Systems, Inc., 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:
- * wharley@bea.com - based on org.eclipse.jdt.internal.ui.util.ExceptionHandler
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.ui.internal.util;
-
-import java.io.StringWriter;
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.apt.ui.internal.AptUIPlugin;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * This code is
- * The default exception handler shows an error dialog when one of its handle methods
- * is called. If the passed exception is a <code>CoreException</code> an error dialog
- * pops up showing the exception's status information. For a <code>InvocationTargetException</code>
- * a normal message dialog pops up showing the exception's message. Additionally the exception
- * is written to the platform log.
- */
-public class ExceptionHandler {
-
- private static ExceptionHandler fgInstance= new ExceptionHandler();
-
- /**
- * Logs the given exception using the platform's logging mechanism. The exception is
- * logged as an error with the error code <code>AptUIPlugin.INTERNAL_ERROR</code>.
- */
- public static void log(Throwable t, String message) {
- AptUIPlugin.log(new Status(IStatus.ERROR, AptUIPlugin.PLUGIN_ID,
- AptUIPlugin.INTERNAL_ERROR, message, t));
- }
-
- /**
- * Handles the given <code>CoreException</code>. The workbench shell is used as a parent
- * for the dialog window.
- *
- * @param e the <code>CoreException</code> to be handled
- * @param title the dialog window's window title
- * @param message message to be displayed by the dialog window
- */
- public static void handle(CoreException e, String title, String message) {
- handle(e, AptUIPlugin.getActiveWorkbenchShell(), title, message);
- }
-
- /**
- * Handles the given <code>CoreException</code>.
- *
- * @param e the <code>CoreException</code> to be handled
- * @param parent the dialog window's parent shell
- * @param title the dialog window's window title
- * @param message message to be displayed by the dialog window
- */
- public static void handle(CoreException e, Shell parent, String title, String message) {
- fgInstance.perform(e, parent, title, message);
- }
-
- /**
- * Handles the given <code>InvocationTargetException</code>. The workbench shell is used
- * as a parent for the dialog window.
- *
- * @param e the <code>InvocationTargetException</code> to be handled
- * @param title the dialog window's window title
- * @param message message to be displayed by the dialog window
- */
- public static void handle(InvocationTargetException e, String title, String message) {
- handle(e, AptUIPlugin.getActiveWorkbenchShell(), title, message);
- }
-
- /**
- * Handles the given <code>InvocationTargetException</code>.
- *
- * @param e the <code>InvocationTargetException</code> to be handled
- * @param parent the dialog window's parent shell
- * @param title the dialog window's window title
- * @param message message to be displayed by the dialog window
- */
- public static void handle(InvocationTargetException e, Shell parent, String title, String message) {
- fgInstance.perform(e, parent, title, message);
- }
-
- //---- Hooks for subclasses to control exception handling ------------------------------------
-
- protected void perform(CoreException e, Shell shell, String title, String message) {
- AptUIPlugin.log(e);
- IStatus status= e.getStatus();
- if (status != null) {
- ErrorDialog.openError(shell, title, message, status);
- } else {
- displayMessageDialog(e, e.getMessage(), shell, title, message);
- }
- }
-
- protected void perform(InvocationTargetException e, Shell shell, String title, String message) {
- Throwable target= e.getTargetException();
- if (target instanceof CoreException) {
- perform((CoreException)target, shell, title, message);
- } else {
- AptUIPlugin.log(e);
- if (e.getMessage() != null && e.getMessage().length() > 0) {
- displayMessageDialog(e, e.getMessage(), shell, title, message);
- } else {
- displayMessageDialog(e, target.getMessage(), shell, title, message);
- }
- }
- }
-
- //---- Helper methods -----------------------------------------------------------------------
-
- private void displayMessageDialog(Throwable t, String exceptionMessage, Shell shell, String title, String message) {
- StringWriter msg= new StringWriter();
- if (message != null) {
- msg.write(message);
- msg.write("\n\n"); //$NON-NLS-1$
- }
- if (exceptionMessage == null || exceptionMessage.length() == 0)
- msg.write(Messages.ExceptionHandler_seeErrorLog);
- else
- msg.write(exceptionMessage);
- MessageDialog.openError(shell, title, msg.toString());
- }
-}
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/IAptHelpContextIds.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/IAptHelpContextIds.java
deleted file mode 100644
index aa6b00a9ab..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/IAptHelpContextIds.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.ui.internal.util;
-
-import org.eclipse.jdt.apt.ui.internal.AptUIPlugin;
-
-/**
- * Help context ids for the Java annotation processing UI.
- * <p>
- * This interface contains constants only; it is not intended to be implemented
- * or extended.
- */
-public interface IAptHelpContextIds {
- public static final String PREFIX= AptUIPlugin.PLUGIN_ID + '.';
-
- // Dialogs
- public static final String ADVANCED_FACTORYPATH_OPTIONS_DIALOG= PREFIX + "advanced_factory_path_options_dialog_context"; //$NON-NLS-1$
- public static final String PROCESSOR_OPTION_INPUT_DIALOG= PREFIX + "processor_option_input_dialog_context"; //$NON-NLS-1$
-
- // Preference/Property pages
- public static final String APTCONFIGURATION_PREFERENCE_PAGE= PREFIX + "apt_configuration_preference_page_context"; //$NON-NLS-1$
- public static final String FACTORYPATH_PREFERENCE_PAGE= PREFIX + "factory_path_preference_page_context"; //$NON-NLS-1$
-}
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/Messages.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/Messages.java
deleted file mode 100644
index e2394d5488..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/Messages.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:
- * wharley@bea.com - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.apt.ui.internal.util;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- *
- */
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.jdt.apt.ui.internal.util.messages"; //$NON-NLS-1$
-
- private Messages() {
- }
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- public static String ExceptionHandler_seeErrorLog;
-}
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/messages.properties b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/messages.properties
deleted file mode 100644
index 24bcf03fb7..0000000000
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/util/messages.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 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
-###############################################################################
-ExceptionHandler_seeErrorLog=See error log for more details.
diff --git a/org.eclipse.jdt.compiler.apt.tests/.classpath b/org.eclipse.jdt.compiler.apt.tests/.classpath
deleted file mode 100644
index 8c8c8d2b5d..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="processors"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jdt.compiler.apt.tests/.cvsignore b/org.eclipse.jdt.compiler.apt.tests/.cvsignore
deleted file mode 100644
index 00e03f5941..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-bin
-lib \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/.project b/org.eclipse.jdt.compiler.apt.tests/.project
deleted file mode 100644
index 42bae08041..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.compiler.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.compiler.apt.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jdt.compiler.apt.tests/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index dbefeaa4c5..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,62 +0,0 @@
-#Tue Dec 05 20:54:14 EST 2006
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-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.discouragedReference=ignore
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
-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.forbiddenReference=ignore
-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.nullReference=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-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.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-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=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.eclipse.jdt.compiler.apt.tests/.settings/org.eclipse.pde.prefs b/org.eclipse.jdt.compiler.apt.tests/.settings/org.eclipse.pde.prefs
deleted file mode 100644
index 86ec428404..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/.settings/org.eclipse.pde.prefs
+++ /dev/null
@@ -1,16 +0,0 @@
-#Mon Nov 05 17:20:35 PST 2007
-compilers.incompatible-environment=1
-compilers.p.build=1
-compilers.p.deprecated=1
-compilers.p.missing-bundle-classpath-entries=2
-compilers.p.missing-packages=2
-compilers.p.no-required-att=0
-compilers.p.not-externalized-att=2
-compilers.p.unknown-attribute=1
-compilers.p.unknown-class=1
-compilers.p.unknown-element=1
-compilers.p.unknown-resource=1
-compilers.p.unresolved-ex-points=0
-compilers.p.unresolved-import=0
-compilers.use-project=true
-eclipse.preferences.version=1
diff --git a/org.eclipse.jdt.compiler.apt.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.compiler.apt.tests/META-INF/MANIFEST.MF
deleted file mode 100644
index e8b7f40f03..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,21 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jdt.compiler.apt.tests;singleton:=true
-Bundle-Version: 1.0.100.qualifier
-Bundle-Vendor: %providerName
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Require-Bundle: org.junit,
- org.eclipse.jdt.core;bundle-version="3.3.0",
- org.eclipse.core.resources,
- org.eclipse.core.runtime
-Bundle-ClassPath: compilerapttests.jar
-Export-Package: org.eclipse.jdt.compiler.apt.tests,
- org.eclipse.jdt.compiler.apt.tests.annotations,
- org.eclipse.jdt.compiler.apt.tests.processors.base,
- org.eclipse.jdt.compiler.apt.tests.processors.checkargs,
- org.eclipse.jdt.compiler.apt.tests.processors.elements,
- org.eclipse.jdt.compiler.apt.tests.processors.genclass,
- org.eclipse.jdt.compiler.apt.tests.processors.visitors
-Import-Package: org.eclipse.jdt.internal.compiler.tool;resolution:=optional
diff --git a/org.eclipse.jdt.compiler.apt.tests/README.TXT b/org.eclipse.jdt.compiler.apt.tests/README.TXT
deleted file mode 100644
index 51ce093b48..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/README.TXT
+++ /dev/null
@@ -1,5 +0,0 @@
-Tips for writing compiler APT tests:
-
- - If you add or modify an annotation processor, you must create a new test processor jar.
- To do so, right-click on apttestprocessors.jardesc and select "Create Jar". The jar file
- must be committed to CVS along with the new processor code. \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/about.html b/org.eclipse.jdt.compiler.apt.tests/about.html
deleted file mode 100644
index 460233046e..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 2, 2006</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/apttestprocessors.jardesc b/org.eclipse.jdt.compiler.apt.tests/apttestprocessors.jardesc
deleted file mode 100644
index de0517361e..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/apttestprocessors.jardesc
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="WINDOWS-1252"?>
-<jardesc>
-<jar path="org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar"/>
-<options buildIfNeeded="true" compress="true" descriptionLocation="/org.eclipse.jdt.compiler.apt.tests/apttestprocessors.jardesc" exportErrors="false" exportWarnings="true" includeDirectoryEntries="false" overwrite="true" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
-<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
-<selectedProjects/>
-<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
-<sealing sealJar="false">
-<packagesToSeal/>
-<packagesToUnSeal/>
-</sealing>
-</manifest>
-<selectedElements exportClassFiles="true" exportJavaFiles="true" exportOutputFolder="false">
-<javaElement handleIdentifier="=org.eclipse.jdt.compiler.apt.tests/processors"/>
-</selectedElements>
-</jardesc>
diff --git a/org.eclipse.jdt.compiler.apt.tests/build.properties b/org.eclipse.jdt.compiler.apt.tests/build.properties
deleted file mode 100644
index 1b1029a05e..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/build.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 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
-###############################################################################
-bin.includes = about.html,\
- plugin.properties,\
- test.xml,\
- compilerapttests.jar,\
- META-INF/,\
- lib/apttestprocessors.jar,\
- resources/
-src.includes = about.html
-source.compilerapttests.jar = src/
-jars.compile.order = compilerapttests.jar,\
- lib/apttestprocessors.jar
-source.lib/apttestprocessors.jar = processors/
-output.compilerapttests.jar = bin/
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
deleted file mode 100644
index da9b4712f0..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.compiler.apt.tests/plugin.properties b/org.eclipse.jdt.compiler.apt.tests/plugin.properties
deleted file mode 100644
index e2ee11fb77..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/plugin.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2006 BEA Systems Inc. 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:
-# wharley@bea.com - initial API and implementation
-###############################################################################
-providerName=Eclipse.org
-pluginName=Java Annotation Processing Tests
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/META-INF/services/javax.annotation.processing.Processor b/org.eclipse.jdt.compiler.apt.tests/processors/META-INF/services/javax.annotation.processing.Processor
deleted file mode 100644
index 4f7f924a49..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/META-INF/services/javax.annotation.processing.Processor
+++ /dev/null
@@ -1,12 +0,0 @@
-org.eclipse.jdt.compiler.apt.tests.processors.genclass.GenClassProc
-org.eclipse.jdt.compiler.apt.tests.processors.checkargs.CheckArgsProc
-org.eclipse.jdt.compiler.apt.tests.processors.elements.ElementProc
-org.eclipse.jdt.compiler.apt.tests.processors.filer.FilerProc
-org.eclipse.jdt.compiler.apt.tests.processors.messager.MessagerProc
-org.eclipse.jdt.compiler.apt.tests.processors.generics.GenericsProc
-org.eclipse.jdt.compiler.apt.tests.processors.inherited.InheritedAnnoProc
-org.eclipse.jdt.compiler.apt.tests.processors.visitors.VisitorProc
-org.eclipse.jdt.compiler.apt.tests.processors.elementutils.ElementUtilsProc
-org.eclipse.jdt.compiler.apt.tests.processors.typemirror.TypeMirrorProc
-org.eclipse.jdt.compiler.apt.tests.processors.typeutils.TypeUtilsProc
-org.eclipse.jdt.compiler.apt.tests.processors.negative.NegativeModelProc
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/CheckArgs.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/CheckArgs.java
deleted file mode 100644
index ebdd5ea51c..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/CheckArgs.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests.annotations;
-
-/**
- * @see org.eclipse.jdt.compiler.apt.tests.processors.checkargs.CheckArgsProc
- */
-public @interface CheckArgs {
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/GenClass.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/GenClass.java
deleted file mode 100644
index 73cb01b204..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/GenClass.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.compiler.apt.tests.annotations;
-
-/**
- * Processing this annotation will produce a class whose name is the value of
- * <code>clazz</code>, with a method whose name is the value of
- * <code>method</code> and whose return type is <code>String</code>.
- * @see org.eclipse.jdt.compiler.apt.tests.processors.genclass.GenClassProc
- */
-public @interface GenClass {
- String clazz();
- String method();
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/GenResource.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/GenResource.java
deleted file mode 100644
index 2973f12850..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/GenResource.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests.annotations;
-
-/**
- * This annotation may be processed to generate a non-Java resource,
- * using the Filer.createResource() API
- */
-public @interface GenResource {
-
- /**
- * package location in which to generate the file, relative to generated file output location.
- */
- String pkg() default "";
-
- /**
- * path of resource file to generate, relative to pkg.
- */
- String relativeName();
-
- /**
- * content of generated resource, or empty string to use binaryContent
- */
- String stringContent() default "";
-
- /**
- * content of generated resource, if stringContent is empty
- */
- byte[] binaryContent() default {};
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/InheritedAnno.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/InheritedAnno.java
deleted file mode 100644
index 1d1e54c401..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/InheritedAnno.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests.annotations;
-
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(value=RetentionPolicy.RUNTIME)
-@Inherited
-public @interface InheritedAnno {} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/TypedAnnos.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/TypedAnnos.java
deleted file mode 100644
index 587f7c70c3..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/annotations/TypedAnnos.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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 implementation
- *
- *******************************************************************************/
-package org.eclipse.jdt.compiler.apt.tests.annotations;
-
-/**
- * These annotation types are visible to processor code and can thus be used
- * with {@link javax.lang.model.element.Element#getAnnotation(Class)}, which
- * returns a reflection proxy of the actual annotation class rather than just
- * an AnnotationMirror.
- */
-public @interface TypedAnnos
-{
- public enum Enum { A, B, C }
-
- public @interface AnnoByte {
- byte value();
- }
- public @interface AnnoBoolean {
- boolean value();
- }
- public @interface AnnoChar {
- char value();
- }
- public @interface AnnoDouble {
- double value();
- }
- public @interface AnnoFloat {
- float value();
- }
- public @interface AnnoInt {
- int value();
- }
- public @interface AnnoLong {
- long value();
- }
- public @interface AnnoShort {
- short value();
- }
- public @interface AnnoString {
- String value();
- }
- public @interface AnnoEnumConst {
- Enum value();
- }
- public @interface AnnoType {
- Class<?> value();
- }
- public @interface AnnoAnnoChar {
- AnnoChar value();
- }
- public @interface AnnoArrayInt {
- int[] value();
- }
- public @interface AnnoArrayString {
- String[] value();
- }
- public @interface AnnoArrayEnumConst {
- Enum[] value();
- }
- public @interface AnnoArrayAnnoChar {
- AnnoChar[] value();
- }
- public @interface AnnoArrayType {
- Class<?>[] value();
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/BaseProcessor.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/BaseProcessor.java
deleted file mode 100644
index 092136212c..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/BaseProcessor.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests.processors.base;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.lang.model.util.Elements;
-import javax.lang.model.util.Types;
-
-/**
- * Base class for writing processors used in test cases.
- */
-public abstract class BaseProcessor extends AbstractProcessor
-{
- protected Elements _elementUtils;
- protected Types _typeUtils;
-
- /**
- * Report an error to the test case code
- * @param value
- */
- public void reportError(String value) {
- // Debugging - don't report error
- // value = "succeeded";
- System.setProperty(this.getClass().getName(), value);
- }
-
- /**
- * Report success to the test case code
- */
- public void reportSuccess() {
- System.setProperty(this.getClass().getName(), "succeeded");
- }
-
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- _elementUtils = processingEnv.getElementUtils();
- _typeUtils = processingEnv.getTypeUtils();
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/IXMLNames.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/IXMLNames.java
deleted file mode 100644
index 14585a607a..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/IXMLNames.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.compiler.apt.tests.processors.base;
-
-/**
- * String constants used in representing the javax.lang.model typesystem as XML.
- *
- * @since 3.4
- */
-public interface IXMLNames {
- static final String ANNOTATION_TAG = "annotation";
- static final String ANNOTATIONS_TAG = "annotations";
- static final String ANNOTATION_VALUE_TAG = "annotation-value";
- static final String ANNOTATION_VALUES_TAG = "annotation-values";
- static final String EXECUTABLE_ELEMENT_TAG = "executable-element";
- static final String INTERFACES_TAG = "interfaces";
- static final String KIND_TAG = "kind";
- static final String MEMBER_TAG = "member";
- static final String MODEL_TAG = "model";
- static final String QNAME_TAG = "qname";
- static final String SNAME_TAG = "sname";
- static final String SUPERCLASS_TAG = "superclass";
- static final String TO_STRING_TAG = "to-string";
- static final String TYPE_ELEMENT_TAG = "type-element";
- static final String TYPE_MIRROR_TAG = "type-mirror";
- static final String TYPE_TAG = "type";
- static final String VALUE_TAG = "value";
- static final String VARIABLE_ELEMENT_TAG = "variable-element";
-
- static final String TYPEKIND_ERROR = "ERROR"; // see javax.lang.model.type.TypeKind
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/XMLComparer.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/XMLComparer.java
deleted file mode 100644
index ddc967ad5b..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/XMLComparer.java
+++ /dev/null
@@ -1,761 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.compiler.apt.tests.processors.base;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.Map.Entry;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * Utility to compare two XML DOM trees that represent JSR269 (javax.lang.model) language models.
- * This could be done with existing third-party XMLDiff tools and a sufficiently articulate DTD, so
- * if it needs to be substantially enhanced at some point in the future, maintainers should consider
- * using that approach instead.
- *
- * This is not a generic XML comparison tool; it has specific expectations about the structure of a
- * JSR269 model, for example, that declarations may contain annotations but not vice versa.
- *
- * Note that in this body of code, we use the term "Decl" or "Declaration" to refer to the the
- * entities represented by javax.lang.model.element.Element, to avoid confusion with XML elements,
- * i.e. org.w3c.dom.Element.
- *
- * @since 3.4
- */
-public class XMLComparer implements IXMLNames {
-
- /**
- * A structure to collect and organize all the contents of an &lt;elements&gt; node, that is,
- * all the things that the {@link javax.lang.model.element.Element#getEnclosedElements()} method
- * would return. The key is the simple name of the entity. The reason this is needed is because
- * simple names can be repeated, e.g., a class may contain both a method and a nested class with
- * the same name.
- *
- * The structure also has a holder for an &lt;annotations&gt; node, as a convenience, because
- * when searching the XML DOM we discover this node at the same time as the element
- * declarations.
- *
- * @since 3.4
- */
- private class DeclarationContents {
- Element annotations = null;
- Element superclass = null;
- Element interfaces = null;
- final TreeMap<String, Element> typeDecls = new TreeMap<String, Element>();
- final TreeMap<String, Element> executableDecls = new TreeMap<String, Element>();
- final TreeMap<String, Element> variableDecls = new TreeMap<String, Element>();
- // TODO: PACKAGE, TYPE_PARAMETER, OTHER
- }
-
- /**
- * Compare two JSR269 language models, using the approximate criteria of the JSR269 spec. Ignore
- * differences in order of sibling elements. If the two do not match, optionally send detailed
- * information about the mismatch to an output stream.
- *
- * @param actual
- * the observed language model
- * @param expected
- * the reference language model
- * @param out
- * a stream to which detailed information on mismatches will be output. Can be null
- * if no detailed information is desired.
- * @param summary
- * a StringBuilder to which will be appended a brief summary of the problem if a
- * problem was encountered. Can be null if no summary is desired.
- * @param ignoreJavacBugs
- * true if mismatches corresponding to known javac bugs should be ignored.
- * @return true if the models match sufficiently to satisfy the spec.
- */
- public static boolean compare(Document actual, Document expected,
- OutputStream out, StringBuilder summary, boolean ignoreJavacBugs) {
- XMLComparer comparer = new XMLComparer(actual, expected, out, summary, ignoreJavacBugs);
- return comparer._compare();
- }
-
- private final Document _actual;
-
- private final Document _expected;
-
- /**
- * If true, don't complain about mismatches corresponding to known javac bugs,
- * even if they represent a violation of the spec. This is useful when running
- * tests against the reference implementation.
- */
- private final boolean _ignoreJavacBugs;
-
- private final PrintStream _out;
-
- private final StringBuilder _summary;
-
- /**
- * Clients should not construct instances of this object.
- */
- private XMLComparer(Document actual, Document expected, OutputStream out, StringBuilder summary, boolean ignoreJavacBugs) {
- _actual = actual;
- _expected = expected;
- _ignoreJavacBugs = ignoreJavacBugs;
- OutputStream os;
- if (out != null) {
- os = out;
- } else {
- os = new OutputStream() {
- public void write(int b) throws IOException {
- // do nothing
- }
- };
- }
- _out = new PrintStream(os, true);
- _summary = summary;
- }
-
- /**
- * Non-static internal comparison routine called from
- * {@link #compare(Document, Document, OutputStream)}
- *
- * @return true if models are equivalent
- */
- private boolean _compare() {
- // navigate to the outermost <model> nodes of each document
- Element actualModel = findRootNode(_actual);
- Element expectedModel = findRootNode(_expected);
- if (actualModel == null) {
- if (expectedModel == null) {
- return true;
- }
- printProblem("Actual model contained no <elements> node.");
- printDifferences();
- return false;
- }
- if (expectedModel == null) {
- printProblem("Actual model contained unexpected elements.");
- printDifferences();
- return false;
- }
-
- return compareDeclarations(actualModel, expectedModel);
- }
-
- /**
- * Collect the contents of an &lt;annotations&gt; node into a map. If there are declarations of
- * the same name, report an error; if there are unexpected contents (e.g., declarations, which
- * should not be contained within an annotations node), report an error.
- *
- * TODO: revisit this - we need to model duplications, in order to handle incorrect code.
- *
- * @param annotsNode
- * must not be null
- * @param map
- * a map from annotation type name to the XML node representing the annotation
- * instance
- * @return true if no errors were reported
- */
- private boolean collectAnnotations(Element annotsNode, Map<String, Element> map) {
- for (Node n = annotsNode.getFirstChild(); n != null; n = n.getNextSibling()) {
- if (n.getNodeType() != Node.ELEMENT_NODE) {
- continue;
- }
- Element e = (Element)n;
- String nodeName = e.getNodeName();
-
- // get 'sname'
- String sname = e.getAttribute(SNAME_TAG);
- if (sname == null) {
- printProblem("A child of an <annotations> node was missing the \"sname\" attribute");
- printDifferences();
- return false;
- }
-
- // categorize
- Element old = null;
- if (ANNOTATION_TAG.equals(nodeName)) {
- old = map.put(sname, e);
- } else {
- printProblem("An <annotations> node unexpectedly contained something other than <annotation>: "
- + nodeName);
- printDifferences();
- return false;
- }
- if (old != null) {
- printProblem("Two sibling annotation mirrors had the same sname: " + sname);
- printDifferences();
- return false;
- }
- }
- return true;
- }
-
- /**
- * Collect the contents of a declaration, including child declarations and annotations, into a
- * collection of maps. If there are declarations of the same type and simple name, report an
- * error; if there are unexpected contents), report an error.
- * TODO: revisit this - we need to model duplications, in order to handle incorrect code.
- *
- * @param elementNode
- * must not be null
- * @param contents
- * must not be null
- * @return true if no errors were reported
- */
- private boolean collectDeclarationContents(Element declarationNode, DeclarationContents contents) {
- for (Node n = declarationNode.getFirstChild(); n != null; n = n.getNextSibling()) {
- if (n.getNodeType() != Node.ELEMENT_NODE) {
- continue;
- }
- Element e = (Element)n;
- String nodeName = e.getNodeName();
-
- if (ANNOTATIONS_TAG.equals(nodeName)) {
- if (contents.annotations != null) {
- printProblem("XML syntax error: a declaration contained more than one <annotations> node");
- printDifferences();
- return false;
- }
- contents.annotations = e;
- } else if (SUPERCLASS_TAG.equals(nodeName)) {
- if (contents.superclass != null) {
- printProblem("XML syntax error: a declaration contained more than one <superclass> node");
- printDifferences();
- return false;
- }
- contents.superclass = e;
- } else if (INTERFACES_TAG.equals(nodeName)) {
- if (contents.interfaces != null) {
- printProblem("XML syntax error: a declaration contained more than one <interfaces> node");
- printDifferences();
- return false;
- }
- contents.interfaces = e;
- } else {
- // get 'sname'
- String sname = e.getAttribute(SNAME_TAG);
- if (sname == null) {
- printProblem("A child of an <elements> node was missing the \"sname\" attribute");
- printDifferences();
- return false;
- }
-
- // categorize
- Element old = null;
- if (EXECUTABLE_ELEMENT_TAG.equals(nodeName)) {
- old = contents.executableDecls.put(sname, e);
- } else if (TYPE_ELEMENT_TAG.equals(nodeName)) {
- old = contents.typeDecls.put(sname, e);
- } else if (VARIABLE_ELEMENT_TAG.equals(nodeName)) {
- old = contents.variableDecls.put(sname, e);
- } else {
- printProblem("A declaration contained an unexpected child node: " + nodeName);
- printDifferences();
- return false;
- }
- if (old != null) {
- printProblem("Two elements of the same kind had the same sname: " + sname);
- printDifferences();
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Collect the &lt;type-mirror&gt; children of a parent node into a map,
- * keyed and sorted by the canonicalized type name.
- * For now, we use the toString() output as the canonical name, even though
- * that is unspecified and implementation-dependent.
- * Reject duplicated types.
- * TODO: revisit this - we need to model duplications, in order to handle incorrect code.
- * @param parent the parent node
- * @param typesMap the map, presumed to be empty on entry
- * @return true if no errors were reported
- */
- private boolean collectTypes(Node parent, Map<String, Element> typesMap) {
- for (Node n = parent.getFirstChild(); n != null; n = n.getNextSibling()) {
- if (n.getNodeType() == Node.ELEMENT_NODE & TYPE_MIRROR_TAG.equals(n.getNodeName())) {
- Element typeMirror = (Element)n;
- String toStringAttr = typeMirror.getAttribute(TO_STRING_TAG);
- if (null == toStringAttr || toStringAttr.length() < 1) {
- printProblem("<type-mirror> node was missing its \"to-string\" attribute");
- printDifferences();
- return false;
- }
- Element old = typesMap.put(toStringAttr, typeMirror);
- if (null != old) {
- printProblem("Two <type-mirror> nodes had the same \"to-string\" attribute: " + toStringAttr);
- printDifferences();
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Compare an actual annotation mirror to the expected reference. It is assumed that the
- * annotation's sname has already been compared. Attributes that exist on the actual annotation
- * but not on the expected annotation are not considered to be a mismatch. Note that the
- * language model representation in XML does not include default values, since these are
- * attributes of the annotation type rather than the annotation instance.
- *
- * @param actualAnnot
- * must be non-null
- * @param expectedAnnot
- * must be non-null
- * @return true if the elements match
- */
- private boolean compareAnnotationNodes(Element actualAnnot, Element expectedAnnot) {
- // Compare attributes of the annotation instances
- // Intentionally ignore the presence of additional actual attributes not present in the
- // expected model
- NamedNodeMap expectedAttrs = expectedAnnot.getAttributes();
- NamedNodeMap actualAttrs = actualAnnot.getAttributes();
- int numAttrs = expectedAttrs.getLength();
- String sname = null;
- for (int i = 0; i < numAttrs; ++i) {
- Node expectedAttr = expectedAttrs.item(i);
- String attrName = expectedAttr.getNodeName();
- Node actualAttr = actualAttrs.getNamedItem(attrName);
- if (actualAttr == null) {
- printProblem("Actual annotation mirror was missing expected attribute: " + attrName);
- printDifferences();
- return false;
- }
- String expectedValue = expectedAttr.getNodeValue();
- String actualValue = actualAttr.getNodeValue();
- if (!expectedValue.equals(actualValue)) {
- printProblem("Actual attribute value was different than expected: attribute "
- + attrName + ", expected " + expectedValue + ", actual " + actualValue);
- printDifferences();
- return false;
- }
- if (SNAME_TAG.equals(attrName)) {
- sname = actualValue;
- }
- }
-
- // Examine member-value pairs
- Element actualValues = findNamedChildElement(actualAnnot, ANNOTATION_VALUES_TAG);
- Element expectedValues = findNamedChildElement(expectedAnnot, ANNOTATION_VALUES_TAG);
- if (actualValues != null && expectedValues != null) {
- if (!compareAnnotationValuesNodes(actualValues, expectedValues)) {
- return false;
- }
- }
- else if (actualValues != null) {
- // expectedValues == null
- printProblem("Found unexpected <annotation-values> in annotation: " + sname);
- printDifferences();
- return false;
- }
- else if (expectedValues != null) {
- // actualValues == null
- printProblem("Missing expected <annotation-values> in annotation: " + sname);
- printDifferences();
- return false;
- }
- // both null is okay
-
- return true;
- }
-
- /**
- * Compare the contents of two &lt;annotations&gt; nodes.
- *
- * @param actualAnnots
- * may be empty, but must not be null
- * @param expectedAnnots
- * may be empty, but must not be null
- * @return true if the contents are equivalent.
- */
- private boolean compareAnnotationsNodes(Element actualAnnots, Element expectedAnnots) {
- // Group declarations alphabetically so they can be compared
- Map<String, Element> actual = new TreeMap<String, Element>();
- Map<String, Element> expected = new TreeMap<String, Element>();
- if (!collectAnnotations(actualAnnots, actual))
- return false;
- if (!collectAnnotations(expectedAnnots, expected))
- return false;
-
- // Compare the collections at this level
- if (!actual.keySet().equals(expected.keySet())) {
- printProblem("Contents of <annotations> nodes did not match");
- printDifferences();
- return false;
- }
-
- // Compare individual annotations in more detail
- for (Map.Entry<String, Element> expectedEntry : expected.entrySet()) {
- String sname = expectedEntry.getKey();
- Element actualElement = actual.get(sname);
- if (!compareAnnotationNodes(actualElement, expectedEntry.getValue())) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Compare the contents of two &lt;annotation-values&gt; nodes; that is, compare
- * actual and expected lists of annotation member/value pairs. These lists do
- * not typically include annotation value defaults, since those are an attribute
- * of an annotation type rather than an annotation instance. Ordering of the list
- * is important: the same pairs, in a different order, is considered a mismatch.
- * @param actual must be non-null
- * @param expected must be non-null
- * @return true if the sets are equivalent
- */
- private boolean compareAnnotationValuesNodes(Element actual, Element expected) {
- Node nActual = actual.getFirstChild();
- for (Node nExpected = expected.getFirstChild(); nExpected != null; nExpected = nExpected.getNextSibling()) {
- if (nExpected.getNodeType() == Node.ELEMENT_NODE && ANNOTATION_VALUE_TAG.equals(nExpected.getNodeName())) {
- while (nActual != null &&
- (nActual.getNodeType() != Node.ELEMENT_NODE ||
- !ANNOTATION_VALUE_TAG.equals(nActual.getNodeName()))) {
- nActual = nActual.getNextSibling();
- }
- if (nActual == null) {
- printProblem("Annotation member-value pairs were different: expected more pairs than were found");
- printDifferences();
- return false;
- }
- // Now we've got two annotation-value elements; compare their attributes.
- // We will ignore "extra" (unexpected) attributes in the actual model.
- if (!compareAttributes(nActual, nExpected)) {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Compare the attributes of two nodes. Ignore attributes that are found on
- * the actual, but not expected, node.
- * @param actual must not be null
- * @param expected must not be null
- * @return true if the attribute lists are equivalent
- */
- private boolean compareAttributes(Node actual, Node expected) {
- NamedNodeMap expectedAttrs = expected.getAttributes();
- NamedNodeMap actualAttrs = actual.getAttributes();
- for (int i = 0; i < expectedAttrs.getLength(); ++i) {
- Node expectedAttr = expectedAttrs.item(i);
- String attrName = expectedAttr.getNodeName();
- Node actualAttr = actualAttrs.getNamedItem(attrName);
- if (actualAttr == null) {
- printProblem("Actual element was missing expected attribute: " + attrName);
- printDifferences();
- return false;
- }
- String expectedValue = expectedAttr.getNodeValue();
- String actualValue = actualAttr.getNodeValue();
- if (!expectedValue.equals(actualValue)) {
- printProblem("Actual attribute value was different than expected: attribute "
- + attrName + ", expected " + expectedValue + ", actual " + actualValue);
- printDifferences();
- return false;
- }
- }
- return true;
- }
-
- /**
- * Compare the sets of element declarations nested within an actual and an expected element.
- * Note that the DeclarationContents object also may contain an &lt;annotations&gt; node,
- * but that must be compared separately.
- *
- * @param actual
- * must not be null
- * @param expected
- * must not be null
- * @return true if the contents are equivalent.
- */
- private boolean compareDeclarationContents(DeclarationContents actual, DeclarationContents expected) {
-
- // Compare each collection at this level
- if (!actual.typeDecls.keySet().equals(expected.typeDecls.keySet())) {
- printProblem("Contents of <elements> nodes did not match: different sets of type-elements");
- printDifferences();
- return false;
- }
- if (!actual.executableDecls.keySet().equals(expected.executableDecls.keySet())) {
- printProblem("Contents of <elements> nodes did not match: different sets of executable-elements");
- printDifferences();
- return false;
- }
- if (!actual.variableDecls.keySet().equals(expected.variableDecls.keySet())) {
- printProblem("Contents of <elements> nodes did not match: different sets of variable-elements");
- printDifferences();
- return false;
- }
-
- // Recurse by comparing individual elements
- for (Map.Entry<String, Element> expectedEntry : expected.typeDecls.entrySet()) {
- String sname = expectedEntry.getKey();
- Element actualElement = actual.typeDecls.get(sname);
- if (!compareDeclarations(actualElement, expectedEntry.getValue())) {
- return false;
- }
- }
- for (Map.Entry<String, Element> expectedEntry : expected.executableDecls.entrySet()) {
- String sname = expectedEntry.getKey();
- Element actualElement = actual.executableDecls.get(sname);
- if (!compareDeclarations(actualElement, expectedEntry.getValue())) {
- return false;
- }
- }
- for (Map.Entry<String, Element> expectedEntry : expected.variableDecls.entrySet()) {
- String sname = expectedEntry.getKey();
- Element actualElement = actual.variableDecls.get(sname);
- if (!compareDeclarations(actualElement, expectedEntry.getValue())) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Compare an actual declaration to the expected reference. It is assumed that the element name
- * (e.g., type-element, variable-element) and sname (e.g., "Foo") have already been compared.
- * Attributes that exist on the actual declaration element but not on the expected declaration
- * element are not considered to be a mismatch.
- *
- * @param actualDecl
- * must be non-null
- * @param expectedDecl
- * must be non-null
- * @return true if the declarations are equivalent
- */
- private boolean compareDeclarations(Element actualDecl, Element expectedDecl) {
- // compare the element kinds and any other relevant attributes
- // Intentionally ignore the presence of additional actual attributes not present in the
- // expected model
- if (!compareAttributes(actualDecl, expectedDecl)) {
- return false;
- }
-
-
- // Find nested element and <annotations> nodes
- DeclarationContents actualContents = new DeclarationContents();
- if (!collectDeclarationContents(actualDecl, actualContents)) {
- return false;
- }
- DeclarationContents expectedContents = new DeclarationContents();
- if (!collectDeclarationContents(expectedDecl, expectedContents)) {
- return false;
- }
-
- // compare annotations on the element
- if (actualContents.annotations != null && expectedContents.annotations != null) {
- if (!compareAnnotationsNodes(actualContents.annotations, expectedContents.annotations)) {
- return false;
- }
- } else if (actualContents.annotations != null) {
- // expectedAnnots == null
- printProblem("Unexpected annotations within element: "
- + expectedDecl.getAttribute(SNAME_TAG));
- printDifferences();
- return false;
- } else if (expectedContents.annotations != null) {
- // actualAnnots == null
- printProblem("Missing expected annotations within element: "
- + actualDecl.getAttribute(SNAME_TAG));
- printDifferences();
- return false;
- }
- // both null at the same time is okay, not a mismatch
-
- // compare superclasses. Ignore if reference does not specify a superclass.
- if (expectedContents.superclass != null) {
- if (actualContents.superclass == null) {
- printProblem("No superclass found for element: " + actualDecl.getAttribute(SNAME_TAG));
- printDifferences();
- return false;
- }
- if (!compareSuperclassNodes(actualContents.superclass, expectedContents.superclass)) {
- return false;
- }
- }
-
- // compare interface lists. Ignore if reference does not specify interfaces.
- // TODO: javac fails to provide unresolved interfaces. Here, we ignore interfaces altogether
- // if we're ignoring javac bugs, which means we also ignore the non-error cases.
- if (expectedContents.interfaces != null && !_ignoreJavacBugs) {
- if (actualContents.interfaces == null) {
- printProblem("No interfaces list found for element: " + actualDecl.getAttribute(SNAME_TAG));
- printDifferences();
- return false;
- }
- if (!compareInterfacesNodes(actualContents.interfaces, expectedContents.interfaces)) {
- return false;
- }
- }
-
- // compare the child elements
- if (!compareDeclarationContents(actualContents, expectedContents)) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Compare two interface lists, i.e., &lt;interfaces&gt; nodes.
- * Each is expected to contain zero or more &lt;type-mirror&gt; nodes.
- * The spec for {@link javax.lang.model.element.TypeElement#getInterfaces()}
- * does not say anything about the order of the items returned, so here we
- * load them into a Map<String, Element> keyed by the type's toString()
- * output. Note that toString() on a TypeMirror is not very well
- * specified either, so this is not guaranteed to produce good results.
- * @param actual the observed &lt;interfaces&gt; node, must be non-null.
- * @param expected the reference &lt;interfaces&gt; node, must be non-null
- * @return true if the nodes are equivalent.
- */
- private boolean compareInterfacesNodes(Element actual, Element expected) {
- Map<String, Element> expectedTypes = new TreeMap<String, Element>();
- Map<String, Element> actualTypes = new TreeMap<String, Element>();
- if (!collectTypes(expected, expectedTypes)) {
- return false;
- }
- if (!collectTypes(actual, actualTypes)) {
- return false;
- }
- if (expectedTypes.size() != actualTypes.size()) {
- if (_ignoreJavacBugs) {
- // javac has a known bug where it does not correctly model
- // unresolved interface types. Ideally we could still verify
- // the resolved ones but that seems like more work than it's worth.
- return true;
- }
- printProblem("Actual and expected interface lists have different sizes: expected = " +
- expectedTypes.size() + ", actual = " + actualTypes.size());
- printDifferences();
- return false;
- }
- Iterator<Entry<String, Element>> expectedIter = expectedTypes.entrySet().iterator();
- Iterator<Entry<String, Element>> actualIter = actualTypes.entrySet().iterator();
- // if we got this far, the two maps are the same size
- while (expectedIter.hasNext()) {
- Entry<String, Element> expectedEntry = expectedIter.next();
- Entry<String, Element> actualEntry = actualIter.next();
- if (!compareTypeMirrors(actualEntry.getValue(), expectedEntry.getValue())) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Compare two &lt;superclass&gt; nodes. Each is expected to contain
- * exactly one &lt;type-mirror&gt; node.
- *
- * @param actual the observed &lt;superclass&gt; node; must not be null
- * @param expected the reference &lt;superclass&gt; node; must not be null
- * @return true if the superclass types are equivalent
- */
- private boolean compareSuperclassNodes(Element actual, Element expected) {
- Element expectedType = findNamedChildElement(expected, TYPE_MIRROR_TAG);
- if (expectedType == null) {
- // Syntax error in the reference model, i.e., problem in test code
- printProblem("Bug in reference model: a <superclass> node was missing its <type-mirror> element");
- printDifferences();
- return false;
- }
- Element actualType = findNamedChildElement(actual, TYPE_MIRROR_TAG);
- if (actualType == null) {
- // This probably indicates a problem in the XMLConverter class
- printProblem("Bug in test code: a <superclass> node was missing its <type-mirror> element in the XML model of the observed language model");
- printDifferences();
- return false;
- }
- return compareTypeMirrors(actualType, expectedType);
- }
-
- private boolean compareTypeMirrors(Element actual, Element expected) {
- String expectedKind = expected.getAttribute(KIND_TAG);
- if (expectedKind != null && expectedKind.length() > 0) {
- String actualKind = actual.getAttribute(KIND_TAG);
- if (!expectedKind.equals(actualKind)) {
- printProblem("Superclasses had different kind: expected " + expectedKind + " but found " + actualKind);
- printDifferences();
- return false;
- }
- }
- if (!TYPEKIND_ERROR.equals(expectedKind)) {
- String expectedToString = expected.getAttribute(TO_STRING_TAG);
- if (expectedToString != null && expectedToString.length() > 0) {
- String actualToString = actual.getAttribute(TO_STRING_TAG);
- if (!expectedToString.equals(actualToString)) {
- printProblem("Superclasses had different toString() output: expected " + expectedToString + " but found " + actualToString);
- printDifferences();
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Given some non-null parent, find the first child element with a particular name
- * @return the child, or null if one was not found
- */
- private Element findNamedChildElement(Node parent, String name) {
- for (Node n = parent.getFirstChild(); n != null; n = n.getNextSibling()) {
- if (n.getNodeType() == Node.ELEMENT_NODE && name.equals(n.getNodeName())) {
- return (Element)n;
- }
- }
- return null;
- }
-
- /**
- * Locate the outer &lt;model&gt; node. This node should always exist unless the model is
- * completely empty.
- *
- * @return the root model node, or null if one could not be found.
- */
- private Element findRootNode(Document doc) {
- return findNamedChildElement(doc, MODEL_TAG);
- }
-
- /**
- * Print the actual and expected documents in string form
- *
- * TODO: a cursor to show what was being compared when the difference was detected.
- */
- private void printDifferences() {
- _out.println("Actual was:\n--------");
- _out.println(XMLConverter.xmlToString(_actual));
- _out.println("--------\nAnd expected was:");
- _out.println(XMLConverter.xmlToString(_expected));
- }
-
- /**
- * Report a specific problem.
- */
- private void printProblem(String msg) {
- if (_summary != null) {
- _summary.append(msg);
- }
- _out.println(msg);
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/XMLConverter.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/XMLConverter.java
deleted file mode 100644
index b043242978..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/base/XMLConverter.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.compiler.apt.tests.processors.base;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.List;
-import java.util.Map;
-
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.TypeParameterElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.ElementScanner6;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Generate an XML representation of a language model.
- * Changes to this class will generally require changes to
- * the XMLComparer class (which compares documents generated
- * by this class) and possibly to the reference models of
- * various tests.
- *
- * @since 3.4
- */
-public class XMLConverter extends ElementScanner6<Void, Node> implements IXMLNames {
-
- private final Document _doc;
-
- private XMLConverter(Document doc) {
- _doc = doc;
- }
-
- /**
- * Convert an XML DOM document to a canonical string representation
- */
- public static String xmlToString(Document model) {
- StringWriter s = new StringWriter();
- DOMSource domSource = new DOMSource(model);
- StreamResult streamResult = new StreamResult(s);
- TransformerFactory tf = TransformerFactory.newInstance();
- Transformer serializer;
- try {
- serializer = tf.newTransformer();
- serializer.setOutputProperty(OutputKeys.INDENT, "yes");
- serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "1");
- serializer.transform(domSource, streamResult);
- } catch (Exception e) {
- e.printStackTrace(new PrintWriter(s));
- }
- return s.toString();
- }
-
- /**
- * Recursively convert a collection of language elements (declarations) into an XML representation.
- * @param declarations the collection of language elements to convert
- * @return an XML document whose root node is named &lt;model&gt;.
- * @throws ParserConfigurationException
- */
- public static Document convertModel(Iterable<? extends javax.lang.model.element.Element> declarations) throws ParserConfigurationException {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- Document model = factory.newDocumentBuilder().newDocument();
- org.w3c.dom.Element modelNode = model.createElement(MODEL_TAG);
-
- XMLConverter converter = new XMLConverter(model);
- converter.scan(declarations, modelNode);
- model.appendChild(modelNode);
- return model;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.lang.model.util.ElementScanner6#visitExecutable(javax.lang.model.element.ExecutableElement,
- * java.lang.Object)
- */
- @Override
- public Void visitExecutable(ExecutableElement e, Node target) {
- Element executableNode = _doc.createElement(EXECUTABLE_ELEMENT_TAG);
- executableNode.setAttribute(KIND_TAG, e.getKind().name());
- executableNode.setAttribute(SNAME_TAG, e.getSimpleName().toString());
-
- convertAnnotationMirrors(e, executableNode);
-
- target.appendChild(executableNode);
-
- // scan the method's parameters
- return super.visitExecutable(e, executableNode);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.lang.model.util.ElementScanner6#visitPackage(javax.lang.model.element.PackageElement,
- * java.lang.Object)
- */
- @Override
- public Void visitPackage(PackageElement e, Node target) {
- // TODO not yet implemented
- return super.visitPackage(e, target);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.lang.model.util.ElementScanner6#visitType(javax.lang.model.element.TypeElement,
- * java.lang.Object)
- */
- @Override
- public Void visitType(TypeElement e, Node target) {
- Element typeNode = _doc.createElement(TYPE_ELEMENT_TAG);
- typeNode.setAttribute(KIND_TAG, e.getKind().name());
- typeNode.setAttribute(SNAME_TAG, e.getSimpleName().toString());
- typeNode.setAttribute(QNAME_TAG, e.getQualifiedName().toString());
-
- convertSuperclass(e, typeNode);
- convertInterfaces(e, typeNode);
- convertAnnotationMirrors(e, typeNode);
-
- target.appendChild(typeNode);
-
- // Scan the type's subtypes, fields, and methods
- return super.visitType(e, typeNode);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.lang.model.util.ElementScanner6#visitTypeParameter(javax.lang.model.element.TypeParameterElement,
- * java.lang.Object)
- */
- @Override
- public Void visitTypeParameter(TypeParameterElement e, Node target) {
- // TODO not yet implemented
- return super.visitTypeParameter(e, target);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.lang.model.util.ElementScanner6#visitVariable(javax.lang.model.element.VariableElement,
- * java.lang.Object)
- */
- @Override
- public Void visitVariable(VariableElement e, Node target) {
- Element variableNode = _doc.createElement(VARIABLE_ELEMENT_TAG);
- variableNode.setAttribute(KIND_TAG, e.getKind().name());
- variableNode.setAttribute(SNAME_TAG, e.getSimpleName().toString());
- // TODO: the spec does not restrict the toString() implementation
- variableNode.setAttribute(TYPE_TAG, e.asType().toString());
-
- convertAnnotationMirrors(e, variableNode);
-
- target.appendChild(variableNode);
-
- // Variables do not enclose any elements, so no need to call super.
- return null;
- }
-
- private void convertAnnotationMirrors(javax.lang.model.element.Element e, Node target) {
- List<? extends AnnotationMirror> mirrors = e.getAnnotationMirrors();
- if (mirrors != null && !mirrors.isEmpty()) {
- Element annotationsNode = _doc.createElement(ANNOTATIONS_TAG);
- for (AnnotationMirror am : mirrors) {
- convertAnnotationMirror(am, annotationsNode);
- }
- target.appendChild(annotationsNode);
- }
- }
-
- /**
- * Scan an annotation instance in the model and represent it in XML, including all its explicit
- * values (but not any default values).
- *
- * @param am
- * the annotation mirror to be converted
- * @param target
- * the &lt;annotations&gt; XML node to which a new &lt;annotation&gt; node will be
- * added
- */
- private void convertAnnotationMirror(AnnotationMirror am, Node target) {
- javax.lang.model.element.Element annoElement = am.getAnnotationType().asElement();
- if (annoElement == null) {
- return;
- }
- Element annoNode = _doc.createElement(ANNOTATION_TAG);
- String sname = am.getAnnotationType().asElement().getSimpleName().toString();
- annoNode.setAttribute(SNAME_TAG, sname);
- Map<? extends ExecutableElement, ? extends AnnotationValue> values = am.getElementValues();
- if (values.size() > 0) {
- Element valuesNode = _doc.createElement(ANNOTATION_VALUES_TAG);
- annoNode.appendChild(valuesNode);
- for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : values
- .entrySet()) {
- AnnotationValue valueHolder = entry.getValue();
- if (valueHolder != null) {
- Object value = valueHolder.getValue();
- Element valueNode = _doc.createElement(ANNOTATION_VALUE_TAG);
- valueNode.setAttribute(MEMBER_TAG, entry.getKey().getSimpleName().toString());
- valueNode.setAttribute(TYPE_TAG, value.getClass().getName());
- valueNode.setAttribute(VALUE_TAG, value.toString());
- valuesNode.appendChild(valueNode);
- }
- }
- }
- target.appendChild(annoNode);
- }
-
- /**
- * Scan a type for its extended and implemented interfaces and represent them
- * in XML.
- * @param target the node representing the type; an &lt;interfaces&gt; node
- * will be added as a child of this node, if any interfaces are found.
- */
- private void convertInterfaces(TypeElement e, Node target) {
- List<? extends TypeMirror> interfaces = e.getInterfaces();
- if (interfaces != null && !interfaces.isEmpty()) {
- Element interfacesNode = _doc.createElement(INTERFACES_TAG);
- for (TypeMirror intfc : interfaces) {
- convertTypeMirror(intfc, interfacesNode);
- }
- target.appendChild(interfacesNode);
- }
- }
-
- /**
- * Create a node representing a class declaration's superclass
- * @param tmSuper
- * @param target
- */
- private void convertSuperclass(TypeElement e, Node target) {
- TypeMirror tmSuper = e.getSuperclass();
- if (null != tmSuper) {
- Element node = _doc.createElement(SUPERCLASS_TAG);
- convertTypeMirror(tmSuper, node);
- target.appendChild(node);
- }
- }
-
- /**
- * Represent an arbitrary TypeMirror in XML, and append it as a child to
- * the specified parent node.
- *
- * Note this is problematic, because TypeMirror has no well-specified ways
- * to canonicalize an arbitrary (and possibly erroneous) type.
- *
- * @param tm must be non-null
- * @param target the parent XML node, to which this new node will be appended
- */
- private void convertTypeMirror(TypeMirror tm, Node target) {
- Element n = _doc.createElement(TYPE_MIRROR_TAG);
- n.setAttribute(KIND_TAG, tm.getKind().name());
- n.setAttribute(TO_STRING_TAG, tm.toString());
- // TODO: potentially walk type-variables here
- target.appendChild(n);
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/checkargs/CheckArgsProc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/checkargs/CheckArgsProc.java
deleted file mode 100644
index 0b1108f77c..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/checkargs/CheckArgsProc.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.compiler.apt.tests.processors.checkargs;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.TypeElement;
-
-/**
- * A processor that echoes its command-line arguments to standard out.
- */
-@SupportedAnnotationTypes("org.eclipse.jdt.compiler.apt.tests.annotations.CheckArgs")
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-public class CheckArgsProc extends AbstractProcessor {
-
- private final static String[] _expected =
- {
- "foo", "bar",
- "novalue", null,
- "bar2", null
- };
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.AbstractProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)
- */
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- if (roundEnv.processingOver())
- return true;
-
- Map<String, String> options = new HashMap<String, String>(processingEnv.getOptions());
- options.remove("phase");
- if (_expected.length/2 != options.size()) {
- throw new IllegalStateException(
- "Bad processor arguments: expected " + _expected.length/2 +
- " arguments but found " + options.size());
- }
- for (int i = 0; i < _expected.length; ++i) {
- String key = _expected[i++];
- String value = _expected[i];
- String observedValue = options.get(key);
- if (value == null && observedValue != null) {
- throw new IllegalStateException(
- "Bad processor arguments: key " + key +
- " expected null value but observed value " + observedValue);
- }
- else if (value != null && !value.equals(observedValue)){
- throw new IllegalStateException(
- "Bad processor arguments: key " + key +
- " expected value " + value + " but observed value " + observedValue);
- }
- }
- return true;
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/ElementProc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/ElementProc.java
deleted file mode 100644
index e5c5e04beb..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/ElementProc.java
+++ /dev/null
@@ -1,818 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests.processors.elements;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.NestingKind;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.DeclaredType;
-import javax.lang.model.type.MirroredTypeException;
-import javax.lang.model.type.MirroredTypesException;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.ElementFilter;
-
-import org.eclipse.jdt.compiler.apt.tests.annotations.TypedAnnos;
-import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
-
-/**
- * A processor that explores the "model" target hierarchy and complains if it does
- * not find what it expects. To enable this processor, add
- * -Aorg.eclipse.jdt.compiler.apt.tests.processors.elements.ElementProc to the command line.
- * @since 3.3
- */
-@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-public class ElementProc extends BaseProcessor {
-
- // The set of elements we expect getRootElements to return in package pa
- private static final String[] ROOT_ELEMENT_NAMES = new String[] {
- "targets.model.pa.AnnoZ", "targets.model.pa.A", "targets.model.pa.IA", "targets.model.pa.ExceptionA"};
-
- // Initialized in collectElements()
- private TypeElement _elementIA;
- private TypeElement _elementAB;
- private TypeElement _elementA;
- private TypeElement _elementD;
- private TypeElement _elementDChild;
- private TypeElement _elementAnnoZ;
- private TypeElement _elementString;
-
- // Initialized in examineDMethods()
- private ExecutableElement _methodDvoid;
- private TypeElement _elementDEnum;
-
- // Always return false from this processor, because it supports "*".
- // The return value does not signify success or failure!
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- if (roundEnv.processingOver()) {
- // We're not interested in the postprocessing round.
- return false;
- }
- Map<String, String> options = processingEnv.getOptions();
- if (!options.containsKey(this.getClass().getName())) {
- // Disable this processor unless we are intentionally performing the test.
- return false;
- }
-
- if (!collectElements()) {
- return false;
- }
-
- if (!examineRoundEnv(roundEnv)) {
- return false;
- }
-
- if (!examineABInterfaces()) {
- return false;
- }
-
- if (!examineABModifiers()) {
- return false;
- }
-
- if (!examineDHierarchy()) {
- return false;
- }
-
- if (!examineAMethodsAndFields()) {
- return false;
- }
-
- if (!examineAMethodThrowables()) {
- return false;
- }
-
- if (!examineDMethods()) {
- return false;
- }
-
- if (!examineDEnum()) {
- return false;
- }
-
- if (!examinePBPackage()) {
- return false;
- }
-
- if (!examineDAnnotations()) {
- return false;
- }
-
- if (!examineGetAnnotation()) {
- return false;
- }
-
- reportSuccess();
- return false;
- }
-
- /**
- * Collect some elements that will be reused in various tests
- * @return true if all tests passed
- */
- private boolean collectElements() {
- _elementIA = _elementUtils.getTypeElement("targets.model.pa.IA");
- if (_elementIA == null) {
- reportError("element IA was not found");
- return false;
- }
- if (_elementIA.getKind() != ElementKind.INTERFACE) {
- reportError("IA claims to not be an interface");
- return false;
- }
- if (_elementIA.getNestingKind() != NestingKind.TOP_LEVEL) {
- reportError("NestingKind of element IA is not TOP_LEVEL");
- return false;
- }
-
- _elementA = _elementUtils.getTypeElement("targets.model.pa.A");
- if (_elementA == null) {
- reportError("element A was not found");
- return false;
- }
- if (_elementA.getKind() != ElementKind.CLASS) {
- reportError("A claims to not be a class");
- return false;
- }
-
- _elementAnnoZ = _elementUtils.getTypeElement("targets.model.pa.AnnoZ");
- if (_elementAnnoZ == null) {
- reportError("element AnnoZ was not found");
- return false;
- }
- if (_elementAnnoZ.getKind() != ElementKind.ANNOTATION_TYPE) {
- reportError("AnnoZ claims to not be an annotation type");
- return false;
- }
-
- _elementAB = _elementUtils.getTypeElement("targets.model.pb.AB");
- if (_elementAB == null) {
- reportError("element AB was not found");
- return false;
- }
- if (_elementAB.getKind() != ElementKind.CLASS) {
- reportError("AB claims to not be a class");
- return false;
- }
-
- _elementD = _elementUtils.getTypeElement("targets.model.pb.D");
- if (_elementD == null) {
- reportError("element D was not found");
- return false;
- }
- if (_elementD.getKind() != ElementKind.CLASS) {
- reportError("D claims to not be a class");
- return false;
- }
-
- _elementDChild = _elementUtils.getTypeElement("targets.model.pb.DChild");
- if (_elementDChild == null) {
- reportError("secondary element DChild was not found");
- return false;
- }
- if (_elementDChild.getKind() != ElementKind.CLASS) {
- reportError("DChild claims to not be a class");
- return false;
- }
- _elementString = _elementUtils.getTypeElement("java.lang.String");
- return true;
- }
-
- /**
- * Check the methods on RoundEnvironment method
- * @return true if all tests passed
- */
- private boolean examineRoundEnv(RoundEnvironment roundEnv) {
- // Verify that we get the root elements we expect
- Set<String> expectedRootElementNames = new HashSet<String>(ROOT_ELEMENT_NAMES.length);
- for (String name : ROOT_ELEMENT_NAMES) {
- expectedRootElementNames.add(name);
- }
- Set<? extends Element> actualRootElements = roundEnv.getRootElements();
- if (null == actualRootElements) {
- reportError("getRootElements() returned null");
- return false;
- }
- for (Element e : actualRootElements) {
- if (e instanceof TypeElement) {
- String name = ((TypeElement)e).getQualifiedName().toString();
- if (name.startsWith("targets.model.pa.") && !expectedRootElementNames.remove(name)) {
- reportError("Missing root element " + name);
- return false;
- }
- }
- }
- if (!expectedRootElementNames.isEmpty()) {
- reportError("Found extra root elements including " + expectedRootElementNames.iterator().next());
- return false;
- }
-
- // Verify that we get the annotations we expect
- Set<? extends Element> annotatedWithAnnoZ = roundEnv.getElementsAnnotatedWith(_elementAnnoZ);
- if (null == annotatedWithAnnoZ || !annotatedWithAnnoZ.contains(_elementD)) {
- reportError("Elements annotated with AnnoZ does not include D");
- return false;
- }
-
- // targets.model.pc.Deprecation contains @Deprecated annotations
- Set<? extends Element> annotatedWithDeprecated = roundEnv.getElementsAnnotatedWith(Deprecated.class);
- if (null == annotatedWithDeprecated) {
- reportError("getElementsAnnotatedWith(@Deprecated) returned null");
- return false;
- }
- boolean foundDeprecation = false;
- for (TypeElement deprecatedElement : ElementFilter.typesIn(annotatedWithDeprecated)) {
- if ("targets.model.pc.Deprecation".equals(deprecatedElement.getQualifiedName().toString())) {
- foundDeprecation = true;
- break;
- }
- }
- if (!foundDeprecation) {
- reportError("getElementsAnnotatedWith(@Deprecation) did not find targets.model.pc.Deprecation");
- }
-
- return true;
- }
-
- /**
- * Examine the interfaces that AB implements
- * @return true if all tests passed
- */
- private boolean examineABInterfaces() {
- List<? extends TypeMirror> interfacesAB = _elementAB.getInterfaces();
- if (null == interfacesAB) {
- reportError("AB.getInterfaces() returned null");
- return false;
- }
- boolean foundIAinterface = false;
- for (TypeMirror type : interfacesAB) {
- Element decl = _typeUtils.asElement(type);
- if (null == decl) {
- reportError("One of AB's interfaces, " + type.toString() + ", produced null from Types.asElement()");
- return false;
- }
- if (_elementIA.equals(decl)) {
- foundIAinterface = true;
- break;
- }
- }
- if (!foundIAinterface) {
- reportError("AB does not have IA as an interface");
- return false;
- }
- return true;
- }
-
- /**
- * Examine the modifiers of AB's contents
- * @return true if all tests passed
- */
- private boolean examineABModifiers() {
- Map<String, Element> contents = new HashMap<String, Element>();
- for (Element enclosed : _elementAB.getEnclosedElements()) {
- contents.put(enclosed.getSimpleName().toString(), enclosed);
- }
- Element publicMethod = contents.get("methodIAString");
- Element protectedField = contents.get("_fieldListIA");
- Element privateClass = contents.get("E");
- if (null == publicMethod || null == protectedField || null == privateClass) {
- reportError("AB does not contain the expected enclosed elements");
- return false;
- }
- Set<Modifier> modifiers = publicMethod.getModifiers();
- if (!modifiers.contains(Modifier.PUBLIC) || modifiers.size() > 1) {
- reportError("AB.methodIAString() has unexpected modifiers");
- return false;
- }
- modifiers = protectedField.getModifiers();
- if (!modifiers.contains(Modifier.PROTECTED) || modifiers.size() > 1) {
- reportError("AB._fieldListIA() has unexpected modifiers");
- return false;
- }
- modifiers = privateClass.getModifiers();
- if (!modifiers.contains(Modifier.PRIVATE) || modifiers.size() > 1) {
- reportError("AB.E() has unexpected modifiers");
- return false;
- }
- return true;
- }
-
- /**
- * Examine the hierarchy of element D
- * @return true if all tests passed
- */
- private boolean examineDHierarchy() {
- TypeMirror supertypeD = _elementD.getSuperclass();
- if (null == supertypeD) {
- reportError("element D's supertype was null");
- return false;
- }
- Element superclassD = _typeUtils.asElement(supertypeD);
- if (!_elementAB.equals(superclassD)) {
- reportError("element D's superclass did not equal element AB");
- return false;
- }
-
- return true;
- }
-
- /**
- * Examine the methods and fields of element A
- * @return true if all tests passed
- */
- private boolean examineAMethodsAndFields() {
- // METHODS
- List<? extends Element> enclosedA = _elementA.getEnclosedElements();
- if (enclosedA == null) {
- reportError("elementA.getEnclosedElements() returned null");
- return false;
- }
- List<ExecutableElement> methodsA = ElementFilter.methodsIn(enclosedA);
- ExecutableElement methodIAString = null;
- for (ExecutableElement method : methodsA) {
- Name methodName = method.getSimpleName();
- if ("methodIAString".equals(methodName.toString())) {
- methodIAString = method;
- }
- }
- if (null == methodIAString) {
- reportError("element A did not contain methodIAString()");
- return false;
- }
- if (methodIAString.getKind() != ElementKind.METHOD) {
- reportError("A.methodIAString is not an ElementKind.METHOD");
- return false;
- }
- Element enclosingMethodIAStringInA = methodIAString.getEnclosingElement();
- if (null == enclosingMethodIAStringInA || !_elementA.equals(enclosingMethodIAStringInA)) {
- reportError("Element enclosing A.methodIAString() is not A");
- return false;
- }
-
- // RETURN AND PARAMS
- TypeMirror returnType = methodIAString.getReturnType();
- if (!(returnType instanceof DeclaredType) || returnType.getKind() != TypeKind.DECLARED) {
- reportError("Return type of A.methodIAString() is not a declared type");
- return false;
- }
- if (!_elementString.equals(((DeclaredType)returnType).asElement())) {
- reportError("Return type of A.methodIAString() does not equal java.lang.String");
- return false;
- }
- List<? extends VariableElement> paramsMethodIAString = methodIAString.getParameters();
- VariableElement int1 = null;
- for (VariableElement param : paramsMethodIAString) {
- int1 = param;
- }
- TypeMirror int1Type = int1.asType();
- if (null == int1Type || int1Type.getKind() != TypeKind.INT) {
- reportError("The first parameter of A.methodIAString() is not of int type");
- return false;
- }
- if (!("int1".equals(int1.getSimpleName().toString()))) {
- reportError("The first parameter of A.methodIAString() is not named int1");
- return false;
- }
-
- // FIELDS
- List<VariableElement> fieldsA = ElementFilter.fieldsIn(enclosedA);
- VariableElement fieldAint = null;
- for (VariableElement field : fieldsA) {
- Name fieldName = field.getSimpleName();
- if ("_fieldAint".equals(fieldName.toString())) {
- fieldAint = field;
- }
- }
- if (null == fieldAint) {
- reportError("element A did not contain _fieldAint");
- return false;
- }
- if (fieldAint.getKind() != ElementKind.FIELD) {
- reportError("A._fieldAint is not an ElementKind.FIELD");
- return false;
- }
- return true;
- }
-
- /**
- * Examine the methods of A which have throws clauses
- * @return true if all tests passed
- */
- private boolean examineAMethodThrowables() {
- List<ExecutableElement> methodsA = ElementFilter.methodsIn(_elementA.getEnclosedElements());
- ExecutableElement methodIAString = null; // no throws clauses
- ExecutableElement methodThrows1 = null;
- ExecutableElement methodThrows2 = null;
- for (ExecutableElement method : methodsA) {
- String methodName = method.getSimpleName().toString();
- if ("methodIAString".equals(methodName)) {
- methodIAString = method;
- }
- if ("methodThrows1".equals(methodName)) {
- methodThrows1 = method;
- }
- else if ("methodThrows2".equals(methodName)) {
- methodThrows2 = method;
- }
- }
- if (null == methodIAString || null == methodThrows1 || null == methodThrows2) {
- reportError("element A did not contain methodIAString(), methodThrows1(), or methodThrows2()");
- return false;
- }
- List<? extends TypeMirror> thrownTypes0 = methodIAString.getThrownTypes();
- List<? extends TypeMirror> thrownTypes1 = methodThrows1.getThrownTypes();
- List<? extends TypeMirror> thrownTypes2 = methodThrows2.getThrownTypes();
- if (null == thrownTypes0 || null == thrownTypes1 || null == thrownTypes2) {
- reportError("getThrownTypes() on A.methodIAString(), methodThrows1(), or methodThrows2() returned null");
- return false;
- }
- if (!thrownTypes0.isEmpty()) {
- reportError("A.methodIAString unexpectedly reports having a throws clause");
- return false;
- }
- boolean foundEA = false;
- for (TypeMirror type : thrownTypes1) {
- Element element = _typeUtils.asElement(type);
- if ("ExceptionA".equals(element.getSimpleName().toString())) {
- foundEA = true;
- }
- }
- if (thrownTypes1.size() != 1 || !foundEA) {
- reportError("A.methodThrows1() reported unexpected throwables");
- return false;
- }
- foundEA = false;
- boolean foundUOE = false;
- for (TypeMirror type : thrownTypes2) {
- Element element = _typeUtils.asElement(type);
- if ("UnsupportedOperationException".equals(element.getSimpleName().toString())) {
- foundUOE = true;
- }
- else if ("ExceptionA".equals(element.getSimpleName().toString())) {
- foundEA = true;
- }
- }
- if (thrownTypes2.size() != 2 || !foundEA || !foundUOE) {
- reportError("A.methodThrows2() reported unexpected throwables");
- return false;
- }
- return true;
- }
-
- /**
- * Examine the methods of D (which are interesting because of an enum param and void return)
- * @return true if all tests passed
- */
- private boolean examineDMethods() {
- List<ExecutableElement> methodsD = ElementFilter.methodsIn(_elementD.getEnclosedElements());
- _methodDvoid = null;
- for (ExecutableElement method : methodsD) {
- Name methodName = method.getSimpleName();
- if ("methodDvoid".equals(methodName.toString())) {
- _methodDvoid = method;
- }
- }
- if (null == _methodDvoid) {
- reportError("element D did not contain methodDvoid()");
- return false;
- }
- TypeMirror returnType = _methodDvoid.getReturnType();
- if (returnType.getKind() != TypeKind.VOID) {
- reportError("D.methodDvoid() return type was not void");
- return false;
- }
- List<? extends VariableElement> params = _methodDvoid.getParameters();
- if (null == params || params.isEmpty()) {
- reportError("D.methodDvoid() reports no parameters");
- return false;
- }
- VariableElement param1 = params.iterator().next();
- TypeMirror param1Type = param1.asType();
- if (null == param1Type || param1Type.getKind() != TypeKind.DECLARED) {
- reportError("First parameter of D.methodDvoid() is not a declared type");
- return false;
- }
- if (!"targets.model.pb.D.DEnum".equals(param1Type.toString())) {
- reportError("Type of first parameter of D.methodDvoid() is not DEnum");
- return false;
- }
- Element param1TypeElement = ((DeclaredType)param1Type).asElement();
- if (null == param1TypeElement || param1TypeElement.getKind() != ElementKind.ENUM || !(param1TypeElement instanceof TypeElement)) {
- reportError("Type of first parameter of D.methodDvoid() is not an enum");
- return false;
- }
- _elementDEnum = (TypeElement)param1TypeElement;
- return true;
- }
-
- /**
- * Check the DEnum type declared inside element D
- * @return true if all tests passed
- */
- private boolean examineDEnum()
- {
- if (_elementDEnum.getNestingKind() != NestingKind.MEMBER) {
- reportError("Type DEnum is not NestingKind.MEMBER");
- return false;
- }
- Map<String, VariableElement> values = new LinkedHashMap<String, VariableElement>();
- for (VariableElement enclosedElement : ElementFilter.fieldsIn(_elementDEnum.getEnclosedElements())) {
- values.put(enclosedElement.getSimpleName().toString(), enclosedElement);
- }
- if (values.size() != 3) {
- reportError("DEnum should have three values, but instead has: " + values.size());
- return false;
- }
- Iterator<String> iter = values.keySet().iterator();
- if (!"DEnum1".equals(iter.next()) || !"DEnum2".equals(iter.next()) || !"DEnum3".equals(iter.next())) {
- reportError("DEnum does not have the expected values in the expected order");
- return false;
- }
- return true;
- }
-
- /**
- * Check the PackageDeclaration of pb
- * @return true if all tests passed
- */
- private boolean examinePBPackage() {
- Element packagePB = _elementAB.getEnclosingElement();
- if (!(packagePB instanceof PackageElement) || packagePB.getKind() != ElementKind.PACKAGE) {
- reportError("element AB is not enclosed by a package");
- return false;
- }
- if (!("targets.model.pb".equals(((PackageElement)packagePB).getQualifiedName().toString()))) {
- reportError("The name of package pb is not targets.model.pb");
- return false;
- }
- return true;
- }
-
- /**
- * Read the annotations on element D (class and method)
- * @return true if all tests passed
- */
- private boolean examineDAnnotations() {
- // Examine annotation on class declaration
- List<? extends AnnotationMirror> annotsD = _elementD.getAnnotationMirrors();
- if (null == annotsD || annotsD.isEmpty()) {
- reportError("element D reports no annotations");
- return false;
- }
- for (AnnotationMirror annotD : annotsD) {
- DeclaredType annotDType = annotD.getAnnotationType();
- if (null == annotDType) {
- reportError("annotation mirror of AnnoZ on element D reports null type");
- return false;
- }
- Element annotDElem = annotDType.asElement();
- if (!(annotDElem instanceof TypeElement) ||
- !"targets.model.pa.AnnoZ".equals(((TypeElement)annotDElem).getQualifiedName().toString())) {
- reportError("annotation on element D is not TypeElement targets.model.pa.AnnoZ");
- return false;
- }
- Map<? extends ExecutableElement, ? extends AnnotationValue> values = annotD.getElementValues();
- if (null == values || values.isEmpty()) {
- reportError("@AnnoZ on element D reports no values");
- return false;
- }
- boolean foundStringMethod = false;
- for (Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : values.entrySet()) {
- String methodName = entry.getKey().getSimpleName().toString();
- if ("annoZString".equals(methodName)) {
- foundStringMethod = true;
- Object value = entry.getValue().getValue();
- if (!"annoZOnD".equals(value)) {
- reportError("Value of annoZString param on element D is not \"annoZOnD\"");
- return false;
- }
- }
- }
- if (!foundStringMethod) {
- reportError("Failed to find method annoZString on @AnnoZ on element D");
- return false;
- }
-
- // Check Elements.getElementValuesWithDefaults()
- Map<? extends ExecutableElement, ? extends AnnotationValue> defaults =
- _elementUtils.getElementValuesWithDefaults(annotD);
- if (null == defaults) {
- reportError("Element.getElementValuesWithDefaults(annotD) returned null");
- return false;
- }
- for (Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : defaults.entrySet()) {
- String methodName = entry.getKey().getSimpleName().toString();
- if ("annoZString".equals(methodName)) {
- foundStringMethod = true;
- Object value = entry.getValue().getValue();
- if (!"annoZOnD".equals(value)) {
- reportError("Explicit value of AnnoZ.annoZString is not \"annoZOnD\"");
- return false;
- }
- }
- else if ("annoZint".equals(methodName)) {
- foundStringMethod = true;
- Object value = entry.getValue().getValue();
- if (null == value || !value.equals(17)) {
- reportError("Default value of AnnoZ.annoZint() is not 17");
- return false;
- }
- }
- }
- }
-
- List<? extends AnnotationMirror> annotsMethodDvoid = _methodDvoid.getAnnotationMirrors();
- if (null == annotsMethodDvoid || annotsMethodDvoid.isEmpty()) {
- reportError("method D.methodDvoid() reports no annotations");
- return false;
- }
- for (AnnotationMirror annotMethodDvoid : annotsMethodDvoid) {
- DeclaredType annotDType = annotMethodDvoid.getAnnotationType();
- if (null == annotDType) {
- reportError("annotation mirror of AnnoZ on D.methodDvoid() reports null type");
- return false;
- }
- Element annotDElem = annotDType.asElement();
- if (!(annotDElem instanceof TypeElement) ||
- !"targets.model.pa.AnnoZ".equals(((TypeElement)annotDElem).getQualifiedName().toString())) {
- reportError("annotation on D.methodDvoid() is not TypeElement targets.model.pa.AnnoZ");
- return false;
- }
- Map<? extends ExecutableElement, ? extends AnnotationValue> values = annotMethodDvoid.getElementValues();
- if (null == values || values.isEmpty()) {
- reportError("@AnnoZ on D.methodDvoid() reports no values");
- return false;
- }
- boolean foundIntMethod = false;
- for (Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : values.entrySet()) {
- String methodName = entry.getKey().getSimpleName().toString();
- if ("annoZint".equals(methodName)) {
- foundIntMethod = true;
- Object value = entry.getValue().getValue();
- if (!(value instanceof Integer) || (Integer)value != 31) {
- reportError("Value of annoZint param on D.methodDvoid() is not 31");
- return false;
- }
- }
- }
- if (!foundIntMethod) {
- reportError("Failed to find method annoZint on @AnnoZ on D.methodDvoid()");
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Test the Element.getAnnotation() implementation
- * @return true if all tests passed
- */
- private boolean examineGetAnnotation() {
- TypeElement annotatedElement = _elementUtils.getTypeElement("targets.model.pc.AnnotatedWithManyTypes.Annotated");
- if (null == annotatedElement || annotatedElement.getKind() != ElementKind.CLASS) {
- reportError("examineGetAnnotation: couldn't get AnnotatedWithManyTypes.Annotated element");
- return false;
- }
- final String badValue = "examineGetAnnotation: unexpected value for ";
- TypedAnnos.AnnoByte annoByte = annotatedElement.getAnnotation(TypedAnnos.AnnoByte.class);
- if (null == annoByte || annoByte.value() != 3) {
- reportError(badValue + "AnnoByte");
- return false;
- }
- TypedAnnos.AnnoBoolean annoBoolean = annotatedElement.getAnnotation(TypedAnnos.AnnoBoolean.class);
- if (null == annoBoolean || !annoBoolean.value()) {
- reportError(badValue + "AnnoBoolean");
- return false;
- }
- TypedAnnos.AnnoChar annoChar = annotatedElement.getAnnotation(TypedAnnos.AnnoChar.class);
- if (null == annoChar || annoChar.value() != 'c') {
- reportError(badValue + "AnnoChar");
- return false;
- }
- TypedAnnos.AnnoDouble annoDouble = annotatedElement.getAnnotation(TypedAnnos.AnnoDouble.class);
- if (null == annoDouble || annoDouble.value() != 6.3) {
- reportError(badValue + "AnnoDouble");
- return false;
- }
- TypedAnnos.AnnoFloat annoFloat = annotatedElement.getAnnotation(TypedAnnos.AnnoFloat.class);
- if (null == annoFloat || annoFloat.value() != 26.7F) {
- reportError(badValue + "AnnoFloat");
- return false;
- }
- TypedAnnos.AnnoInt annoInt = annotatedElement.getAnnotation(TypedAnnos.AnnoInt.class);
- if (null == annoInt || annoInt.value() != 19) {
- reportError(badValue + "AnnoInt");
- return false;
- }
- TypedAnnos.AnnoLong annoLong = annotatedElement.getAnnotation(TypedAnnos.AnnoLong.class);
- if (null == annoLong || annoLong.value() != 300L) {
- reportError(badValue + "AnnoLong");
- return false;
- }
- TypedAnnos.AnnoShort annoShort = annotatedElement.getAnnotation(TypedAnnos.AnnoShort.class);
- if (null == annoShort || annoShort.value() != 289) {
- reportError(badValue + "AnnoShort");
- return false;
- }
- TypedAnnos.AnnoString annoString = annotatedElement.getAnnotation(TypedAnnos.AnnoString.class);
- if (null == annoString || !"foo".equals(annoString.value())) {
- reportError(badValue + "AnnoString");
- return false;
- }
- TypedAnnos.AnnoEnumConst annoEnumConst = annotatedElement.getAnnotation(TypedAnnos.AnnoEnumConst.class);
- if (null == annoEnumConst || annoEnumConst.value() != TypedAnnos.Enum.A) {
- reportError(badValue + "AnnoEnumConst");
- return false;
- }
- TypedAnnos.AnnoType annoType = annotatedElement.getAnnotation(TypedAnnos.AnnoType.class);
- if (null == annoType) {
- reportError(badValue + "AnnoType");
- return false;
- }
- try {
- Class<?> clazz = annoType.value();
- reportError("examineGetAnnotation: annoType.value() should have thrown a MirroredTypeException but instead returned " + clazz);
- return false;
- }
- catch (MirroredTypeException mte) {
- TypeMirror clazzMirror = mte.getTypeMirror();
- if (null == clazzMirror || clazzMirror.getKind() != TypeKind.DECLARED) {
- reportError("examineGetAnnotation: annoType.value() returned an incorrect mirror: " + clazzMirror);
- return false;
- }
- }
- TypedAnnos.AnnoAnnoChar annoAnnoChar = annotatedElement.getAnnotation(TypedAnnos.AnnoAnnoChar.class);
- if (null == annoAnnoChar || null == annoAnnoChar.value() || 'x' != annoAnnoChar.value().value()) {
- reportError(badValue + "AnnoAnnoChar");
- return false;
- }
- TypedAnnos.AnnoArrayInt annoArrayInt = annotatedElement.getAnnotation(TypedAnnos.AnnoArrayInt.class);
- if (null == annoArrayInt) {
- reportError(badValue + "AnnoArrayInt");
- return false;
- }
- int[] arrayInt = annoArrayInt.value();
- if (arrayInt == null || arrayInt.length != 3 || arrayInt[1] != 8) {
- reportError(badValue + "AnnoArrayInt contents");
- return false;
- }
- //TODO: AnnoArrayString
- //TODO: AnnoArrayAnnoChar
- //TODO: AnnoArrayEnumConst
- TypedAnnos.AnnoArrayType annoArrayType = annotatedElement.getAnnotation(TypedAnnos.AnnoArrayType.class);
- if (null == annoArrayType) {
- reportError(badValue + "AnnoArrayType");
- return false;
- }
- try {
- Class<?>[] contents = annoArrayType.value();
- reportError("examineGetAnnotation: annoArrayType.value() should have thrown a MirroredTypesException but instead returned " + contents);
- return false;
- }
- catch (MirroredTypesException mte) {
- List<? extends TypeMirror> clazzMirrors = mte.getTypeMirrors();
- if (null == clazzMirrors || clazzMirrors.size() != 2) {
- reportError("examineGetAnnotation: annoArrayType.value() returned an incorrect mirror list");
- return false;
- }
- }
- catch (MirroredTypeException mte) {
- // ignore, because javac incorrectly throws this; see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6519115
- }
- return true;
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elementutils/ElementUtilsProc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elementutils/ElementUtilsProc.java
deleted file mode 100644
index cebde2e875..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elementutils/ElementUtilsProc.java
+++ /dev/null
@@ -1,950 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests.processors.elementutils;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.util.ElementFilter;
-import javax.lang.model.util.Elements;
-
-import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
-
-/**
- * A processor that exercises the methods on the Elements utility. To enable this processor, add
- * -Aorg.eclipse.jdt.compiler.apt.tests.processors.elementutils.ElementUtilsProc to the command line.
- * @since 3.3
- */
-@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-public class ElementUtilsProc extends BaseProcessor
-{
- // Initialized in collectElements()
- private TypeElement _elementF;
- private TypeElement _elementFChild;
- private TypeElement _elementFEnum;
- private TypeElement _elementG;
- private TypeElement _elementH;
- private TypeElement _elementJ;
- private TypeElement _elementAnnoX;
- private ExecutableElement _annoXValue;
- private TypeElement _elementAnnoY;
- private ExecutableElement _annoYValue;
-
- // Always return false from this processor, because it supports "*".
- // The return value does not signify success or failure!
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
- {
- if (roundEnv.processingOver()) {
- // We're not interested in the postprocessing round.
- return false;
- }
- Map<String, String> options = processingEnv.getOptions();
- if (!options.containsKey(this.getClass().getName())) {
- // Disable this processor unless we are intentionally performing the test.
- return false;
- }
-
- if (!collectElements()) {
- return false;
- }
-
- if (!examineGetAllAnnotations()) {
- return false;
- }
-
- if (!examineGetAllMembers()) {
- return false;
- }
-
- if (!examineIsDeprecated()) {
- return false;
- }
-
- if (!examineBinaryName()) {
- return false;
- }
-
- if (!examineGetDocComment()) {
- return false;
- }
-
- if (!examineHidesField()) {
- return false;
- }
-
- if (!examineHidesClass()) {
- return false;
- }
-
- if (!examineHidesMethod()) {
- return false;
- }
-
- if (!examineOverrides()) {
- return false;
- }
-
- reportSuccess();
- return false;
- }
-
- /**
- * Collect some elements that will be reused in various tests
- * @return true if successful
- */
- private boolean collectElements()
- {
- _elementF = _elementUtils.getTypeElement("targets.model.pc.F");
- if (_elementF == null || _elementF.getKind() != ElementKind.CLASS) {
- reportError("element F was not found or was not a class");
- return false;
- }
- _elementFChild = _elementUtils.getTypeElement("targets.model.pc.F.FChild");
- if (_elementFChild == null || _elementFChild.getKind() != ElementKind.CLASS) {
- reportError("element FChild was not found or was not a class");
- return false;
- }
- _elementFEnum = _elementUtils.getTypeElement("targets.model.pc.F.FEnum");
- if (_elementFEnum == null || _elementFEnum.getKind() != ElementKind.ENUM) {
- reportError("enum F.FEnum was not found or was not an enum");
- return false;
- }
- _elementG = _elementUtils.getTypeElement("targets.model.pc.G");
- if (_elementG == null || _elementG.getKind() != ElementKind.CLASS) {
- reportError("element G was not found or was not a class");
- return false;
- }
- _elementH = _elementUtils.getTypeElement("targets.model.pc.H");
- if (_elementH == null || _elementH.getKind() != ElementKind.CLASS) {
- reportError("element H was not found or was not a class");
- return false;
- }
- _elementJ = _elementUtils.getTypeElement("targets.model.pc.J");
- if (_elementJ == null || _elementJ.getKind() != ElementKind.CLASS) {
- reportError("element J was not found or was not a class");
- return false;
- }
-
- _elementAnnoX = _elementUtils.getTypeElement("targets.model.pc.AnnoX");
- if (null == _elementAnnoX || _elementAnnoX.getKind() != ElementKind.ANNOTATION_TYPE) {
- reportError("annotation type annoX was not found or was not an annotation");
- return false;
- }
- for (ExecutableElement method : ElementFilter.methodsIn(_elementAnnoX.getEnclosedElements())) {
- if ("value".equals(method.getSimpleName().toString())) {
- _annoXValue = method;
- }
- }
- if (null == _annoXValue) {
- reportError("Could not find value() method in annotation type AnnoX");
- return false;
- }
-
- _elementAnnoY = _elementUtils.getTypeElement("targets.model.pc.AnnoY");
- if (null == _elementAnnoY || _elementAnnoY.getKind() != ElementKind.ANNOTATION_TYPE) {
- reportError("annotation type annoY was not found or was not an annotation");
- return false;
- }
- for (ExecutableElement method : ElementFilter.methodsIn(_elementAnnoY.getEnclosedElements())) {
- if ("value".equals(method.getSimpleName().toString())) {
- _annoYValue = method;
- }
- }
- if (null == _annoYValue) {
- reportError("Could not find value() method in annotation type AnnoY");
- return false;
- }
-
- return true;
- }
-
- /**
- * Test the {@link Elements#getAllAnnotationMirrors()} method
- * @return true if all tests passed
- */
- private boolean examineGetAllAnnotations()
- {
- List<? extends AnnotationMirror> annotationsH = _elementUtils.getAllAnnotationMirrors(_elementH);
- if (null == annotationsH) {
- reportError("examineGetAllAnnotations: getAllAnnotationMirrors(_elementH) returned null");
- return false;
- }
- // H has AnnoY("on H"), G has AnnoX("on G"), and F has hidden AnnoY("on F").
- int foundF = 0;
- int foundG = 0;
- int foundH = 0;
- for (AnnotationMirror anno : annotationsH) {
- Map<? extends ExecutableElement, ? extends AnnotationValue> values = anno.getElementValues();
- AnnotationValue valueY = values.get(_annoYValue);
- if (null != valueY) {
- if ("on F".equals(valueY.getValue())) {
- foundF++;
- }
- else if ("on H".equals(valueY.getValue())) {
- foundH++;
- }
- else {
- reportError("examineGetAllAnnotations: unexpected value for annotation AnnoY");
- return false;
- }
- }
- else {
- AnnotationValue valueX = values.get(_annoXValue);
- if (null != valueX) {
- if ("on G".equals(valueX.getValue())) {
- foundG++;
- }
- else {
- reportError("examineGetAllAnnotations: unexpected value for annotation AnnoX");
- return false;
- }
- }
- else {
- reportError("examineGetAllAnnotations: getAllAnnotationMirrors(_elementH) returned a mirror with no value()");
- return false;
- }
- }
- }
- if (0 != foundF || 1 != foundG || 1 != foundH) {
- reportError("examineGetAllAnnotations: getAllAnnotationMirrors() found wrong number of annotations on H");
- return false;
- }
- return true;
- }
-
- /**
- * Test the {@link Elements#getAllMembers()} method
- * @return true if all tests passed
- */
- private boolean examineGetAllMembers()
- {
- List<? extends Element> members = _elementUtils.getAllMembers(_elementG);
- if (null == members) {
- reportError("examineGetAllMembers: getAllMembers(_elementG) returned null");
- return false;
- }
-
- // G member list should contain Object methods, e.g., hashCode()
- boolean foundHashCode = false;
- for (ExecutableElement method : ElementFilter.methodsIn(members)) {
- if ("hashCode".equals(method.getSimpleName().toString())) {
- foundHashCode = true;
- break;
- }
- }
- if (!foundHashCode) {
- reportError("examineGetAllMembers: getAllMembers(_elementG) did not include method hashCode()");
- return false;
- }
-
- // G member list should contain F's nested FChild class
- boolean foundFChild = false;
- for (TypeElement type : ElementFilter.typesIn(members)) {
- if (type.equals(_elementFChild)) {
- foundFChild = true;
- break;
- }
- }
- if (!foundFChild) {
- reportError("examineGetAllMembers: getAllMembers(_elementG) did not include class FChild");
- return false;
- }
-
- // G member list should contain F's _fieldT1_protected
- // G member list should not contain F's _fieldT1_private, because it is hidden
- boolean foundFProtectedField = false;
- for (VariableElement field : ElementFilter.fieldsIn(members)) {
- if ("_fieldT1_protected".equals(field.getSimpleName().toString())) {
- foundFProtectedField = true;
- }
- else if ("_fieldT1_private".equals(field.getSimpleName().toString())) {
- reportError("examineGetAllMembers: getAllMembers(_elementG) included the private inherited field _fieldT1_private");
- return false;
- }
- }
- if (!foundFProtectedField) {
- reportError("examineGetAllMembers: getAllMembers(_elementG) did not return the protected inherited field _fieldT1_protected");
- return false;
- }
-
- // G member list should contain G() constructor
- // G member list should not contain F() constructor
- boolean foundGConstructor = false;
- for (ExecutableElement method : ElementFilter.constructorsIn(members)) {
- Element enclosing = method.getEnclosingElement();
- if (_elementG.equals(enclosing)) {
- foundGConstructor = true;
- }
- else {
- reportError("examineGetAllMembers: getAllMembers(_elementG) returned a constructor for an element other than G");
- return false;
- }
- }
- if (!foundGConstructor) {
- reportError("examineGetAllMembers: getAllMembers(_elementG) did not include G's constructor");
- return false;
- }
-
- // G member list should contain G's method_T1(String)
- // G member list should not contain F's method_T1(T1), because it is overridden by G
- boolean foundGMethodT1 = false;
- for (ExecutableElement method : ElementFilter.methodsIn(members)) {
- Element enclosing = method.getEnclosingElement();
- if ("method_T1".equals(method.getSimpleName().toString())) {
- if (_elementG.equals(enclosing)) {
- foundGMethodT1 = true;
- }
- else {
- reportError("examineGetAllMembers: getAllMembers(_elementG) included an overridden version of method_T1()");
- return false;
- }
- }
- }
- if (!foundGMethodT1) {
- reportError("examineGetAllMembers: getAllMembers(_elementG) did not include G's method_T1(String)");
- return false;
- }
- return true;
- }
-
- /**
- * Test the {@link Elements#isDeprecated()} method
- * @return true if all tests passed
- */
- private boolean examineIsDeprecated()
- {
- Element _deprecatedElem = _elementUtils.getTypeElement("targets.model.pc.Deprecation");
- if (null == _deprecatedElem) {
- reportError("examineIsDeprecated: Couldn't find targets.model.pc.Deprecation");
- return false;
- }
- ExecutableElement methodDeprecated = null;
- ExecutableElement methodNotDeprecated = null;
- for (ExecutableElement method : ElementFilter.methodsIn(_deprecatedElem.getEnclosedElements())) {
- if ("deprecatedMethod".equals(method.getSimpleName().toString())) {
- methodDeprecated = method;
- }
- else if ("nonDeprecatedMethod".equals(method.getSimpleName().toString())) {
- methodNotDeprecated = method;
- }
- }
- if (null == methodDeprecated || null == methodNotDeprecated) {
- reportError("examineIsDeprecated: Could not find methods Deprecation.deprecatedMethod() or Deprecation.nonDeprecatedMethod()");
- return false;
- }
- if (_elementUtils.isDeprecated(methodNotDeprecated)) {
- reportError("examineIsDeprecated: ElementUtils.isDeprecated(Deprecation.nonDeprecatedMethod()) is true");
- return false;
- }
- if (!_elementUtils.isDeprecated(methodDeprecated)) {
- reportError("examineIsDeprecated: ElementUtils.isDeprecated(Deprecation.deprecatedMethod()) is false");
- return false;
- }
- TypeElement classDeprecated = null;
- TypeElement classNotDeprecated = null;
- TypeElement interfaceDeprecated = null;
- TypeElement interfaceNotDeprecated = null;
- for (TypeElement type : ElementFilter.typesIn(_deprecatedElem.getEnclosedElements())) {
- if ("deprecatedClass".equals(type.getSimpleName().toString())) {
- classDeprecated = type;
- }
- else if ("nonDeprecatedClass".equals(type.getSimpleName().toString())) {
- classNotDeprecated = type;
- }
- else if ("deprecatedInterface".equals(type.getSimpleName().toString())) {
- interfaceDeprecated = type;
- }
- else if ("nonDeprecatedInterface".equals(type.getSimpleName().toString())) {
- interfaceNotDeprecated = type;
- }
- }
- if (null == classDeprecated || null == classNotDeprecated) {
- reportError("examineIsDeprecated: Could not find methods Deprecation.deprecatedClass() or Deprecation.nonDeprecatedClass()");
- return false;
- }
- if (null == interfaceDeprecated || null == interfaceNotDeprecated) {
- reportError("examineIsDeprecated: Could not find methods Deprecation.deprecatedInterface() or Deprecation.nonDeprecatedInterface()");
- return false;
- }
- if (_elementUtils.isDeprecated(classNotDeprecated)) {
- reportError("examineIsDeprecated: ElementUtils.isDeprecated(Deprecation.nonDeprecatedClass()) is true");
- return false;
- }
- if (!_elementUtils.isDeprecated(classDeprecated)) {
- reportError("examineIsDeprecated: ElementUtils.isDeprecated(Deprecation.deprecatedClass()) is false");
- return false;
- }
- if (_elementUtils.isDeprecated(interfaceNotDeprecated)) {
- reportError("examineIsDeprecated: ElementUtils.isDeprecated(Deprecation.nonDeprecatedInterface()) is true");
- return false;
- }
- if (!_elementUtils.isDeprecated(interfaceDeprecated)) {
- reportError("examineIsDeprecated: ElementUtils.isDeprecated(Deprecation.deprecatedInterface()) is false");
- return false;
- }
-
- TypeElement deprecatedInnerClass = _elementUtils.getTypeElement("targets.model.pc.Deprecation.deprecatedClass");
- if (null == deprecatedInnerClass) {
- reportError("examineIsDeprecated: Couldn't find class Deprecation.deprecatedClass");
- return false;
- }
-
- return true;
- }
-
- /**
- * Test the {@link Elements#getBinaryName(TypeElement)} method
- * @return true if all tests passed
- */
- private boolean examineBinaryName() {
- final String refNameF = "targets.model.pc.F";
- final String refBNameFChild = "targets.model.pc.F$FChild";
- final String refBNameFEnum = "targets.model.pc.F$FEnum";
- String bnameF = _elementUtils.getBinaryName(_elementF).toString();
- if (!refNameF.equals(bnameF)) {
- reportError("examineBinaryName: getBinaryName(F) should be " + refNameF + ", was: " + bnameF);
- return false;
- }
- String bnameFChild = _elementUtils.getBinaryName(_elementFChild).toString();
- if (!refBNameFChild.equals(bnameFChild)) {
- reportError("examineBinaryName: getBinaryName(F) should be " + refBNameFChild + ", was: " + bnameF);
- return false;
- }
- String bnameFEnum = _elementUtils.getBinaryName(_elementFEnum).toString();
- if (!refBNameFEnum.equals(bnameFEnum)) {
- reportError("examineBinaryName: getBinaryName(F) should be " + refBNameFEnum + ", was: " + bnameF);
- return false;
- }
- return true;
- }
-
- /**
- * Test the {@link Elements#getDocComment(TypeElement)} method
- * @return true if all tests passed
- */
- private boolean examineGetDocComment() {
- // Javadoc for element F and its enclosed elements - map of element simple name to javadoc
- Map<String, String> nameToDoc = new HashMap<String, String>();
- nameToDoc.put("F", " Javadoc on element F\n @param <T1> a type parameter\n");
- nameToDoc.put("FChild", " Javadoc on nested element FChild\n");
- nameToDoc.put("FEnum", " Javadoc on nested enum FEnum\n Two lines long\n");
- nameToDoc.put("FChildI",
- " Javadoc on nested interface FChildI\n" +
- "\tthis line has tab after asterisk and ends with another tab\t\n" +
- "\tthis one too\t\n" +
- " this line has three spaces after asterisk and ends with three spaces \n" +
- " this line has only one space before the asterisk\n");
- nameToDoc.put("_fieldT1_protected", "Javadoc on field _fieldT1_protected, inline format ");
- nameToDoc.put("_fieldT1_private",
- "\n" +
- " Javadoc on _fieldT1_private\n" +
- " this line starts with two spaces, no asterisk\n" +
- " This line starts, contains\tand ends with a tab\t\n" +
- " This line starts with a space, tab, space, tab, space\n");
- nameToDoc.put("fieldInt", null);
- nameToDoc.put("method_T1", " Javadoc on F.method_T1\n");
- nameToDoc.put("method_String", null);
- nameToDoc.put("getAnonymousObjectAbstract", "");
- nameToDoc.put("add", "\n @add(int)\n");
- nameToDoc.put("foo", "\n Creates a new instance of AllChecks \n");
- nameToDoc.put("bar", " @bar\t(int)\n");
- nameToDoc.put("bar2", "\t@bar2(int)\n");
- nameToDoc.put("m", " Method\tm\n");
- nameToDoc.put("m1", "This is a comment for the method m1,\n" +
- " it is on two lines\n");
- nameToDoc.put("m2", "Another comment - starts on first line and\n" +
- " continue on the second line ");
- nameToDoc.put("m3", " One more test case that.\n" +
- " needs\n" +
- " to be verified.\n" +
- "\n" +
- " An empty line with no spaces need to be seen as an empty line.\n" +
- "\n" +
- " End of the comment.\n");
-
- String actual = _elementUtils.getDocComment(_elementF);
- String expected = nameToDoc.get("F");
- if (!expected.equals(actual)) {
- reportError("examineGetDocComment: Unexpected result from getDocComment(F): " + actual);
- return false;
- }
- for (Element e : _elementF.getEnclosedElements()) {
- String name = e.getSimpleName().toString();
- if (nameToDoc.containsKey(name)) {
- actual = _elementUtils.getDocComment(e);
- expected = nameToDoc.get(name);
- if (expected == null && actual != null) {
- reportError("examineGetDocComment: Expected getDocComment(" + name + ") to return null, but got " + _elementUtils.getDocComment(e));
- return false;
- }
- else if (expected != null) {
- if (!expected.equals(actual)) {
- reportError("examineGetDocComment: Unexpected result from getDocComment(" + name + "): " + _elementUtils.getDocComment(e));
- return false;
- }
- }
-
- }
- }
-
- return true;
- }
-
- /**
- * Test the {@link Elements#hides(Element, Element)} method for fields
- * @return true if all tests passed
- */
- private boolean examineHidesField() {
- VariableElement fieldIntJ = null;
- VariableElement fieldIntH = null;
- VariableElement fieldIntG = null;
- VariableElement fieldIntF = null;
- ExecutableElement methodFieldIntJ = null;
- for (VariableElement field : ElementFilter.fieldsIn(_elementF.getEnclosedElements())) {
- if ("fieldInt".equals(field.getSimpleName().toString())) {
- fieldIntF = field;
- break;
- }
- }
- for (VariableElement field : ElementFilter.fieldsIn(_elementG.getEnclosedElements())) {
- if ("fieldInt".equals(field.getSimpleName().toString())) {
- fieldIntG = field;
- break;
- }
- }
- for (VariableElement field : ElementFilter.fieldsIn(_elementH.getEnclosedElements())) {
- if ("fieldInt".equals(field.getSimpleName().toString())) {
- fieldIntH = field;
- break;
- }
- }
- for (VariableElement field : ElementFilter.fieldsIn(_elementJ.getEnclosedElements())) {
- if ("fieldInt".equals(field.getSimpleName().toString())) {
- fieldIntJ = field;
- break;
- }
- }
- for (ExecutableElement method : ElementFilter.methodsIn(_elementJ.getEnclosedElements())) {
- if ("fieldInt".equals(method.getSimpleName().toString())) {
- methodFieldIntJ = method;
- break;
- }
- }
- if (null == fieldIntJ || null == fieldIntH || null == fieldIntG || null == fieldIntF) {
- reportError("examineHidesField: Failed to find field \"fieldInt\" in either F, G, H, or J");
- return false;
- }
- if (null == methodFieldIntJ) {
- reportError("examineHidesField: Failed to find method \"fieldInt()\" in J");
- return false;
- }
- // Should hide:
- if (!_elementUtils.hides(fieldIntH, fieldIntF)) {
- reportError("examineHidesField: H.fieldInt should hide F.fieldInt");
- return false;
- }
- // Should not hide:
- if (_elementUtils.hides(fieldIntF, fieldIntF)) {
- reportError("examineHidesField: F.fieldInt should not hide itself");
- return false;
- }
- if (_elementUtils.hides(fieldIntF, fieldIntG)) {
- reportError("examineHidesField: F.fieldInt should not hide G.fieldInt");
- return false;
- }
- if (!_elementUtils.hides(fieldIntG, fieldIntF)) {
- reportError("examineHidesField: G.fieldInt should hide F.fieldInt");
- return false;
- }
- if (_elementUtils.hides(fieldIntJ, fieldIntG)) {
- reportError("examineHidesField: J.fieldInt should not hide G.fieldInt");
- return false;
- }
- if (_elementUtils.hides(fieldIntJ, methodFieldIntJ)) {
- reportError("examineHidesField: field J.fieldInt should not hide method J.fieldInt()");
- return false;
- }
- return true;
- }
-
- /**
- * Test the {@link Elements#hides(Element, Element)} method for nested classes
- * @return true if all tests passed
- */
- private boolean examineHidesClass() {
- TypeElement elementFChildOnF = null;
- TypeElement elementFChildOnH = null;
- TypeElement elementFOnJ = null;
- TypeElement elementFChildOnJ = null;
- TypeElement elementIFChildOnIF = null;
- TypeElement elementIFChildOnH = null;
- TypeElement elementIF = _elementUtils.getTypeElement("targets.model.pc.IF");
- for (TypeElement element : ElementFilter.typesIn(elementIF.getEnclosedElements())) {
- String name = element.getSimpleName().toString();
- if ("IFChild".equals(name)) {
- elementIFChildOnIF = element;
- break;
- }
- }
- for (TypeElement element : ElementFilter.typesIn(_elementF.getEnclosedElements())) {
- String name = element.getSimpleName().toString();
- if ("FChild".equals(name)) {
- elementFChildOnF = element;
- break;
- }
- }
- for (TypeElement element : ElementFilter.typesIn(_elementH.getEnclosedElements())) {
- String name = element.getSimpleName().toString();
- if ("FChild".equals(name)) {
- elementFChildOnH = element;
- }
- else if ("IFChild".equals(name)) {
- elementIFChildOnH = element;
- }
- }
- for (TypeElement element : ElementFilter.typesIn(_elementJ.getEnclosedElements())) {
- String name = element.getSimpleName().toString();
- if ("FChild".equals(name)) {
- elementFChildOnJ = element;
- }
- else if ("F".equals(name)) {
- elementFOnJ = element;
- }
- }
- Element elementFPackage = _elementF.getEnclosingElement();
-
- // Should hide:
- if (!_elementUtils.hides(elementFChildOnH, elementFChildOnF)) {
- reportError("examineHidesClass: H.FChild should hide F.FChild");
- return false;
- }
- if (!_elementUtils.hides(elementIFChildOnH, elementIFChildOnIF)) {
- reportError("examineHidesClass: H.IFChild should hide IF.IFChild");
- return false;
- }
- // Should not hide:
- if (_elementUtils.hides(elementFChildOnF, elementFChildOnF)) {
- reportError("examineHidesClass: F.FChild should not hide itself");
- return false;
- }
- if (_elementUtils.hides(elementIFChildOnH, elementFChildOnF)) {
- reportError("examineHidesClass: H.IFChild should not hide F.FChild");
- return false;
- }
- if (_elementUtils.hides(elementFChildOnF, elementFChildOnH)) {
- reportError("examineHidesClass: F.FChild should not hide H.FChild");
- return false;
- }
- if (_elementUtils.hides(elementFChildOnJ, elementFChildOnF)) {
- reportError("examineHidesClass: J.FChild should not hide F.FChild");
- return false;
- }
- if (_elementUtils.hides(_elementF, elementFOnJ)) {
- reportError("examineHidesClass: J.F should not hide F");
- return false;
- }
- if (_elementUtils.hides(_elementF, elementFPackage) || _elementUtils.hides(elementFPackage, _elementF)) {
- reportError("examineHidesClass: F should not hide its enclosing package, and vice versa");
- return false;
- }
- return true;
- }
-
- /**
- * Test the {@link Elements#hides(Element, Element)} method for methods
- * @return true if all tests passed
- */
- private boolean examineHidesMethod() {
- ExecutableElement methodStaticOnF = null;
- ExecutableElement methodStatic2OnF = null;
- ExecutableElement methodT1OnF = null;
- ExecutableElement methodStaticOnG = null;
- ExecutableElement methodT1OnG = null;
- ExecutableElement methodStaticOnH = null;
- ExecutableElement methodStaticIntOnH = null;
- ExecutableElement methodStaticOnJ = null;
- for (ExecutableElement method : ElementFilter.methodsIn(_elementF.getEnclosedElements())) {
- String name = method.getSimpleName().toString();
- if ("staticMethod".equals(name)) {
- methodStaticOnF = method;
- }
- else if ("staticMethod2".equals(name)) {
- methodStatic2OnF = method;
- }
- else if ("method_T1".equals(name)) {
- methodT1OnF = method;
- }
- }
- for (ExecutableElement method : ElementFilter.methodsIn(_elementG.getEnclosedElements())) {
- String name = method.getSimpleName().toString();
- if ("staticMethod".equals(name)) {
- methodStaticOnG = method;
- }
- else if ("method_T1".equals(name)) {
- methodT1OnG = method;
- }
- }
- for (ExecutableElement method : ElementFilter.methodsIn(_elementH.getEnclosedElements())) {
- String name = method.getSimpleName().toString();
- if ("staticMethod".equals(name)) {
- if (method.getParameters().isEmpty()) {
- methodStaticOnH = method;
- }
- else {
- methodStaticIntOnH = method;
- }
- }
- }
- for (ExecutableElement method : ElementFilter.methodsIn(_elementJ.getEnclosedElements())) {
- String name = method.getSimpleName().toString();
- if ("staticMethod".equals(name)) {
- methodStaticOnJ = method;
- break;
- }
- }
- if (methodStaticOnF == null || methodStatic2OnF == null || methodT1OnF == null) {
- reportError("examineHidesMethod: Failed to find an expected method on F");
- return false;
- }
- if (methodStaticOnG == null || methodT1OnG == null) {
- reportError("examineHidesMethod: Failed to find an expected method on G");
- return false;
- }
- if (methodStaticOnH == null || methodStaticIntOnH == null) {
- reportError("examineHidesMethod: Failed to find an expected method on H");
- return false;
- }
- if (methodStaticOnJ == null) {
- reportError("examineHidesMethod: Failed to find an expected method on J");
- return false;
- }
-
- // The should-hide cases
- if (!_elementUtils.hides(methodStaticOnH, methodStaticOnG)) {
- reportError("examineHidesMethod: H.staticMethod() should hide G.staticMethod()");
- return false;
- }
-
- // The should-not-hide cases
- if (_elementUtils.hides(methodStaticOnG, methodStaticOnG)) {
- reportError("examineHidesMethod: G.staticMethod() should not hide itself");
- return false;
- }
- if (_elementUtils.hides(methodStaticOnG, methodStaticOnF)) {
- reportError("examineHidesMethod: G.staticMethod() should not hide (private) F.staticMethod()");
- return false;
- }
- if (_elementUtils.hides(methodStaticOnG, methodStaticOnH)) {
- reportError("examineHidesMethod: G.staticMethod() should not hide H.staticMethod()");
- return false;
- }
- if (_elementUtils.hides(methodStaticOnG, methodStatic2OnF)) {
- reportError("examineHidesMethod: G.staticMethod() should not hide F.staticMethod2()");
- return false;
- }
- if (_elementUtils.hides(methodStaticOnJ, methodStaticOnG)) {
- reportError("examineHidesMethod: J.staticMethod() should not hide G.staticMethod()");
- return false;
- }
- if (_elementUtils.hides(methodStaticIntOnH, methodStaticOnG)) {
- reportError("examineHidesMethod: H.staticMethod(int) should not hide G.staticMethod()");
- return false;
- }
- if (_elementUtils.hides(methodT1OnG, methodT1OnF)) {
- reportError("examineHidesMethod: G.methodT1() should not hide F.methodT1(), because they aren't static (JLS 8.4.8.2)");
- return false;
- }
- return true;
- }
-
- /**
- * Test the {@link Elements#overrides(ExecutableElement, ExecutableElement, TypeElement)} implementation
- * @return true if all tests passed
- */
- private boolean examineOverrides() {
- // D extends (C extends A implements B). X is unrelated.
- TypeElement typeA = _elementUtils.getTypeElement("targets.model.pc.Overriding.A");
- TypeElement typeB = _elementUtils.getTypeElement("targets.model.pc.Overriding.B");
- TypeElement typeC = _elementUtils.getTypeElement("targets.model.pc.Overriding.C");
- TypeElement typeD = _elementUtils.getTypeElement("targets.model.pc.Overriding.D");
- TypeElement typeX = _elementUtils.getTypeElement("targets.model.pc.F");
- if (typeA == null || typeB == null || typeC == null || typeD == null) {
- reportError("Unable to find types in targets.model.pc.Overriding");
- return false;
- }
- ExecutableElement methodAF = null;
- ExecutableElement methodAG = null;
- ExecutableElement methodAH = null;
- ExecutableElement methodAJ = null;
- ExecutableElement methodBF = null;
- ExecutableElement methodBG = null;
- ExecutableElement methodBH = null;
- ExecutableElement methodCH = null;
- ExecutableElement methodDF = null;
- ExecutableElement methodDG = null;
- ExecutableElement methodDJ = null;
- ExecutableElement methodXF = null;
- for (ExecutableElement method : ElementFilter.methodsIn(typeA.getEnclosedElements())) {
- String name = method.getSimpleName().toString();
- if ("f".equals(name)) {
- methodAF = method;
- }
- else if ("g".equals(name)) {
- methodAG = method;
- }
- else if ("h".equals(name)) {
- methodAH = method;
- }
- else if ("j".equals(name)) {
- methodAJ = method;
- }
- }
- for (ExecutableElement method : ElementFilter.methodsIn(typeB.getEnclosedElements())) {
- String name = method.getSimpleName().toString();
- if ("f".equals(name)) {
- methodBF = method;
- }
- else if ("g".equals(name)) {
- methodBG = method;
- }
- else if ("h".equals(name)) {
- methodBH = method;
- }
- }
- for (ExecutableElement method : ElementFilter.methodsIn(typeC.getEnclosedElements())) {
- String name = method.getSimpleName().toString();
- if ("h".equals(name)) {
- methodCH = method;
- break;
- }
- }
- for (ExecutableElement method : ElementFilter.methodsIn(typeD.getEnclosedElements())) {
- String name = method.getSimpleName().toString();
- if ("f".equals(name)) {
- methodDF = method;
- }
- else if ("g".equals(name)) {
- methodDG = method;
- }
- else if ("j".equals(name)) {
- methodDJ = method;
- }
- }
- for (ExecutableElement method : ElementFilter.methodsIn(typeX.getEnclosedElements())) {
- String name = method.getSimpleName().toString();
- if ("f".equals(name)) {
- methodXF = method;
- break;
- }
- }
- if (null == methodAF || null == methodAG || null == methodAH || null == methodAJ ||
- null == methodBF || null == methodBG || null == methodBH ||
- null == methodCH ||
- null == methodDF || null == methodDG || null == methodDJ ||
- null == methodXF) {
- reportError("examineOverrides: could not find some methods");
- return false;
- }
-
- // Should override:
- if (!_elementUtils.overrides(methodAF, methodBF, typeC)) {
- reportError("examineOverrides: A.f() should override B.f() in the context of C");
- return false;
- }
- if (!_elementUtils.overrides(methodCH, methodAH, typeC)) {
- reportError("examineOverrides: C.h() should override A.h() in the context of C");
- return false;
- }
- if (!_elementUtils.overrides(methodCH, methodAH, typeD)) {
- reportError("examineOverrides: C.h() should override A.h() in the context of D");
- return false;
- }
- if (!_elementUtils.overrides(methodDF, methodBF, typeD)) {
- reportError("examineOverrides: D.f() should override B.f() in the context of D");
- return false;
- }
- if (!_elementUtils.overrides(methodDG, methodBG, typeD)) {
- reportError("examineOverrides: D.g() should override B.g() in the context of D");
- return false;
- }
- if (!_elementUtils.overrides(methodDJ, methodAJ, typeD)) {
- reportError("examineOverrides: D.j() should override A.j() in the context of D");
- return false;
- }
- if (!_elementUtils.overrides(methodAH, methodBH, typeC)) {
- reportError("examineOverrides: A.h() should override B.h() in the context of C (even though C.h does too)");
- return false;
- }
-
- // Should not override:
- if (_elementUtils.overrides(methodAF, methodAF, typeA)) {
- reportError("examineOverrides: A.f() should not override itself in the context of A");
- return false;
- }
- if (_elementUtils.overrides(methodAF, methodAF, typeC)) {
- reportError("examineOverrides: A.f() should not override itself in the context of C");
- return false;
- }
- if (_elementUtils.overrides(methodAF, methodBF, typeA)) {
- reportError("examineOverrides: A.f() should not override B.f() in the context of A");
- return false;
- }
- if (_elementUtils.overrides(methodAG, methodBG, typeC)) {
- reportError("examineOverrides: private A.g() should not override B.g() in the context of C");
- return false;
- }
- if (_elementUtils.overrides(methodDG, methodAG, typeD)) {
- reportError("examineOverrides: D.g() should not override private A.g() in the context of D");
- return false;
- }
- if (_elementUtils.overrides(methodXF, methodAF, typeD)) {
- reportError("examineOverrides: unrelated X.f() should not override A.f() in the context of D");
- return false;
- }
- if (_elementUtils.overrides(methodXF, methodBF, typeX)) {
- reportError("examineOverrides: X.f() should not override unrelated B.f() in the context of X");
- return false;
- }
-
- // These cases seem like they should return false, but javac returns true:
- if (!_elementUtils.overrides(methodDJ, methodAJ, typeC)) {
- reportError("examineOverrides: to match javac, D.j() should override A.j() in the context of C");
- return false;
- }
- if (!_elementUtils.overrides(methodDF, methodAF, typeC)) {
- reportError("examineOverrides: to match javac, D.f() should override A.f() in the context of C");
- return false;
- }
- if (!_elementUtils.overrides(methodDF, methodBF, typeC)) {
- reportError("examineOverrides: to match javac, D.f() should override B.f() in the context of C");
- return false;
- }
-
- return true;
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/filer/FilerProc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/filer/FilerProc.java
deleted file mode 100644
index a96bd38fff..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/filer/FilerProc.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests.processors.filer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Set;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.Filer;
-import javax.annotation.processing.Messager;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedOptions;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic;
-import javax.tools.FileObject;
-import javax.tools.StandardLocation;
-import javax.tools.Diagnostic.Kind;
-
-import org.eclipse.jdt.compiler.apt.tests.annotations.GenResource;
-
-/**
- * A processor that reads the GenResource annotation and produces the specified Java type
- */
-@SupportedAnnotationTypes({ "org.eclipse.jdt.compiler.apt.tests.annotations.GenResource" })
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-@SupportedOptions({})
-public class FilerProc extends AbstractProcessor {
-
- private ProcessingEnvironment _processingEnv;
- private Messager _messager;
- private Filer _filer;
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.AbstractProcessor#init(javax.annotation.processing.ProcessingEnvironment)
- */
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- _processingEnv = processingEnv;
- _filer = _processingEnv.getFiler();
- _messager = _processingEnv.getMessager();
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.AbstractProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)
- */
- @Override
- public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv)
- {
- if (!annotations.isEmpty()) {
- round(annotations, roundEnv);
- }
- return true;
- }
-
- /**
- * Perform a round of processing
- */
- private void round(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- TypeElement genClassAnno = annotations.iterator().next();
- Set<? extends Element> annotatedEls = roundEnv.getElementsAnnotatedWith(genClassAnno);
- for (Element e : annotatedEls) {
- GenResource genClassMirror = e.getAnnotation(GenResource.class);
- generateType(genClassMirror, e);
- }
- }
-
- /**
- * @param genResourceMirror
- */
- private void generateType(GenResource genResourceMirror, Element annotatedEl) {
- // Collect and validate the parameters of the annotation
- String pkg = null;
- String relativeName = null;
- String stringContent = null;
- byte[] binaryContent = null;
- try {
- pkg = genResourceMirror.pkg();
- relativeName = genResourceMirror.relativeName();
- stringContent = genResourceMirror.stringContent();
- binaryContent = genResourceMirror.binaryContent();
- } catch (Exception e) {
- _messager.printMessage(Diagnostic.Kind.WARNING, "Unable to read @GenResource annotation" + e.getLocalizedMessage(), annotatedEl);
- return;
- }
- if (relativeName.length() == 0) {
- // User hasn't specified relativeName yet
- _messager.printMessage(Diagnostic.Kind.WARNING, "The relativeName attribute is missing", annotatedEl);
- return;
- }
-
- FileObject fo = null;
- try {
- fo = _filer.createResource(StandardLocation.SOURCE_OUTPUT, pkg, relativeName, annotatedEl);
- } catch (IOException e) {
- _messager.printMessage(Diagnostic.Kind.WARNING,
- "Unable to open resource file for pkg " + pkg + ", relativeName " +
- relativeName + ": " + e.getLocalizedMessage(), annotatedEl);
- return;
- }
- if (null == fo) {
- _messager.printMessage(Diagnostic.Kind.WARNING, "Filer.createResource() returned null", annotatedEl);
- return;
- }
- if (stringContent.isEmpty()) {
- // Binary content. Open an OutputStream.
- OutputStream os = null;
- try {
- os = fo.openOutputStream();
- os.write(binaryContent);
- }
- catch (Exception e) {
- _messager.printMessage(Kind.ERROR, e.getLocalizedMessage(), annotatedEl);
- return;
- }
- finally {
- try {
- os.close();
- } catch (IOException e) {
- _messager.printMessage(Kind.ERROR, e.getLocalizedMessage(), annotatedEl);
- }
- }
- }
- else {
- // String content. Open a Writer.
- Writer w = null;
- try {
- w = fo.openWriter();
- w.write(stringContent);
- }
- catch (Exception e) {
- _messager.printMessage(Kind.ERROR, e.getLocalizedMessage(), annotatedEl);
- return;
- }
- finally {
- try {
- w.close();
- } catch (IOException e) {
- _messager.printMessage(Kind.ERROR, e.getLocalizedMessage(), annotatedEl);
- }
- }
- }
-
-
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/genclass/GenClassProc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/genclass/GenClassProc.java
deleted file mode 100644
index dab2adb966..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/genclass/GenClassProc.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.compiler.apt.tests.processors.genclass;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.Filer;
-import javax.annotation.processing.Messager;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.util.Elements;
-import javax.tools.Diagnostic;
-import javax.tools.JavaFileObject;
-
-@SupportedAnnotationTypes("org.eclipse.jdt.compiler.apt.tests.annotations.GenClass")
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-public class GenClassProc extends AbstractProcessor {
-
- private Messager _messager;
- private Filer _filer;
- private Elements _elementUtil;
- private TypeElement _annoDecl;
-
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- _filer = processingEnv.getFiler();
- _messager = processingEnv.getMessager();
- _elementUtil = processingEnv.getElementUtils();
- _annoDecl = _elementUtil.getTypeElement("org.eclipse.jdt.compiler.apt.tests.annotations.GenClass");
-
- //System.out.println("Processor options are: ");
- //for (Map.Entry<String, String> option : processingEnv.getOptions().entrySet()) {
- // System.out.println(option.getKey() + " -> " + option.getValue());
- //}
- }
-
- @Override
- public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment roundEnv) {
-
- if (annotations == null || annotations.isEmpty()) {
- return true;
- }
- // sanity check
- if (!annotations.contains(_annoDecl)) {
- throw new IllegalArgumentException("process() called on an unexpected set of annotations");
- }
-
- // get annotated declarations - could also use getElsAnnoWith(Class) form.
- for (Element d : roundEnv.getElementsAnnotatedWith(_annoDecl)) {
- // get annotations on the declaration
- String clazz = null;
- String method = null;
- for (AnnotationMirror am : d.getAnnotationMirrors()) {
- if (am.getAnnotationType().asElement().equals(_annoDecl)) {
- // query the annotation to get its values
- Map<? extends ExecutableElement, ? extends AnnotationValue> values = am.getElementValues();
- // find the "clazz" and "msg" values
- for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : values.entrySet()) {
- // System.out.println("found a value named " + entry.getKey().getSimpleName() + " with value " + entry.getValue().getValue());
- ExecutableElement key = entry.getKey();
- AnnotationValue value = entry.getValue();
- String keyName = key.getSimpleName().toString();
- if ("clazz".equals(keyName)) {
- clazz = (String)(value.getValue());
- }
- if ("method".equals(keyName)) {
- method = (String)(value.getValue());
- }
- }
-
- if (null == clazz || clazz.length() > 40) {
- _messager.printMessage(Diagnostic.Kind.WARNING, "Long name for clazz()", d, am);
- clazz = null;
- break;
- }
- if (null == method || method.length() > 10) {
- _messager.printMessage(Diagnostic.Kind.WARNING, "Long name for method()", d, am);
- method = null;
- break;
- }
- }
- }
-
- if (null != clazz && null != method && !roundEnv.processingOver())
- createSourceFile(d, clazz, method);
- }
- return true;
- }
-
- /**
- * Create a source file named 'name', with contents
- * that reflect 'method' and 'name'.
- * @param parent the parent element
- * @param clazz a fully qualified classname
- * @param method the name of a method that will be
- * added to the class
- */
- private void createSourceFile(Element parent, String clazz, String method) {
- int lastDot = clazz.lastIndexOf('.');
- if (lastDot <= 0 || clazz.length() == lastDot)
- return;
- String pkg = clazz.substring(0, lastDot);
- String lname = clazz.substring(lastDot + 1);
- Writer w = null;
- PrintWriter pw = null;
- try {
- JavaFileObject jfo = _filer.createSourceFile(clazz, parent);
- w = jfo.openWriter();
- pw = new PrintWriter(w);
- pw.println("package " + pkg + ";");
- pw.println("public class " + lname + " {");
- pw.println("\tpublic String " + method + "() {");
- // This compile error won't be reported if the -proc:only flag is set:
- // pw.println("\t\tb = a;");
- pw.println("\t\treturn new String(\"" + clazz + "\");");
- pw.println("\t}");
- pw.println("}");
- pw.close();
- w.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/generics/GenericsProc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/generics/GenericsProc.java
deleted file mode 100644
index 91f115ec82..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/generics/GenericsProc.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests.processors.generics;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.TypeParameterElement;
-import javax.lang.model.type.DeclaredType;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.ElementFilter;
-
-import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
-
-/**
- * Processor that tests our handling of parameterized types
- * by exploring the parameterized types in resources/targets.
- */
-@SupportedAnnotationTypes({"*"})
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-public class GenericsProc extends BaseProcessor
-{
- // Initialized in collectElements()
- private TypeElement _elementA;
- private TypeElement _elementAC;
- private TypeElement _elementObject;
- private TypeElement _elementString;
- private TypeElement _elementIterator;
-
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv)
- {
- super.init(processingEnv);
- }
-
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
- {
- if (roundEnv.processingOver()) {
- return false;
- }
- Map<String, String> options = processingEnv.getOptions();
- if (!options.containsKey(this.getClass().getName())) {
- // Disable this processor unless we are intentionally performing the test.
- return false;
- }
-
- if (!collectElements()) {
- return false;
- }
- if (!examineACNames()) {
- return false;
- }
- if (!examineACTypeParams()) {
- return false;
- }
- if (!examineATypeParams()) {
- return false;
- }
- if (!examineFTypeParams()) {
- return false;
- }
-
- reportSuccess();
- return false;
- }
-
- /**
- * Collect some elements that will be reused in various tests
- * @return true if all tests passed
- */
- private boolean collectElements() {
- _elementAC = _elementUtils.getTypeElement("targets.model.pb.AC");
- if (_elementAC == null) {
- reportError("element AC was not found");
- return false;
- }
- if (_elementAC.getKind() != ElementKind.CLASS) {
- reportError("AC claims to not be a class");
- return false;
- }
- _elementA = _elementUtils.getTypeElement("targets.model.pa.A");
- if (_elementA == null || _elementA.getKind() != ElementKind.CLASS) {
- reportError("element A was not found or was not a class");
- return false;
- }
- _elementObject = _elementUtils.getTypeElement("java.lang.Object");
- _elementString = _elementUtils.getTypeElement("java.lang.String");
- _elementIterator = _elementUtils.getTypeElement("java.util.Iterator");
- return true;
- }
-
- /**
- * Examine the qualified and simple names of element AC and subelements
- * @return true if all tests passed
- */
- private boolean examineACNames()
- {
- String qnameAC = _elementAC.getQualifiedName().toString();
- if (!"targets.model.pb.AC".equals(qnameAC)) {
- reportError("AC's qualified name is unexpected: " + qnameAC);
- return false;
- }
- String snameAC = _elementAC.getSimpleName().toString();
- if (!"AC".equals(snameAC)) {
- reportError("AC's simple name is unexpected: " + snameAC);
- return false;
- }
- List<TypeElement> childElements = ElementFilter.typesIn(_elementAC.getEnclosedElements());
- if (childElements == null || childElements.size() != 1) {
- reportError("AC should contain one child type");
- return false;
- }
- TypeElement elementACInner = childElements.iterator().next();
- String qnameInner = elementACInner.getQualifiedName().toString();
- if (!"targets.model.pb.AC.ACInner".equals(qnameInner)) {
- reportError("AC.ACInner's qualified name is unexpected: " + qnameInner);
- return false;
- }
- String snameInner = elementACInner.getSimpleName().toString();
- if (!"ACInner".equals(snameInner)) {
- reportError("AC.ACInner's simple name is unexpected: " + snameInner);
- return false;
- }
- return true;
- }
-
- /**
- * Examine the type parameters of element AC
- * @return true if all tests passed
- */
- private boolean examineACTypeParams()
- {
- List<? extends TypeParameterElement> params = _elementAC.getTypeParameters();
- if (null == params || params.size() != 2) {
- reportError("element AC does not report 2 type parameters");
- return false;
- }
- Iterator<? extends TypeParameterElement> iter = params.iterator();
- TypeParameterElement t1 = iter.next();
- TypeParameterElement t2 = iter.next();
- if (!"T1".equals(t1.getSimpleName().toString()) ||
- !"T2".equals(t2.getSimpleName().toString())) {
- reportError("Type parameters of element AC are not named T1 and T2");
- return false;
- }
- if (t1.getKind() != ElementKind.TYPE_PARAMETER) {
- reportError("Type parameter T1 of element AC claims not to be ElementKind.TYPE_PARAMTER");
- return false;
- }
- if (!_elementAC.equals(t2.getGenericElement())) {
- reportError("Type parameter T2 of element AC does not return AC from getGenericElement()");
- return false;
- }
- List<? extends TypeMirror> boundsT1 = t1.getBounds();
- if (null == boundsT1 || boundsT1.size() != 2) {
- reportError("Type parameter T1 of element AC has wrong number of bounds");
- return false;
- }
- TypeMirror boundT1_0 = boundsT1.get(0);
- if (!(boundT1_0 instanceof DeclaredType) || !_elementString.equals(((DeclaredType)boundT1_0).asElement())) {
- reportError("Bound[0] of type parameter T1 of element AC is not String");
- return false;
- }
- TypeMirror boundT1_1 = boundsT1.get(1);
- if (!(boundT1_1 instanceof DeclaredType) || !_elementIterator.equals(((DeclaredType)boundT1_1).asElement())) {
- reportError("Bound[1] of type parameter T1 of element AC is not Iterator");
- return false;
- }
- return true;
- }
-
- /**
- * Examine the type parameters of element A
- * @return true if all tests passed
- */
- private boolean examineATypeParams()
- {
- List<? extends TypeParameterElement> params = _elementA.getTypeParameters();
- if (null == params || !params.isEmpty()) {
- reportError("element A reports an unexpected number of type parameters: " + params);
- return false;
- }
- return true;
- }
-
- /**
- * Examine the type parameters of element F
- * @return true if all tests passed
- */
- private boolean examineFTypeParams()
- {
- TypeElement elementF = _elementUtils.getTypeElement("targets.model.pc.F");
- if (null == elementF || elementF.getKind() != ElementKind.CLASS) {
- reportError("examineFTypeParams: couldn't load element F");
- return false;
- }
- List<? extends TypeParameterElement> params = elementF.getTypeParameters();
- if (null == params || params.size() != 1) {
- reportError("examineFTypeParams: F reports an unexpected number of type parameters: " + params);
- return false;
- }
- TypeParameterElement param = params.iterator().next();
- List<? extends TypeMirror> bounds = param.getBounds();
- if (null == bounds || bounds.size() != 1) {
- reportError("examineFTypeParams: F's type parameter has an unexpected number of bounds: " + bounds);
- return false;
- }
- TypeMirror elementType = _elementObject.asType();
- if (!elementType.equals(bounds.iterator().next())) {
- reportError("examineFTypeParams: F's type bounds should only contain Object");
- return false;
- }
- return true;
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/inherited/InheritedAnnoProc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/inherited/InheritedAnnoProc.java
deleted file mode 100644
index 1a8664fe6a..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/inherited/InheritedAnnoProc.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests.processors.inherited;
-
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedOptions;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.TypeElement;
-
-import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
-
-/**
- * A processor that tests the dispatch functionality in the presence of annotations that are
- * @Inherited. To enable this processor, add
- * -Aorg.eclipse.jdt.compiler.apt.tests.processors.inherited.InheritedAnnoProc to the command line.
- *
- * @since 3.3
- */
-@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-@SupportedOptions("org.eclipse.jdt.compiler.apt.tests.processors.inherited.InheritedAnnoProc")
-public class InheritedAnnoProc extends BaseProcessor
-{
- // Initialized in collectElements:
- private TypeElement _inheritedAnno;
- private TypeElement _notInheritedAnno;
- private TypeElement _elementA;
- private TypeElement _elementAChild;
- private TypeElement _elementANotAnnotated;
- private TypeElement _elementAIntf;
- private TypeElement _elementAEnum;
- private Element _elementAi;
- private Element _elementAfoo;
- private Element _elementAinit; // c'tor with no param
- private Element _elementAinitI; // c'tor with int param
- private Element _elementAa; // method with c'tor-like name
-
- private TypeElement _elementB;
- private TypeElement _elementBChild;
- private TypeElement _elementBNotAnnotated;
- private Element _elementBfoo;
- private Element _elementBi;
-
- // Always return false from this processor, because it supports "*".
- // The return value does not signify success or failure!
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
- {
- if (roundEnv.processingOver()) {
- return false;
- }
- Map<String, String> options = processingEnv.getOptions();
- if (!options.containsKey(this.getClass().getName())) {
- // Disable this processor unless we are intentionally performing the test.
- return false;
- }
-
- if (!collectElements()) {
- return false;
- }
-
- if (!examineGetRootElements(roundEnv)) {
- return false;
- }
-
- if (!examineGetElementsAnnotatedWith(roundEnv)) {
- return false;
- }
-
- reportSuccess();
- return false;
- }
-
- private boolean collectElements() {
- _inheritedAnno = _elementUtils.getTypeElement("org.eclipse.jdt.compiler.apt.tests.annotations.InheritedAnno");
- _notInheritedAnno = _elementUtils.getTypeElement("NotInheritedAnno");
- if (null == _inheritedAnno || null == _notInheritedAnno) {
- reportError("collectElements: Couldn't load annotation type");
- return false;
- }
-
- _elementA = _elementUtils.getTypeElement("InheritanceA");
- for (Element e : _elementA.getEnclosedElements()) {
- String name = e.getSimpleName().toString();
- if ("AChild".equals(name)) {
- _elementAChild = (TypeElement)e;
- }
- else if ("ANotAnnotated".equals(name)) {
- _elementANotAnnotated = (TypeElement)e;
- }
- else if ("AIntf".equals(name)) {
- _elementAIntf = (TypeElement)e;
- }
- else if ("AEnum".equals(name)) {
- _elementAEnum = (TypeElement)e;
- }
- else if ("i".equals(name)) {
- _elementAi = e;
- }
- else if ("foo".equals(name)) {
- _elementAfoo = e;
- }
- else if ("InheritanceA".equals(name)) {
- _elementAa = e;
- }
- else if ("<init>".equals(name)) {
- if (((ExecutableElement)e).getParameters().isEmpty()) {
- _elementAinit = e;
- }
- else {
- _elementAinitI = e;
- }
- }
- }
- if (null == _elementA || null == _elementAChild || null == _elementANotAnnotated ||
- null == _elementAi || null == _elementAfoo || null == _elementAinitI || null == _elementAa ||
- null == _elementAIntf || null == _elementAEnum || null == _elementAinit) {
- reportError("collectElements: couldn't load elements from InheritanceA");
- return false;
- }
-
- _elementB = _elementUtils.getTypeElement("InheritanceB");
- for (Element e : _elementB.getEnclosedElements()) {
- String name = e.getSimpleName().toString();
- if ("BChild".equals(name)) {
- _elementBChild = (TypeElement)e;
- }
- else if ("BNotAnnotated".equals(name)) {
- _elementBNotAnnotated = (TypeElement)e;
- }
- else if ("i".equals(name)) {
- _elementBi = e;
- }
- else if ("foo".equals(name)) {
- _elementBfoo = e;
- }
- }
- if (null == _elementB || null == _elementBChild || null == _elementBNotAnnotated ||
- null == _elementBi || null == _elementBfoo) {
- reportError("collectElements: couldn't load elements from InheritanceB");
- return false;
- }
-
- return true;
- }
-
- /**
- * Test the getRootElements implementation.
- * @param roundEnv
- * @return true if tests passed
- */
- private boolean examineGetRootElements(RoundEnvironment roundEnv)
- {
- // Expect to see all elements (unaffected by presence of @Inherited)
- final Element[] expected = {_notInheritedAnno, _elementA, _elementB};
-
- Set<? extends Element> elements = new HashSet<Element>(roundEnv.getRootElements());
- for (Element element : expected) {
- if (!elements.remove(element)) {
- reportError("examineRootElements: root elements did not contain expected element " + element.getSimpleName());
- return false;
- }
- }
- if (!elements.isEmpty()) {
- reportError("examineRootElements: root elements contained unexpected elements " + elements);
- return false;
- }
- return true;
- }
-
- private boolean examineGetElementsAnnotatedWith(RoundEnvironment roundEnv)
- {
- // Elements we expect to get from getElementsAnnotatedWith(@InheritedAnno)
- final Element[] expectedInherited =
- { _elementA, _elementAChild, _elementAIntf, _elementAEnum,
- _elementAi, _elementAfoo, _elementAinit, _elementAinitI, _elementAa,
- _elementB, _elementBChild };
-
- Set<? extends Element> actualInherited = new HashSet<Element>(roundEnv.getElementsAnnotatedWith(_inheritedAnno));
- for (Element element : expectedInherited) {
- if (!actualInherited.remove(element)) {
- reportError("examineGetElementsAnnotatedWith(@InheritedAnno): did not contain expected element " + element.getSimpleName());
- return false;
- }
- }
- if (!actualInherited.isEmpty()) {
- reportError("examineGetElementsAnnotatedWith(@InheritedAnno): contained unexpected elements " + actualInherited);
- return false;
- }
-
- // Elements we expect to get from getElementsAnnotatedWith(@NotInheritedAnno)
- final Element[] expectedNotInherited =
- { _elementA, _elementAChild, _elementAIntf, _elementAEnum,
- _elementAi, _elementAfoo, _elementAinit, _elementAinitI, _elementAa };
-
- Set<? extends Element> actualNotInherited = new HashSet<Element>(roundEnv.getElementsAnnotatedWith(_notInheritedAnno));
- for (Element element : expectedNotInherited) {
- if (!actualNotInherited.remove(element)) {
- reportError("examineGetElementsAnnotatedWith(@NotInheritedAnno): did not contain expected element " + element.getSimpleName());
- return false;
- }
- }
- if (!actualNotInherited.isEmpty()) {
- reportError("examineGetElementsAnnotatedWith(@NotInheritedAnno): contained unexpected elements " + actualNotInherited);
- return false;
- }
-
- return true;
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/messager/MessagerProc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/messager/MessagerProc.java
deleted file mode 100644
index 2023104dc0..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/messager/MessagerProc.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests.processors.messager;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.Messager;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedOptions;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.Elements;
-import javax.tools.Diagnostic.Kind;
-
-/**
- * A processor that uses the Messager interface to report errors against various
- * elements in the targets.model resource hierarchy. To enable this processor, add
- * -Aorg.eclipse.jdt.compiler.apt.tests.processors.messager.MessagerProc to the command line.
- * <p>
- * The idea of this processor is that it calls the Messager interface with various messages
- * on various elements. If the interface itself fails, an error is reported via the
- * reportError() method, which sets a system property that the calling test case will
- * inspect. Then, following processor execution, the calling test case will inspect all
- * the messages that were passed to Messager, to make sure that they all made it into the
- * compiler error output in the expected way.
- *
- * @since 3.3
- */
-@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-@SupportedOptions("org.eclipse.jdt.compiler.apt.tests.processors.messager.MessagerProc")
-public class MessagerProc extends AbstractProcessor {
-
- private static final String CLASSNAME = MessagerProc.class.getName();
-
- /**
- * Report an error to the test case code.
- * This is not the same as reporting via Messager! Use this if some API fails.
- * @param value will be displayed in the test output, in the event of failure.
- * Can be anything except "succeeded".
- */
- public static void reportError(String value) {
- // Uncomment for processor debugging - don't report error
- // value = "succeeded";
- System.setProperty(CLASSNAME, value);
- }
-
- /**
- * Report success to the test case code
- */
- public static void reportSuccess() {
- System.setProperty(CLASSNAME, "succeeded");
- }
-
- private Elements _elementUtils;
- //private Types _typeUtils;
- private Messager _messager;
-
- // Initialized in collectElements()
- private TypeElement _elementD;
-
- // Initialized in collectElements()
-// private ExecutableElement _methodElement;
-
- // Initialized in collectElements()
- private TypeElement _element2;
-
- // Initialized in collectElements()
- private AnnotationMirror _annotationMirror;
-
- // Initialized in collectElements()
- private AnnotationValue _annotationValue;
-
- // Initialized in collectElements()
- private TypeElement _elementE;
-
- // Initialized in collectElements()
- private ExecutableElement _methodElement;
-
- // Initialized in collectElements()
- private VariableElement _variableElement;
-
- // Initialized in collectElements()
- private TypeElement _elementF;
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.AbstractProcessor#init(javax.annotation.processing.ProcessingEnvironment)
- */
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- _elementUtils = processingEnv.getElementUtils();
- //_typeUtils = processingEnv.getTypeUtils();
- _messager = processingEnv.getMessager();
- }
-
- // Always return false from this processor, because it supports "*".
- // The return value does not signify success or failure!
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- if (roundEnv.processingOver()) {
- // We're not interested in the postprocessing round.
- return false;
- }
- Map<String, String> options = processingEnv.getOptions();
- if (!options.containsKey(CLASSNAME)) {
- // Disable this processor unless we are intentionally performing the test.
- return false;
- }
-
- if (null == _messager) {
- reportError("Env.getMessager() returned null");
- return false;
- }
-
- if (!collectElements()) {
- return false;
- }
-
- if (!printErrorsOnElements()) {
- return false;
- }
-
- MessagerProc.reportSuccess();
- return false;
- }
-
- /**
- * Collect some elements that will be reused in various tests
- * @return true if all tests passed
- */
- private boolean collectElements() {
- _elementD = _elementUtils.getTypeElement("targets.errors.pb.D");
- if (null == _elementD || _elementD.getKind() != ElementKind.CLASS) {
- reportError("Element D was not found or was not a class");
- return false;
- }
-// printVariableElements(_elementD);
-
- _elementE = _elementUtils.getTypeElement("targets.errors.pb.E");
- if (null == _elementE || _elementE.getKind() != ElementKind.CLASS) {
- reportError("Element E was not found or was not a class");
- return false;
- }
-// printVariableElements(_elementE);
-
- _elementF = _elementUtils.getTypeElement("targets.errors.pb.F");
- if (null == _elementF || _elementF.getKind() != ElementKind.CLASS) {
- reportError("Element F was not found or was not a class");
- return false;
- }
-// printVariableElements(_elementF);
-
- List<? extends Element> enclosedElements = _elementE.getEnclosedElements();
- for (Element element : enclosedElements) {
- switch(element.getKind()) {
- case METHOD :
- ExecutableElement executableElement = (ExecutableElement) element;
- StringBuilder builder = new StringBuilder(executableElement.getSimpleName());
- String name = String.valueOf(builder);
- if ("foo".equals(name) && _methodElement == null) {
- _methodElement = executableElement;
- }
- break;
- case FIELD :
- VariableElement variableElement = (VariableElement) element;
- builder = new StringBuilder(variableElement.getSimpleName());
- name = String.valueOf(builder);
- if ("j".equals(name) && _variableElement == null) {
- _variableElement = variableElement;
- }
- }
- }
-
- if (_methodElement == null) {
- reportError("Element for method foo could not be found");
- return false;
- }
-
- if (_variableElement == null) {
- reportError("Element for field j could not be found");
- return false;
- }
-
- List<? extends AnnotationMirror> annotationMirrors = _elementD.getAnnotationMirrors();
- for (AnnotationMirror mirror : annotationMirrors) {
- if (_annotationMirror == null) {
- _annotationMirror = mirror;
- break;
- }
- }
- if (_annotationMirror == null) {
- reportError("Annotation mirror was not found");
- return false;
- }
- Map<? extends ExecutableElement, ? extends AnnotationValue> elementValues = _annotationMirror.getElementValues();
- Collection<? extends AnnotationValue> values = elementValues.values();
- for (AnnotationValue value : values) {
- if (_annotationValue == null) {
- _annotationValue = value;
- break;
- }
- }
- if (_annotationValue == null) {
- reportError("Annotation value was not found");
- return false;
- }
-
- _element2 = _elementUtils.getTypeElement("java.lang.String");
- if (_element2 == null) {
- reportError("Element for java.lang.String could not be found");
- return false;
- }
-// printVariableElements(_element2);
-
- return true;
- }
-
- static void printVariableElements(final TypeElement typeElement) {
- List<? extends Element> enclosedElements = typeElement.getEnclosedElements();
- for (Element element : enclosedElements) {
- switch(element.getKind()) {
- case ENUM :
- System.out.println("enum type : " + element.getSimpleName());
- break;
- case CLASS :
- System.out.println("class : " + element.getSimpleName());
- break;
- case INSTANCE_INIT :
- System.out.println("initializer : " + element.getSimpleName());
- break;
- case STATIC_INIT :
- System.out.println("static initializer : " + element.getSimpleName());
- break;
- case FIELD :
- System.out.println("field : " + element.getSimpleName());
- break;
- case CONSTRUCTOR :
- System.out.println("constructor : " + element.getSimpleName());
- ExecutableElement executableElement = (ExecutableElement) element;
- List<? extends VariableElement> parameters = executableElement.getParameters();
- for (VariableElement variableElement : parameters) {
- System.out.print("name = " + variableElement.getSimpleName());
- TypeMirror typeMirror = variableElement.asType();
- System.out.print(" type = " + typeMirror);
- System.out.println(" type kind = " + typeMirror.getKind());
- }
- break;
- case METHOD :
- System.out.println("method : " + element.getSimpleName());
- executableElement = (ExecutableElement) element;
- parameters = executableElement.getParameters();
- for (VariableElement variableElement : parameters) {
- System.out.print("name = " + variableElement.getSimpleName());
- TypeMirror typeMirror = variableElement.asType();
- System.out.print(" type = " + typeMirror);
- System.out.println(" type kind = " + typeMirror.getKind());
- }
- }
- }
- }
-
- private boolean printErrorsOnElements() {
- _messager.printMessage(Kind.NOTE, "Informational message not associated with an element");
- _messager.printMessage(Kind.ERROR, "Error on element D", _elementD);
- _messager.printMessage(Kind.ERROR, "Error on element D", _elementD, _annotationMirror);
- _messager.printMessage(Kind.ERROR, "Error on element D", _elementD, _annotationMirror, _annotationValue);
- _messager.printMessage(Kind.ERROR, "Error on element java.lang.String", _element2);
- _messager.printMessage(Kind.WARNING, "Warning on method foo", _methodElement);
- _messager.printMessage(Kind.NOTE, "Note for field j", _variableElement);
- return true;
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/negative/NegativeModelProc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/negative/NegativeModelProc.java
deleted file mode 100644
index cace969514..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/negative/NegativeModelProc.java
+++ /dev/null
@@ -1,697 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.compiler.apt.tests.processors.negative;
-
-import java.io.ByteArrayOutputStream;
-import java.io.StringReader;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedOptions;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.DeclaredType;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.Elements;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.eclipse.jdt.compiler.apt.tests.processors.base.XMLComparer;
-import org.eclipse.jdt.compiler.apt.tests.processors.base.XMLConverter;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-
-/**
- * An annotation processor that investigates the model produced by code containing
- * semantic errors such as missing types. To enable this processor, add
- * -Aorg.eclipse.jdt.compiler.apt.tests.processors.negative.NegativeModelProc to the
- * command line.
- *
- * Optionally, enable just a single test, by adding an integer value denoting the
- * test to the option key. For example, to enable testNegative2, add
- * -Aorg.eclipse.jdt.compiler.apt.tests.processors.negative.NegativeModelProc=2
- * to the command line. If 0 or no value is specified, all tests will be run.
- */
-@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-@SupportedOptions({"org.eclipse.jdt.compiler.apt.tests.processors.negative.NegativeModelProc", NegativeModelProc.IGNORE_JAVAC_BUGS})
-public class NegativeModelProc extends AbstractProcessor
-{
- /**
- * Reference model for types in Negative5 test
- */
- private static final String NEGATIVE_4_MODEL =
- "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
- "<model>\n" +
- " <type-element kind=\"CLASS\" qname=\"targets.negative.pa.Negative4\" sname=\"Negative4\">\n" +
- " <superclass>\n" +
- " <type-mirror kind=\"DECLARED\" to-string=\"java.lang.Object\"/>\n" +
- " </superclass>\n" +
- " <executable-element kind=\"CONSTRUCTOR\" sname=\"&lt;init&gt;\"/>\n" +
- " <executable-element kind=\"METHOD\" sname=\"zorkRaw\"/>\n" +
- " <executable-element kind=\"METHOD\" sname=\"zorkOfString\"/>\n" +
- " <executable-element kind=\"METHOD\" sname=\"ifooOfString\"/>\n" +
- " <executable-element kind=\"METHOD\" sname=\"ibarRaw\"/>\n" +
- " <executable-element kind=\"METHOD\" sname=\"ibarOfT1T2\"/>\n" +
- " </type-element>\n" +
- "</model>\n";
-
- /**
- * Reference model for types in Negative5 test
- */
- private static final String NEGATIVE_5_MODEL =
- "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
- "<model>\n" +
- " <type-element kind=\"CLASS\" qname=\"targets.negative.pa.Negative5\" sname=\"Negative5\">\n" +
- " <superclass>\n" +
- " <type-mirror kind=\"DECLARED\" to-string=\"java.lang.Object\"/>\n" +
- " </superclass>\n" +
- " <executable-element kind=\"CONSTRUCTOR\" sname=\"&lt;init&gt;\"/>\n" +
- " <type-element kind=\"CLASS\" qname=\"targets.negative.pa.Negative5.C1\" sname=\"C1\">\n" +
- " <superclass>\n" +
- " <type-mirror kind=\"ERROR\" to-string=\"M1\"/>\n" +
- " </superclass>\n" +
- " <interfaces>\n" +
- " <type-mirror kind=\"ERROR\" to-string=\"M2\"/>\n" +
- " </interfaces>\n" +
- " <executable-element kind=\"CONSTRUCTOR\" sname=\"&lt;init&gt;\"/>\n" +
- " </type-element>\n" +
- " <type-element kind=\"CLASS\" qname=\"targets.negative.pa.Negative5.C2\" sname=\"C2\">\n" +
- " <superclass>\n" +
- " <type-mirror kind=\"ERROR\" to-string=\"java.lang.Object\"/>\n" +
- " </superclass>\n" +
- " <executable-element kind=\"CONSTRUCTOR\" sname=\"&lt;init&gt;\"/>\n" +
- " </type-element>\n" +
- " <type-element kind=\"INTERFACE\" qname=\"targets.negative.pa.Negative5.I1\" sname=\"I1\">\n" +
- " <superclass>\n" +
- " <type-mirror kind=\"NONE\" to-string=\"&lt;none&gt;\"/>\n" +
- " </superclass>\n" +
- " <interfaces>\n" +
- " <type-mirror kind=\"ERROR\" to-string=\"M10\"/>\n" +
- " </interfaces>\n" +
- " </type-element>\n" +
- " <type-element kind=\"INTERFACE\" qname=\"targets.negative.pa.Negative5.I2\" sname=\"I2\">\n" +
- " <superclass>\n" +
- " <type-mirror kind=\"NONE\" to-string=\"&lt;none&gt;\"/>\n" +
- " </superclass>\n" +
- " </type-element>\n" +
- " </type-element>\n" +
- " <type-element kind=\"INTERFACE\" qname=\"targets.negative.pa.INegative5\" sname=\"INegative5\">\n" +
- " <superclass>\n" +
- " <type-mirror kind=\"NONE\" to-string=\"&lt;none&gt;\"/>\n" +
- " </superclass>\n" +
- " <type-element kind=\"CLASS\" qname=\"targets.negative.pa.INegative5.C101\" sname=\"C101\">\n" +
- " <superclass>\n" +
- " <type-mirror kind=\"ERROR\" to-string=\"M101\"/>\n" +
- " </superclass>\n" +
- " <interfaces>\n" +
- " <type-mirror kind=\"ERROR\" to-string=\"M103\"/>\n" +
- " <type-mirror kind=\"ERROR\" to-string=\"M104\"/>\n" +
- " </interfaces>\n" +
- " <executable-element kind=\"CONSTRUCTOR\" sname=\"&lt;init&gt;\"/>\n" +
- " </type-element>\n" +
- " <type-element kind=\"CLASS\" qname=\"targets.negative.pa.INegative5.C102\" sname=\"C102\">\n" +
- " <superclass>\n" +
- " <type-mirror kind=\"ERROR\" to-string=\"java.lang.Object\"/>\n" +
- " </superclass>\n" +
- " <executable-element kind=\"CONSTRUCTOR\" sname=\"&lt;init&gt;\"/>\n" +
- " </type-element>\n" +
- " <type-element kind=\"INTERFACE\" qname=\"targets.negative.pa.INegative5.I101\" sname=\"I101\">\n" +
- " <superclass>\n" +
- " <type-mirror kind=\"NONE\" to-string=\"&lt;none&gt;\"/>\n" +
- " </superclass>\n" +
- " <interfaces>\n" +
- " <type-mirror kind=\"ERROR\" to-string=\"M110\"/>\n" +
- " <type-mirror kind=\"ERROR\" to-string=\"M111\"/>\n" +
- " </interfaces>\n" +
- " </type-element>\n" +
- " <type-element kind=\"INTERFACE\" qname=\"targets.negative.pa.INegative5.I102\" sname=\"I102\">\n" +
- " <superclass>\n" +
- " <type-mirror kind=\"NONE\" to-string=\"&lt;none&gt;\"/>\n" +
- " </superclass>\n" +
- " <interfaces>\n" +
- " <type-mirror kind=\"ERROR\" to-string=\"M112\"/>\n" +
- " </interfaces>\n" +
- " </type-element>\n" +
- " </type-element>\n" +
- "</model>";
-
- /**
- * Reference model for class Negative6.
- */
- private static final String NEGATIVE_6_MODEL =
- "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
- "<model>\n" +
- " <type-element kind=\"CLASS\" qname=\"targets.negative.pa.Negative6\" sname=\"Negative6\">\n" +
- " <superclass>\n" +
- " <type-mirror kind=\"DECLARED\" to-string=\"java.lang.Object\"/>\n" +
- " </superclass>\n" +
- " <executable-element kind=\"METHOD\" sname=\"method1\">\n" +
- " <annotations>\n" +
- " <annotation sname=\"M11\"/>\n" +
- " </annotations>\n" +
- " <variable-element kind=\"PARAMETER\" sname=\"arg0\" type=\"M16\">\n" +
- " <annotations>\n" +
- " <annotation sname=\"M13\"/>\n" +
- " </annotations>\n" +
- " </variable-element>\n" +
- " </executable-element>\n" +
- " <executable-element kind=\"METHOD\" sname=\"method2\">\n" +
- " <annotations>\n" +
- " <annotation sname=\"M21\"/>\n" +
- " </annotations>\n" +
- " <variable-element kind=\"PARAMETER\" sname=\"arg0\" type=\"int\">\n" +
- " <annotations>\n" +
- " <annotation sname=\"M22\"/>\n" +
- " </annotations>\n" +
- " </variable-element>\n" +
- " </executable-element>\n" +
- " <executable-element kind=\"METHOD\" sname=\"method3\">\n" +
- " <variable-element kind=\"PARAMETER\" sname=\"arg0\" type=\"java.lang.String\">\n" +
- " <annotations>\n" +
- " <annotation sname=\"M31\"/>\n" +
- " </annotations>\n" +
- " </variable-element>\n" +
- " <variable-element kind=\"PARAMETER\" sname=\"arg1\" type=\"java.lang.String\">\n" +
- " <annotations>\n" +
- " <annotation sname=\"M32\"/>\n" +
- " </annotations>\n" +
- " </variable-element>\n" +
- " </executable-element>\n" +
- " <executable-element kind=\"CONSTRUCTOR\" sname=\"&lt;init&gt;\">\n" +
- " <annotations>\n" +
- " <annotation sname=\"M41\"/>\n" +
- " </annotations>\n" +
- " <variable-element kind=\"PARAMETER\" sname=\"arg0\" type=\"M43\">\n" +
- " <annotations>\n" +
- " <annotation sname=\"M42\"/>\n" +
- " </annotations>\n" +
- " </variable-element>\n" +
- " </executable-element>\n" +
- " </type-element>\n" +
- "</model>";
-
- /**
- * Reference model for class Negative7.
- */
- private static final String NEGATIVE_7_MODEL =
- "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
- "<model>\n" +
- " <type-element kind=\"INTERFACE\" qname=\"targets.negative.pa.Negative7\" sname=\"Negative7\">\n" +
- " <superclass>\n" +
- " <type-mirror kind=\"NONE\" to-string=\"&lt;none&gt;\"/>\n" +
- " </superclass>\n" +
- " <executable-element kind=\"METHOD\" sname=\"method1\">\n" +
- " <annotations>\n" +
- " <annotation sname=\"A1\"/>\n" +
- " </annotations>\n" +
- " <variable-element kind=\"PARAMETER\" sname=\"arg0\" type=\"int\">\n" +
- " <annotations>\n" +
- " <annotation sname=\"A1\"/>\n" +
- " </annotations>\n" +
- " </variable-element>\n" +
- " </executable-element>\n" +
- " </type-element>\n" +
- " <type-element kind=\"INTERFACE\" qname=\"targets.negative.pa.Negative7A\" sname=\"Negative7A\">\n" +
- " <superclass>\n" +
- " <type-mirror kind=\"NONE\" to-string=\"&lt;none&gt;\"/>\n" +
- " </superclass>\n" +
- " <interfaces>\n" +
- " <type-mirror kind=\"DECLARED\" to-string=\"java.lang.Cloneable\"/>\n" +
- " </interfaces>\n" +
- " <executable-element kind=\"METHOD\" sname=\"method1\">\n" +
- " <annotations>\n" +
- " <annotation sname=\"A1\"/>\n" +
- " </annotations>\n" +
- " <variable-element kind=\"PARAMETER\" sname=\"arg0\" type=\"int\">\n" +
- " <annotations>\n" +
- " <annotation sname=\"A1\"/>\n" +
- " </annotations>\n" +
- " </variable-element>\n" +
- " </executable-element>\n" +
- " </type-element>\n" +
- "</model>\n";
-
- /**
- * Declare this option (-AignoreJavacBugs) to ignore failures of cases that are
- * known to fail under javac, i.e., known bugs in javac.
- */
- public static final String IGNORE_JAVAC_BUGS = "ignoreJavacBugs";
-
- private static final String CLASSNAME = NegativeModelProc.class.getName();
-
- private static final String[] testMethodNames = {
- "checkNegative1",
- "checkNegative2",
- "checkNegative3",
- "checkNegative4",
- "checkNegative5",
- "checkNegative6",
- "checkNegative7",
- };
-
- private static final Method[] testMethods = new Method[testMethodNames.length];
-
- /**
- * Report an error to the test case code.
- * This is not the same as reporting via Messager! Use this if some API fails.
- * @param value will be displayed in the test output, in the event of failure.
- * Can be anything except "succeeded".
- */
- public static void reportError(String value) {
- // Uncomment for processor debugging - don't report error
- // value = "succeeded";
- System.setProperty(CLASSNAME, value);
- }
-
- /**
- * Report success to the test case code
- */
- public static void reportSuccess() {
- System.setProperty(CLASSNAME, "succeeded");
- }
-
- private Elements _elementUtils;
-
- // 0 means run all tests; otherwise run just the (1-based) single test indicated
- private int _oneTest;
-
- // Report failures on tests that are already known to be unsupported
- private boolean _reportFailingCases = true;
-
- // If processor options don't include this processor's classname, don't run the proc at all.
- private boolean _processorEnabled;
-
- private boolean _ignoreJavacBugs = false;
-
-
- public NegativeModelProc() {
- for (int i = 0; i < testMethodNames.length; ++i) {
- try {
- testMethods[i] = NegativeModelProc.class.getMethod(testMethodNames[i]);
- } catch (Exception e) {
- e.printStackTrace();
- throw new IllegalStateException(e);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.AbstractProcessor#init(javax.annotation.processing.ProcessingEnvironment)
- */
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- _elementUtils = processingEnv.getElementUtils();
-
- // parse options
- _oneTest = -1;
- Map<String, String> options = processingEnv.getOptions();
- _processorEnabled = options.containsKey(CLASSNAME);
- String oneTestOption = options.get(CLASSNAME);
- if (oneTestOption == null || oneTestOption.length() == 0) {
- _oneTest = 0;
- }
- else {
- try {
- _oneTest = Integer.parseInt(oneTestOption);
- } catch (Exception e) {
- // report it in process(), where we have better error reporting capability
- }
- }
- _ignoreJavacBugs = options.containsKey(IGNORE_JAVAC_BUGS);
- }
-
- // Always return false from this processor, because it supports "*".
- // The return value does not signify success or failure!
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- if (!_processorEnabled) {
- // Disable this processor unless we are intentionally performing the test.
- return false;
- }
- if (roundEnv.processingOver()) {
- // We're not interested in the postprocessing round.
- return false;
- }
- if (_oneTest < 0 || _oneTest > testMethodNames.length) {
- reportError("Invalid test method specified: " + processingEnv.getOptions().get(CLASSNAME));
- return false;
- }
-
- // Reflectively invoke the specified tests.
- try {
- if (_oneTest == 0) {
- for (Method testMethod : testMethods) {
- Object success = testMethod.invoke(this);
- if (!(success instanceof Boolean) || !(Boolean)success) {
- return false;
- }
- }
- }
- else {
- Object success = testMethods[_oneTest - 1].invoke(this);
- if (!(success instanceof Boolean) || !(Boolean)success) {
- return false;
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- reportError("Exception thrown while invoking test method: " + e);
- return false;
- }
-
- reportSuccess();
- return false;
- }
-
- /**
- * Check the annotations in the model of resources/targets.negative.pa.Negative1
- * @return true if all tests passed
- */
- public boolean checkNegative1() {
- TypeElement elementN1 = _elementUtils.getTypeElement("targets.negative.pa.Negative1");
- if (null == elementN1 || elementN1.getKind() != ElementKind.CLASS) {
- reportError("Element Negative1 was not found or was not a class");
- return false;
- }
- AnnotationMirror am3 = findAnnotation(elementN1, "A3");
- if (_reportFailingCases && null == am3) {
- reportError("Couldn't find annotation A3 on class Negative1");
- return false;
- }
- List<? extends Element> enclosedElements = elementN1.getEnclosedElements();
- boolean foundM1 = false; // do we find an element of unresolved type?
- for (Element element : enclosedElements) {
- String name = element.getSimpleName().toString();
- if ("m1".equals(name)) {
- foundM1 = true;
- TypeKind tk = element.asType().getKind();
- if (tk != TypeKind.ERROR && tk != TypeKind.DECLARED) {
- reportError("Field Negative1.m1 has a type of unexpected kind " + tk);
- return false;
- }
- AnnotationMirror am4 = findAnnotation(element, "A4");
- if (_reportFailingCases && null == am4) {
- reportError("Couldn't find annotation A4 on field Negative1.m1");
- return false;
- }
- }
- else if ("i1".equals(name)) {
- AnnotationMirror am5 = findAnnotation(element, "A5");
- if (_reportFailingCases && null == am5) {
- reportError("Couldn't find annotation A5 on field Negative1.i1");
- return false;
- }
- }
- else if ("m2".equals(name)) {
- AnnotationMirror am8 = findAnnotation(element, "A8");
- if (_reportFailingCases && null == am8) {
- reportError("Couldn't find annotation A8 on field Negative1.m2");
- return false;
- }
- }
- else if ("s1".equals(name)) {
- AnnotationMirror am = findAnnotation(element, "Anno1");
- if (null == am) {
- reportError("Couldn't find annotation Anno on field Negative1.s1");
- return false;
- }
- Map<? extends ExecutableElement, ? extends AnnotationValue> values = am.getElementValues();
- for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : values.entrySet()) {
- if ("value".equals(entry.getKey().getSimpleName().toString())) {
- if (!"spud".equals(entry.getValue().getValue())) {
- reportError("Unexpected value for Anno1 on Negative1.s1: " + entry.getValue().getValue());
- return false;
- }
- }
- }
- }
- }
- if (_reportFailingCases && !foundM1) {
- reportError("Couldn't find field Negative1.m1, presumably because its type is missing");
- return false;
- }
- return true;
- }
-
- /**
- * Check the annotations in the model of resources/targets.negative.pa.Negative2
- * @return true if all tests passed
- */
- public boolean checkNegative2() {
- TypeElement elementN2 = _elementUtils.getTypeElement("targets.negative.pa.Negative2");
- if (null == elementN2 || elementN2.getKind() != ElementKind.CLASS) {
- reportError("Element Negative2 was not found or was not a class");
- return false;
- }
- List<? extends Element> enclosedElements = elementN2.getEnclosedElements();
- for (Element element : enclosedElements) {
- String name = element.getSimpleName().toString();
- if ("m1".equals(name)) {
- AnnotationMirror am2 = findAnnotation(element, "Anno2");
- if (_reportFailingCases && null == am2) {
- reportError("Couldn't find annotation Anno2 on method Negative2.m1");
- return false;
- }
- }
- else if ("m2".equals(name)) {
- AnnotationMirror am1 = findAnnotation(element, "Anno1");
- if (_reportFailingCases && null == am1) {
- reportError("Couldn't find annotation Anno1 on method Negative2.m2");
- return false;
- }
- AnnotationMirror am3 = findAnnotation(element, "FakeAnno3");
- if (_reportFailingCases && null == am3) {
- reportError("Couldn't find annotation FakeAnno3 on method Negative2.m2");
- return false;
- }
- }
- else if ("m3".equals(name)) {
- AnnotationMirror am2 = findAnnotation(element, "Anno2");
- if (_reportFailingCases && null == am2) {
- reportError("Couldn't find annotation Anno2 on method Negative2.m3");
- return false;
- }
- AnnotationMirror am3 = findAnnotation(element, "FakeAnno3");
- if (_reportFailingCases && null == am3) {
- reportError("Couldn't find annotation FakeAnno3 on method Negative2.m3");
- return false;
- }
- }
- else if ("m4".equals(name)) {
- AnnotationMirror am4 = findAnnotation(element, "Anno4");
- if (_reportFailingCases && null == am4) {
- reportError("Couldn't find annotation Anno4 on method Negative2.m4");
- return false;
- }
- Map<? extends ExecutableElement, ? extends AnnotationValue> values = am4.getElementValues();
- for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : values.entrySet()) {
- if ("value".equals(entry.getKey().getSimpleName().toString())) {
- String value = entry.getValue().getValue().toString();
- if (!"123".equals(value) && !"<error>".equals(value)) {
- reportError("Unexpected value for Anno4 on Negative1.s1: " + value);
- return false;
- }
- }
- }
- }
- }
- return true;
- }
-
- /**
- * Check the model of resources/targets.negative.pa.Negative3
- * @return true if all tests passed
- */
- public boolean checkNegative3() {
- TypeElement elementN3 = _elementUtils.getTypeElement("targets.negative.pa.Negative3");
- if (null == elementN3 || elementN3.getKind() != ElementKind.CLASS) {
- reportError("Element Negative3 was not found or was not a class");
- return false;
- }
- List<? extends Element> enclosedElements = elementN3.getEnclosedElements();
- for (Element element : enclosedElements) {
- String name = element.getSimpleName().toString();
- if ("foo".equals(name)) {
- ElementKind kind = element.getKind();
- if (_reportFailingCases && ElementKind.METHOD != kind) {
- reportError("Element 'foo' was expected to be a METHOD but was a " + kind);
- return false;
- }
- List<? extends VariableElement> params = ((ExecutableElement)element).getParameters();
- if (_reportFailingCases && (params == null || params.size() != 1)) {
- reportError("Expected method Negative3.foo() to have one param, but found " +
- (params == null ? 0 : params.size()));
- return false;
- }
- VariableElement param1 = params.iterator().next();
- TypeMirror param1Type = param1.asType();
- TypeKind tkind = param1Type.getKind();
- if (_reportFailingCases && TypeKind.ERROR != tkind && TypeKind.DECLARED != tkind) {
- reportError("Expected the TypeKind of Negative3.foo() param to be ERROR or DECLARED, but found " + tkind);
- return false;
- }
- // The behavior of TypeMirror.toString() is suggested, not required, by its javadoc.
- // So, this is a test of whether we behave like javac, rather than whether we meet the spec.
- String pname = param1Type.toString();
- if (_reportFailingCases && !"M2.M3.M4".equals(pname)) {
- reportError("Expected toString() of the type of Negative3.foo() param to be M2.M3.M4, but found " + pname);
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Check the model of resources/targets.negative.pa.Negative4
- * @return true if all tests passed
- */
- public boolean checkNegative4() throws Exception {
- TypeElement elementN4 = _elementUtils.getTypeElement("targets.negative.pa.Negative4");
- if (null == elementN4 || elementN4.getKind() != ElementKind.CLASS) {
- reportError("Element Negative4 was not found or was not a class");
- return false;
- }
-
- return checkModel(Collections.singletonList(elementN4), NEGATIVE_4_MODEL, "Negative4");
- }
-
-
- public boolean checkNegative5() throws Exception {
- List<TypeElement> rootElements = new ArrayList<TypeElement>();
- TypeElement element = _elementUtils.getTypeElement("targets.negative.pa.Negative5");
- if (null == element) {
- reportError("Element Negative5 was not found");
- return false;
- }
- rootElements.add(element);
- element = _elementUtils.getTypeElement("targets.negative.pa.INegative5");
- if (null == element) {
- reportError("Element INegative5 was not found");
- return false;
- }
- rootElements.add(element);
-
- return checkModel(rootElements, NEGATIVE_5_MODEL, "Negative5");
- }
-
- /**
- * Check the model of resources/targets.negative.pa.Negative6
- * @return true if all tests passed
- */
- public boolean checkNegative6() throws Exception {
-
- // Get the root of the Negative6 model
- TypeElement element = _elementUtils.getTypeElement("targets.negative.pa.Negative6");
- if (null == element || element.getKind() != ElementKind.CLASS) {
- reportError("Element Negative6 was not found or was not a class");
- return false;
- }
-
- return checkModel(Collections.singletonList(element), NEGATIVE_6_MODEL, "Negative6");
- }
-
- /**
- * Check the model of resources/targets.negative.pa.Negative7
- * @return true if all tests passed
- */
- public boolean checkNegative7() throws Exception {
-
- // Get the roots of the Negative7 model
- List<TypeElement> rootElements = new ArrayList<TypeElement>();
- TypeElement element = _elementUtils.getTypeElement("targets.negative.pa.Negative7");
- if (null == element) {
- reportError("Element Negative7 was not found");
- return false;
- }
- rootElements.add(element);
- element = _elementUtils.getTypeElement("targets.negative.pa.Negative7A");
- if (null == element) {
- reportError("Element Negative7A was not found");
- return false;
- }
- rootElements.add(element);
-
- return checkModel(rootElements, NEGATIVE_7_MODEL, "Negative7");
- }
-
- /**
- * Compare a set of elements to a reference model, and output error information if there is a
- * mismatch.
- *
- * @param rootElements
- * @param expected
- * a string representation of the XML reference model, as it would be serialized by
- * XMLConverter
- * @param name
- * the name of the test, which is used for human-readable output
- * @return true if the actual and expected models were equivalent
- * @throws Exception
- */
- private boolean checkModel(List<TypeElement> rootElements, String expected, String name) throws Exception {
- Document actualModel = XMLConverter.convertModel(rootElements);
-
- InputSource source = new InputSource(new StringReader(expected));
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- Document expectedModel = factory.newDocumentBuilder().parse(source);
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- StringBuilder summary = new StringBuilder();
- summary.append("Test ").append(name).append(" failed; see console for details. ");
- boolean success = XMLComparer.compare(actualModel, expectedModel, out, summary, _ignoreJavacBugs);
- if (!success) {
- System.out.println("Test " + name + " failed. Detailed output follows:");
- System.out.print(out.toString());
- System.out.println("=============== end output ===============");
- reportError(summary.toString());
- }
- return success;
- }
-
- /**
- * Find a particular annotation on a specified element.
- * @param el the annotated element
- * @param name the simple name of the annotation
- * @return a mirror for the annotation, or null if the annotation was not found.
- */
- private AnnotationMirror findAnnotation(Element el, String name) {
- for (AnnotationMirror am : el.getAnnotationMirrors()) {
- DeclaredType annoType = am.getAnnotationType();
- if (null != annoType) {
- Element annoTypeElement = annoType.asElement();
- if (null != annoTypeElement) {
- if (name.equals(annoTypeElement.getSimpleName().toString())) {
- return am;
- }
- }
- }
- }
- return null;
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/typemirror/TypeMirrorProc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/typemirror/TypeMirrorProc.java
deleted file mode 100644
index 8c19421837..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/typemirror/TypeMirrorProc.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests.processors.typemirror;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.DeclaredType;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.ElementFilter;
-
-import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
-
-/**
- * A processor that explores the "model" target hierarchy with an emphasis
- * on exploring the TypeMirror APIs. To enable this processor, add
- * -Aorg.eclipse.jdt.compiler.apt.tests.processors.typemirror.TypeMirrorProc
- * to the command line.
- * @since 3.3
- */
-@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-public class TypeMirrorProc extends BaseProcessor
-{
- // Initialized in collectElements()
- private TypeElement _elementAC;
- private TypeElement _elementF;
- private TypeElement _elementFChild;
- private TypeMirror _typeString;
- private TypeMirror _typeNumber;
-
- // Always return false from this processor, because it supports "*".
- // The return value does not signify success or failure!
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- if (roundEnv.processingOver()) {
- // We're not interested in the postprocessing round.
- return false;
- }
- Map<String, String> options = processingEnv.getOptions();
- if (!options.containsKey(this.getClass().getName())) {
- // Disable this processor unless we are intentionally performing the test.
- return false;
- }
-
- if (!collectElements()) {
- return false;
- }
-
- if (!examineGetEnclosingType()) {
- return false;
- }
-
- if (!examineGetTypeArguments()) {
- return false;
- }
-
- reportSuccess();
- return false;
- }
-
- /**
- * Collect some elements that will be reused in various tests
- * @return true if all tests passed
- */
- private boolean collectElements() {
- _elementF = _elementUtils.getTypeElement("targets.model.pc.F");
- if (_elementF == null || _elementF.getKind() != ElementKind.CLASS) {
- reportError("element F was not found or was not a class");
- return false;
- }
- _elementFChild = _elementUtils.getTypeElement("targets.model.pc.F.FChild");
- if (_elementFChild == null || _elementFChild.getKind() != ElementKind.CLASS) {
- reportError("element FChild was not found or was not a class");
- return false;
- }
- _elementAC = _elementUtils.getTypeElement("targets.model.pb.AC");
- if (_elementAC == null || _elementAC.getKind() != ElementKind.CLASS) {
- reportError("element AC was not found or was not a class");
- return false;
- }
-
- TypeElement e = _elementUtils.getTypeElement("java.lang.String");
- _typeString = e.asType();
- e = _elementUtils.getTypeElement("java.lang.Number");
- _typeNumber = e.asType();
- return true;
- }
-
- /**
- * Examine the DeclaredType.getEnclosingType() implementation
- * @return true if all tests passed
- */
- private boolean examineGetEnclosingType() {
- TypeMirror outer = _elementF.asType();
- if (!(outer instanceof DeclaredType)) {
- reportError("F.asType() did not return a DeclaredType");
- return false;
- }
- TypeMirror inner = _elementFChild.asType();
- if (!(outer instanceof DeclaredType)) {
- reportError("F.FChild.asType() did not return a DeclaredType");
- return false;
- }
- TypeMirror innerParent = ((DeclaredType)inner).getEnclosingType();
- if (!_typeUtils.isSameType(outer, innerParent)) {
- reportError("Enclosing type of FChild (" + innerParent + ") is not F (" + outer + ")");
- return false;
- }
- return true;
- }
-
- /**
- * Examine the DeclaredType.getTypeArguments() implementation
- * @return true if all tests passed
- */
- private boolean examineGetTypeArguments() {
- VariableElement fieldMapStringNumber = null;
- VariableElement fieldRawList = null;
- for (VariableElement field : ElementFilter.fieldsIn(_elementAC.getEnclosedElements())) {
- String name = field.getSimpleName().toString();
- if ("_fieldMapStringNumber".equals(name)) {
- fieldMapStringNumber = field;
- }
- else if ("_fieldRawList".equals(name)) {
- fieldRawList = field;
- }
- }
- if (null == fieldMapStringNumber || fieldMapStringNumber.getKind() != ElementKind.FIELD) {
- reportError("Unable to find field AC._fieldMapStringNumber");
- return false;
- }
- if (null == fieldRawList || fieldRawList.getKind() != ElementKind.FIELD) {
- reportError("Unable to find field AC._fieldRawList");
- return false;
- }
- TypeMirror typeMap = fieldMapStringNumber.asType();
- if (typeMap == null || typeMap.getKind() != TypeKind.DECLARED) {
- reportError("Field AC._fieldMapStringNumber was not found or had wrong type kind");
- return false;
- }
- TypeMirror typeRawList = fieldRawList.asType();
- if (typeRawList == null || typeRawList.getKind() != TypeKind.DECLARED) {
- reportError("Field AC._fieldRawList was not found or had wrong type kind");
- return false;
- }
- List<? extends TypeMirror> args = ((DeclaredType)typeMap).getTypeArguments();
- if (args == null || args.size() != 2) {
- reportError("AC._fieldMapStringNumber.asType().getTypeArguments() returned wrong number of args: " + args);
- return false;
- }
- Iterator<? extends TypeMirror> argsIterator = args.iterator();
- if (!_typeUtils.isSameType(_typeString, argsIterator.next()) ||
- !_typeUtils.isSameType(_typeNumber, argsIterator.next())) {
- reportError("AC._fieldMapStringNumber.asType().getTypeArguments() returned wrong args: " + args);
- return false;
- }
- args = ((DeclaredType)typeRawList).getTypeArguments();
- if (args == null || args.size() != 0) {
- reportError("AC._fieldRawList.asType().getTypeArguments() returned wrong number of args: " + args);
- return false;
- }
-
- return true;
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/typeutils/TypeUtilsProc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/typeutils/TypeUtilsProc.java
deleted file mode 100644
index f168ecfd56..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/typeutils/TypeUtilsProc.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests.processors.typeutils;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.type.DeclaredType;
-import javax.lang.model.type.NoType;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-
-import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
-
-/**
- * A processor that exercises the methods on the Elements utility. To enable this processor, add
- * -Aorg.eclipse.jdt.compiler.apt.tests.processors.typeutils.TypeUtilsProc to the command line.
- * @since 3.3
- */
-@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-public class TypeUtilsProc extends BaseProcessor
-{
-
- // Always return false from this processor, because it supports "*".
- // The return value does not signify success or failure!
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
- {
- if (roundEnv.processingOver()) {
- // We're not interested in the postprocessing round.
- return false;
- }
- Map<String, String> options = processingEnv.getOptions();
- if (!options.containsKey(this.getClass().getName())) {
- // Disable this processor unless we are intentionally performing the test.
- return false;
- }
-
- if (!examinePrimitives()) {
- return false;
- }
-
- if (!examineNoType()) {
- return false;
- }
-
- if (!examineGetDeclaredType()) {
- return false;
- }
-
- reportSuccess();
- return false;
- }
-
- /**
- * Test the implementation of primitive types and the getPrimitiveType() method
- * @return true if tests passed
- */
- private boolean examinePrimitives() {
- TypeElement integerElement = _elementUtils.getTypeElement("java.lang.Integer");
- if (null == integerElement) {
- reportError("Failed to get element java.lang.Integer");
- return false;
- }
- TypeMirror integerType = integerElement.asType();
- if (null == integerType) {
- reportError("Failed to get element java.lang.Integer as a type");
- return false;
- }
- TypeMirror intType = _typeUtils.getPrimitiveType(TypeKind.INT);
- if (null == intType || intType.getKind() != TypeKind.INT) {
- reportError("Failed to get primitive type INT");
- return false;
- }
- TypeMirror floatType = _typeUtils.getPrimitiveType(TypeKind.FLOAT);
- if (null == floatType || floatType.getKind() != TypeKind.FLOAT) {
- reportError("Failed to get primitive type FLOAT");
- return false;
- }
- if (!intType.equals(_typeUtils.unboxedType(integerType))) {
- reportError("unboxedType(java.lang.Integer) is not primitive int");
- return false;
- }
- if (!_typeUtils.isAssignable(intType, floatType)) {
- reportError("isAssignable(int, float) should be true");
- return false;
- }
- if (_typeUtils.isAssignable(floatType, intType)) {
- reportError("isAssignable(float, int) should be false");
- return false;
- }
-
- // TYPE IDENTITY
- if (_typeUtils.isSameType(intType, floatType)) {
- reportError("Primitive type int is reported to be same as float");
- return false;
- }
- if (!_typeUtils.isSameType(floatType, floatType)) {
- reportError("Primitive type float is reported to not be same as itself");
- return false;
- }
-
- // SUBTYPES
- if (!_typeUtils.isSubtype(intType, intType)) {
- reportError("Primitive type int is not a subtype of itself");
- return false;
- }
- if (!_typeUtils.isSubtype(intType, floatType)) {
- reportError("Primitive type int is not a subtype of float");
- return false;
- }
- if (_typeUtils.isSubtype(floatType, intType)) {
- reportError("Primitive type float is a subtype of int");
- return false;
- }
-
- // BOXING
- if (!_typeUtils.isAssignable(intType, integerType)) {
- reportError("isAssignable(int, java.lang.Integer) should be true");
- return false;
- }
- if (!_typeUtils.isAssignable(integerType, intType)) {
- reportError("isAssignable(java.lang.Integer, int) should be true");
- return false;
- }
- if (!_typeUtils.isAssignable(integerType, floatType)) {
- reportError("isAssignable(java.lang.Integer, float) should be true");
- return false;
- }
- if (_typeUtils.isAssignable(floatType, integerType)) {
- reportError("isAssignable(float, java.lang.Integer) should be false");
- return false;
- }
-
- return true;
- }
-
- /**
- * Test the implementation of NoType and the getNoType() method
- * @return true if tests passed
- */
- private boolean examineNoType() {
- NoType noType = _typeUtils.getNoType(TypeKind.NONE);
- if (null == noType || noType.getKind() != TypeKind.NONE) {
- reportError("getNoType() didn't return a TypeKind.NONE type");
- return false;
- }
- if (!"<none>".equals(noType.toString())) {
- reportError("NoType has the wrong name: " + noType.toString());
- return false;
- }
- return true;
- }
-
- /**
- * Test the implementation of {@link javax.lang.model.util.Types#getDeclaredType()}
- * @return
- */
- private boolean examineGetDeclaredType() {
- TypeElement elementD = _elementUtils.getTypeElement("targets.model.pb.D");
- TypeElement elementAB = _elementUtils.getTypeElement("targets.model.pb.AB");
- TypeMirror typeAB = _typeUtils.getDeclaredType(elementAB);
- if (!(typeAB instanceof DeclaredType) || typeAB.getKind() != TypeKind.DECLARED) {
- reportError("Types.getDeclaredType(elementAB) returned bad value: " + typeAB);
- return false;
- }
- TypeMirror typeDSuper = elementD.getSuperclass();
- if (typeDSuper == null || !_typeUtils.isSameType(typeAB, typeDSuper)) {
- reportError("Type of AB and superclass of D are not same type");
- return false;
- }
- // TODO: check getDeclaredType for generic types and for contained types
- return true;
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/visitors/VisitorProc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/visitors/VisitorProc.java
deleted file mode 100644
index fb387cacb2..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/visitors/VisitorProc.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests.processors.visitors;
-
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.TypeParameterElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.AbstractAnnotationValueVisitor6;
-import javax.lang.model.util.ElementScanner6;
-
-import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
-
-/**
- * Processor that tests a variety of Visitors
- */
-@SupportedAnnotationTypes({"*"})
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
-public class VisitorProc extends BaseProcessor
-{
- /**
- * This visitor is invoked on the top-level types in resources/targets/model.
- * We expect to see each of the visitX() methods get hit as a result.
- */
- private static class ElementVisitorTester extends ElementScanner6<Void, Void> {
-
- public enum Visited { TYPE, EXECUTABLE, VARIABLE, TYPEPARAM, PACKAGE, UNKNOWN }
-
- private EnumSet<Visited> _visited = EnumSet.noneOf(Visited.class);
-
- public boolean checkVisits() {
- boolean asExpected = true;
- asExpected &= _visited.contains(Visited.TYPE);
- asExpected &= _visited.contains(Visited.EXECUTABLE);
- asExpected &= _visited.contains(Visited.VARIABLE);
- // TODO: Following two cases not yet implemented:
- //asExpected &= _visited.contains(Visited.TYPEPARAM);
- //asExpected &= _visited.contains(Visited.PACKAGE);
- return asExpected;
- }
-
- /**
- * Check that we can visit types.
- * @return true if all tests passed
- */
- @Override
- public Void visitType(TypeElement e, Void p) {
- _visited.add(Visited.TYPE);
- // Scan the type's subtypes, fields, and methods
- return super.visitType(e, p);
- }
-
- /**
- * Check that we can visit methods.
- */
- @Override
- public Void visitExecutable(ExecutableElement e, Void p) {
- _visited.add(Visited.EXECUTABLE);
- // Scan the method's parameters
- return super.visitExecutable(e, p);
- }
-
- /**
- * Check that we can visit variables.
- */
- @Override
- public Void visitVariable(VariableElement e, Void p) {
- _visited.add(Visited.VARIABLE);
- // Variables do not enclose any elements, so no need to call super.
- return null;
- }
-
- /**
- * Check that we can visit type parameters.
- */
- @Override
- public Void visitTypeParameter(TypeParameterElement e, Void p) {
- _visited.add(Visited.TYPEPARAM);
- // Type parameters do not enclose any elements, so no need to call super.
- return null;
- }
-
- /**
- * Check that we can visit packages.
- */
- @Override
- public Void visitPackage(PackageElement e, Void p) {
- _visited.add(Visited.PACKAGE);
- // We don't want to scan the package's types here, so don't call super.
- return null;
- }
-
- /**
- * This should not actually be encountered.
- */
- @Override
- public Void visitUnknown(Element e, Void p) {
- _visited.add(Visited.UNKNOWN);
- return null;
- }
-
- }
-
- /*
- * The specific values checked by this visitor correspond to values in targets.model.pc.TypedAnnos.java
- */
- private static class AnnotationVisitorTester extends AbstractAnnotationValueVisitor6<Void, Void> {
-
- public enum Visited { ANNOTATION, ARRAY, BOOLEAN, BYTE, CHAR, DOUBLE, ENUMCONSTANT, FLOAT, INT, LONG, SHORT, STRING, TYPE }
-
- private EnumSet<Visited> _visited = EnumSet.noneOf(Visited.class);
-
- public boolean checkVisits() {
- boolean asExpected = true;
- asExpected &= _visited.contains(Visited.ANNOTATION);
- asExpected &= _visited.contains(Visited.ARRAY);
- asExpected &= _visited.contains(Visited.BOOLEAN);
- asExpected &= _visited.contains(Visited.BYTE);
- asExpected &= _visited.contains(Visited.CHAR);
- asExpected &= _visited.contains(Visited.DOUBLE);
- asExpected &= _visited.contains(Visited.ENUMCONSTANT);
- asExpected &= _visited.contains(Visited.FLOAT);
- asExpected &= _visited.contains(Visited.INT);
- asExpected &= _visited.contains(Visited.LONG);
- asExpected &= _visited.contains(Visited.SHORT);
- asExpected &= _visited.contains(Visited.STRING);
- asExpected &= _visited.contains(Visited.TYPE);
- return asExpected;
- }
-
- @Override
- public Void visitAnnotation(AnnotationMirror a, Void p)
- {
- if (a != null && a.getElementValues() != null) {
- _visited.add(Visited.ANNOTATION);
- }
- // we could scan the values of the nested annotation here, but that doesn't help our test case
- return null;
- }
-
- @Override
- public Void visitArray(List<? extends AnnotationValue> vals, Void p)
- {
- if ( null != vals && vals.size() == 2 ) {
- if ( vals.iterator().next().getValue() instanceof TypeMirror) {
- _visited.add(Visited.ARRAY);
- }
- }
- // we could scan the array values here, but that doesn't help our test case
- return null;
- }
-
- @Override
- public Void visitBoolean(boolean b, Void p)
- {
- if (b) {
- _visited.add(Visited.BOOLEAN);
- }
- return null;
- }
-
- @Override
- public Void visitByte(byte b, Void p)
- {
- if (b == 3) {
- _visited.add(Visited.BYTE);
- }
- return null;
- }
-
- @Override
- public Void visitChar(char c, Void p)
- {
- if (c == 'c') {
- _visited.add(Visited.CHAR);
- }
- return null;
- }
-
- @Override
- public Void visitDouble(double d, Void p)
- {
- if (d == 6.3) {
- _visited.add(Visited.DOUBLE);
- }
- return null;
- }
-
- @Override
- public Void visitEnumConstant(VariableElement c, Void p)
- {
- if (c.getKind() == ElementKind.ENUM_CONSTANT) {
- if ("A".equals(c.getSimpleName().toString())) {
- _visited.add(Visited.ENUMCONSTANT);
- }
- }
- return null;
- }
-
- @Override
- public Void visitFloat(float f, Void p)
- {
- if (f == 26.7F) {
- _visited.add(Visited.FLOAT);
- }
- return null;
- }
-
- @Override
- public Void visitInt(int i, Void p)
- {
- if (i == 19) {
- _visited.add(Visited.INT);
- }
- return null;
- }
-
- @Override
- public Void visitLong(long i, Void p)
- {
- if (i == 300L) {
- _visited.add(Visited.LONG);
- }
- return null;
- }
-
- @Override
- public Void visitShort(short s, Void p)
- {
- if (s == 289) {
- _visited.add(Visited.SHORT);
- }
- return null;
- }
-
- @Override
- public Void visitString(String s, Void p)
- {
- if ("foo".equals(s)) {
- _visited.add(Visited.STRING);
- }
- return null;
- }
-
- @Override
- public Void visitType(TypeMirror t, Void p)
- {
- if ("java.lang.Exception".equals(t.toString())) {
- _visited.add(Visited.TYPE);
- }
- return null;
- }
-
- }
-
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv)
- {
- super.init(processingEnv);
- }
-
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
- {
- if (roundEnv.processingOver()) {
- return false;
- }
- Map<String, String> options = processingEnv.getOptions();
- if (!options.containsKey(this.getClass().getName())) {
- // Disable this processor unless we are intentionally performing the test.
- return false;
- }
- ElementVisitorTester elementVisitor = new ElementVisitorTester();
- elementVisitor.scan(roundEnv.getRootElements(), null);
- if (!elementVisitor.checkVisits()) {
- reportError("Element visitor was not visited as expected");
- return false;
- }
-
- AnnotationVisitorTester annoValVisitor = new AnnotationVisitorTester();
- TypeElement typedAnnosDecl = _elementUtils.getTypeElement("org.eclipse.jdt.compiler.apt.tests.annotations.TypedAnnos");
- if (null == typedAnnosDecl) {
- reportError("Couldn't find targets.model.pc.AnnotatedWithManyTypes");
- return false;
- }
- for (TypeElement anno : annotations) {
- if (typedAnnosDecl.equals(anno.getEnclosingElement())) {
- for (Element elem : roundEnv.getElementsAnnotatedWith(anno)) {
- for (AnnotationMirror annoMirror : elem.getAnnotationMirrors()) {
- if (anno.equals(annoMirror.getAnnotationType().asElement())) {
- Map<? extends ExecutableElement, ? extends AnnotationValue> values = annoMirror.getElementValues();
- for (AnnotationValue val : values.values()) {
- val.accept(annoValVisitor, null);
- }
- }
- }
- }
- }
- }
- if (!annoValVisitor.checkVisits()) {
- reportError("Annotation value visitor was not visited as expected");
- return false;
- }
-
- reportSuccess();
- return false;
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/HasCheckArgs.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/HasCheckArgs.java
deleted file mode 100644
index a393a2fda1..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/HasCheckArgs.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * wharley@bea.com - initial API and implementation
- *******************************************************************************/
-package targets.dispatch;
-
-import org.eclipse.jdt.compiler.apt.tests.annotations.CheckArgs;
-
-/**
- * Target for annotation processing test. Processing this
- * has no effect, but invokes a processor that complains
- * if it does not see expected environment variables.
- * @see org.eclipse.jdt.compiler.apt.tests.processors.checkargs.CheckArgsProc.
- */
-@CheckArgs
-public class HasCheckArgs {
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/HasGenClass.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/HasGenClass.java
deleted file mode 100644
index 456db33166..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/HasGenClass.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * wharley@bea.com - initial API and implementation
- *******************************************************************************/
-/*
- * Target for annotation processing test. Processing this
- * should result in generation of a class gen.HgcGen with
- * method public String foo().
- * @see org.eclipse.jdt.compiler.apt.tests.processors.genclass.GenClassProc.
- */
-package targets.dispatch;
-
-import org.eclipse.jdt.compiler.apt.tests.annotations.GenClass;
-
-// This class will be generated by the annotation processor
-import gen.HgcGen;
-
-@GenClass(clazz="gen.HgcGen", method="foo")
-public class HasGenClass {
- String get() {
- return (new HgcGen()).foo();
- }
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/TwoAnnotations.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/TwoAnnotations.java
deleted file mode 100644
index 1c098d755d..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/TwoAnnotations.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * wharley@bea.com - initial API and implementation
- *******************************************************************************/
-package targets.dispatch;
-
-import org.eclipse.jdt.compiler.apt.tests.annotations.CheckArgs;
-import org.eclipse.jdt.compiler.apt.tests.annotations.GenClass;
-
-/**
- * Target for annotation processor tests.
- * @since 3.3
- */
-@CheckArgs
-@GenClass(clazz="gen.TwoAnnotationsGen", method="foo")
-public class TwoAnnotations {
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/X.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/X.java
deleted file mode 100644
index 57183a2305..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/X.java
+++ /dev/null
@@ -1,9 +0,0 @@
-import p.Y;
-import p.Z;
-
-public class X extends Y {
- public static void main(String[] args) {
- System.out.println(new Y());
- System.out.println(new Z());
- }
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/inheritedanno/InheritanceA.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/inheritedanno/InheritanceA.java
deleted file mode 100644
index 3cce79ddff..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/inheritedanno/InheritanceA.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-import org.eclipse.jdt.compiler.apt.tests.annotations.InheritedAnno;
-
-@InheritedAnno
-@NotInheritedAnno
-public class InheritanceA {
- @InheritedAnno
- @NotInheritedAnno
- public InheritanceA() {}
-
- @InheritedAnno
- @NotInheritedAnno
- public InheritanceA(int i) {}
-
- // Not a constructor: has a return value
- @InheritedAnno
- @NotInheritedAnno
- public void InheritanceA() {}
-
- @InheritedAnno
- @NotInheritedAnno
- public class AChild {}
-
- public class ANotAnnotated {}
-
- @InheritedAnno
- @NotInheritedAnno
- public interface AIntf {}
-
- @InheritedAnno
- @NotInheritedAnno
- public void foo() {}
-
- @InheritedAnno
- @NotInheritedAnno
- public int i;
-
- @InheritedAnno
- @NotInheritedAnno
- public enum AEnum { A, B }
-}
-
-class InheritanceB extends InheritanceA {
- public class BChild extends AChild {}
-
- public class BNotAnnotated extends ANotAnnotated {}
-
- public interface BIntf extends AIntf {}
-
- public void foo() {}
-
- public int i;
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/inheritedanno/NotInheritedAnno.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/inheritedanno/NotInheritedAnno.java
deleted file mode 100644
index bab6b0b286..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/inheritedanno/NotInheritedAnno.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-@interface NotInheritedAnno {} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/p/Y.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/p/Y.java
deleted file mode 100644
index 1c93301f58..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/p/Y.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package p;
-
-public class Y extends Z {} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/p/Z.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/p/Z.java
deleted file mode 100644
index 0b5f4d65e0..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/dispatch/p/Z.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package p;
-
-public class Z {} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pa/AnnoZ.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pa/AnnoZ.java
deleted file mode 100644
index 16ab111335..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pa/AnnoZ.java
+++ /dev/null
@@ -1,13 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package target.errors.pa;
-
-public @interface AnnoZ {
- String annoZString();
- int annoZint() default 17;
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pb/D.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pb/D.java
deleted file mode 100644
index 36b4c5f95d..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pb/D.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.errors.pb;
-
-import target.errors.pa.AnnoZ;
-
-@AnnoZ(
- annoZString = "annoZOnD")
-@SuppressWarnings("all")
-public class D {
- public enum DEnum { DEnum1, DEnum2, DEnum3 }
-
- @AnnoZ(annoZString = "annoZOnDMethod", annoZint = 31)
- public void methodDvoid(DEnum dEnum1) {
- }
-}
-
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pb/E.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pb/E.java
deleted file mode 100644
index 65ed9c6198..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pb/E.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.errors.pb;
-
-@SuppressWarnings("all")
-public class E {
- public void foo(int i) {}
-
- public static int j;
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pb/F.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pb/F.java
deleted file mode 100644
index 48a1eb24c9..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/errors/pb/F.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.errors.pb;
-
-public class F {
-
- enum C {
- CONST1, CONST2
- }
-
- int field;
-
- static {
- }
-
- {
- field = 1;
- }
-
- F(int i) {
- this.field = i;
- }
-
- static class Member {
- }
-
- public void foo(int i) throws Exception {}
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/filer/FilerTarget1.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/filer/FilerTarget1.java
deleted file mode 100644
index 92aa350919..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/filer/FilerTarget1.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * wharley@bea.com - initial API and implementation
- *******************************************************************************/
-/*
- * Target for annotation processing test. Processing this
- * should result in generation of a class gen.HgcGen with
- * method public String foo().
- * @see org.eclipse.jdt.compiler.apt.tests.processors.genclass.GenClassProc.
- */
-package targets.filer;
-
-import org.eclipse.jdt.compiler.apt.tests.annotations.GenResource;
-
-public class FilerTarget1 {
- @GenResource(pkg="resources", relativeName="txt/text.txt", stringContent="A generated string")
- interface A {}
-
- @GenResource(pkg="resources", relativeName="dat/binary.dat", binaryContent={102, 110, 111, 114, 100})
- interface B {}
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/A.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/A.java
deleted file mode 100644
index 3aaf0eaf31..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/A.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pa;
-
-public class A implements IA {
- public String methodIAString(int int1)
- {
- _fieldAint = int1;
- return String.valueOf(_fieldAint);
- }
-
- public void methodThrows1() throws ExceptionA {
- if (_fieldAint < 0) {
- throw new ExceptionA();
- }
- }
-
- public void methodThrows2() throws ExceptionA, UnsupportedOperationException {
- if (_fieldAint > 0) {
- throw new ExceptionA();
- }
- else {
- throw new UnsupportedOperationException();
- }
- }
-
- private int _fieldAint;
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/AnnoZ.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/AnnoZ.java
deleted file mode 100644
index 15ecc63f95..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/AnnoZ.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pa;
-
-import java.lang.annotation.Inherited;
-
-@Inherited
-public @interface AnnoZ {
- String annoZString();
- int annoZint() default 17;
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/ExceptionA.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/ExceptionA.java
deleted file mode 100644
index a821cfa3e6..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/ExceptionA.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pa;
-
-public class ExceptionA extends Exception {
- private static final long serialVersionUID = 1L;
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/IA.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/IA.java
deleted file mode 100644
index 497b0eb8c4..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pa/IA.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pa;
-
-public interface IA {
- public String methodIAString(int int1);
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/AB.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/AB.java
deleted file mode 100644
index fe1a79b69c..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/AB.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pb;
-
-import java.util.List;
-import targets.model.pa.IA;
-
-public class AB implements IB, IA {
- private class E {
-
- }
-
- protected List<IA> _fieldListIA;
-
- public String methodIAString(int int1) { return (new E()).toString(); }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/AC.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/AC.java
deleted file mode 100644
index 360a621e48..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/AC.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pb;
-
-import java.util.*;
-import targets.model.pa.IA;
-
-@SuppressWarnings("unchecked") // contains some raw types
-public class AC<T1 extends String & Iterator, T2> implements IC, IA {
-
- protected class ACInner<T3> {
-
- }
-
- private List<String> _fieldListString = new ArrayList<String>();
-
- public Map<String, Number> _fieldMapStringNumber = null;
-
- public List _fieldRawList = null;
-
- public String methodIAString(int int1) {
- return _fieldListString.iterator().next();
- }
-
- public T1 methodGetT1(T2 paramT2) {
- return null;
- }
-
- public List<T1> methodGetListT1() {
- return null;
- }
-
- public Map<T1, List<T2>> methodGetMapT1ListT2( Iterator<T2> paramIterT2 ) {
- return null;
- }
-
- public Map<String, Number> methodGetMapStringNumber() {
- return _fieldMapStringNumber;
- }
-
- public List<? extends T1> methodGetQExtendsT1() {
- return null;
- }
-
- public <T3 extends List<T2>> void methodT3Void(T3 paramT3) {
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/D.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/D.java
deleted file mode 100644
index 29dad6a1de..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/D.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pb;
-
-import targets.model.pa.AnnoZ;
-
-@AnnoZ(annoZString = "annoZOnD")
-public class D extends AB {
- public enum DEnum { DEnum1, DEnum2, DEnum3 }
-
- @AnnoZ(annoZString = "annoZOnDMethod", annoZint = 31)
- public void methodDvoid(DEnum dEnum1) {}
-}
-
-// Should inherit AnnoZ
-class DChild extends D {} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/IB.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/IB.java
deleted file mode 100644
index c0ed2792f9..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/IB.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pb;
-
-public interface IB {
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/IC.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/IC.java
deleted file mode 100644
index f5d41e4b60..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pb/IC.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pb;
-
-public interface IC extends IB {
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/AnnoX.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/AnnoX.java
deleted file mode 100644
index 1ab4d86f9f..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/AnnoX.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pc;
-
-import java.lang.annotation.Inherited;
-
-@Inherited
-@interface AnnoX {
- String value();
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/AnnoY.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/AnnoY.java
deleted file mode 100644
index 28aa08ff7c..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/AnnoY.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pc;
-
-@interface AnnoY {
- String value();
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/AnnotatedWithManyTypes.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/AnnotatedWithManyTypes.java
deleted file mode 100644
index d432c24a66..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/AnnotatedWithManyTypes.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pc;
-
-import org.eclipse.jdt.compiler.apt.tests.annotations.*;
-
-/**
- * Annotated with variously typed values.
- */
-public class AnnotatedWithManyTypes {
- // Do not change this code without also changing VisitorProc and ElementProc
- @TypedAnnos.AnnoByte(3)
- @TypedAnnos.AnnoBoolean(true)
- @TypedAnnos.AnnoChar('c')
- @TypedAnnos.AnnoDouble(6.3)
- @TypedAnnos.AnnoFloat(26.7F)
- @TypedAnnos.AnnoInt(19)
- @TypedAnnos.AnnoLong(300L)
- @TypedAnnos.AnnoShort(289)
- @TypedAnnos.AnnoString("foo")
- @TypedAnnos.AnnoEnumConst(TypedAnnos.Enum.A)
- @TypedAnnos.AnnoType(Exception.class)
- @TypedAnnos.AnnoAnnoChar(@TypedAnnos.AnnoChar('x'))
- @TypedAnnos.AnnoArrayInt({5, 8, 11})
- @TypedAnnos.AnnoArrayString({"bar", "quux"})
- @TypedAnnos.AnnoArrayEnumConst({TypedAnnos.Enum.B, TypedAnnos.Enum.C})
- @TypedAnnos.AnnoArrayType({ String.class, Annotated.class })
- @TypedAnnos.AnnoArrayAnnoChar({@TypedAnnos.AnnoChar('y'), @TypedAnnos.AnnoChar('z')})
- public class Annotated {}
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/Deprecation.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/Deprecation.java
deleted file mode 100644
index 208d0f4f09..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/Deprecation.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pc;
-
-@SuppressWarnings("deprecation")
-@Deprecated
-public class Deprecation {
- @Deprecated
- public class deprecatedClass {}
-
- @Deprecated
- public enum deprecatedEnum { Val1 }
-
- @Deprecated
- public interface deprecatedInterface {}
-
- @Deprecated
- public String deprecatedField;
-
- @Deprecated
- void deprecatedMethod() {}
-
- public class nonDeprecatedClass {}
-
- public enum nonDeprecatedEnum { Val1 }
-
- public interface nonDeprecatedInterface {}
-
- public String nonDeprecatedField;
-
- void nonDeprecatedMethod() {}
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/F.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/F.java
deleted file mode 100644
index bd736cdd34..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/F.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-
-// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-// CAUTION! THIS FILE CONTAINS SPECIFIC COMBINATIONS OF TABS AND SPACES,
-// FOR TESTING WHITESPACE HANDLING IN JAVADOC. DO NOT REFORMAT OR MODIFY
-// WHITESPACE IN ANY JAVADOC IN THIS FILE.
-// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-package targets.model.pc;
-
-/**
- * Javadoc on element F
- * @param <T1> a type parameter
- */
-@AnnoY("on F")
-public class F<T1> {
- /**
- * Javadoc on nested element FChild
- */
- public class FChild {
- }
-
- /**
- * Javadoc on nested enum FEnum
- * Two lines long
- */
- enum FEnum { FEnum1, FEnum2 }
-
- /**
- * Javadoc on nested interface FChildI
- * this line has tab after asterisk and ends with another tab
- * this one too
- * this line has three spaces after asterisk and ends with three spaces
- * this line has only one space before the asterisk
- */
- public interface FChildI {}
-
- /** Javadoc on field _fieldT1_protected, inline format */
- protected T1 _fieldT1_protected;
-
- // Next line has a space at the end, after the double asterisks
- /**
- * Javadoc on _fieldT1_private
- this line starts with two spaces, no asterisk
- This line starts, contains and ends with a tab
- This line starts with a space, tab, space, tab, space
- */
- private T1 _fieldT1_private;
-
- int fieldInt;
-
- /**
- * Javadoc on F.method_T1
- */
- @AnnoY("on F.method_T1")
- T1 method_T1(T1 param1)
- {
- return null;
- }
-
- String method_String(T1 param1)
- {
- _fieldT1_private = param1;
- return _fieldT1_private.toString();
- }
-
- // not hidden by G.staticMethod() - private
- private static void staticMethod()
- {
- }
-
- // not hidden by G.staticMethod - different name
- public static void staticMethod2()
- {
- }
-
- @SuppressWarnings("deprecation")
- @Deprecated
- void deprecatedMethod()
- {
- }
-
- // unrelated to the same-signature methods in Overriding.java
- void f() {}
-
- /************************/
- /*** Abstract methods ***/
- /************************/
-
- public Object getAnonymousObjectAbstract() {
- return null;
- }
-
- /**
- * @add(int)
- */
- int add (int j) {
- return j + j;
- }
-
- /**
- * Creates a new instance of AllChecks
- */
- public void foo() {
- }
-
- /**
- * @bar (int)
- */
- int bar(int i) { return i; }
-
- /**
- * @bar2(int)
- */
- int bar2(int i) { return i; }
-
-/**
- Method m
- */
- void m() {}
-
- /** This is a comment for the method m1,
- * it is on two lines
- */
- void m1() {}
-
- /** Another comment - starts on first line and
- continue on the second line */
- void m2() {}
-
- /**
- * One more test case that.
- * needs
- * to be verified.
- *
- * An empty line with no spaces need to be seen as an empty line.
- *
- * End of the comment.
- */
- void m3() {}
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/G.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/G.java
deleted file mode 100644
index 69816b3b49..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/G.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pc;
-
-import targets.model.pa.IA;
-
-@AnnoX("on G")
-public abstract class G extends F<String> implements IA, IF {
- public String _fieldString;
-
- int fieldInt; // hides definition in F
-
- @Override
- @AnnoY("on G.method_T1")
- String method_T1(String param1)
- {
- return null;
- }
-
- String method2_String()
- {
- return null;
- }
-
- // hides F.staticMethod()
- public static void staticMethod()
- {
- }
-
- // Method declared in an interface but not implemented:
- //public String methodIAString(int int1)
- //{
- // return null;
- //}
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/H.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/H.java
deleted file mode 100644
index b3366d0708..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/H.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pc;
-
-@AnnoY("on H")
-public class H extends G {
- int fieldInt; // hides definition in G
-
- public String methodIAString(int int1)
- {
- return null;
- }
-
- // hides G.staticMethod and F.staticMethod
- public static void staticMethod()
- {
- }
-
- // different signature; does not hide G.staticMethod
- public static void staticMethod(int int1)
- {
- }
-
- public class FChild {} // hides definition in F
- public class IFChild {} // hides definition in IF
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/IF.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/IF.java
deleted file mode 100644
index 1a3625d985..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/IF.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pc;
-
-@AnnoY("on IF")
-public interface IF {
- public class IFChild {
-
- }
- public String _stringIF = "constant";
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/J.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/J.java
deleted file mode 100644
index 8dc4461521..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/J.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pc;
-
-public class J {
- int fieldInt; // same-named fields in F, G, and H do NOT hide this; unrelated enclosing classes
-
- int fieldInt() { return 0; } // does not hide, and is not hidden by, any of the fields named fieldInt in F, G, H, or this.
-
- public class FChild {} // does not hide, and is not hidden by, same class in F or H
-
- public class F {} // does not hide, and is not hidden by, outer class F
-
- public static void staticMethod() {} // does not hide, and is not hidden by, F.staticMethod()
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/Overriding.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/Overriding.java
deleted file mode 100644
index 949c0639b3..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/pc/Overriding.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.model.pc;
-
-public class Overriding {
- public class A {
- public void f() {} // overrides OverB.f() in context of OverC, but not in context of OverD
- private void g() {} // does not override OverB.g() in any context
- public void h() {} // overrides OverB.h() in context of OverC and OverD
- public void j() {}
- }
-
- public interface B {
- public void f();
- public void g();
- public void h();
- }
-
- abstract public class C extends A implements B {
- public void h() {}
- public void j() {}
- }
-
- public class D extends C {
- public void f() {}
- public void g() {}
- public void j() {}
- }
-}
-
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative1.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative1.java
deleted file mode 100644
index caca1df37f..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative1.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.negative.pa;
-
-/**
- * This code is syntactic but contains semantic errors due to missing types.
- * All the A* and Missing* types are expected to be unresolved.
- * The desired behavior is specified in the javadoc for package
- * javax.lang.model.element: in general, missing types should be replaced
- * by empty types with the same name.
- */
-@interface Anno1 {
- String value() default "foo";
-}
-@A1.A2.A3 class Negative1 {
- @Anno1("spud") String s1;
- @A4 Missing1 m1 = MISSING_VAL1;
- @A5(@A6(@A7)) int i1;
- @A8 Missing2.Missing3.Missing4 m2;
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative2.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative2.java
deleted file mode 100644
index a547a1b88d..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative2.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.negative.pa;
-
-import targets.negative.pz.*;
-
-/**
- * This code is syntactic but contains semantic errors due to missing types.
- * The desired behavior is specified in the javadoc for package
- * javax.lang.model.element: in general, missing types should be replaced
- * by empty types with the same name.
- */
-@interface Anno1 {
-
-}
-@interface Anno4 {
- int value();
-}
-class Negative2 {
- @Anno2(123) void m1(); // Anno2 is in pz and is not public
- @Anno1 @FakeAnno3 void m2(); // FakeAnno3 is undefined
- @Anno2(456) @FakeAnno3 void m3(); // Anno2 is not visible and FakeAnno3 is undefined
- @Anno4("notAnInt") void m4(); // Anno4 takes an int value
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative3.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative3.java
deleted file mode 100644
index a75c171c92..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative3.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.negative.pa;
-
-/**
- * This code is syntactic but contains semantic errors due to missing types.
- * All the M* types (M for "Missing") are expected to be unresolved.
- * The desired behavior is specified in the javadoc for package
- * javax.lang.model.element: in general, missing types should be replaced
- * by empty types with the same name.
- */
-class Negative3 {
- M1 foo(M2.M3.M4 param) {}
-}
-
-interface I2 extends MI1 {
- M5 boo(M6.M7.M8 param);
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative4.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative4.java
deleted file mode 100644
index f08ab76a99..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative4.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.negative.pa;
-
-/**
- * This code contains missing types and generic types with incorrect parameters.
- * The desired behavior is specified in the javadoc for package
- * javax.lang.model.element: in general, missing types should be replaced
- * by empty types with the same name.
- */
-interface IFoo {}
-interface IBar<T1> {}
-
-class Negative4 {
- // Zork is unknown
- Zork zorkRaw() { return null; }
- Zork<String> zorkOfString() { return null; }
-
- // IFoo does not take a type parameter
- IFoo<String> ifooOfString() { return null; }
-
- // IBar has one type parameter
- IBar ibarRaw() { return null; }
- IBar<String, Object> ibarOfT1T2() { return null; }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative5.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative5.java
deleted file mode 100644
index 7f0448be07..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative5.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.negative.pa;
-
-/**
- * This code contains missing types. The missing types all start with 'M'.
- * The desired behavior is specified in the javadoc for package
- * javax.lang.model.element: in general, missing types should be replaced
- * by empty types with the same name.
- */
-class Negative5 {
- class C1 extends M1 implements M2 {}
- class C2 extends M3<M4<M5>> implements M6<M7>, M8<M9> {}
- interface I1 extends M10 {}
- interface I2 extends M11<M12> {}
-}
-
-interface INegative5 {
- class C101 extends M101 implements M103, M104 {}
- class C102 extends M105<M106> implements M107<M108, MP109> {}
- interface I101 extends M110, M111 {}
- interface I102 extends M112, M113<M114> {}
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative6.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative6.java
deleted file mode 100644
index eff297a755..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative6.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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
- *******************************************************************************/
-package targets.negative.pa;
-
-/**
- * Test case for annotations on non-generic parameters.
- * This code contains missing types, including missing annotation types.
- * The missing types all start with 'M'.
- * The desired behavior is specified in the javadoc for package
- * javax.lang.model.element: in general, missing types should be replaced
- * by empty types with the same name.
- */
-class Negative6 {
- @M11 M12 method1(@M13(@M14(@M15)) M16 arg0) { return null; }
- @M21("foo") String method2(@M22(value2 = "bar") int arg0) { return null; }
- String method3(@M31(1) String arg0, @M32(2) String arg1) { return null; }
- @M41 Negative6(@M42 M43 arg0) {}
-}
-
-
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative7.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative7.java
deleted file mode 100644
index ba561e2ef5..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pa/Negative7.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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
- *******************************************************************************/
-package targets.negative.pa;
-
-/**
- * Test case for annotations on non-generic parameters.
- * This code contains missing types, including missing annotation types.
- * The missing types all start with 'M'.
- * The desired behavior is specified in the javadoc for package
- * javax.lang.model.element: in general, missing types should be replaced
- * by empty types with the same name.
- */
-@interface A1 {}
-
-interface Negative7 extends M11 {
- @A1 int method1(@A1 int arg0);
-}
-
-interface Negative7A extends Cloneable {
- @A1 int method1(@A1 int arg0);
-}
-
-
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pz/Anno2.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pz/Anno2.java
deleted file mode 100644
index 528c65d9a4..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/resources/targets/negative/pz/Anno2.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- *******************************************************************************/
-package targets.negative.pz;
-
-/* package */ @interface Anno2 {
- int value();
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AllTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AllTests.java
deleted file mode 100644
index e26370eac6..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AllTests.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.compiler.apt.tests;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Helper class to run all the compiler tool tests
- */
-public class AllTests extends TestCase {
- // run all tests
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTestSuite(BatchDispatchTests.class);
- suite.addTestSuite(ModelTests.class);
- suite.addTestSuite(MessagerTests.class);
- suite.addTestSuite(FilerTests.class);
- suite.addTestSuite(ModelUtilTests.class);
- // Not yet supported:
- // suite.addTestSuite(NegativeTests.class);
- return suite;
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchDispatchTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchDispatchTests.java
deleted file mode 100644
index ef1f3bbe10..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchDispatchTests.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.compiler.apt.tests;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.tools.JavaCompiler;
-import javax.tools.ToolProvider;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Test the ability to execute annotation processors in batch mode, including
- * tests of file generation, processor environment, etc.
- * <p>
- * This suite is not meant to exhaustively test typesystem functionality.
- * @since 3.3
- */
-public class BatchDispatchTests extends TestCase {
-
- // Processor class names; see corresponding usage in the processor classes.
- private static final String INHERITEDANNOPROC = "org.eclipse.jdt.compiler.apt.tests.processors.inherited.InheritedAnnoProc";
-
- private static final String[] ONE_ARG_OPTIONS = {
- "-s",
- "-processor",
- "-processorpath"
- };
- private static final String[] ZERO_ARG_OPTIONS = {
- "-proc:none",
- "-proc:only",
- "-XprintProcessorInfo",
- "-XprintRounds"
- };
-
-
- public static TestSuite suite() {
- TestSuite suite = new TestSuite();
- suite.addTestSuite(BatchDispatchTests.class);
- return suite;
- }
-
- public BatchDispatchTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- BatchTestUtils.init();
- }
-
- /**
- * Verify that Eclipse compiler properly supports apt-related command line options
- */
- public void testCheckOptions() {
- for (String option : ONE_ARG_OPTIONS) {
- assertEquals(option + " requires 1 argument", 1, BatchTestUtils.getEclipseCompiler().isSupportedOption(option));
- }
- for (String option : ZERO_ARG_OPTIONS) {
- assertEquals(option + " requires no argument", 0, BatchTestUtils.getEclipseCompiler().isSupportedOption(option));
- }
- }
-
- /**
- * Veriy that processor sees correct environment options
- * (sanity check with system compiler)
- * @throws IOException
- */
- public void testProcessorArgumentsWithSystemCompiler() throws IOException {
- // System compiler
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- internalTestProcessorArguments(compiler);
- }
-
- /**
- * Veriy that processor sees correct environment options
- * when called from Eclipse compiler
- * @throws IOException
- */
- public void testProcessorArgumentsWithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestProcessorArguments(compiler);
- }
-
- /**
- * Read annotation values and generate a class using system compiler (javac)
- * This is a sanity check to verify that the processors, sample code, and
- * compiler options are correct.
- * @throws IOException
- */
- public void testCompilerOneClassWithSystemCompiler() throws IOException {
- // System compiler
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- internalTestGenerateClass(compiler);
- }
-
- /**
- * Read annotation values and generate a class using Eclipse compiler
- * @throws IOException
- */
- public void testCompilerOneClassWithEclipseCompiler() throws IOException {
- // Eclipse compiler
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestGenerateClass(compiler);
- }
-
- /**
- * Validate the inherited annotations test against the javac compiler.
- * @throws IOException
- */
- public void testInheritedAnnosWithSystemCompiler() throws IOException {
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- internalTestInheritance(compiler, INHERITEDANNOPROC);
- }
-
- /**
- * Test dispatch of annotation processor on inherited annotations.
- * @throws IOException
- */
- public void testInheritedAnnosWithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestInheritance(compiler, INHERITEDANNOPROC);
- }
-
- /**
- * Verify that if a type has two annotations, both processors are run.
- * @throws IOException
- */
- public void testTwoAnnotations() throws IOException {
- File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "dispatch");
- File inputFile = BatchTestUtils.copyResource("targets/dispatch/TwoAnnotations.java", targetFolder);
- assertNotNull("No input file", inputFile);
-
- List<String> options = new ArrayList<String>();
- // See corresponding list in CheckArgsProc processor.
- // Processor will throw IllegalStateException if it detects a mismatch.
- options.add("-Afoo=bar");
- options.add("-Anovalue");
- options.add("-Abar2=");
- BatchTestUtils.compileOneClass(BatchTestUtils.getEclipseCompiler(), options, inputFile);
-
- // check that the src and class files were generated
- File genSrcFile = TestUtils.concatPath(BatchTestUtils.getGenFolderName(), "gen", "TwoAnnotationsGen.java");
- assertTrue("generated src file does not exist", genSrcFile.exists());
-
- File classFile = TestUtils.concatPath(BatchTestUtils.getBinFolderName(), "targets", "dispatch", "TwoAnnotations.class");
- assertTrue("ordinary src file was not compiled", classFile.exists());
-
- File genClassFile = TestUtils.concatPath(BatchTestUtils.getBinFolderName(), "gen", "TwoAnnotationsGen.class");
- assertTrue("generated src file was not compiled", genClassFile.exists());
- }
-
- // Called with system compiler and Eclipse compiler
- private void internalTestGenerateClass(JavaCompiler compiler) throws IOException {
- File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "dispatch");
- File inputFile = BatchTestUtils.copyResource("targets/dispatch/HasGenClass.java", targetFolder);
- assertNotNull("No input file", inputFile);
-
- List<String> options = new ArrayList<String>();
- BatchTestUtils.compileOneClass(compiler, options, inputFile);
-
- // check that the gen-src and class files were generated
- File genSrcFile = TestUtils.concatPath(BatchTestUtils.getGenFolderName(), "gen", "HgcGen.java");
- assertTrue("generated src file does not exist", genSrcFile.exists());
-
- File classFile = TestUtils.concatPath(BatchTestUtils.getBinFolderName(), "targets", "dispatch", "HasGenClass.class");
- assertTrue("ordinary src file was not compiled", classFile.exists());
-
- File genClassFile = TestUtils.concatPath(BatchTestUtils.getBinFolderName(), "gen", "HgcGen.class");
- assertTrue("generated src file was not compiled", genClassFile.exists());
- }
-
- // Called with system compiler and Eclipse compiler
- private void internalTestProcessorArguments(JavaCompiler compiler) throws IOException {
- File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "dispatch");
- File inputFile = BatchTestUtils.copyResource("targets/dispatch/HasCheckArgs.java", targetFolder);
- assertNotNull("No input file", inputFile);
-
- List<String> options = new ArrayList<String>();
- // See corresponding list in CheckArgsProc processor.
- // Processor will throw IllegalStateException if it detects a mismatch.
- options.add("-Afoo=bar");
- options.add("-Anovalue");
- options.add("-Abar2=");
- BatchTestUtils.compileOneClass(compiler, options, inputFile);
- }
-
- /**
- * Test functionality by running a particular processor against the types in
- * resources/targets. The processor must support "*" (the set of all annotations)
- * and must report its errors or success via the methods in BaseProcessor.
- * @throws IOException
- */
- private void internalTestInheritance(JavaCompiler compiler, String processorClass) throws IOException {
- System.clearProperty(processorClass);
- File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets/dispatch", "inheritedanno");
- BatchTestUtils.copyResources("targets/dispatch/inheritedanno", targetFolder);
-
- List<String> options = new ArrayList<String>();
- options.add("-A" + processorClass);
- BatchTestUtils.compileTree(compiler, options, targetFolder);
-
- // If it succeeded, the processor will have set this property to "succeeded";
- // if not, it will set it to an error value.
- assertEquals("succeeded", System.getProperty(processorClass));
- }
-
- /**
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=209961
- */
- public void test209961() throws IOException {
- File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "dispatch");
- File inputFile = BatchTestUtils.copyResource("targets/dispatch/X.java", targetFolder);
- assertNotNull("No input file", inputFile);
- File classpathEntry =TestUtils.concatPath(
- new File(BatchTestUtils.getPluginDirectoryPath(), BatchTestUtils.getResourceFolderName()).getAbsolutePath(),
- "targets",
- "dispatch");
-
- List<String> options = new ArrayList<String>();
- // See corresponding list in CheckArgsProc processor.
- // Processor will throw IllegalStateException if it detects a mismatch.
- options.add("-classpath");
- options.add(classpathEntry.getAbsolutePath());
- options.add("-verbose");
-
- BatchTestUtils.compileOneClass(BatchTestUtils.getEclipseCompiler(), options, inputFile);
- }
-
- @Override
- protected void tearDown() throws Exception {
- BatchTestUtils.tearDown();
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchTestUtils.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchTestUtils.java
deleted file mode 100644
index 341b9df9d2..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchTestUtils.java
+++ /dev/null
@@ -1,482 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.ServiceLoader;
-
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.JavaCompiler.CompilationTask;
-
-import junit.framework.Assert;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * Helper class to support compilation and results checking for tests running in batch mode.
- * @since 3.3
- */
-public class BatchTestUtils {
- private static final String RESOURCES_DIR = "resources";
- // relative to plugin directory
- private static final String PROCESSOR_JAR_NAME = "lib/apttestprocessors.jar";
- private static String _processorJarPath;
-
- // locations to copy and generate files
- private static String _tmpFolder;
-
- private static JavaCompiler _eclipseCompiler;
-
- private static String _tmpSrcFolderName;
- private static File _tmpSrcDir;
- private static String _tmpBinFolderName;
- private static File _tmpBinDir;
- private static String _tmpGenFolderName;
- private static File _tmpGenDir;
-
- /**
- * Create a class that contains an annotation that generates another class,
- * and compile it. Verify that generation and compilation succeeded.
- */
- public static void compileOneClass(JavaCompiler compiler, List<String> options, File inputFile) {
- StandardJavaFileManager manager = compiler.getStandardFileManager(null, Locale.getDefault(), Charset.defaultCharset());
-
- // create new list containing inputfile
- List<File> files = new ArrayList<File>();
- files.add(inputFile);
- Iterable<? extends JavaFileObject> units = manager.getJavaFileObjectsFromFiles(files);
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
-
- options.add("-d");
- options.add(_tmpBinFolderName);
- options.add("-s");
- options.add(_tmpGenFolderName);
- options.add("-cp");
- options.add(_tmpSrcFolderName + File.pathSeparator + _tmpGenFolderName + File.pathSeparator + _processorJarPath);
- options.add("-processorpath");
- options.add(_processorJarPath);
- options.add("-XprintRounds");
- options.add("-XprintProcessorInfo");
- CompilationTask task = compiler.getTask(printWriter, manager, null, options, null, units);
- Boolean result = task.call();
-
- if (!result.booleanValue()) {
- String errorOutput = stringWriter.getBuffer().toString();
- System.err.println("Compilation failed: " + errorOutput);
- Assert.assertTrue("Compilation failed : " + errorOutput, false);
- }
- }
-
- public static void compileTree(JavaCompiler compiler, List<String> options, File targetFolder) {
- StandardJavaFileManager manager = compiler.getStandardFileManager(null, Locale.getDefault(), Charset.defaultCharset());
-
- // create new list containing inputfile
- List<File> files = new ArrayList<File>();
- findFilesUnder(targetFolder, files);
- Iterable<? extends JavaFileObject> units = manager.getJavaFileObjectsFromFiles(files);
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
-
- options.add("-d");
- options.add(_tmpBinFolderName);
- options.add("-s");
- options.add(_tmpGenFolderName);
- options.add("-cp");
- options.add(_tmpSrcFolderName + File.pathSeparator + _tmpGenFolderName + File.pathSeparator + _processorJarPath);
- options.add("-processorpath");
- options.add(_processorJarPath);
- options.add("-XprintRounds");
- CompilationTask task = compiler.getTask(printWriter, manager, null, options, null, units);
- Boolean result = task.call();
-
- if (!result.booleanValue()) {
- String errorOutput = stringWriter.getBuffer().toString();
- System.err.println("Compilation failed: " + errorOutput);
- Assert.assertTrue("Compilation failed : " + errorOutput, false);
- }
- }
-
- /**
- * Compile the contents of a directory tree, collecting errors so that they can be
- * compared with expected errors.
- * @param compiler the system compiler or Eclipse compiler
- * @param options will be passed to the compiler
- * @param targetFolder the folder to compile
- * @param errors a StringWriter into which compiler output will be written
- * @return true if the compilation was successful
- */
- public static boolean compileTreeWithErrors(JavaCompiler compiler, List<String> options, File targetFolder, StringWriter errors) {
- StandardJavaFileManager manager = compiler.getStandardFileManager(null, Locale.getDefault(), Charset.defaultCharset());
-
- // create new list containing inputfile
- List<File> files = new ArrayList<File>();
- findFilesUnder(targetFolder, files);
- Iterable<? extends JavaFileObject> units = manager.getJavaFileObjectsFromFiles(files);
- PrintWriter printWriter = new PrintWriter(errors);
-
- options.add("-d");
- options.add(_tmpBinFolderName);
- options.add("-s");
- options.add(_tmpGenFolderName);
- options.add("-cp");
- options.add(_tmpSrcFolderName + File.pathSeparator + _tmpGenFolderName + File.pathSeparator + _processorJarPath);
- options.add("-processorpath");
- options.add(_processorJarPath);
- CompilationTask task = compiler.getTask(printWriter, manager, null, options, null, units);
- Boolean result = task.call();
-
- return result.booleanValue();
- }
-
- /**
- * Recursively collect all the files under some root. Ignore directories named "CVS".
- * Used when compiling multiple source files.
- * @param files a List<File> to which all the files found will be added
- * @return the set of Files under a root folder.
- */
- public static void findFilesUnder(File rootFolder, List<File> files) {
- for (File child : rootFolder.listFiles()) {
- if ("CVS".equals(child.getName())) {
- continue;
- }
- if (child.isDirectory()) {
- findFilesUnder(child, files);
- }
- else {
- files.add(child);
- }
- }
- }
-
- /** @return the name of the folder where class files will be saved */
- public static String getBinFolderName() {
- return _tmpBinFolderName;
- }
-
- public static JavaCompiler getEclipseCompiler() {
- return _eclipseCompiler;
- }
-
- /** @return the name of the folder where generated files will be placed */
- public static String getGenFolderName() {
- return _tmpGenFolderName;
- }
-
- /** @return the name of the folder where source files will be found during compilation */
- public static String getSrcFolderName() {
- return _tmpSrcFolderName;
- }
-
- public static String getResourceFolderName() {
- return RESOURCES_DIR;
- }
-
- /**
- * Load Eclipse compiler and create temporary directories on disk
- */
- public static void init()
- {
- _tmpFolder = System.getProperty("java.io.tmpdir");
- if (_tmpFolder.endsWith(File.separator)) {
- _tmpFolder += "eclipse-temp";
- } else {
- _tmpFolder += (File.separator + "eclipse-temp");
- }
- _tmpBinFolderName = _tmpFolder + File.separator + "bin";
- _tmpBinDir = new File(_tmpBinFolderName);
- BatchTestUtils.deleteTree(_tmpBinDir); // remove existing contents
- _tmpBinDir.mkdirs();
- assert _tmpBinDir.exists() : "couldn't mkdirs " + _tmpBinFolderName;
-
- _tmpGenFolderName = _tmpFolder + File.separator + "gen-src";
- _tmpGenDir = new File(_tmpGenFolderName);
- BatchTestUtils.deleteTree(_tmpGenDir); // remove existing contents
- _tmpGenDir.mkdirs();
- assert _tmpGenDir.exists() : "couldn't mkdirs " + _tmpGenFolderName;
-
- _tmpSrcFolderName = _tmpFolder + File.separator + "src";
- _tmpSrcDir = new File(_tmpSrcFolderName);
- BatchTestUtils.deleteTree(_tmpSrcDir); // remove existing contents
- _tmpSrcDir.mkdirs();
- assert _tmpSrcDir.exists() : "couldn't mkdirs " + _tmpSrcFolderName;
-
- try {
- _processorJarPath = setupProcessorJar(PROCESSOR_JAR_NAME, _tmpFolder);
- } catch (IOException e) {
- e.printStackTrace();
- }
- Assert.assertNotNull("No processor jar path set", _processorJarPath);
- File processorJar = new File(_processorJarPath);
- Assert.assertTrue("Couldn't find processor jar at " + processorJar.getAbsolutePath(), processorJar.exists());
-
- ServiceLoader<JavaCompiler> javaCompilerLoader = ServiceLoader.load(JavaCompiler.class);//, EclipseCompiler.class.getClassLoader());
- Class<?> c = null;
- try {
- c = Class.forName("org.eclipse.jdt.internal.compiler.tool.EclipseCompiler");
- } catch (ClassNotFoundException e) {
- // ignore
- }
- if (c == null) {
- Assert.assertTrue("Eclipse compiler is not available", false);
- }
- int compilerCounter = 0;
- for (JavaCompiler javaCompiler : javaCompilerLoader) {
- compilerCounter++;
- if (c.isInstance(javaCompiler)) {
- _eclipseCompiler = javaCompiler;
- }
- }
- Assert.assertEquals("Only one compiler available", 1, compilerCounter);
- Assert.assertNotNull("No Eclipse compiler found", _eclipseCompiler);
- }
-
- public static void tearDown() {
- new File(_processorJarPath).deleteOnExit();
- BatchTestUtils.deleteTree(new File(_tmpFolder));
- }
- protected static String getPluginDirectoryPath() {
- try {
- URL platformURL = Platform.getBundle("org.eclipse.jdt.compiler.apt.tests").getEntry("/");
- return new File(FileLocator.toFileURL(platformURL).getFile()).getAbsolutePath();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return null;
- }
- public static byte[] read(java.io.File file) throws java.io.IOException {
- int fileLength;
- byte[] fileBytes = new byte[fileLength = (int) file.length()];
- java.io.FileInputStream stream = null;
- try {
- stream = new java.io.FileInputStream(file);
- int bytesRead = 0;
- int lastReadSize = 0;
- while ((lastReadSize != -1) && (bytesRead != fileLength)) {
- lastReadSize = stream.read(fileBytes, bytesRead, fileLength - bytesRead);
- bytesRead += lastReadSize;
- }
- } finally {
- if (stream != null) {
- stream.close();
- }
- }
- return fileBytes;
- }
-
- /**
- * @return true if this file's end-of-line delimiters should be replaced with
- * a platform-independent value, e.g. for compilation.
- */
- public static boolean shouldConvertToIndependentLineDelimiter(File file) {
- return file.getName().endsWith(".java");
- }
-
- /**
- * Copy a file from one location to another, unless the destination file already exists and has
- * the same timestamp and file size. Create the destination location if necessary. Convert line
- * delimiters according to {@link #shouldConvertToIndependentLineDelimiter(File)}.
- *
- * @param src
- * the full path to the resource location.
- * @param destFolder
- * the full path to the destination location.
- * @throws IOException
- */
- public static void copyResource(File src, File dest) throws IOException {
- if (dest.exists() &&
- src.lastModified() < dest.lastModified() &&
- src.length() == dest.length())
- {
- return;
- }
-
- // read source bytes
- byte[] srcBytes = null;
- srcBytes = read(src);
-
- if (shouldConvertToIndependentLineDelimiter(src)) {
- String contents = new String(srcBytes);
- contents = TestUtils.convertToIndependentLineDelimiter(contents);
- srcBytes = contents.getBytes();
- }
-
- File destFolder = dest.getParentFile();
- if (!destFolder.exists()) {
- if (!destFolder.mkdirs()) {
- throw new IOException("Unable to create directory " + destFolder);
- }
- }
- // write bytes to dest
- FileOutputStream out = null;
- try {
- out = new FileOutputStream(dest);
- out.write(srcBytes);
- out.flush();
- } finally {
- if (out != null) {
- out.close();
- }
- }
- }
-
- /**
- * Copy a resource that is located under the <code>resources</code> folder of the plugin to a
- * corresponding location under the specified target folder. Convert line delimiters according
- * to {@link #shouldConvertToIndependentLineDelimiter(File)}.
- *
- * @param resourcePath
- * the relative path under <code>[plugin-root]/resources</code> of the resource to
- * be copied
- * @param targetFolder
- * the absolute path of the folder under which the resource will be copied. Folder
- * and subfolders will be created if necessary.
- * @return a file representing the copied resource
- * @throws IOException
- */
- public static File copyResource(String resourcePath, File targetFolder) throws IOException {
- File resDir = new File(getPluginDirectoryPath(), RESOURCES_DIR);
- File resourceFile = new File(resDir, resourcePath);
- File targetFile = new File(targetFolder, resourcePath);
- copyResource(resourceFile, targetFile);
- return targetFile;
- }
-
- /**
- * Copy all the files under the directory specified by src to the directory
- * specified by dest. The src and dest directories must exist; child directories
- * under dest will be created as required. Existing files in dest will be
- * overwritten. Newlines will be converted according to
- * {@link #shouldConvertToIndependentLineDelimiter(File)}. Directories
- * named "CVS" will be ignored.
- * @param resourceFolderName the name of the source folder, relative to
- * <code>[plugin-root]/resources</code>
- * @param the absolute path of the destination folder
- * @throws IOException
- */
- public static void copyResources(String resourceFolderName, File destFolder) throws IOException {
- File resDir = new File(getPluginDirectoryPath(), RESOURCES_DIR);
- File resourceFolder = new File(resDir, resourceFolderName);
- copyResources(resourceFolder, destFolder);
- }
-
- private static void copyResources(File resourceFolder, File destFolder) throws IOException {
- if (resourceFolder == null) {
- return;
- }
- // Copy all resources in this folder
- String[] children = resourceFolder.list();
- if (null == children) {
- return;
- }
- // if there are any children, (recursively) copy them
- for (String child : children) {
- if ("CVS".equals(child)) {
- continue;
- }
- File childRes = new File(resourceFolder, child);
- File childDest = new File(destFolder, child);
- if (childRes.isDirectory()) {
- copyResources(childRes, childDest);
- }
- else {
- copyResource(childRes, childDest);
- }
- }
- }
-
- public static String setupProcessorJar(String processorJar, String tmpDir) throws IOException {
- File libDir = new File(getPluginDirectoryPath());
- File libFile = new File(libDir, processorJar);
- File destinationDir = new File(tmpDir);
- File destinationFile = new File(destinationDir, processorJar);
- copyResource(libFile, destinationFile);
- return destinationFile.getCanonicalPath();
- }
-
- /**
- * Recursively delete the contents of a directory, including any subdirectories.
- * This is not optimized to handle very large or deep directory trees efficiently.
- * @param f is either a normal file (which will be deleted) or a directory
- * (which will be emptied and then deleted).
- */
- public static void deleteTree(File f)
- {
- if (null == f) {
- return;
- }
- File[] children = f.listFiles();
- if (null != children) {
- // if f has any children, (recursively) delete them
- for (File child : children) {
- deleteTree(child);
- }
- }
- // At this point f is either a normal file or an empty directory
- f.delete();
- }
-
- /**
- * Check the contents of a file.
- * @return true if the contents of <code>genTextFile</code> exactly match <code>string</code>
- */
- public static boolean fileContentsEqualText(File genTextFile, String input) {
- long length = genTextFile.length();
- if (length != input.length()) {
- return false;
- }
- char[] contents = new char[512];
-
- Reader r = null;
- try {
- r = new BufferedReader(new FileReader(genTextFile));
- int ofs = 0;
- while (length > 0) {
- int read = r.read(contents);
- String match = input.substring(ofs, ofs + read);
- if (!match.contentEquals(new String(contents, 0, read))) {
- return false;
- }
- ofs += read;
- length -= read;
- }
- return true;
- } catch (IOException e) {
- e.printStackTrace();
- return false;
- } finally {
- if (r != null)
- try {
- r.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/FilerTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/FilerTests.java
deleted file mode 100644
index a854706bdc..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/FilerTests.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.tools.JavaCompiler;
-import javax.tools.ToolProvider;
-
-import junit.framework.TestCase;
-
-/**
- * Test the implementation of the Filer interface,
- * in more detail than BatchDispatchTests does.
- * @since 3.4
- */
-public class FilerTests extends TestCase {
-
- /**
- * Validate the testElement test against the javac compiler.
- * @throws IOException
- */
- public void testElementWithSystemCompiler() throws IOException {
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- internalTestCreateResource(compiler);
- }
-
- /**
- * Attempt to read various elements of the Element hierarchy.
- * @throws IOException
- */
- public void testElementWithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestCreateResource(compiler);
- }
-
- /**
- * Test the createResource() by processing resources/targets/filer/FilerTarget1.java
- * and verifying the existence and content of the resulting files.
- * @throws IOException
- */
- private void internalTestCreateResource(JavaCompiler compiler) throws IOException {
- File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "filer");
- File inputFile = BatchTestUtils.copyResource("targets/filer/FilerTarget1.java", targetFolder);
- assertNotNull("No input file", inputFile);
-
- List<String> options = new ArrayList<String>();
- BatchTestUtils.compileOneClass(compiler, options, inputFile);
-
- // check that the resource and class files were generated
- File genTextFile = TestUtils.concatPath(BatchTestUtils.getGenFolderName(), "resources", "txt", "text.txt");
- assertTrue("generated text file does not exist", genTextFile.exists());
-
- File genBinaryFile = TestUtils.concatPath(BatchTestUtils.getGenFolderName(), "resources", "dat", "binary.dat");
- assertTrue("generated binary file does not exist", genBinaryFile.exists());
-
- File classFile = TestUtils.concatPath(BatchTestUtils.getBinFolderName(), "targets", "filer", "FilerTarget1.class");
- assertTrue("ordinary src file was not compiled", classFile.exists());
-
- // See corresponding test data in FilerTarget1.java
- assertTrue(BatchTestUtils.fileContentsEqualText(genTextFile, "A generated string"));
- assertTrue(BatchTestUtils.fileContentsEqualText(genBinaryFile, new String(new byte[] {102, 110, 111, 114, 100})));
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- BatchTestUtils.init();
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/MessagerTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/MessagerTests.java
deleted file mode 100644
index fc3bf17a8a..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/MessagerTests.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.tools.JavaCompiler;
-import javax.tools.ToolProvider;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for the implementation of javax.annotation.processing.Messager
- * @since 3.3
- */
-public class MessagerTests extends TestCase {
- // See corresponding usages in the MessagerProc class
- private static final String MESSAGERPROCNAME = "org.eclipse.jdt.compiler.apt.tests.processors.messager.MessagerProc";
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- BatchTestUtils.init();
- }
-
- /**
- * Validate the testMessager test against the javac compiler.
- * @throws IOException
- */
- public void testMessagerWithSystemCompiler() throws IOException {
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- internalTestMessager(compiler);
- }
-
- /**
- * Attempt to report errors on various elements, using the Eclipse compiler.
- * @throws IOException
- */
- public void testMessagerWithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestMessager(compiler);
- }
-
- /**
- * Attempt to report errors on various elements.
- * @throws IOException
- */
- private void internalTestMessager(JavaCompiler compiler) throws IOException {
- System.clearProperty(MESSAGERPROCNAME);
- File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "errors");
- BatchTestUtils.copyResources("targets/errors", targetFolder);
-
- // Turn on the MessagerProc - without this, it will just return without doing anything
- List<String> options = new ArrayList<String>();
- options.add("-A" + MESSAGERPROCNAME);
-
- // Invoke processing by compiling the targets.model resources
- StringWriter errors = new StringWriter();
- boolean success = BatchTestUtils.compileTreeWithErrors(compiler, options, targetFolder, errors);
-
- assertTrue("errors should not be empty", errors.getBuffer().length() != 0);
- assertTrue("Compilation should have failed due to expected errors, but it didn't", !success);
-
- // If it succeeded, the processor will have set this property to "succeeded";
- // if not, it will set it to an error value.
- String property = System.getProperty(MESSAGERPROCNAME);
- assertNotNull("No property", property);
- assertEquals("succeeded", property);
-
- // TODO: check "errors" against expected values to ensure that the problems were correctly reported
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- System.clearProperty(MESSAGERPROCNAME);
- super.tearDown();
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/ModelTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/ModelTests.java
deleted file mode 100644
index 15372feeb1..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/ModelTests.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.tools.JavaCompiler;
-import javax.tools.ToolProvider;
-
-import junit.framework.TestCase;
-
-/**
- * Tests of the type system implementation
- * @since 3.3
- */
-public class ModelTests extends TestCase {
-
- // Processor class names; see corresponding usage in the processor classes.
- private static final String ELEMENTPROC = "org.eclipse.jdt.compiler.apt.tests.processors.elements.ElementProc";
- private static final String GENERICSPROC = "org.eclipse.jdt.compiler.apt.tests.processors.generics.GenericsProc";
- private static final String TYPEMIRRORPROC = "org.eclipse.jdt.compiler.apt.tests.processors.typemirror.TypeMirrorProc";
- private static final String VISITORPROC = "org.eclipse.jdt.compiler.apt.tests.processors.visitors.VisitorProc";
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- BatchTestUtils.init();
- }
-
- /**
- * Validate the testElement test against the javac compiler.
- * @throws IOException
- */
- public void testElementWithSystemCompiler() throws IOException {
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- internalTest(compiler, ELEMENTPROC);
- }
-
- /**
- * Attempt to read various elements of the Element hierarchy.
- * @throws IOException
- */
- public void testElementWithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTest(compiler, ELEMENTPROC);
- }
-
- /**
- * Validate the testTypeMirror test against the javac compiler.
- * @throws IOException
- */
- public void testTypeMirrorWithSystemCompiler() throws IOException {
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- internalTest(compiler, TYPEMIRRORPROC);
- }
-
- /**
- * Attempt to read various elements of the TypeMirror hierarchy.
- * @throws IOException
- */
- public void testTypeMirrorWithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTest(compiler, TYPEMIRRORPROC);
- }
-
- /**
- * Validate the generics test against the javac compiler.
- * @throws IOException
- */
- public void testGenericsWithSystemCompiler() throws IOException {
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- internalTest(compiler, GENERICSPROC);
- }
-
- /**
- * Test handling of generic types.
- * @throws IOException
- */
- public void testGenericsWithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTest(compiler, GENERICSPROC);
- }
-
- /**
- * Validate the visitors test against the javac compiler.
- * @throws IOException
- */
- public void testVisitorsWithSystemCompiler() throws IOException {
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- internalTest(compiler, VISITORPROC);
- }
-
- /**
- * Test the Visitor method implementations.
- * @throws IOException
- */
- public void testVisitorsWithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTest(compiler, VISITORPROC);
- }
-
- /**
- * Test functionality by running a particular processor against the types in
- * resources/targets. The processor must support "*" (the set of all annotations)
- * and must report its errors or success via the methods in BaseProcessor.
- * @throws IOException
- */
- private void internalTest(JavaCompiler compiler, String processorClass) throws IOException {
- System.clearProperty(processorClass);
- File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "model");
- BatchTestUtils.copyResources("targets/model", targetFolder);
-
- List<String> options = new ArrayList<String>();
- options.add("-A" + processorClass);
- BatchTestUtils.compileTree(compiler, options, targetFolder);
-
- // If it succeeded, the processor will have set this property to "succeeded";
- // if not, it will set it to an error value.
- assertEquals("succeeded", System.getProperty(processorClass));
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/ModelUtilTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/ModelUtilTests.java
deleted file mode 100644
index 20fa557f4e..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/ModelUtilTests.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.tools.JavaCompiler;
-import javax.tools.ToolProvider;
-
-import junit.framework.TestCase;
-
-/**
- *
- */
-public class ModelUtilTests extends TestCase
-{
- // Processor class names; see corresponding usage in the processor classes.
- private static final String ELEMENTUTILSPROC = "org.eclipse.jdt.compiler.apt.tests.processors.elementutils.ElementUtilsProc";
- private static final String TYPEUTILSPROC = "org.eclipse.jdt.compiler.apt.tests.processors.typeutils.TypeUtilsProc";
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- BatchTestUtils.init();
- }
-
- /**
- * Validate the testElements test against the javac compiler.
- * @throws IOException
- */
- public void testElementsWithSystemCompiler() throws IOException {
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- internalTest(compiler, ELEMENTUTILSPROC);
- }
-
- /**
- * Test the Elements utility implementation.
- * @throws IOException
- */
- public void testElementsWithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTest(compiler, ELEMENTUTILSPROC);
- }
-
- /**
- * Validate the testTypes test against the javac compiler.
- * @throws IOException
- */
- public void testTypesWithSystemCompiler() throws IOException {
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- internalTest(compiler, TYPEUTILSPROC);
- }
-
- /**
- * Test the Types utility implementation.
- * @throws IOException
- */
- public void testTypesWithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTest(compiler, TYPEUTILSPROC);
- }
-
- /**
- * Test functionality by running a particular processor against the types in
- * resources/targets. The processor must support "*" (the set of all annotations)
- * and must report its errors or success via the methods in BaseProcessor.
- * @throws IOException
- */
- private void internalTest(JavaCompiler compiler, String processorClass) throws IOException {
- System.clearProperty(processorClass);
- File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "model");
- BatchTestUtils.copyResources("targets/model", targetFolder);
-
- List<String> options = new ArrayList<String>();
- options.add("-A" + processorClass);
- BatchTestUtils.compileTree(compiler, options, targetFolder);
-
- // If it succeeded, the processor will have set this property to "succeeded";
- // if not, it will set it to an error value.
- assertEquals("succeeded", System.getProperty(processorClass));
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/NegativeTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/NegativeTests.java
deleted file mode 100644
index 991b4e3c0f..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/NegativeTests.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.compiler.apt.tests;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import javax.tools.JavaCompiler;
-import javax.tools.ToolProvider;
-
-import junit.framework.TestCase;
-
-/**
- * Test cases for annotation processing behavior when code contains semantic errors
- */
-public class NegativeTests extends TestCase
-{
- // See corresponding usages in the NegativeModelProc class
- private static final String NEGATIVEMODELPROCNAME = "org.eclipse.jdt.compiler.apt.tests.processors.negative.NegativeModelProc";
- private static final String IGNOREJAVACBUGS = "ignoreJavacBugs";
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- BatchTestUtils.init();
- }
-
- /**
- * Validate the testNegativeModel test against the javac compiler.
- * All test routines are executed.
- * @throws IOException
- */
- public void testNegativeModelWithSystemCompiler() throws IOException {
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
-
- internalTestNegativeModel(compiler, 0, Collections.singletonList("-A" + IGNOREJAVACBUGS));
- }
-
- /**
- * Inspect model of resources/targets.negative.pa.Negative1,
- * using the Eclipse compiler.
- * @throws IOException
- */
- public void testNegativeModel1WithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestNegativeModel(compiler, 1, null);
- }
-
- /**
- * Inspect model of resources/targets.negative.pa.Negative2,
- * using the Eclipse compiler.
- * @throws IOException
- */
- public void testNegativeModel2WithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestNegativeModel(compiler, 2, null);
- }
-
- /**
- * Inspect model of resources/targets.negative.pa.Negative3,
- * using the Eclipse compiler.
- * @throws IOException
- */
- public void testNegativeModel3WithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestNegativeModel(compiler, 3, null);
- }
-
- /**
- * Inspect model of resources/targets.negative.pa.Negative4,
- * using the Eclipse compiler.
- * @throws IOException
- */
- public void testNegativeModel4WithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestNegativeModel(compiler, 4, null);
- }
-
- /**
- * Inspect model of resources/targets.negative.pa.Negative5,
- * using the Eclipse compiler.
- * @throws IOException
- */
- public void testNegativeModel5WithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestNegativeModel(compiler, 5, null);
- }
-
- /**
- * Inspect model of resources/targets.negative.pa.Negative6,
- * using the Eclipse compiler.
- * @throws IOException
- */
- public void testNegativeModel6WithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestNegativeModel(compiler, 6, null);
- }
-
- /**
- * Inspect model of resources/targets.negative.pa.Negative7,
- * using the Eclipse compiler.
- * @throws IOException
- */
- public void testNegativeModel7WithEclipseCompiler() throws IOException {
- JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestNegativeModel(compiler, 7, null);
- }
-
- /**
- * Attempt to report errors on various elements.
- * @throws IOException
- */
- private void internalTestNegativeModel(JavaCompiler compiler, int test, Collection<String> extraOptions) throws IOException {
- System.clearProperty(NEGATIVEMODELPROCNAME);
- File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "negative");
- BatchTestUtils.copyResources("targets/negative", targetFolder);
-
- // Turn on the NegativeModelProc - without this, it will just return without doing anything
- List<String> options = new ArrayList<String>();
- options.add("-A" + NEGATIVEMODELPROCNAME + "=" + test);
- if (null != extraOptions)
- options.addAll(extraOptions);
-
- // Invoke processing by compiling the targets.model resources
- StringWriter errors = new StringWriter();
- boolean success = BatchTestUtils.compileTreeWithErrors(compiler, options, targetFolder, errors);
-
- assertTrue("errors should not be empty", errors.getBuffer().length() != 0);
- assertTrue("Compilation should have failed due to expected errors, but it didn't", !success);
-
- // If it succeeded, the processor will have set this property to "succeeded";
- // if not, it will set it to an error value.
- String property = System.getProperty(NEGATIVEMODELPROCNAME);
- assertNotNull("No property - probably processing did not take place", property);
- assertEquals("succeeded", property);
-
- // TODO: check "errors" against expected values to ensure that the problems were correctly reported
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- System.clearProperty(NEGATIVEMODELPROCNAME);
- super.tearDown();
- }
-
-
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/TestUtils.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/TestUtils.java
deleted file mode 100644
index fe754731d2..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/TestUtils.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.compiler.apt.tests;
-
-import java.io.File;
-
-/**
- * @since 3.3
- */
-public class TestUtils {
-
- /**
- * Convert an array of strings into a path.
- * E.g., turn { "a", "b", "c.d" } into a File representing "a/b/c.d".
- */
- public static File concatPath(String... names) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < names.length; ++i) {
- if (i > 0) {
- sb.append(File.separator);
- }
- sb.append(names[i]);
- }
- return new File(sb.toString());
- }
-
- public static String convertToIndependentLineDelimiter(String source) {
- if (source.indexOf('\n') == -1 && source.indexOf('\r') == -1) return source;
- StringBuffer buffer = new StringBuffer();
- for (int i = 0, length = source.length(); i < length; i++) {
- char car = source.charAt(i);
- if (car == '\r') {
- buffer.append('\n');
- if (i < length-1 && source.charAt(i+1) == '\n') {
- i++; // skip \n after \r
- }
- } else {
- buffer.append(car);
- }
- }
- return buffer.toString();
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt.tests/test.xml b/org.eclipse.jdt.compiler.apt.tests/test.xml
deleted file mode 100644
index 640eb8b700..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/test.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0"?>
-
-<project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <property name="eclipse-home" value="${basedir}\..\.." />
-
- <!-- sets the properties eclipse-home, and library-file -->
- <property name="plugin-name" value="org.eclipse.jdt.compiler.apt.tests" />
- <property name="library-file" value="${eclipse-home}/plugins/org.eclipse.test/library.xml" />
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp />
- <delete>
- <fileset dir="${eclipse-home}" includes="org*.xml" />
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <property name="jdt-compiler-apt-folder" value="${eclipse-home}/jdt_compiler_apt_folder" />
- <delete dir="${jdt-compiler-apt-folder}" quiet="true" />
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${jdt-compiler-apt-folder}/data" />
- <property name="plugin-name" value="${plugin-name}" />
- <property name="classname" value="org.eclipse.jdt.compiler.apt.tests.AllTests" />
- </ant>
- </target>
-
- <!-- This target holds code to cleanup the testing environment after -->
- <!-- after all of the tests have been run. You can use this target to -->
- <!-- delete temporary files that have been created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen -->
- <!-- after all the tests have been run should go here. -->
- <target name="run" depends="init,suite,cleanup">
- <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
- <property name="includes" value="org*.xml" />
- <property name="output-file" value="${plugin-name}.xml" />
- </ant>
- </target>
-
- <!-- This target runs the performance test suites. -->
- <target name="performance">
- </target>
-
-</project>
diff --git a/org.eclipse.jdt.compiler.apt.tests/things-to-test.txt b/org.eclipse.jdt.compiler.apt.tests/things-to-test.txt
deleted file mode 100644
index b15df2ca1d..0000000000
--- a/org.eclipse.jdt.compiler.apt.tests/things-to-test.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-Inherited annotations
-Processors that support "*"
-Package annotations
-Annotations on nested types
-Processor discovery on classpath, procpath, and explicit
-Code snippet and variable evaluation; Quick Outline (should NOT generate new types?)
-FilerException thrown when processor tries to create same file twice. See javadoc for Filer.
-Annotations on every possible element (fields, parameters, member classes, methods...)
-Originating elements of every possible type (including package and things that can't be annotated)
-Static and instance initializers (e.g., ElementKind.getKind())
-Get package (ie enclosing element) of binary type, or other potentially-unresolved type
-Default (unnamed) packages
-Visitors \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt/.classpath b/org.eclipse.jdt.compiler.apt/.classpath
deleted file mode 100644
index 121e527a93..0000000000
--- a/org.eclipse.jdt.compiler.apt/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jdt.compiler.apt/.project b/org.eclipse.jdt.compiler.apt/.project
deleted file mode 100644
index 5c975648fd..0000000000
--- a/org.eclipse.jdt.compiler.apt/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.compiler.apt</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.compiler.apt/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jdt.compiler.apt/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index b9cbb628ce..0000000000
--- a/org.eclipse.jdt.compiler.apt/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,62 +0,0 @@
-#Fri Feb 16 14:58:08 EST 2007
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-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.discouragedReference=ignore
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
-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.forbiddenReference=ignore
-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=warning
-org.eclipse.jdt.core.compiler.problem.nullReference=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-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.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-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=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.eclipse.jdt.compiler.apt/META-INF/MANIFEST.MF b/org.eclipse.jdt.compiler.apt/META-INF/MANIFEST.MF
deleted file mode 100644
index e7dda6a5d1..0000000000
--- a/org.eclipse.jdt.compiler.apt/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,13 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %fragmentName
-Bundle-SymbolicName: org.eclipse.jdt.compiler.apt
-Bundle-Version: 1.0.100.qualifier
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Bundle-Vendor: %providerName
-Fragment-Host: org.eclipse.jdt.core;bundle-version="[3.3.0,4.0.0)"
-Bundle-Localization: compiler_apt_fragment
-Export-Package: org.eclipse.jdt.internal.compiler.apt.dispatch;x-friends:="org.eclipse.jdt.apt.pluggable.core",
- org.eclipse.jdt.internal.compiler.apt.model;x-friends:="org.eclipse.jdt.apt.pluggable.core",
- org.eclipse.jdt.internal.compiler.apt.util;x-friends:="org.eclipse.jdt.apt.pluggable.core"
-Import-Package: org.eclipse.jdt.internal.compiler.tool;resolution:=optional
diff --git a/org.eclipse.jdt.compiler.apt/about.html b/org.eclipse.jdt.compiler.apt/about.html
deleted file mode 100644
index 460233046e..0000000000
--- a/org.eclipse.jdt.compiler.apt/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 2, 2006</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt/build.properties b/org.eclipse.jdt.compiler.apt/build.properties
deleted file mode 100644
index c0fba21c9b..0000000000
--- a/org.eclipse.jdt.compiler.apt/build.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2007 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-customBuildCallbacks=customBuildCallbacks.xml
-bin.includes = .,\
- META-INF/,\
- about.html,\
- compiler_apt_fragment.properties
-
-src.includes = about.html
-
-jars.compile.order = .
-output.. = bin/
-source.. = src/
-
diff --git a/org.eclipse.jdt.compiler.apt/compiler_apt_fragment.properties b/org.eclipse.jdt.compiler.apt/compiler_apt_fragment.properties
deleted file mode 100644
index 611704261b..0000000000
--- a/org.eclipse.jdt.compiler.apt/compiler_apt_fragment.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2007 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-providerName=Eclipse.org
-fragmentName=Java Compiler Apt
diff --git a/org.eclipse.jdt.compiler.apt/customBuildCallbacks.xml b/org.eclipse.jdt.compiler.apt/customBuildCallbacks.xml
deleted file mode 100644
index 7f5509c02e..0000000000
--- a/org.eclipse.jdt.compiler.apt/customBuildCallbacks.xml
+++ /dev/null
@@ -1,200 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- ===================================================================== -->
-<!-- Custom targets called from a project's generated build.xml -->
-<!-- Set customBuildCallbacks=<path/to/this/file> in your build.properties.-->
-<!-- ===================================================================== -->
-<project name="Build specific targets and properties" default="noDefault">
-
- <!-- ===================================================================== -->
- <!-- Default target -->
- <!-- ===================================================================== -->
- <target name="noDefault">
- <echo message="This file must be called with explicit targets" />
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do before the target build.jars -->
- <!-- Available parameters : -->
- <!-- build.result.folder - folder to contain the build results -->
- <!-- ===================================================================== -->
- <target name="pre.build.jars">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do after the target build.jars -->
- <!-- Available parameters : -->
- <!-- build.result.folder - folder to contain the build results -->
- <!-- ===================================================================== -->
- <target name="post.build.jars">
- <property name="buildLabel" value="global" />
- <property name="postingDirectory" value="${basedir}/../org.eclipse.jdt.core/ecj" />
- <property name="dest" value="${postingDirectory}/${buildLabel}" />
- <mkdir dir="${dest}/checksum" />
- <checksum file="${dest}/ecj-${buildLabel}.jar" property="md5-ecj.jar" />
- <echo message="${md5-ecj.jar} ecj-${buildLabel}.jar" file="${dest}/checksum/ecj-${buildLabel}.jar.md5" />
- <checksum file="${dest}/ecjsrc-${buildLabel}.zip" property="md5-ecjsrc.zip" />
- <echo message="${md5-ecjsrc.zip} ecjsrc-${buildLabel}.zip" file="${dest}/checksum/ecjsrc-${buildLabel}.zip.md5" />
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do before the target build.sources -->
- <!-- Available parameters : -->
- <!-- build.result.folder - folder to contain the build results -->
- <!-- ===================================================================== -->
- <target name="pre.build.sources">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do after the target build.sources -->
- <!-- Available parameters : -->
- <!-- build.result.folder - folder to contain the build results -->
- <!-- ===================================================================== -->
- <target name="post.build.sources">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do before the compilation target <name> -->
- <!-- Substitute "name" with the name of the compilation target, eg @dot -->
- <!-- Available parameters : -->
- <!-- source.foldern : n = 1 ... N, the source folders -->
- <!-- target.folder : where the results of the compilation go -->
- <!-- <name>.classpath : name = name of the compilation target. A -->
- <!-- reference to the classpath structure. -->
- <!-- ===================================================================== -->
- <target name="pre.name">
- </target>
-
- <target name="pre.@dot">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do during the compilation target <name>, after the compile -->
- <!-- but before jaring. Substitute "name" with the name of the compilation-->
- <!-- target, eg @dot -->
- <!-- Available parameters : -->
- <!-- source.foldern : n = 1 ... N, the source folders -->
- <!-- target.folder : where the results of the compilation go -->
- <!-- <name>.classpath : name = name of the compilation target. A -->
- <!-- reference to the classpath structure. -->
- <!-- ===================================================================== -->
- <target name="post.compile.name">
- </target>
-
- <target name="post.compile.@dot">
- <property name="buildLabel" value="global" />
- <property name="postingDirectory" value="${basedir}/../org.eclipse.jdt.core/ecj" />
- <echo message="UPDATE ecj-${buildLabel}.jar" />
- <property name="unjarDestBin" value="${basedir}/tempbin"/>
- <mkdir dir="${unjarDestBin}"/>
- <unjar
- src="${postingDirectory}/${buildLabel}/ecj-${buildLabel}.jar"
- dest="${unjarDestBin}"/>
- <zip destfile="${postingDirectory}/${buildLabel}/ecj-${buildLabel}.jar">
- <fileset dir="${unjarDestBin}"/>
- <fileset dir="${target.folder}">
- <include name="**/*"/>
- </fileset>
- <fileset dir="${basedir}">
- <include name="META-INF/services/**" />
- </fileset>
- </zip>
- <delete dir="${unjarDestBin}" failonerror="false"/>
-
- <echo message="UPDATE ecjsrc-${buildLabel}.zip" />
- <property name="unjarDestSrc" value="${basedir}/tempsrc"/>
- <mkdir dir="${unjarDestSrc}"/>
- <unzip
- src="${postingDirectory}/${buildLabel}/ecjsrc-${buildLabel}.zip"
- dest="${unjarDestSrc}"/>
- <zip destfile="${postingDirectory}/${buildLabel}/ecjsrc-${buildLabel}.zip">
- <zipfileset dir="src" />
- <zipfileset dir="${unjarDestSrc}"/>
- <zipfileset dir="${basedir}">
- <include name="META-INF/services/**" />
- </zipfileset>
- </zip>
- <delete dir="${unjarDestSrc}" failonerror="false"/>
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do after the compilation target <name> -->
- <!-- Substitute "name" with the name of the compilation target, eg @dot -->
- <!-- Available parameters : -->
- <!-- jar.location - the location of the compilation results -->
- <!-- <name>.classpath : name = name of the compilation target. A -->
- <!-- reference to the classpath structure. -->
- <!-- ===================================================================== -->
- <target name="post.name">
- </target>
-
- <target name="post.@dot">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do before the target gather.bin.parts -->
- <!-- Available parameters : -->
- <!-- build.result.folder - folder containing the build results -->
- <!-- target.folder - destination folder -->
- <!-- ===================================================================== -->
- <target name="pre.gather.bin.parts">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do after the target gather.bin.parts -->
- <!-- Available parameters : -->
- <!-- build.result.folder - folder containing the build results -->
- <!-- target.folder - destination folder -->
- <!-- ===================================================================== -->
- <target name="post.gather.bin.parts">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do before the target gather.sources -->
- <!-- Available parameters : -->
- <!-- destination.temp.folder - destination folder -->
- <!-- ===================================================================== -->
- <target name="pre.gather.sources">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do after the target gather.sources -->
- <!-- Available parameters : -->
- <!-- destination.temp.folder - destination folder -->
- <!-- ===================================================================== -->
- <target name="post.gather.sources">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do before the target gather.logs -->
- <!-- Available parameters : -->
- <!-- destination.temp.folder - destination folder -->
- <!-- ===================================================================== -->
- <target name="pre.gather.logs">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do after the target gather.logs -->
- <!-- Available parameters : -->
- <!-- destination.temp.folder - destination folder -->
- <!-- ===================================================================== -->
- <target name="post.gather.logs">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do before the target clean -->
- <!-- Available parameters : -->
- <!-- destination.temp.folder - destination folder -->
- <!-- ===================================================================== -->
- <target name="pre.clean">
- </target>
-
- <!-- ===================================================================== -->
- <!-- Steps to do after the target clean -->
- <!-- Available parameters : -->
- <!-- plugin.destination - final destination of the build -->
- <!-- build.result.folder - results of the compilation -->
- <!-- temp.folder - temporary folder -->
- <!-- ===================================================================== -->
- <target name="post.clean">
- </target>
-</project> \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/AnnotationDiscoveryVisitor.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/AnnotationDiscoveryVisitor.java
deleted file mode 100644
index fd425e4e3e..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/AnnotationDiscoveryVisitor.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.dispatch;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-
-import org.eclipse.jdt.internal.compiler.ASTVisitor;
-import org.eclipse.jdt.internal.compiler.apt.model.Factory;
-import org.eclipse.jdt.internal.compiler.apt.util.ManyToMany;
-import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
-import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
-
-/**
- * This class is used to visit the JDT compiler internal AST to discover annotations,
- * in the course of dispatching to annotation processors.
- */
-public class AnnotationDiscoveryVisitor extends ASTVisitor {
- final BaseProcessingEnvImpl _env;
- final Factory _factory;
- /**
- * Collects a many-to-many map of annotation types to
- * the elements they appear on.
- */
- final ManyToMany<TypeElement, Element> _annoToElement;
-
- public AnnotationDiscoveryVisitor(BaseProcessingEnvImpl env) {
- _env = env;
- _factory = env.getFactory();
- _annoToElement = new ManyToMany<TypeElement, Element>();
- }
-
- @Override
- public boolean visit(Argument argument, BlockScope scope) {
- Annotation[] annotations = argument.annotations;
- if (annotations != null) {
- TypeDeclaration typeDeclaration = scope.referenceType();
- typeDeclaration.binding.resolveTypesFor(((AbstractMethodDeclaration) scope.referenceContext()).binding);
- this.resolveAnnotations(
- scope,
- annotations,
- argument.binding);
- }
- return false;
- }
-
- @Override
- public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
- Annotation[] annotations = constructorDeclaration.annotations;
- if (annotations != null) {
- this.resolveAnnotations(
- constructorDeclaration.scope,
- annotations,
- constructorDeclaration.binding);
- }
- Argument[] arguments = constructorDeclaration.arguments;
- if (arguments != null) {
- int argumentLength = arguments.length;
- for (int i = 0; i < argumentLength; i++) {
- arguments[i].traverse(this, constructorDeclaration.scope);
- }
- }
- return false;
- }
-
- @Override
- public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
- Annotation[] annotations = fieldDeclaration.annotations;
- if (annotations != null) {
- this.resolveAnnotations(scope, annotations, fieldDeclaration.binding);
- }
- return false;
- }
-
- @Override
- public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
- Annotation[] annotations = methodDeclaration.annotations;
- if (annotations != null) {
- this.resolveAnnotations(
- methodDeclaration.scope,
- annotations,
- methodDeclaration.binding);
- }
-
- Argument[] arguments = methodDeclaration.arguments;
- if (arguments != null) {
- int argumentLength = arguments.length;
- for (int i = 0; i < argumentLength; i++) {
- arguments[i].traverse(this, methodDeclaration.scope);
- }
- }
- return false;
- }
-
- @Override
- public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope) {
- Annotation[] annotations = memberTypeDeclaration.annotations;
- if (annotations != null) {
- this.resolveAnnotations(
- memberTypeDeclaration.staticInitializerScope,
- annotations,
- memberTypeDeclaration.binding);
- }
- return true;
- }
-
- @Override
- public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
- Annotation[] annotations = typeDeclaration.annotations;
- if (annotations != null) {
- this.resolveAnnotations(
- typeDeclaration.staticInitializerScope,
- annotations,
- typeDeclaration.binding);
- }
- return true;
- }
-
- private void resolveAnnotations(
- BlockScope scope,
- Annotation[] annotations,
- Binding currentBinding) {
- ASTNode.resolveAnnotations(scope, annotations, currentBinding);
-
- for (Annotation annotation : annotations) {
- AnnotationBinding binding = annotation.getCompilerAnnotation();
- if (binding != null) { // binding should be resolved, but in case it's not, ignore it
- TypeElement anno = (TypeElement)_factory.newElement(binding.getAnnotationType());
- Element element = _factory.newElement(currentBinding);
- _annoToElement.put(anno, element);
- }
- }
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/AptProblem.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/AptProblem.java
deleted file mode 100644
index 51c52b4855..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/AptProblem.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.dispatch;
-
-import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
-
-public class AptProblem extends DefaultProblem {
-
- // The batch compiler does not depend on org.eclipse.jdt.apt.pluggable.core; this
- // is just an arbitrary string to it, namespace notwithstanding. However, the IDE
- // cares about the fact that this string is registered as a marker ID by the
- // org.eclipse.jdt.apt.pluggable.core plug-in.
- private static final String MARKER_ID = "org.eclipse.jdt.apt.pluggable.core.compileProblem"; //$NON-NLS-1$
-
- /** May be null, if it was not possible to identify problem context */
- public final ReferenceContext _referenceContext;
-
- public AptProblem(
- ReferenceContext referenceContext,
- char[] originatingFileName,
- String message,
- int id,
- String[] stringArguments,
- int severity,
- int startPosition,
- int endPosition,
- int line,
- int column)
- {
- super(originatingFileName,
- message,
- id,
- stringArguments,
- severity,
- startPosition,
- endPosition,
- line,
- column);
- _referenceContext = referenceContext;
- }
-
- @Override
- public int getCategoryID() {
- return CAT_UNSPECIFIED;
- }
-
- @Override
- public String getMarkerType() {
- return MARKER_ID;
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseAnnotationProcessorManager.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseAnnotationProcessorManager.java
deleted file mode 100644
index 658a99a5a9..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseAnnotationProcessorManager.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.compiler.apt.dispatch;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jdt.internal.compiler.AbstractAnnotationProcessorManager;
-import org.eclipse.jdt.internal.compiler.Compiler;
-import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-
-/**
- * This class is the central dispatch point for Java 6 annotation processing.
- * This is created and configured by the JDT core; specifics depend on how
- * compilation is being performed, ie from the command line, via the Tool
- * interface, or within the IDE. This class manages the discovery of annotation
- * processors and other information spanning multiple rounds of processing;
- * context that is valid only within a single round is managed by
- * {@link RoundDispatcher}. There may be multiple instances of this class;
- * there is in general one of these for every Compiler that has annotation
- * processing enabled. Within the IDE there will typically be one for every
- * Java project, because each project potentially has a separate processor path.
- *
- * TODO: do something useful with _supportedOptions and _supportedAnnotationTypes.
- */
-public abstract class BaseAnnotationProcessorManager extends AbstractAnnotationProcessorManager
- implements IProcessorProvider
-{
-
- protected PrintWriter _out;
- protected PrintWriter _err;
- protected BaseProcessingEnvImpl _processingEnv;
- protected boolean _isFirstRound = true;
-
- /**
- * The list of processors that have been loaded so far. A processor on this
- * list has been initialized, but may not yet have been called to process().
- */
- protected List<ProcessorInfo> _processors = new ArrayList<ProcessorInfo>();
-
- // Tracing
- protected boolean _printProcessorInfo = false;
- protected boolean _printRounds = false;
- protected int _round;
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.compiler.AbstractAnnotationProcessorManager#configure(org.eclipse.jdt.internal.compiler.batch.Main, java.lang.String[])
- */
- @Override
- public void configure(Object batchCompiler, String[] options) {
- // Implemented by BatchAnnotationProcessorManager.
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.compiler.AbstractAnnotationProcessorManager#configureFromPlatform(org.eclipse.jdt.internal.compiler.Compiler, java.lang.Object)
- */
- @Override
- public void configureFromPlatform(Compiler compiler, Object compilationUnitLocator, Object javaProject) {
- // Implemented by IdeAnnotationProcessorManager.
- throw new UnsupportedOperationException();
- }
-
- @Override
- public List<ProcessorInfo> getDiscoveredProcessors() {
- return _processors;
- }
-
- @Override
- public ICompilationUnit[] getDeletedUnits() {
- return _processingEnv.getDeletedUnits();
- }
-
- @Override
- public ICompilationUnit[] getNewUnits() {
- return _processingEnv.getNewUnits();
- }
-
- @Override
- public ReferenceBinding[] getNewClassFiles() {
- return _processingEnv.getNewClassFiles();
- }
-
- @Override
- public void reset() {
- _processingEnv.reset();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.compiler.AbstractAnnotationProcessorManager#setErr(java.io.PrintWriter)
- */
- @Override
- public void setErr(PrintWriter err) {
- _err = err;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.compiler.AbstractAnnotationProcessorManager#setOut(java.io.PrintWriter)
- */
- @Override
- public void setOut(PrintWriter out) {
- _out = out;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.compiler.AbstractAnnotationProcessorManager#setProcessors(java.lang.Object[])
- */
- @Override
- public void setProcessors(Object[] processors) {
- // Only meaningful in batch mode.
- throw new UnsupportedOperationException();
- }
-
- /**
- * A single "round" of processing, in the sense implied in
- * {@link javax.lang.annotation.processing.Processor}.
- * <p>
- * The Java 6 Processor spec contains ambiguities about how processors that support "*" are
- * handled. Eclipse tries to match Sun's implementation in javac. What that actually does is
- * analogous to inspecting the set of annotions found in the root units and adding an
- * "imaginary" annotation if the set is empty. Processors are then called in order of discovery;
- * for each processor, the intersection between the set of root annotations and the set of
- * annotations the processor supports is calculated, and if it is non-empty, the processor is
- * called. If the processor returns <code>true</code> then the intersection (including the
- * imaginary annotation if one exists) is removed from the set of root annotations and the loop
- * continues, until the set is empty. Of course, the imaginary annotation is not actually
- * included in the set of annotations passed in to the processor. A processor's process() method
- * is not called until its intersection set is non-empty, but thereafter it is called on every
- * round. Note that even if a processor is not called in the first round, if it is called in
- * subsequent rounds, it will be called in the order in which the processors were discovered,
- * rather than being added to the end of the list.
- */
- @Override
- public void processAnnotations(CompilationUnitDeclaration[] units, ReferenceBinding[] referenceBindings, boolean isLastRound) {
- RoundEnvImpl roundEnv = new RoundEnvImpl(units, referenceBindings, isLastRound, _processingEnv);
- if (_isFirstRound) {
- _isFirstRound = false;
- }
- PrintWriter traceProcessorInfo = _printProcessorInfo ? _out : null;
- PrintWriter traceRounds = _printRounds ? _out : null;
- if (traceRounds != null) {
- traceRounds.println("Round " + ++_round + ':'); //$NON-NLS-1$
- }
- RoundDispatcher dispatcher = new RoundDispatcher(
- this, roundEnv, roundEnv.getRootAnnotations(), traceProcessorInfo, traceRounds);
- dispatcher.round();
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseMessagerImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseMessagerImpl.java
deleted file mode 100644
index 55eb0b258e..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseMessagerImpl.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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 - derived base class from BatchMessagerImpl
- *
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.dispatch;
-
-import javax.lang.model.element.Element;
-import javax.tools.Diagnostic.Kind;
-
-import org.eclipse.jdt.internal.compiler.CompilationResult;
-import org.eclipse.jdt.internal.compiler.apt.model.ExecutableElementImpl;
-import org.eclipse.jdt.internal.compiler.apt.model.TypeElementImpl;
-import org.eclipse.jdt.internal.compiler.apt.model.VariableElementImpl;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
-import org.eclipse.jdt.internal.compiler.util.Util;
-
-public class BaseMessagerImpl {
-
- static final String[] NO_ARGUMENTS = new String[0];
-
- /**
- * Create a CategorizedProblem that can be reported to an ICompilerRequestor, etc.
- *
- * @param e the element against which to report the message. If the element is not
- * in the set of elements being compiled in the current round, the reference context
- * and filename will be set to null.
- * @return
- */
- public static AptProblem createProblem(Kind kind, CharSequence msg, Element e) {
- ReferenceContext referenceContext = null;
- int startPosition = 0;
- int endPosition = 0;
- if (e != null) {
- switch(e.getKind()) {
- case ANNOTATION_TYPE :
- case INTERFACE :
- case CLASS :
- case ENUM :
- TypeElementImpl typeElementImpl = (TypeElementImpl) e;
- Binding typeBinding = typeElementImpl._binding;
- if (typeBinding instanceof SourceTypeBinding) {
- SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) typeBinding;
- TypeDeclaration typeDeclaration = (TypeDeclaration) sourceTypeBinding.scope.referenceContext();
- referenceContext = typeDeclaration;
- startPosition = typeDeclaration.sourceStart;
- endPosition = typeDeclaration.sourceEnd;
- }
- break;
- case PACKAGE :
- // nothing to do: there is no reference context for a package
- break;
- case CONSTRUCTOR :
- case METHOD :
- ExecutableElementImpl executableElementImpl = (ExecutableElementImpl) e;
- Binding binding = executableElementImpl._binding;
- if (binding instanceof MethodBinding) {
- MethodBinding methodBinding = (MethodBinding) binding;
- AbstractMethodDeclaration sourceMethod = methodBinding.sourceMethod();
- if (sourceMethod != null) {
- referenceContext = sourceMethod;
- startPosition = sourceMethod.sourceStart;
- endPosition = sourceMethod.sourceEnd;
- }
- }
- break;
- case ENUM_CONSTANT :
- break;
- case EXCEPTION_PARAMETER :
- break;
- case FIELD :
- VariableElementImpl variableElementImpl = (VariableElementImpl) e;
- binding = variableElementImpl._binding;
- if (binding instanceof FieldBinding) {
- FieldBinding fieldBinding = (FieldBinding) binding;
- FieldDeclaration fieldDeclaration = fieldBinding.sourceField();
- if (fieldDeclaration != null) {
- ReferenceBinding declaringClass = fieldBinding.declaringClass;
- if (declaringClass instanceof SourceTypeBinding) {
- SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) declaringClass;
- TypeDeclaration typeDeclaration = (TypeDeclaration) sourceTypeBinding.scope.referenceContext();
- referenceContext = typeDeclaration;
- }
- startPosition = fieldDeclaration.sourceStart;
- endPosition = fieldDeclaration.sourceEnd;
- }
- }
- break;
- case INSTANCE_INIT :
- case STATIC_INIT :
- break;
- case LOCAL_VARIABLE :
- break;
- case PARAMETER :
- break;
- case TYPE_PARAMETER :
- }
- }
- StringBuilder builder = new StringBuilder();
- if (msg != null) {
- builder.append(msg);
- }
- int lineNumber = 0;
- int columnNumber = 1;
- char[] fileName = null;
- if (referenceContext != null) {
- CompilationResult result = referenceContext.compilationResult();
- fileName = result.fileName;
- int[] lineEnds = null;
- lineNumber = startPosition >= 0
- ? Util.getLineNumber(startPosition, lineEnds = result.getLineSeparatorPositions(), 0, lineEnds.length-1)
- : 0;
- columnNumber = startPosition >= 0
- ? Util.searchColumnNumber(result.getLineSeparatorPositions(), lineNumber,startPosition)
- : 0;
- }
- int severity;
- switch(kind) {
- case ERROR :
- severity = ProblemSeverities.Error;
- break;
- default :
- // There is no "INFO" equivalent in JDT
- severity = ProblemSeverities.Warning;
- break;
- }
- return new AptProblem(
- referenceContext,
- fileName,
- String.valueOf(builder),
- 0,
- NO_ARGUMENTS,
- severity,
- startPosition,
- endPosition,
- lineNumber,
- columnNumber);
- }
-
- public BaseMessagerImpl() {
- super();
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java
deleted file mode 100644
index 6595f70ea4..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.compiler.apt.dispatch;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.processing.Filer;
-import javax.annotation.processing.Messager;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.util.Elements;
-import javax.lang.model.util.Types;
-
-import org.eclipse.jdt.internal.compiler.Compiler;
-import org.eclipse.jdt.internal.compiler.apt.model.ElementsImpl;
-import org.eclipse.jdt.internal.compiler.apt.model.Factory;
-import org.eclipse.jdt.internal.compiler.apt.model.TypesImpl;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-
-/**
- * Implementation of ProcessingEnvironment that is common to batch and IDE environments.
- */
-public abstract class BaseProcessingEnvImpl implements ProcessingEnvironment {
-
- // Initialized in subclasses:
- protected Filer _filer;
- protected Messager _messager;
- protected Map<String, String> _processorOptions;
- protected Compiler _compiler;
-
- // Initialized in this base class:
- protected Elements _elementUtils;
- protected Types _typeUtils;
- private List<ICompilationUnit> _addedUnits;
- private List<ReferenceBinding> _addedClassFiles;
- private List<ICompilationUnit> _deletedUnits;
- private boolean _errorRaised;
- private Factory _factory;
-
- public BaseProcessingEnvImpl() {
- _addedUnits = new ArrayList<ICompilationUnit>();
- _addedClassFiles = new ArrayList<ReferenceBinding>();
- _deletedUnits = new ArrayList<ICompilationUnit>();
- _elementUtils = new ElementsImpl(this);
- _typeUtils = new TypesImpl(this);
- _factory = new Factory(this);
- _errorRaised = false;
- }
-
- public void addNewUnit(ICompilationUnit unit) {
- _addedUnits.add(unit);
- }
-
- public void addNewClassFile(ReferenceBinding binding) {
- _addedClassFiles.add(binding);
- }
-
- public Compiler getCompiler() {
- return _compiler;
- }
-
- public ICompilationUnit[] getDeletedUnits() {
- ICompilationUnit[] result = new ICompilationUnit[_deletedUnits.size()];
- _deletedUnits.toArray(result);
- return result;
- }
-
- public ICompilationUnit[] getNewUnits() {
- ICompilationUnit[] result = new ICompilationUnit[_addedUnits.size()];
- _addedUnits.toArray(result);
- return result;
- }
-
- @Override
- public Elements getElementUtils() {
- return _elementUtils;
- }
-
- @Override
- public Filer getFiler() {
- return _filer;
- }
-
- @Override
- public Messager getMessager() {
- return _messager;
- }
-
- @Override
- public Map<String, String> getOptions() {
- return _processorOptions;
- }
-
- @Override
- public Types getTypeUtils() {
- return _typeUtils;
- }
-
- public LookupEnvironment getLookupEnvironment() {
- return _compiler.lookupEnvironment;
- }
-
- @Override
- public SourceVersion getSourceVersion() {
- // As of this writing, RELEASE_6 is the highest level available.
- // It is also the lowest level for which this code can possibly
- // be called. When Java 7 is released, this method will need to
- // return a value based on _compiler.options.sourceLevel.
- return SourceVersion.RELEASE_6;
- }
-
- /**
- * Called when AnnotationProcessorManager has retrieved the list of
- * newly generated compilation units (ie, once per round)
- */
- public void reset() {
- _addedUnits.clear();
- _addedClassFiles.clear();
- _deletedUnits.clear();
- }
-
- /**
- * Has an error been raised in any of the rounds of processing in this build?
- * @return
- */
- public boolean errorRaised()
- {
- return _errorRaised;
- }
-
- /**
- * Set or clear the errorRaised flag. Typically this will be set by the Messager
- * when an error has been raised, and it will never be cleared.
- */
- public void setErrorRaised(boolean b)
- {
- _errorRaised = true;
- }
-
- public Factory getFactory()
- {
- return _factory;
- }
-
- public ReferenceBinding[] getNewClassFiles() {
- ReferenceBinding[] result = new ReferenceBinding[_addedClassFiles.size()];
- _addedClassFiles.toArray(result);
- return result;
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchAnnotationProcessorManager.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchAnnotationProcessorManager.java
deleted file mode 100644
index d6c1a7f383..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchAnnotationProcessorManager.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.dispatch;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ServiceConfigurationError;
-import java.util.ServiceLoader;
-
-import javax.annotation.processing.Processor;
-import javax.tools.StandardLocation;
-
-import org.eclipse.jdt.internal.compiler.batch.Main;
-import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
-
-/**
- * Java 6 annotation processor manager used when compiling from the command line
- * or via the javax.tools.JavaCompiler interface.
- * @see org.eclipse.jdt.internal.compiler.apt.ide.dispatch.IdeAnnotationProcessorManager
- */
-public class BatchAnnotationProcessorManager extends BaseAnnotationProcessorManager
-{
-
- /**
- * Processors that have been set by calling CompilationTask.setProcessors().
- */
- private List<Processor> _setProcessors = null;
- private Iterator<Processor> _setProcessorIter = null;
-
- /**
- * Processors named with the -processor option on the command line.
- */
- private List<String> _commandLineProcessors;
- private Iterator<String> _commandLineProcessorIter = null;
-
- private ServiceLoader<Processor> _serviceLoader = null;
- private Iterator<Processor> _serviceLoaderIter;
-
- private ClassLoader _procLoader;
-
- // Set this to true in order to trace processor discovery when -XprintProcessorInfo is specified
- private final static boolean VERBOSE_PROCESSOR_DISCOVERY = true;
- private boolean _printProcessorDiscovery = false;
-
- /**
- * Zero-arg constructor so this object can be easily created via reflection.
- * A BatchAnnotationProcessorManager cannot be used until its
- * {@link #configure(Main, String[])} method has been called.
- */
- public BatchAnnotationProcessorManager()
- {
- }
-
- @Override
- public void configure(Object batchCompiler, String[] commandLineArguments) {
- if (null != _processingEnv) {
- throw new IllegalStateException(
- "Calling configure() more than once on an AnnotationProcessorManager is not supported"); //$NON-NLS-1$
- }
- BatchProcessingEnvImpl processingEnv = new BatchProcessingEnvImpl(this, (Main) batchCompiler, commandLineArguments);
- _processingEnv = processingEnv;
- _procLoader = processingEnv.getFileManager().getClassLoader(StandardLocation.ANNOTATION_PROCESSOR_PATH);
- parseCommandLine(commandLineArguments);
- _round = 0;
- }
-
- /**
- * If a -processor option was specified in command line arguments,
- * parse it into a list of qualified classnames.
- * @param commandLineArguments contains one string for every space-delimited token on the command line
- * @return a list of qualified classnames, or null if there was no -processor option.
- */
- private void parseCommandLine(String[] commandLineArguments) {
- List<String> commandLineProcessors = null;
- for (int i = 0; i < commandLineArguments.length; ++i) {
- String option = commandLineArguments[i];
- if ("-XprintProcessorInfo".equals(option)) { //$NON-NLS-1$
- _printProcessorInfo = true;
- _printProcessorDiscovery = VERBOSE_PROCESSOR_DISCOVERY;
- }
- else if ("-XprintRounds".equals(option)) { //$NON-NLS-1$
- _printRounds = true;
- }
- else if ("-processor".equals(option)) { //$NON-NLS-1$
- commandLineProcessors = new ArrayList<String>();
- String procs = commandLineArguments[++i];
- for (String proc : procs.split(",")) { //$NON-NLS-1$
- commandLineProcessors.add(proc);
- }
- break;
- }
- }
- _commandLineProcessors = commandLineProcessors;
- if (null != _commandLineProcessors) {
- _commandLineProcessorIter = _commandLineProcessors.iterator();
- }
- }
-
- @Override
- public ProcessorInfo discoverNextProcessor() {
- if (null != _setProcessors) {
- // If setProcessors() was called, use that list until it's empty and then stop.
- if (_setProcessorIter.hasNext()) {
- Processor p = _setProcessorIter.next();
- p.init(_processingEnv);
- ProcessorInfo pi = new ProcessorInfo(p);
- _processors.add(pi);
- if (_printProcessorDiscovery && null != _out) {
- _out.println("API specified processor: " + pi); //$NON-NLS-1$
- }
- return pi;
- }
- return null;
- }
-
- if (null != _commandLineProcessors) {
- // If there was a -processor option, iterate over processor names,
- // creating and initializing processors, until no more names are found, then stop.
- if (_commandLineProcessorIter.hasNext()) {
- String proc = _commandLineProcessorIter.next();
- try {
- Class<?> clazz = _procLoader.loadClass(proc);
- Object o = clazz.newInstance();
- Processor p = (Processor) o;
- p.init(_processingEnv);
- ProcessorInfo pi = new ProcessorInfo(p);
- _processors.add(pi);
- if (_printProcessorDiscovery && null != _out) {
- _out.println("Command line specified processor: " + pi); //$NON-NLS-1$
- }
- return pi;
- } catch (Exception e) {
- // TODO: better error handling
- throw new AbortCompilation(null, e);
- }
- }
- return null;
- }
-
- // if no processors were explicitly specified with setProcessors()
- // or the command line, search the processor path with ServiceLoader.
- if (null == _serviceLoader ) {
- _serviceLoader = ServiceLoader.load(Processor.class, _procLoader);
- _serviceLoaderIter = _serviceLoader.iterator();
- }
- try {
- if (_serviceLoaderIter.hasNext()) {
- Processor p = _serviceLoaderIter.next();
- p.init(_processingEnv);
- ProcessorInfo pi = new ProcessorInfo(p);
- _processors.add(pi);
- if (_printProcessorDiscovery && null != _out) {
- StringBuilder sb = new StringBuilder();
- sb.append("Discovered processor service "); //$NON-NLS-1$
- sb.append(pi);
- sb.append("\n supporting "); //$NON-NLS-1$
- sb.append(pi.getSupportedAnnotationTypesAsString());
- sb.append("\n in "); //$NON-NLS-1$
- sb.append(getProcessorLocation(p));
- _out.println(sb.toString());
- }
- return pi;
- }
- } catch (ServiceConfigurationError e) {
- // TODO: better error handling
- throw new AbortCompilation(null, e);
- }
- return null;
- }
-
- /**
- * Used only for debugging purposes. Generates output like "file:jar:D:/temp/jarfiles/myJar.jar!/".
- * Surely this code already exists in several hundred other places?
- * @return the location whence a processor class was loaded.
- */
- private String getProcessorLocation(Processor p) {
- // Get the classname in a form that can be passed to ClassLoader.getResource(),
- // e.g., "pa/pb/pc/Outer$Inner.class"
- boolean isMember = false;
- Class<?> outerClass = p.getClass();
- StringBuilder innerName = new StringBuilder();
- while (outerClass.isMemberClass()) {
- innerName.insert(0, outerClass.getSimpleName());
- innerName.insert(0, '$');
- isMember = true;
- outerClass = outerClass.getEnclosingClass();
- }
- String path = outerClass.getName();
- path = path.replace('.', '/');
- if (isMember) {
- path = path + innerName;
- }
- path = path + ".class"; //$NON-NLS-1$
-
- // Find the URL for the class resource and strip off the resource name itself
- String location = _procLoader.getResource(path).toString();
- if (location.endsWith(path)) {
- location = location.substring(0, location.length() - path.length());
- }
- return location;
- }
-
- @Override
- public void reportProcessorException(Processor p, Exception e) {
- // TODO: if (verbose) report the processor
- throw new AbortCompilation(null, e);
- }
-
- @Override
- public void setProcessors(Object[] processors) {
- if (!_isFirstRound) {
- throw new IllegalStateException("setProcessors() cannot be called after processing has begun"); //$NON-NLS-1$
- }
- // Cast all the processors here, rather than failing later.
- // But don't call init() until the processor is actually needed.
- _setProcessors = new ArrayList<Processor>(processors.length);
- for (Object o : processors) {
- Processor p = (Processor)o;
- _setProcessors.add(p);
- }
- _setProcessorIter = _setProcessors.iterator();
-
- // processors set this way take precedence over anything on the command line
- _commandLineProcessors = null;
- _commandLineProcessorIter = null;
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchFilerImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchFilerImpl.java
deleted file mode 100644
index 1009ae9f00..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchFilerImpl.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.internal.compiler.apt.dispatch;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.HashSet;
-
-import javax.annotation.processing.Filer;
-import javax.annotation.processing.FilerException;
-import javax.lang.model.element.Element;
-import javax.tools.FileObject;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardLocation;
-import javax.tools.JavaFileManager.Location;
-
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-
-/**
- * Implementation of Filer used when compilation is driven by command line
- * or by Tool interface. This version does not need to keep track of
- * dependencies.
- */
-public class BatchFilerImpl implements Filer {
-
- protected final BaseAnnotationProcessorManager _dispatchManager;
- protected final BaseProcessingEnvImpl _env;
- protected final JavaFileManager _fileManager;
- protected final HashSet<URI> _createdFiles;
-
- public BatchFilerImpl(BaseAnnotationProcessorManager dispatchManager, BatchProcessingEnvImpl env)
- {
- _dispatchManager = dispatchManager;
- _fileManager = env._fileManager;
- _env = env;
- _createdFiles = new HashSet<URI>();
- }
-
- public void addNewUnit(ICompilationUnit unit) {
- _env.addNewUnit(unit);
- }
-
- public void addNewClassFile(ReferenceBinding binding) {
- _env.addNewClassFile(binding);
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Filer#createClassFile(java.lang.CharSequence, javax.lang.model.element.Element[])
- */
- @Override
- public JavaFileObject createClassFile(CharSequence name,
- Element... originatingElements) throws IOException
- {
- //TODO: do we need to check validity of 'name', or can we trust the filemanager to handle that?
- JavaFileObject jfo = _fileManager.getJavaFileForOutput(
- StandardLocation.CLASS_OUTPUT, name.toString(), JavaFileObject.Kind.CLASS, null);
- URI uri = jfo.toUri();
- if (_createdFiles.contains(uri)) {
- throw new FilerException("Class file already created : " + name); //$NON-NLS-1$
- }
-
- _createdFiles.add(uri);
- return new HookedJavaFileObject(jfo, jfo.getName(), this);
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Filer#createResource(javax.tools.JavaFileManager.Location, java.lang.CharSequence, java.lang.CharSequence, javax.lang.model.element.Element[])
- */
- @Override
- public FileObject createResource(Location location, CharSequence pkg,
- CharSequence relativeName, Element... originatingElements)
- throws IOException {
- //TODO: do we need to check validity of 'name', or can we trust the filemanager to handle that?
- FileObject fo = _fileManager.getFileForOutput(
- location, pkg.toString(), relativeName.toString(), null);
- URI uri = fo.toUri();
- if (_createdFiles.contains(uri)) {
- throw new FilerException("Resource already created : " + location + '/' + pkg + '/' + relativeName); //$NON-NLS-1$
- }
-
- _createdFiles.add(uri);
- return fo;
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Filer#createSourceFile(java.lang.CharSequence, javax.lang.model.element.Element[])
- */
- @Override
- public JavaFileObject createSourceFile(CharSequence name,
- Element... originatingElements) throws IOException {
- //TODO: do we need to check validity of 'name', or can we trust the filemanager to handle that?
- JavaFileObject jfo = _fileManager.getJavaFileForOutput(
- StandardLocation.SOURCE_OUTPUT, name.toString(), JavaFileObject.Kind.SOURCE, null);
- URI uri = jfo.toUri();
- if (_createdFiles.contains(uri)) {
- throw new FilerException("Source file already created : " + name); //$NON-NLS-1$
- }
-
- _createdFiles.add(uri);
- // hook the file object's writers to create compilation unit and add to addedUnits()
- return new HookedJavaFileObject(jfo, jfo.getName(), this);
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Filer#getResource(javax.tools.JavaFileManager.Location, java.lang.CharSequence, java.lang.CharSequence)
- */
- @Override
- public FileObject getResource(Location location, CharSequence pkg,
- CharSequence relativeName) throws IOException {
- //TODO: do we need to check validity of 'name', or can we trust the filemanager to handle that?
- FileObject fo = _fileManager.getFileForInput(
- location, pkg.toString(), relativeName.toString());
- URI uri = fo.toUri();
- if (_createdFiles.contains(uri)) {
- throw new FilerException("Resource already created : " + location + '/' + pkg + '/' + relativeName); //$NON-NLS-1$
- }
-
- _createdFiles.add(uri);
- return fo;
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchMessagerImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchMessagerImpl.java
deleted file mode 100644
index 1d2fba3a62..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchMessagerImpl.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.internal.compiler.apt.dispatch;
-
-import javax.annotation.processing.Messager;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.tools.Diagnostic.Kind;
-
-import org.eclipse.jdt.core.compiler.CategorizedProblem;
-import org.eclipse.jdt.internal.compiler.batch.Main;
-
-/**
- * An implementation of Messager that reports messages via the Compiler
- */
-public class BatchMessagerImpl extends BaseMessagerImpl implements Messager {
-
- private final Main _compiler;
- private final BaseProcessingEnvImpl _processingEnv;
-
- public BatchMessagerImpl(BaseProcessingEnvImpl processingEnv, Main compiler) {
- _compiler = compiler;
- _processingEnv = processingEnv;
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Messager#printMessage(javax.tools.Diagnostic.Kind, java.lang.CharSequence)
- */
- @Override
- public void printMessage(Kind kind, CharSequence msg) {
- printMessage(kind, msg, null, null, null);
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Messager#printMessage(javax.tools.Diagnostic.Kind, java.lang.CharSequence, javax.lang.model.element.Element)
- */
- @Override
- public void printMessage(Kind kind, CharSequence msg, Element e) {
- printMessage(kind, msg, e, null, null);
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Messager#printMessage(javax.tools.Diagnostic.Kind, java.lang.CharSequence, javax.lang.model.element.Element, javax.lang.model.element.AnnotationMirror)
- */
- @Override
- public void printMessage(Kind kind, CharSequence msg, Element e,
- AnnotationMirror a) {
- printMessage(kind, msg, e, a, null);
-
- }
-
- /* (non-Javadoc)
- * @see javax.annotation.processing.Messager#printMessage(javax.tools.Diagnostic.Kind, java.lang.CharSequence, javax.lang.model.element.Element, javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationValue)
- */
- @Override
- public void printMessage(Kind kind, CharSequence msg, Element e,
- AnnotationMirror a, AnnotationValue v) {
- //TODO: we are currently ignoring 'a' and 'v'
- if (kind == Kind.ERROR) {
- _processingEnv.setErrorRaised(true);
- }
- CategorizedProblem problem = createProblem(kind, msg, e);
- if (problem != null) {
- this._compiler.addExtraProblems(problem);
- }
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchProcessingEnvImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchProcessingEnvImpl.java
deleted file mode 100644
index ac70cde204..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchProcessingEnvImpl.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.internal.compiler.apt.dispatch;
-
-import java.lang.reflect.Field;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.tools.JavaFileManager;
-
-import org.eclipse.jdt.internal.compiler.apt.util.EclipseFileManager;
-import org.eclipse.jdt.internal.compiler.batch.Main;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
-
-/**
- * The implementation of ProcessingEnvironment that is used when compilation is
- * driven by the command line or by the Tool interface. This environment uses
- * the JavaFileManager provided by the compiler.
- * @see org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl
- */
-public class BatchProcessingEnvImpl extends BaseProcessingEnvImpl {
-
- protected final BaseAnnotationProcessorManager _dispatchManager;
- protected final JavaFileManager _fileManager;
- protected final Main _compilerOwner;
-
- public BatchProcessingEnvImpl(BaseAnnotationProcessorManager dispatchManager, Main batchCompiler,
- String[] commandLineArguments)
- {
- super();
- _compilerOwner = batchCompiler;
- _compiler = batchCompiler.batchCompiler;
- _dispatchManager = dispatchManager;
- Class<?> c = null;
- try {
- c = Class.forName("org.eclipse.jdt.internal.compiler.tool.EclipseCompilerImpl"); //$NON-NLS-1$
- } catch (ClassNotFoundException e) {
- // ignore
- }
- Field field = null;
- JavaFileManager javaFileManager = null;
- if (c != null) {
- try {
- field = c.getField("fileManager"); //$NON-NLS-1$
- } catch (SecurityException e) {
- // ignore
- } catch (IllegalArgumentException e) {
- // ignore
- } catch (NoSuchFieldException e) {
- // ignore
- }
- }
- if (field != null) {
- try {
- javaFileManager = (JavaFileManager) field.get(batchCompiler);
- } catch (IllegalArgumentException e) {
- // ignore
- } catch (IllegalAccessException e) {
- // ignore
- }
- }
- if (javaFileManager != null) {
- _fileManager = javaFileManager;
- } else {
- String encoding = (String) batchCompiler.options.get(CompilerOptions.OPTION_Encoding);
- Charset charset = encoding != null ? Charset.forName(encoding) : null;
- JavaFileManager manager = new EclipseFileManager(batchCompiler.compilerLocale, charset);
- ArrayList<String> options = new ArrayList<String>();
- for (String argument : commandLineArguments) {
- options.add(argument);
- }
- for (Iterator<String> iterator = options.iterator(); iterator.hasNext(); ) {
- manager.handleOption(iterator.next(), iterator);
- }
- _fileManager = manager;
- }
- _processorOptions = Collections.unmodifiableMap(parseProcessorOptions(commandLineArguments));
- _filer = new BatchFilerImpl(_dispatchManager, this);
- _messager = new BatchMessagerImpl(this, _compilerOwner);
- }
-
- /**
- * Parse the -A command line arguments so that they can be delivered to
- * processors with {@link ProcessingEnvironment#getOptions(). In Sun's Java 6
- * version of javac, unlike in the Java 5 apt tool, only the -A options are
- * passed to processors, not the other command line options; that behavior
- * is repeated here.
- * @param args the equivalent of the args array from the main() method.
- * @return a map of key to value, or key to null if there is no value for
- * a particular key. The "-A" is stripped from the key, so a command-line
- * argument like "-Afoo=bar" will result in an entry with key "foo" and
- * value "bar".
- */
- private Map<String, String> parseProcessorOptions(String[] args) {
- Map<String, String> options = new LinkedHashMap<String, String>();
- for (String arg : args) {
- if (!arg.startsWith("-A")) { //$NON-NLS-1$
- continue;
- }
- int equals = arg.indexOf('=');
- if (equals == 2) {
- // option begins "-A=" - not valid
- Exception e = new IllegalArgumentException("-A option must have a key before the equals sign"); //$NON-NLS-1$
- throw new AbortCompilation(null, e);
- }
- if (equals == arg.length() - 1) {
- // option ends with "=" - not valid
- options.put(arg.substring(2, equals), null);
- } else if (equals == -1) {
- // no value
- options.put(arg.substring(2), null);
- } else {
- // value and key
- options.put(arg.substring(2, equals), arg.substring(equals + 1));
- }
- }
- return options;
- }
-
- public JavaFileManager getFileManager() {
- return _fileManager;
- }
-
- @Override
- public Locale getLocale() {
- return _compilerOwner.compilerLocale;
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/HookedJavaFileObject.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/HookedJavaFileObject.java
deleted file mode 100644
index f4fce77d59..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/HookedJavaFileObject.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.internal.compiler.apt.dispatch;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-
-import javax.tools.ForwardingJavaFileObject;
-import javax.tools.JavaFileObject;
-
-import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
-import org.eclipse.jdt.internal.compiler.env.IBinaryType;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-
-/**
- * A delegating JavaFileObject that hooks the close() methods of the Writer
- * or OutputStream objects that it produces, and notifies the annotation
- * dispatch manager when a new compilation unit is produced.
- */
-public class HookedJavaFileObject extends
- ForwardingJavaFileObject<JavaFileObject>
-{
- // A delegating Writer that passes all commands to its contained Writer,
- // but hooks close() to notify the annotation dispatch manager of the new unit.
- private class ForwardingWriter extends Writer {
- private final Writer _w;
- ForwardingWriter(Writer w) {
- _w = w;
- }
- @Override
- public Writer append(char c) throws IOException {
- return _w.append(c);
- }
- @Override
- public Writer append(CharSequence csq, int start, int end)
- throws IOException {
- return _w.append(csq, start, end);
- }
- @Override
- public Writer append(CharSequence csq) throws IOException {
- return _w.append(csq);
- }
- // This is the only interesting method - it has to notify the
- // dispatch manager of the new file.
- @Override
- public void close() throws IOException {
- _w.close();
- closed();
- }
- @Override
- public void flush() throws IOException {
- _w.flush();
- }
- @Override
- public void write(char[] cbuf) throws IOException {
- _w.write(cbuf);
- }
- @Override
- public void write(int c) throws IOException {
- _w.write(c);
- }
- @Override
- public void write(String str, int off, int len)
- throws IOException {
- _w.write(str, off, len);
- }
- @Override
- public void write(String str) throws IOException {
- _w.write(str);
- }
- @Override
- public void write(char[] cbuf, int off, int len)
- throws IOException {
- _w.write(cbuf, off, len);
- }
- @Override
- protected Object clone() throws CloneNotSupportedException {
- return new ForwardingWriter(this._w);
- }
- @Override
- public int hashCode() {
- return _w.hashCode();
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final ForwardingWriter other = (ForwardingWriter) obj;
- if (_w == null) {
- if (other._w != null)
- return false;
- } else if (!_w.equals(other._w))
- return false;
- return true;
- }
- @Override
- public String toString() {
- return "ForwardingWriter wrapping " + _w.toString(); //$NON-NLS-1$
- }
- }
-
- // A delegating Writer that passes all commands to its contained Writer,
- // but hooks close() to notify the annotation dispatch manager of the new unit.
- private class ForwardingOutputStream extends OutputStream {
- private final OutputStream _os;
-
- ForwardingOutputStream(OutputStream os) {
- _os = os;
- }
-
- @Override
- public void close() throws IOException {
- _os.close();
- closed();
- }
- @Override
- public void flush() throws IOException {
- _os.flush();
- }
- @Override
- public void write(byte[] b, int off, int len) throws IOException {
- _os.write(b, off, len);
- }
- @Override
- public void write(byte[] b) throws IOException {
- _os.write(b);
- }
- @Override
- public void write(int b) throws IOException {
- _os.write(b);
- }
- @Override
- protected Object clone() throws CloneNotSupportedException {
- return new ForwardingOutputStream(this._os);
- }
- @Override
- public int hashCode() {
- return _os.hashCode();
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final ForwardingOutputStream other = (ForwardingOutputStream) obj;
- if (_os == null) {
- if (other._os != null)
- return false;
- } else if (!_os.equals(other._os))
- return false;
- return true;
- }
- @Override
- public String toString() {
- return "ForwardingOutputStream wrapping " + _os.toString(); //$NON-NLS-1$
- }
- }
-
- /**
- * The Filer implementation that we need to notify when a new file is created.
- */
- protected final BatchFilerImpl _filer;
-
- /**
- * The name of the file that is created; this is passed to the CompilationUnit constructor,
- * and ultimately to the java.io.File constructor, so it is a normal pathname, just like
- * what would be on the compiler command line.
- */
- protected final String _fileName;
-
- /**
- * A compilation unit is created when the writer or stream is closed. Only do this once.
- */
- private boolean _closed = false;
-
- public HookedJavaFileObject(JavaFileObject fileObject, String fileName, BatchFilerImpl filer) {
- super(fileObject);
- _filer = filer;
- _fileName = fileName;
- }
-
- @Override
- public OutputStream openOutputStream() throws IOException {
- return new ForwardingOutputStream(super.openOutputStream());
- }
-
- @Override
- public Writer openWriter() throws IOException {
- return new ForwardingWriter(super.openWriter());
- }
-
- protected void closed() {
- if (!_closed) {
- _closed = true;
- //TODO: support encoding
- switch(this.getKind()) {
- case SOURCE :
- CompilationUnit unit = new CompilationUnit(null, _fileName, null /* encoding */);
- _filer.addNewUnit(unit);
- break;
- case CLASS :
- IBinaryType binaryType = null;
- try {
- binaryType = ClassFileReader.read(_fileName);
- } catch (ClassFormatException e) {
- // ignore
- } catch (IOException e) {
- // ignore
- }
- if (binaryType != null) {
- char[] name = binaryType.getName();
- ReferenceBinding type = this._filer._env._compiler.lookupEnvironment.getType(CharOperation.splitOn('/', name));
- if (type != null && type.isValidBinding() && type.isBinaryBinding()) {
- _filer.addNewClassFile(type);
- }
- }
- }
- }
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/IProcessorProvider.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/IProcessorProvider.java
deleted file mode 100644
index e776ad6c48..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/IProcessorProvider.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.internal.compiler.apt.dispatch;
-
-import java.util.List;
-
-import javax.annotation.processing.Processor;
-
-/**
- * Implementors know how to discover annotation processors, and maintain a list of processors that
- * have been discovered and initialized so far.
- */
-public interface IProcessorProvider {
-
- /**
- * Return the next processor that can be discovered, according to the order and discovery rules
- * of the provider (see, for instance, {@link Processor}.
- * @return a ProcessorInfo wrapping an initialized Processor, or <code>null</code> if there are
- * no more processors to be discovered.
- */
- ProcessorInfo discoverNextProcessor();
-
- /**
- * @return the list of all processors that have been discovered so far. This list will grow when
- * {@link #discoverNextProcessor()} is called.
- */
- List<ProcessorInfo> getDiscoveredProcessors();
-
- /**
- * Called when a processor throws an exception. This may abort compilation, throw an
- * unchecked exception, etc; the caller should not assume that this method will return.
- *
- * @param p the processor, if known, or null if not.
- * @param e
- */
- void reportProcessorException(Processor p, Exception e);
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/ProcessorInfo.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/ProcessorInfo.java
deleted file mode 100644
index b9a463da60..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/ProcessorInfo.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.internal.compiler.apt.dispatch;
-
-import java.util.Iterator;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.annotation.processing.Processor;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.TypeElement;
-
-/**
- * Cached information associated with a {@link Processor} in the context
- * of annotation processor dispatch.
- * <p>
- * This class supports inclusion in a collection by implementing
- * equals() and hashCode(). Its concept of identity is based on
- * the class object of the Processor that it wraps; so, for instance,
- * it is not possible to have a Set that contains more than one
- * instance of a particular Processor class. In fact, it is possible
- * to have more than one instance of a Processor if there are multiple
- * build threads, but within the context of a particular dispatch
- * manager, there will only be one of any given Processor class.
- */
-public class ProcessorInfo {
- final Processor _processor;
- final Set<String> _supportedOptions;
- final SourceVersion _supportedSourceVersion;
-
- private final Pattern _supportedAnnotationTypesPattern;
- private final boolean _supportsStar;
- private boolean _hasBeenCalled;
-
- /**
- * Create a ProcessorInfo wrapping a particular Processor. The Processor must already have been
- * initialized (that is,
- * {@link Processor#init(javax.annotation.processing.ProcessingEnvironment)} must already have
- * been called). Its getSupportedXXX() methods will be called and the results will be cached.
- */
- public ProcessorInfo(Processor p)
- {
- _processor = p;
- _hasBeenCalled = false;
- _supportedSourceVersion = p.getSupportedSourceVersion();
- _supportedOptions = p.getSupportedOptions();
- Set<String> supportedAnnotationTypes = p.getSupportedAnnotationTypes();
-
- boolean supportsStar = false;
- if (null != supportedAnnotationTypes && !supportedAnnotationTypes.isEmpty()) {
- StringBuilder regex = new StringBuilder();
- Iterator<String> iName = supportedAnnotationTypes.iterator();
- while (true) {
- String name = iName.next();
- supportsStar |= "*".equals(name); //$NON-NLS-1$
- String escapedName1 = name.replace(".", "\\."); //$NON-NLS-1$ //$NON-NLS-2$
- String escapedName2 = escapedName1.replace("*", ".*"); //$NON-NLS-1$ //$NON-NLS-2$
- regex.append(escapedName2);
- if (!iName.hasNext()) {
- break;
- }
- regex.append('|');
- }
- _supportedAnnotationTypesPattern = Pattern.compile(regex.toString());
- }
- else {
- _supportedAnnotationTypesPattern = null;
- }
- _supportsStar = supportsStar;
- }
-
- /**
- * Compute the subset of <code>annotations</code> that are described by <code>annotationTypes</code>,
- * and determine whether the processor should be called. A processor will be called if it has
- * any annotations to process, or if it supports "*", or if it was called in a previous round.
- * If the return value of this method is true once for a given processor, then it will always be true on
- * subsequent calls.
- *
- * @param annotations a set of annotation types
- * @param annotationTypes a set of names, which may use the wildcard "*", as described in
- * {@link Processor#getSupportedAnnotationTypes()}.
- * @param result an empty modifiable set, which upon return will contain a subset of <code>annotations</code>, which may be empty but will not be null.
- * @return true if the processor should be called on this round.
- */
- public boolean computeSupportedAnnotations(Set<TypeElement> annotations, Set<TypeElement> result)
- {
- if (null != annotations && !annotations.isEmpty() && null != _supportedAnnotationTypesPattern) {
- for (TypeElement annotation : annotations) {
- Matcher matcher = _supportedAnnotationTypesPattern.matcher(annotation.getQualifiedName().toString());
- if (matcher.matches()) {
- result.add(annotation);
- }
- }
- }
- boolean call = _hasBeenCalled || _supportsStar || !result.isEmpty();
- _hasBeenCalled |= call;
- return call;
- }
-
- /**
- * @return true if the processor included "*" among its list of supported annotations.
- */
- public boolean supportsStar()
- {
- return _supportsStar;
- }
-
- /**
- * Must be called at the beginning of a build to ensure that no information is
- * carried over from the previous build. In particular, processors are
- * required to be called on every round after the round in which they are
- * first called; this method resets the "has been called" flag.
- */
- public void reset()
- {
- _hasBeenCalled = false;
- }
-
- @Override
- public int hashCode() {
- return _processor.getClass().hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final ProcessorInfo other = (ProcessorInfo) obj;
- if (!_processor.getClass().equals(other._processor.getClass()))
- return false;
- return true;
- }
-
- @Override
- public String toString()
- {
- return _processor.getClass().getName();
- }
-
- /**
- * @return a string representing the set of supported annotation types, in a format
- * suitable for debugging. The format is unspecified and subject to change.
- */
- public String getSupportedAnnotationTypesAsString()
- {
- StringBuilder sb = new StringBuilder();
- sb.append('[');
- Iterator<String> iAnnots = _processor.getSupportedAnnotationTypes().iterator();
- boolean hasNext = iAnnots.hasNext();
- while (hasNext) {
- sb.append(iAnnots.next());
- hasNext = iAnnots.hasNext();
- if (hasNext) {
- sb.append(',');
- }
- }
- sb.append(']');
- return sb.toString();
- }
-}
-
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundDispatcher.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundDispatcher.java
deleted file mode 100644
index 86e0687067..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundDispatcher.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.internal.compiler.apt.dispatch;
-
-import java.io.PrintWriter;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.annotation.processing.RoundEnvironment;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-
-/**
- * Manages context during a single round of annotation processing.
- */
-public class RoundDispatcher {
-
- private final Set<TypeElement> _unclaimedAnnotations;
- private final RoundEnvironment _roundEnv;
- private final IProcessorProvider _provider;
- private boolean _searchForStar = false;
- private final PrintWriter _traceProcessorInfo;
- private final PrintWriter _traceRounds;
-
- /**
- * Processors discovered so far. This list may grow during the
- * course of a round, as additional processors are discovered.
- */
- private final List<ProcessorInfo> _processors;
-
- /**
- * @param rootAnnotations a possibly empty but non-null set of annotations on the
- * root compilation units of this round. A local copy of the set will be made, to
- * avoid modifying the set passed in.
- * @param traceProcessorInfo a PrintWriter that processor trace output will be sent
- * to, or null if tracing is not desired.
- * @param traceRounds
- */
- public RoundDispatcher(
- IProcessorProvider provider,
- RoundEnvironment env,
- Set<TypeElement> rootAnnotations,
- PrintWriter traceProcessorInfo,
- PrintWriter traceRounds)
- {
- _provider = provider;
- _processors = provider.getDiscoveredProcessors();
- _roundEnv = env;
- _unclaimedAnnotations = new HashSet<TypeElement>(rootAnnotations);
- _traceProcessorInfo = traceProcessorInfo;
- _traceRounds = traceRounds;
- }
-
- /**
- * Handle a complete round, dispatching to all appropriate processors.
- */
- public void round()
- {
- if (null != _traceRounds) {
- StringBuilder sbElements = new StringBuilder();
- sbElements.append("\tinput files: {"); //$NON-NLS-1$
- Iterator<? extends Element> iElements = _roundEnv.getRootElements().iterator();
- boolean hasNext = iElements.hasNext();
- while (hasNext) {
- sbElements.append(iElements.next());
- hasNext = iElements.hasNext();
- if (hasNext) {
- sbElements.append(',');
- }
- }
- sbElements.append('}');
- _traceRounds.println(sbElements.toString());
-
- StringBuilder sbAnnots = new StringBuilder();
- sbAnnots.append("\tannotations: ["); //$NON-NLS-1$
- Iterator<TypeElement> iAnnots = _unclaimedAnnotations.iterator();
- hasNext = iAnnots.hasNext();
- while (hasNext) {
- sbAnnots.append(iAnnots.next());
- hasNext = iAnnots.hasNext();
- if (hasNext) {
- sbAnnots.append(',');
- }
- }
- sbAnnots.append(']');
- _traceRounds.println(sbAnnots.toString());
-
- _traceRounds.println("\tlast round: " + _roundEnv.processingOver()); //$NON-NLS-1$
- }
-
- // If there are no root annotations, try to find a processor that claims "*"
- _searchForStar = _unclaimedAnnotations.isEmpty();
-
- // Iterate over all the already-found processors, giving each one a chance at the unclaimed
- // annotations. If a processor is called at all, it is called on every subsequent round
- // including the final round, but it may be called with an empty set of annotations.
- for (ProcessorInfo pi : _processors) {
- handleProcessor(pi);
- }
-
- // If there are any unclaimed annotations, or if there were no root annotations and
- // we have not yet run into a processor that claimed "*", continue discovery.
- while (_searchForStar || !_unclaimedAnnotations.isEmpty()) {
- ProcessorInfo pi = _provider.discoverNextProcessor();
- if (null == pi) {
- // There are no more processors to be discovered.
- break;
- }
- handleProcessor(pi);
- }
-
- // TODO: If !unclaimedAnnos.isEmpty(), issue a warning.
- }
-
- /**
- * Evaluate a single processor. Depending on the unclaimed annotations,
- * the annotations this processor supports, and whether it has already been
- * called in a previous round, possibly call its process() method.
- */
- private void handleProcessor(ProcessorInfo pi)
- {
- try {
- Set<TypeElement> annotationsToProcess = new HashSet<TypeElement>();
- boolean shouldCall = pi.computeSupportedAnnotations(
- _unclaimedAnnotations, annotationsToProcess);
- if (shouldCall) {
- boolean claimed = pi._processor.process(annotationsToProcess, _roundEnv);
- if (null != _traceProcessorInfo && !_roundEnv.processingOver()) {
- StringBuilder sb = new StringBuilder();
- sb.append("Processor "); //$NON-NLS-1$
- sb.append(pi._processor.getClass().getName());
- sb.append(" matches ["); //$NON-NLS-1$
- Iterator<TypeElement> i = annotationsToProcess.iterator();
- boolean hasNext = i.hasNext();
- while (hasNext) {
- sb.append(i.next());
- hasNext = i.hasNext();
- if (hasNext) {
- sb.append(' ');
- }
- }
- sb.append("] and returns "); //$NON-NLS-1$
- sb.append(claimed);
- _traceProcessorInfo.println(sb.toString());
- }
- if (claimed) {
- // The processor claimed its annotations.
- _unclaimedAnnotations.removeAll(annotationsToProcess);
- if (pi.supportsStar()) {
- _searchForStar = false;
- }
- }
- }
- } catch (Exception e) {
- // If a processor throws an exception (as opposed to reporting an error),
- // report it and abort compilation by throwing AbortCompilation.
- _provider.reportProcessorException(pi._processor, e);
- }
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundEnvImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundEnvImpl.java
deleted file mode 100644
index 22f85a39e4..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundEnvImpl.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.dispatch;
-
-import java.lang.annotation.Annotation;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.annotation.processing.RoundEnvironment;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.util.ElementFilter;
-
-import org.eclipse.jdt.internal.compiler.apt.model.Factory;
-import org.eclipse.jdt.internal.compiler.apt.model.TypeElementImpl;
-import org.eclipse.jdt.internal.compiler.apt.util.ManyToMany;
-import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-
-public class RoundEnvImpl implements RoundEnvironment
-{
- private final BaseProcessingEnvImpl _processingEnv;
- private final boolean _isLastRound;
- private final CompilationUnitDeclaration[] _units;
- private final ManyToMany<TypeElement, Element> _annoToUnit;
- private final ReferenceBinding[] _binaryTypes;
- private final Factory _factory;
- private Set<Element> _rootElements = null;
-
- public RoundEnvImpl(CompilationUnitDeclaration[] units, ReferenceBinding[] binaryTypeBindings, boolean isLastRound, BaseProcessingEnvImpl env) {
- _processingEnv = env;
- _isLastRound = isLastRound;
- _units = units;
- _factory = _processingEnv.getFactory();
-
- // Discover the annotations that will be passed to Processor.process()
- AnnotationDiscoveryVisitor visitor = new AnnotationDiscoveryVisitor(_processingEnv);
- if (_units != null) {
- for (CompilationUnitDeclaration unit : _units) {
- unit.traverse(visitor, unit.scope);
- }
- }
- _annoToUnit = visitor._annoToElement;
- if (binaryTypeBindings != null) collectAnnotations(binaryTypeBindings);
- _binaryTypes = binaryTypeBindings;
- }
-
- private void collectAnnotations(ReferenceBinding[] referenceBindings) {
- for (ReferenceBinding referenceBinding : referenceBindings) {
- // collect all annotations from the binary types
- AnnotationBinding[] annotationBindings = referenceBinding.getAnnotations();
- for (AnnotationBinding annotationBinding : annotationBindings) {
- TypeElement anno = (TypeElement)_factory.newElement(annotationBinding.getAnnotationType());
- Element element = _factory.newElement(referenceBinding);
- _annoToUnit.put(anno, element);
- }
- FieldBinding[] fieldBindings = referenceBinding.fields();
- for (FieldBinding fieldBinding : fieldBindings) {
- annotationBindings = fieldBinding.getAnnotations();
- for (AnnotationBinding annotationBinding : annotationBindings) {
- TypeElement anno = (TypeElement)_factory.newElement(annotationBinding.getAnnotationType());
- Element element = _factory.newElement(fieldBinding);
- _annoToUnit.put(anno, element);
- }
- }
- MethodBinding[] methodBindings = referenceBinding.methods();
- for (MethodBinding methodBinding : methodBindings) {
- annotationBindings = methodBinding.getAnnotations();
- for (AnnotationBinding annotationBinding : annotationBindings) {
- TypeElement anno = (TypeElement)_factory.newElement(annotationBinding.getAnnotationType());
- Element element = _factory.newElement(methodBinding);
- _annoToUnit.put(anno, element);
- }
- }
- ReferenceBinding[] memberTypes = referenceBinding.memberTypes();
- collectAnnotations(memberTypes);
- }
- }
-
- /**
- * Return the set of annotation types that were discovered on the root elements.
- * This does not include inherited annotations, only those directly on the root
- * elements.
- * @return a set of annotation types, possibly empty.
- */
- public Set<TypeElement> getRootAnnotations()
- {
- return Collections.unmodifiableSet(_annoToUnit.getKeySet());
- }
-
- @Override
- public boolean errorRaised()
- {
- return _processingEnv.errorRaised();
- }
-
- /**
- * From the set of root elements and their enclosed elements, return the subset that are annotated
- * with {@code a}. If {@code a} is annotated with the {@link java.lang.annotations.Inherited}
- * annotation, include those elements that inherit the annotation from their superclasses.
- * Note that {@link java.lang.annotations.Inherited} only applies to classes (i.e. TypeElements).
- */
- @Override
- public Set<? extends Element> getElementsAnnotatedWith(TypeElement a)
- {
- if (a.getKind() != ElementKind.ANNOTATION_TYPE) {
- throw new IllegalArgumentException("Argument must represent an annotation type"); //$NON-NLS-1$
- }
- Binding annoBinding = ((TypeElementImpl)a)._binding;
- if (0 != (annoBinding.getAnnotationTagBits() & TagBits.AnnotationInherited)) {
- Set<Element> annotatedElements = new HashSet<Element>(_annoToUnit.getValues(a));
- // For all other root elements that are TypeElements, and for their recursively enclosed
- // types, add each element if it has a superclass are annotated with 'a'
- ReferenceBinding annoTypeBinding = (ReferenceBinding)((TypeElementImpl)a)._binding;
- for (TypeElement element : ElementFilter.typesIn(getRootElements())) {
- ReferenceBinding typeBinding = (ReferenceBinding)((TypeElementImpl)element)._binding;
- addAnnotatedElements(annoTypeBinding, typeBinding, annotatedElements);
- }
- return Collections.unmodifiableSet(annotatedElements);
- }
- return Collections.unmodifiableSet(_annoToUnit.getValues(a));
- }
-
- /**
- * For every type in types that is a class and that is annotated with anno, either directly or by inheritance,
- * add that type to result. Recursively descend on each types's child classes as well.
- * @param anno the compiler binding for an annotation type
- * @param types a set of types, not necessarily all classes
- * @param result must be a modifiable Set; will accumulate annotated classes
- */
- private void addAnnotatedElements(ReferenceBinding anno, ReferenceBinding type, Set<Element> result) {
- if (type.isClass()) {
- if (inheritsAnno(type, anno)) {
- result.add(_factory.newElement(type));
- }
- }
- for (ReferenceBinding element : type.memberTypes()) {
- addAnnotatedElements(anno, element, result);
- }
- }
-
- /**
- * Check whether an element has a superclass that is annotated with an @Inherited annotation.
- * @param element must be a class (not an interface, enum, etc.).
- * @param anno must be an annotation type, and must be @Inherited
- * @return true if element has a superclass that is annotated with anno
- */
- private boolean inheritsAnno(ReferenceBinding element, ReferenceBinding anno) {
- do {
- AnnotationBinding[] annos = element.getAnnotations();
- for (AnnotationBinding annoBinding : annos) {
- if (annoBinding.getAnnotationType() == anno) {
- // element is annotated with anno
- return true;
- }
- }
- } while (null != (element = element.superclass()));
- return false;
- }
-
- @Override
- public Set<? extends Element> getElementsAnnotatedWith(Class<? extends Annotation> a)
- {
- String canonicalName = a.getCanonicalName();
- if (canonicalName == null) {
- // null for anonymous and local classes or an array of those
- throw new IllegalArgumentException("Argument must represent an annotation type"); //$NON-NLS-1$
- }
- TypeElement annoType = _processingEnv.getElementUtils().getTypeElement(canonicalName);
- return getElementsAnnotatedWith(annoType);
- }
-
- @Override
- public Set<? extends Element> getRootElements()
- {
- if (_units == null) {
- return Collections.emptySet();
- }
- if (_rootElements == null) {
- Set<Element> elements = new HashSet<Element>(_units.length);
- for (CompilationUnitDeclaration unit : _units) {
- if (null == unit.scope || null == unit.scope.topLevelTypes)
- continue;
- for (SourceTypeBinding binding : unit.scope.topLevelTypes) {
- Element element = _factory.newElement(binding);
- if (null == element) {
- throw new IllegalArgumentException("Top-level type binding could not be converted to element: " + binding); //$NON-NLS-1$
- }
- elements.add(element);
- }
- }
- if (this._binaryTypes != null) {
- for (ReferenceBinding typeBinding : _binaryTypes) {
- TypeElement element = (TypeElement)_factory.newElement(typeBinding);
- if (null == element) {
- throw new IllegalArgumentException("Top-level type binding could not be converted to element: " + typeBinding); //$NON-NLS-1$
- }
- elements.add(element);
- }
- }
- _rootElements = elements;
- }
- return _rootElements;
- }
-
- @Override
- public boolean processingOver()
- {
- return _isLastRound;
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationMirrorImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationMirrorImpl.java
deleted file mode 100644
index 1a8eb288d4..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationMirrorImpl.java
+++ /dev/null
@@ -1,521 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.model;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.type.DeclaredType;
-import javax.lang.model.type.MirroredTypeException;
-import javax.lang.model.type.MirroredTypesException;
-import javax.lang.model.type.TypeMirror;
-
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-
-public class AnnotationMirrorImpl implements AnnotationMirror, InvocationHandler {
-
- public final BaseProcessingEnvImpl _env;
- public final AnnotationBinding _binding;
-
- /* package */ AnnotationMirrorImpl(BaseProcessingEnvImpl env, AnnotationBinding binding) {
- _env = env;
- _binding = binding;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof AnnotationMirrorImpl) {
- if (this._binding == null) {
- return ((AnnotationMirrorImpl) obj)._binding == null;
- }
- return equals(this._binding, ((AnnotationMirrorImpl) obj)._binding);
- }
- return false;
- }
-
- private static boolean equals(AnnotationBinding annotationBinding, AnnotationBinding annotationBinding2) {
- if (annotationBinding.getAnnotationType() != annotationBinding2.getAnnotationType()) return false;
- final ElementValuePair[] elementValuePairs = annotationBinding.getElementValuePairs();
- final ElementValuePair[] elementValuePairs2 = annotationBinding2.getElementValuePairs();
- final int length = elementValuePairs.length;
- if (length != elementValuePairs2.length) return false;
- loop: for (int i = 0; i < length; i++) {
- ElementValuePair pair = elementValuePairs[i];
- // loop on the given pair to make sure one will match
- for (int j = 0; j < length; j++) {
- ElementValuePair pair2 = elementValuePairs2[j];
- if (pair.binding == pair2.binding) {
- if (pair.value == null) {
- if (pair2.value == null) {
- continue loop;
- }
- return false;
- } else {
- if (pair2.value == null
- || !pair2.value.equals(pair.value)) {
- return false;
- }
- }
- continue loop;
- }
- }
- return false;
- }
- return true;
- }
-
- public DeclaredType getAnnotationType() {
- if (this._binding == null) {
- return _env.getFactory().getErrorType();
- }
- ReferenceBinding annoType = _binding.getAnnotationType();
- return _env.getFactory().newAnnotationType(annoType);
- }
-
- /**
- * @return all the members of this annotation mirror that have explicit values.
- * Default values are not included.
- */
- public Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValues() {
- if (this._binding == null) {
- return Collections.emptyMap();
- }
- ElementValuePair[] pairs = _binding.getElementValuePairs();
- Map<ExecutableElement, AnnotationValue> valueMap =
- new HashMap<ExecutableElement, AnnotationValue>(pairs.length);
- for (ElementValuePair pair : pairs) {
- MethodBinding method = pair.getMethodBinding();
- if (method == null) {
- // ideally we should be able to create a fake ExecuableElementImpl
- continue;
- }
- ExecutableElement e = new ExecutableElementImpl(_env, method);
- AnnotationValue v = new AnnotationValueImpl(_env, pair.getValue(), method.returnType);
- valueMap.put(e, v);
- }
- return Collections.unmodifiableMap(valueMap);
- }
-
- /**
- * {@see Elements#getElementValuesWithDefaults()}
- * @return all the members of this annotation mirror that have explicit or default
- * values.
- */
- public Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValuesWithDefaults() {
- if (this._binding == null) {
- return Collections.emptyMap();
- }
- ElementValuePair[] pairs = _binding.getElementValuePairs();
- ReferenceBinding annoType = _binding.getAnnotationType();
- Map<ExecutableElement, AnnotationValue> valueMap =
- new HashMap<ExecutableElement, AnnotationValue>();
- for (MethodBinding method : annoType.methods()) {
- // if binding is in ElementValuePair list, then get value from there
- boolean foundExplicitValue = false;
- for (int i = 0; i < pairs.length; ++i) {
- MethodBinding explicitBinding = pairs[i].getMethodBinding();
- if (method == explicitBinding) {
- ExecutableElement e = new ExecutableElementImpl(_env, explicitBinding);
- AnnotationValue v = new AnnotationValueImpl(_env, pairs[i].getValue(), explicitBinding.returnType);
- valueMap.put(e, v);
- foundExplicitValue = true;
- break;
- }
- }
- // else get default value if one exists
- if (!foundExplicitValue) {
- Object defaultVal = method.getDefaultValue();
- if (null != defaultVal) {
- ExecutableElement e = new ExecutableElementImpl(_env, method);
- AnnotationValue v = new AnnotationValueImpl(_env, defaultVal, method.returnType);
- valueMap.put(e, v);
- }
- }
- }
- return Collections.unmodifiableMap(valueMap);
- }
-
- public int hashCode() {
- if (this._binding == null) return this._env.hashCode();
- return this._binding.hashCode();
- }
-
- /*
- * Used by getAnnotation(), which returns a reflective proxy of the annotation class. When processors then
- * invoke methods such as value() on the annotation proxy, this method is called.
- * <p>
- * A challenge here is that the processor was not necessarily compiled against the same annotation
- * definition that the compiler is looking at right now, not to mention that the annotation itself
- * may be defective in source. So the actual type of the value may be quite different than the
- * type expected by the caller, which will result in a ClassCastException, which is ugly for the
- * processor to try to catch. So we try to catch and correct this type mismatch where possible.
- * <p>
- * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
- */
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- {
- if (this._binding == null) return null;
- final String methodName = method.getName();
- if ( args == null || args.length == 0 ) {
- if( methodName.equals("hashCode") ) { //$NON-NLS-1$
- return new Integer( hashCode() );
- }
- else if( methodName.equals("toString") ) { //$NON-NLS-1$
- return toString();
- }
- else if( methodName.equals("annotationType")) { //$NON-NLS-1$
- return proxy.getClass().getInterfaces()[0];
- }
- }
- else if ( args.length == 1 && methodName.equals("equals") ) { //$NON-NLS-1$
- return new Boolean( equals( args[0] ) );
- }
-
- // If it's not one of the above methods, it must be an annotation member, so it cannot take any arguments
- if ( args != null && args.length != 0 ) {
- throw new NoSuchMethodException("method " + method.getName() + formatArgs(args) + " does not exist on annotation " + toString()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- final MethodBinding methodBinding = getMethodBinding(methodName);
- if ( methodBinding == null ) {
- throw new NoSuchMethodException("method " + method.getName() + "() does not exist on annotation" + toString()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- Object actualValue = null;
- boolean foundMethod = false;
- ElementValuePair[] pairs = _binding.getElementValuePairs();
- for (ElementValuePair pair : pairs) {
- if (methodName.equals(new String(pair.getName()))) {
- actualValue = pair.getValue();
- foundMethod = true;
- break;
- }
- }
- if (!foundMethod) {
- // couldn't find explicit value; see if there's a default
- actualValue = methodBinding.getDefaultValue();
- }
- Class<?> expectedType = method.getReturnType();
- TypeBinding actualType = methodBinding.returnType;
- return getReflectionValue(actualValue, actualType, expectedType);
- }
-
- /*
- * (non-Javadoc)
- * Sun implementation shows the values. We avoid that here,
- * because getting the values is not idempotent.
- */
- @Override
- public String toString() {
- if (this._binding == null) {
- return "@any()"; //$NON-NLS-1$
- }
- return "@" + _binding.getAnnotationType().debugName(); //$NON-NLS-1$
- }
-
- /**
- * Used for constructing exception message text.
- * @return a string like "(a, b, c)".
- */
- 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(", "); //$NON-NLS-1$
- builder.append(args[i].getClass().getName());
- }
- builder.append(')');
- return builder.toString();
- }
-
- /**
- * Find a particular annotation member by name.
- * @return a compiler method binding, or null if no member was found.
- */
- private MethodBinding getMethodBinding(String name) {
- ReferenceBinding annoType = _binding.getAnnotationType();
- MethodBinding[] methods = annoType.getMethods(name.toCharArray());
- for (MethodBinding method : methods) {
- // annotation members have no parameters
- if (method.parameters.length == 0) {
- return method;
- }
- }
- return null;
- }
-
- /**
- * Convert an annotation member value from JDT into Reflection, and from whatever its actual type
- * is into whatever type the reflective invoker of a method is expecting.
- * <p>
- * Only certain types are permitted as member values. Specifically, a member must be a constant,
- * and must be either a primitive type, String, Class, an enum constant, an annotation, or an
- * array of any of those. Multidimensional arrays are not permitted.
- *
- * @param annoValue the value as represented by {@link ElementValuePair#getValue()}
- * @param actualType the return type of the corresponding {@link MethodBinding}
- * @param expectedType the type that the reflective method invoker is expecting
- * @return an object of the expected type representing the annotation member value,
- * or an appropriate dummy value (such as null) if no value is available
- */
- private Object getReflectionValue(Object actualValue, TypeBinding actualType, Class<?> expectedType)
- {
- if (null == expectedType) {
- // With no expected type, we can't even guess at a conversion
- return null;
- }
- if (null == actualValue) {
- // Return a type-appropriate equivalent of null
- return Factory.getMatchingDummyValue(expectedType);
- }
- if (expectedType.isArray()) {
- if (Class.class.equals(expectedType.getComponentType())) {
- // package Class[]-valued return as a MirroredTypesException
- if (actualType.isArrayType() && actualValue instanceof Object[] &&
- ((ArrayBinding)actualType).leafComponentType.erasure().id == TypeIds.T_JavaLangClass) {
- Object[] bindings = (Object[])actualValue;
- List<TypeMirror> mirrors = new ArrayList<TypeMirror>(bindings.length);
- for (int i = 0; i < bindings.length; ++i) {
- if (bindings[i] instanceof TypeBinding) {
- mirrors.add(_env.getFactory().newTypeMirror((TypeBinding)bindings[i]));
- }
- }
- throw new MirroredTypesException(mirrors);
- }
- // TODO: actual value is not a TypeBinding[]. Should we return a TypeMirror[] around an ErrorType?
- return null;
- }
- // Handle arrays of types other than Class, e.g., int[], MyEnum[], ...
- return convertJDTArrayToReflectionArray(actualValue, actualType, expectedType);
- }
- else if (Class.class.equals(expectedType)) {
- // package the Class-valued return as a MirroredTypeException
- if (actualValue instanceof TypeBinding) {
- TypeMirror mirror = _env.getFactory().newTypeMirror((TypeBinding)actualValue);
- throw new MirroredTypeException(mirror);
- }
- else {
- // TODO: actual value is not a TypeBinding. Should we return a TypeMirror around an ErrorType?
- return null;
- }
- }
- else {
- // Handle unitary values of type other than Class, e.g., int, MyEnum, ...
- return convertJDTValueToReflectionType(actualValue, actualType, expectedType);
- }
- }
-
- /**
- * Convert an array of JDT types as obtained from ElementValuePair.getValue()
- * (e.g., an Object[] containing IntConstant elements) to the type expected by
- * a reflective method invocation (e.g., int[]).
- * <p>
- * This does not handle arrays of Class, but it does handle primitives, enum constants,
- * and types such as String.
- * @param jdtValue the actual value returned by ElementValuePair.getValue() or MethodBinding.getDefault()
- * @param jdtType the return type of the annotation method binding
- * @param expectedType the type that the invoker of the method is expecting; must be an array type
- * @return an Object which is, e.g., an int[]; or null, if an array cannot be created.
- */
- private Object convertJDTArrayToReflectionArray(Object jdtValue, TypeBinding jdtType, Class<?> expectedType)
- {
- assert null != expectedType && expectedType.isArray();
- if (!jdtType.isArrayType() || !(jdtValue instanceof Object[])) {
- // TODO: wrap solo element into one-length array
- return null;
- }
- TypeBinding jdtLeafType = jdtType.leafComponentType();
- Object[] jdtArray = (Object[])jdtValue;
- Class<?> expectedLeafType = expectedType.getComponentType();
- final int length = jdtArray.length;
- final Object returnArray = Array.newInstance(expectedLeafType, length);
- for (int i = 0; i < length; ++i) {
- Object jdtElementValue = jdtArray[i];
- if (expectedLeafType.isPrimitive() || String.class.equals(expectedLeafType)) {
- if (jdtElementValue instanceof Constant) {
- if (boolean.class.equals(expectedLeafType)) {
- Array.setBoolean(returnArray, i, ((Constant)jdtElementValue).booleanValue());
- }
- else if (byte.class.equals(expectedLeafType)) {
- Array.setByte(returnArray, i, ((Constant)jdtElementValue).byteValue());
- }
- else if (char.class.equals(expectedLeafType)) {
- Array.setChar(returnArray, i, ((Constant)jdtElementValue).charValue());
- }
- else if (double.class.equals(expectedLeafType)) {
- Array.setDouble(returnArray, i, ((Constant)jdtElementValue).doubleValue());
- }
- else if (float.class.equals(expectedLeafType)) {
- Array.setFloat(returnArray, i, ((Constant)jdtElementValue).floatValue());
- }
- else if (int.class.equals(expectedLeafType)) {
- Array.setInt(returnArray, i, ((Constant)jdtElementValue).intValue());
- }
- else if (long.class.equals(expectedLeafType)) {
- Array.setLong(returnArray, i, ((Constant)jdtElementValue).longValue());
- }
- else if (short.class.equals(expectedLeafType)) {
- Array.setShort(returnArray, i, ((Constant)jdtElementValue).shortValue());
- }
- else if (String.class.equals(expectedLeafType)) {
- Array.set(returnArray, i, ((Constant)jdtElementValue).stringValue());
- }
- }
- else {
- // Primitive or string is expected, but our actual value cannot be coerced into one.
- // TODO: if the actual value is an array of primitives, should we unpack the first one?
- Factory.setArrayMatchingDummyValue(returnArray, i, expectedLeafType);
- }
- }
- else if (expectedLeafType.isEnum()) {
- Object returnVal = null;
- if (jdtLeafType != null && jdtLeafType.isEnum() && jdtElementValue instanceof FieldBinding) {
- FieldBinding binding = (FieldBinding)jdtElementValue;
- try {
- Field returnedField = null;
- returnedField = expectedLeafType.getField( new String(binding.name) );
- if (null != returnedField) {
- returnVal = returnedField.get(null);
- }
- }
- catch (NoSuchFieldException nsfe) {
- // return null
- }
- catch (IllegalAccessException iae) {
- // return null
- }
- }
- Array.set(returnArray, i, returnVal);
- }
- else if (expectedLeafType.isAnnotation()) {
- // member value is expected to be an annotation type. Wrap it in an Annotation proxy.
- Object returnVal = null;
- if (jdtLeafType.isAnnotationType() && jdtElementValue instanceof AnnotationBinding) {
- AnnotationMirrorImpl annoMirror =
- (AnnotationMirrorImpl)_env.getFactory().newAnnotationMirror((AnnotationBinding)jdtElementValue);
- returnVal = Proxy.newProxyInstance(expectedLeafType.getClassLoader(),
- new Class[]{ expectedLeafType }, annoMirror );
- }
- Array.set(returnArray, i, returnVal);
- }
- else {
- Array.set(returnArray, i, null);
- }
- }
- return returnArray;
- }
-
- /**
- * Convert a JDT annotation value as obtained from ElementValuePair.getValue()
- * (e.g., IntConstant, FieldBinding, etc.) to the type expected by a reflective
- * method invocation (e.g., int, an enum constant, etc.).
- * @return a value of type {@code expectedType}, or a dummy value of that type if
- * the actual value cannot be converted.
- */
- private Object convertJDTValueToReflectionType(Object jdtValue, TypeBinding actualType, Class<?> expectedType) {
- if (expectedType.isPrimitive() || String.class.equals(expectedType)) {
- if (jdtValue instanceof Constant) {
- if (boolean.class.equals(expectedType)) {
- return ((Constant)jdtValue).booleanValue();
- }
- else if (byte.class.equals(expectedType)) {
- return ((Constant)jdtValue).byteValue();
- }
- else if (char.class.equals(expectedType)) {
- return ((Constant)jdtValue).charValue();
- }
- else if (double.class.equals(expectedType)) {
- return ((Constant)jdtValue).doubleValue();
- }
- else if (float.class.equals(expectedType)) {
- return ((Constant)jdtValue).floatValue();
- }
- else if (int.class.equals(expectedType)) {
- return ((Constant)jdtValue).intValue();
- }
- else if (long.class.equals(expectedType)) {
- return ((Constant)jdtValue).longValue();
- }
- else if (short.class.equals(expectedType)) {
- return ((Constant)jdtValue).shortValue();
- }
- else if (String.class.equals(expectedType)) {
- return ((Constant)jdtValue).stringValue();
- }
- }
- // Primitive or string is expected, but our actual value cannot be coerced into one.
- // TODO: if the actual value is an array of primitives, should we unpack the first one?
- return Factory.getMatchingDummyValue(expectedType);
- }
- else if (expectedType.isEnum()) {
- Object returnVal = null;
- if (actualType != null && actualType.isEnum() && jdtValue instanceof FieldBinding) {
-
- FieldBinding binding = (FieldBinding)jdtValue;
- try {
- Field returnedField = null;
- returnedField = expectedType.getField( new String(binding.name) );
- if (null != returnedField) {
- returnVal = returnedField.get(null);
- }
- }
- catch (NoSuchFieldException nsfe) {
- // return null
- }
- catch (IllegalAccessException iae) {
- // return null
- }
- }
- return null == returnVal ? Factory.getMatchingDummyValue(expectedType) : returnVal;
- }
- else if (expectedType.isAnnotation()) {
- // member value is expected to be an annotation type. Wrap it in an Annotation proxy.
- if (actualType.isAnnotationType() && jdtValue instanceof AnnotationBinding) {
- AnnotationMirrorImpl annoMirror =
- (AnnotationMirrorImpl)_env.getFactory().newAnnotationMirror((AnnotationBinding)jdtValue);
- return Proxy.newProxyInstance(expectedType.getClassLoader(),
- new Class[]{ expectedType }, annoMirror );
- }
- else {
- // No way to cast a non-annotation value to an annotation type; return null to caller
- return null;
- }
- }
- else {
- return Factory.getMatchingDummyValue(expectedType);
- }
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationValueImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationValueImpl.java
deleted file mode 100644
index 36a93296d1..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/AnnotationValueImpl.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.AnnotationValueVisitor;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.TypeMirror;
-
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.impl.DoubleConstant;
-import org.eclipse.jdt.internal.compiler.impl.FloatConstant;
-import org.eclipse.jdt.internal.compiler.impl.LongConstant;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.problem.ShouldNotImplement;
-
-public class AnnotationValueImpl implements AnnotationValue, TypeIds {
-
- /*
- * Additions to T_* constants in TypeIds.
- */
- private static final int T_AnnotationMirror = -1;
- private static final int T_EnumConstant = -2;
- private static final int T_ClassObject = -3;
- private static final int T_ArrayType = -4;
-
- private final BaseProcessingEnvImpl _env;
-
- /**
- * The annotation value, as it would be returned by
- * {@link #getValue()}. For instance, an Integer (for an int
- * constant), a VariableElement (for an enum constant), or
- * a List<AnnotationValueImpl> containing multiple such (for an array type).
- */
- private final Object _value;
-
- /**
- * The type stored in _value, represented as a T_* value from {@link TypeIds}
- * or one of the additional T_* values defined in this class.
- */
- private final int _kind;
-
- /**
- * @param value
- * The JDT representation of a compile-time constant. See
- * {@link ElementValuePair#getValue()} for possible object types:
- * <ul>
- * <li>{@link org.eclipse.jdt.internal.compiler.impl.Constant} for member
- * of primitive type or String</li>
- * <li>{@link TypeBinding} for a member value of type
- * {@link java.lang.Class}</li>
- * <li>{@link FieldBinding} for an enum constant</li>
- * <li>{@link AnnotationBinding} for an annotation instance</li>
- * <li><code>Object[]</code> for a member value of array type, where the
- * array entries are one of the above</li>
- * </ul>
- * @param type
- * The JDT representation of the type of the constant, as determined
- * by the return type of the element. This is needed because the type
- * of the value may have been widened (e.g., byte to int) by the compiler
- * and we need to call the proper visitor. This is used only for base types.
- * If it is null or not a BaseTypeBinding, it is ignored and the type is
- * determined from the type of the value.
- */
- public AnnotationValueImpl(BaseProcessingEnvImpl env, Object value, TypeBinding type) {
- _env = env;
- int kind[] = new int[1];
- if (type == null) {
- _value = convertToMirrorType(value, type, kind);
- _kind = kind[0];
- } else if (type.isArrayType()) {
- List<AnnotationValue> convertedValues = null;
- TypeBinding valueType = ((ArrayBinding)type).elementsType();
- if (value instanceof Object[]) {
- Object[] values = (Object[])value;
- convertedValues = new ArrayList<AnnotationValue>(values.length);
- for (Object oneValue : values) {
- convertedValues.add(new AnnotationValueImpl(_env, oneValue, valueType));
- }
- } else {
- convertedValues = new ArrayList<AnnotationValue>(1);
- convertedValues.add(new AnnotationValueImpl(_env, value, valueType));
- }
- _value = Collections.unmodifiableList(convertedValues);
- _kind = T_ArrayType;
- } else {
- _value = convertToMirrorType(value, type, kind);
- _kind = kind[0];
- }
- }
-
- /**
- * Convert the JDT representation of a single constant into its javax.lang.model
- * representation. For instance, convert a StringConstant into a String, or
- * a FieldBinding into a VariableElement. This does not handle the case where
- * value is an Object[].
- * @param value the JDT object
- * @param type the return type of the annotation member. If null or not a
- * BaseTypeBinding, this is ignored and the value is inspected to determine type.
- * @param kind an int array whose first element will be set to the type of the
- * converted object, represented with T_* values from TypeIds or from this class.
- * @return
- */
- private Object convertToMirrorType(Object value, TypeBinding type, int kind[]) {
- if (type == null) {
- kind[0] = TypeIds.T_JavaLangString;
- return "<error>"; //$NON-NLS-1$
- } else if (type instanceof BaseTypeBinding || type.id == TypeIds.T_JavaLangString) {
- if (value == null) {
- if (type instanceof BaseTypeBinding
- || type.id == TypeIds.T_JavaLangString) {
- // return a string with error in it to reflect a value that could not be resolved
- kind[0] = TypeIds.T_JavaLangString;
- return "<error>"; //$NON-NLS-1$
- } else if (type.isAnnotationType()) {
- kind[0] = T_AnnotationMirror;
- return _env.getFactory().newAnnotationMirror(null);
- }
- } else if (value instanceof Constant) {
- if (type instanceof BaseTypeBinding) {
- kind[0] = ((BaseTypeBinding)type).id;
- }
- else if (type.id == TypeIds.T_JavaLangString) {
- kind[0] = ((Constant)value).typeID();
- } else {
- // error case
- kind[0] = TypeIds.T_JavaLangString;
- return "<error>"; //$NON-NLS-1$
- }
- switch (kind[0]) {
- case T_boolean:
- return ((Constant)value).booleanValue();
- case T_byte:
- return ((Constant)value).byteValue();
- case T_char:
- return ((Constant)value).charValue();
- case T_double:
- return ((Constant)value).doubleValue();
- case T_float:
- return ((Constant)value).floatValue();
- case T_int:
- try {
- if (value instanceof LongConstant
- || value instanceof DoubleConstant
- || value instanceof FloatConstant) {
- // error case
- kind[0] = TypeIds.T_JavaLangString;
- return "<error>"; //$NON-NLS-1$
- }
- return ((Constant)value).intValue();
- } catch (ShouldNotImplement e) {
- kind[0] = TypeIds.T_JavaLangString;
- return "<error>"; //$NON-NLS-1$
- }
- case T_JavaLangString:
- return ((Constant)value).stringValue();
- case T_long:
- return ((Constant)value).longValue();
- case T_short:
- return ((Constant)value).shortValue();
- }
- }
- } else if (type.isEnum()) {
- if (value instanceof FieldBinding) {
- kind[0] = T_EnumConstant;
- return (VariableElement) _env.getFactory().newElement((FieldBinding) value);
- } else {
- kind[0] = TypeIds.T_JavaLangString;
- return "<error>"; //$NON-NLS-1$
- }
- } else if (type.isAnnotationType()) {
- if (value instanceof AnnotationBinding) {
- kind[0] = T_AnnotationMirror;
- return _env.getFactory().newAnnotationMirror((AnnotationBinding) value);
- }
- } else if (value instanceof TypeBinding) {
- kind[0] = T_ClassObject;
- return _env.getFactory().newTypeMirror((TypeBinding) value);
- }
- // error case
- kind[0] = TypeIds.T_JavaLangString;
- return "<error>"; //$NON-NLS-1$
- }
-
- @SuppressWarnings("unchecked") // Need to cast Object _value to a List<AnnotationValue>
- @Override
- public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
- switch (_kind) {
- case TypeIds.T_boolean:
- return v.visitBoolean((Boolean)_value, p);
- case TypeIds.T_byte:
- return v.visitByte((Byte)_value, p);
- case TypeIds.T_char:
- return v.visitChar((Character)_value, p);
- case TypeIds.T_double:
- return v.visitDouble((Double)_value, p);
- case TypeIds.T_float:
- return v.visitFloat((Float)_value, p);
- case TypeIds.T_int:
- return v.visitInt((Integer)_value, p);
- case TypeIds.T_JavaLangString:
- return v.visitString((String)_value, p);
- case TypeIds.T_long:
- return v.visitLong((Long)_value, p);
- case TypeIds.T_short:
- return v.visitShort((Short)_value, p);
- case T_EnumConstant:
- return v.visitEnumConstant((VariableElement)_value, p);
- case T_ClassObject:
- return v.visitType((TypeMirror)_value, p);
- case T_AnnotationMirror:
- return v.visitAnnotation((AnnotationMirror)_value, p);
- case T_ArrayType:
- return v.visitArray((List<AnnotationValue>)_value, p);
- default:
- return null;
- }
- }
-
- @Override
- public Object getValue() {
- return _value;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof AnnotationValueImpl) {
- return this._value.equals(((AnnotationValueImpl) obj)._value);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return this._value.hashCode() + this._kind;
- }
-
- @Override
- public String toString() {
- if (null == _value) {
- return "null"; //$NON-NLS-1$
- }
- return _value.toString();
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ArrayTypeImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ArrayTypeImpl.java
deleted file mode 100644
index d7db6457b7..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ArrayTypeImpl.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.compiler.apt.model;
-
-import javax.lang.model.type.ArrayType;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.type.TypeVisitor;
-
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-
-/**
- * Implementation of ArrayType, which represents an array of some type.
- */
-public class ArrayTypeImpl extends TypeMirrorImpl implements ArrayType {
-
- ArrayTypeImpl(BaseProcessingEnvImpl env, ArrayBinding binding) {
- super(env, binding);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.ArrayType#getComponentType()
- */
- @Override
- public TypeMirror getComponentType() {
- return _env.getFactory().newTypeMirror(((ArrayBinding)_binding).elementsType());
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.TypeMirror#accept(javax.lang.model.type.TypeVisitor, java.lang.Object)
- */
- @Override
- public <R, P> R accept(TypeVisitor<R, P> v, P p) {
- return v.visitArray(this, p);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.TypeMirror#getKind()
- */
- @Override
- public TypeKind getKind() {
- return TypeKind.ARRAY;
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/DeclaredTypeImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/DeclaredTypeImpl.java
deleted file mode 100644
index 44def0365e..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/DeclaredTypeImpl.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 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.internal.compiler.apt.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.type.DeclaredType;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.type.TypeVisitor;
-
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-
-/**
- * Implementation of DeclaredType, which refers to a particular usage or instance of a type.
- * Contrast with {@link TypeElement}, which is an element that potentially defines a family
- * of DeclaredTypes.
- */
-public class DeclaredTypeImpl extends TypeMirrorImpl implements DeclaredType {
-
- private final ElementKind _elementKindHint;
-
- /* package */ DeclaredTypeImpl(BaseProcessingEnvImpl env, ReferenceBinding binding) {
- super(env, binding);
- _elementKindHint = null;
- }
-
- /**
- * Create a DeclaredType that knows in advance what kind of element to produce from asElement().
- * This is useful in the case where the type binding is to an unresolved type, but we know
- * from context what type it is - e.g., an annotation type.
- */
- /* package */ DeclaredTypeImpl(BaseProcessingEnvImpl env, ReferenceBinding binding, ElementKind elementKindHint) {
- super(env, binding);
- _elementKindHint = elementKindHint;
- }
-
- @Override
- public Element asElement() {
- // The JDT compiler does not distinguish between type elements and declared types
- return _env.getFactory().newElement((ReferenceBinding)_binding, _elementKindHint);
- }
-
- @Override
- public TypeMirror getEnclosingType() {
- ReferenceBinding binding = (ReferenceBinding)_binding;
- ReferenceBinding enclosingType = binding.enclosingType();
- if (enclosingType != null) return _env.getFactory().newDeclaredType(enclosingType);
- return _env.getFactory().getNoType(TypeKind.NONE);
- }
-
- /*
- * (non-Javadoc)
- * @see javax.lang.model.type.DeclaredType#getTypeArguments()
- * @see javax.lang.model.element.TypeElement#getTypeParameters().
- */
- @Override
- public List<? extends TypeMirror> getTypeArguments() {
- ReferenceBinding binding = (ReferenceBinding)_binding;
- if (binding.isParameterizedType()) {
- ParameterizedTypeBinding ptb = (ParameterizedTypeBinding)_binding;
- TypeBinding[] arguments = ptb.arguments;
- int length = arguments == null ? 0 : arguments.length;
- if (length == 0) return Collections.emptyList();
- List<TypeMirror> args = new ArrayList<TypeMirror>(length);
- for (TypeBinding arg : arguments) {
- args.add(_env.getFactory().newTypeMirror(arg));
- }
- return Collections.unmodifiableList(args);
- }
- if (binding.isGenericType()) {
- TypeVariableBinding[] typeVariables = binding.typeVariables();
- List<TypeMirror> args = new ArrayList<TypeMirror>(typeVariables.length);
- for (TypeBinding arg : typeVariables) {
- args.add(_env.getFactory().newTypeMirror(arg));
- }
- return Collections.unmodifiableList(args);
- }
- return Collections.emptyList();
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.TypeMirror#accept(javax.lang.model.type.TypeVisitor, java.lang.Object)
- */
- @Override
- public <R, P> R accept(TypeVisitor<R, P> v, P p) {
- return v.visitDeclared(this, p);
- }
-
- @Override
- public TypeKind getKind() {
- return TypeKind.DECLARED;
- }
-
- @Override
- public String toString() {
- return new String(_binding.readableName());
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementImpl.java
deleted file mode 100644
index 92ec14b3da..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementImpl.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.model;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Proxy;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.Elements;
-
-import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-
-/**
- * Element represents any defined Java language element - a package,
- * a method, a class or interface. Contrast with DeclaredType.
- */
-public abstract class ElementImpl
- implements javax.lang.model.element.Element, IElementInfo
-{
- public final BaseProcessingEnvImpl _env;
- public final Binding _binding;
-
- protected ElementImpl(BaseProcessingEnvImpl env, Binding binding) {
- _env = env;
- _binding = binding;
- }
-
- @Override
- public TypeMirror asType() {
- return _env.getFactory().newTypeMirror(_binding);
- }
-
- @SuppressWarnings("unchecked") // for cast of newProxyInstance() to A
- @Override
- public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
- AnnotationBinding[] annoInstances = getAnnotationBindings();
- if( annoInstances == null || annoInstances.length == 0 || annotationClass == null )
- return null;
-
- String annoTypeName = annotationClass.getName();
- if( annoTypeName == null ) return null;
- annoTypeName = annoTypeName.replace('$', '.');
- for( AnnotationBinding annoInstance : annoInstances) {
- if (annoInstance == null)
- continue;
- ReferenceBinding binding = annoInstance.getAnnotationType();
- if ( binding != null && binding.isAnnotationType() ) {
- char[] qName;
- if (binding.isMemberType()) {
- qName = CharOperation.concatWith(binding.enclosingType().compoundName, binding.sourceName, '.');
- CharOperation.replace(qName, '$', '.');
- } else {
- qName = CharOperation.concatWith(binding.compoundName, '.');
- }
- if( annoTypeName.equals(new String(qName)) ){
- AnnotationMirrorImpl annoMirror =
- (AnnotationMirrorImpl)_env.getFactory().newAnnotationMirror(annoInstance);
- return (A)Proxy.newProxyInstance(annotationClass.getClassLoader(),
- new Class[]{ annotationClass }, annoMirror );
- }
- }
- }
- return null;
- }
-
- /**
- * @return the set of compiler annotation bindings on this element
- */
- protected abstract AnnotationBinding[] getAnnotationBindings();
-
- @Override
- public List<? extends AnnotationMirror> getAnnotationMirrors() {
- return _env.getFactory().getAnnotationMirrors(getAnnotationBindings());
- }
-
- @Override
- public Set<Modifier> getModifiers() {
- // Most subclasses implement this; this default is appropriate for
- // PackageElement and TypeParameterElement.
- return Collections.emptySet();
- }
-
- @Override
- public Name getSimpleName() {
- return new NameImpl(_binding.shortReadableName());
- }
-
- @Override
- public int hashCode() {
- return _binding.hashCode();
- }
-
- // TODO: equals() implemented as == of JDT bindings. Valid within
- // a single Compiler instance; breaks in IDE if processors cache values.
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final ElementImpl other = (ElementImpl) obj;
- if (_binding == null) {
- if (other._binding != null)
- return false;
- } else if (_binding != other._binding)
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return _binding.toString();
- }
-
- @Override
- public String getFileName() {
- // Subclasses should override and return something of value
- return null;
- }
-
- /**
- * @return the package containing this element. The package of a PackageElement is itself.
- * @see javax.lang.model.util.Elements#getPackageOf(javax.lang.model.element.Element)
- */
- abstract /* package */ PackageElement getPackage();
-
- /**
- * Subclassed by VariableElementImpl, TypeElementImpl, and ExecutableElementImpl.
- * This base implementation suffices for other types.
- * @see Elements#hides()
- * @return true if this element hides {@code hidden}
- */
- public boolean hides(Element hidden)
- {
- return false;
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl.java
deleted file mode 100644
index 67baade031..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl.java
+++ /dev/null
@@ -1,671 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 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.internal.compiler.apt.model;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.util.Elements;
-
-import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Javadoc;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodVerifier;
-import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-
-/**
- * Utilities for working with language elements.
- * There is one of these for every ProcessingEnvironment.
- */
-public class ElementsImpl implements Elements {
-
- // Used for parsing Javadoc comments: matches initial delimiter, followed by whitespace
- private static final Pattern INITIAL_DELIMITER = Pattern.compile("^\\s*/\\*+"); //$NON-NLS-1$
-
- private final BaseProcessingEnvImpl _env;
-
- /*
- * The processing env creates and caches an ElementsImpl. Other clients should
- * not create their own; they should ask the env for it.
- */
- public ElementsImpl(BaseProcessingEnvImpl env) {
- _env = env;
- }
-
- /**
- * Return all the annotation mirrors on this element, including inherited annotations.
- * Annotations are inherited only if the annotation type is meta-annotated with @Inherited,
- * and the annotation is on a class: e.g., annotations are not inherited for interfaces, methods,
- * or fields.
- */
- @Override
- public List<? extends AnnotationMirror> getAllAnnotationMirrors(Element e) {
- // if e is a class, walk up its superclass hierarchy looking for @Inherited annotations not already in the list
- if (e.getKind() == ElementKind.CLASS && e instanceof TypeElementImpl) {
- List<AnnotationBinding> annotations = new ArrayList<AnnotationBinding>();
- // A class can only have one annotation of a particular annotation type.
- Set<ReferenceBinding> annotationTypes = new HashSet<ReferenceBinding>();
- ReferenceBinding binding = (ReferenceBinding)((TypeElementImpl)e)._binding;
- while (null != binding) {
- for (AnnotationBinding annotation : binding.getAnnotations()) {
- if (annotation == null) continue;
- ReferenceBinding annotationType = annotation.getAnnotationType();
- if (!annotationTypes.contains(annotationType)) {
- annotationTypes.add(annotationType);
- annotations.add(annotation);
- }
- }
- binding = binding.superclass();
- }
- List<AnnotationMirror> list = new ArrayList<AnnotationMirror>(annotations.size());
- for (AnnotationBinding annotation : annotations) {
- list.add(_env.getFactory().newAnnotationMirror(annotation));
- }
- return Collections.unmodifiableList(list);
- }
- else {
- return e.getAnnotationMirrors();
- }
- }
-
- /**
- * Compute a list of all the visible entities in this type. Specifically:
- * <ul>
- * <li>All nested types declared in this type, including interfaces and enums</li>
- * <li>All protected or public nested types declared in this type's superclasses
- * and superinterfaces, that are not hidden by a name collision</li>
- * <li>All methods declared in this type, including constructors but not
- * including static or instance initializers, and including abstract
- * methods and unimplemented methods declared in interfaces</li>
- * <li>All protected or public methods declared in this type's superclasses,
- * that are not overridden by another method, but not including constructors
- * or initializers. Includes abstract methods and methods declared in
- * superinterfaces but not implemented</li>
- * <li>All fields declared in this type, including constants</li>
- * <li>All non-private fields declared in this type's superclasses and
- * superinterfaces, that are not hidden by a name collision.</li>
- * </ul>
- */
- @Override
- public List<? extends Element> getAllMembers(TypeElement type) {
- if (null == type || !(type instanceof TypeElementImpl)) {
- return Collections.emptyList();
- }
- ReferenceBinding binding = (ReferenceBinding)((TypeElementImpl)type)._binding;
- // Map of element simple name to binding
- Map<String, ReferenceBinding> types = new HashMap<String, ReferenceBinding>();
- // Javac implementation does not take field name collisions into account
- List<FieldBinding> fields = new ArrayList<FieldBinding>();
- // For methods, need to compare parameters, not just names
- Map<String, Set<MethodBinding>> methods = new HashMap<String, Set<MethodBinding>>();
- Set<ReferenceBinding> superinterfaces = new LinkedHashSet<ReferenceBinding>();
- boolean ignoreVisibility = true;
- while (null != binding) {
- addMembers(binding, ignoreVisibility, types, fields, methods);
- Set<ReferenceBinding> newfound = new LinkedHashSet<ReferenceBinding>();
- collectSuperInterfaces(binding, superinterfaces, newfound);
- for (ReferenceBinding superinterface : newfound) {
- addMembers(superinterface, false, types, fields, methods);
- }
- superinterfaces.addAll(newfound);
- binding = binding.superclass();
- ignoreVisibility = false;
- }
- List<Element> allMembers = new ArrayList<Element>();
- for (ReferenceBinding nestedType : types.values()) {
- allMembers.add(_env.getFactory().newElement(nestedType));
- }
- for (FieldBinding field : fields) {
- allMembers.add(_env.getFactory().newElement(field));
- }
- for (Set<MethodBinding> sameNamedMethods : methods.values()) {
- for (MethodBinding method : sameNamedMethods) {
- allMembers.add(_env.getFactory().newElement(method));
- }
- }
- return allMembers;
- }
-
- /**
- * Recursively depth-first walk the tree of superinterfaces of a type, collecting
- * all the unique superinterface bindings. (Note that because of generics, a type may
- * have multiple unique superinterface bindings corresponding to the same interface
- * declaration.)
- * @param existing bindings already in this set will not be re-added or recursed into
- * @param newfound newly found bindings will be added to this set
- */
- private void collectSuperInterfaces(ReferenceBinding type,
- Set<ReferenceBinding> existing, Set<ReferenceBinding> newfound) {
- for (ReferenceBinding superinterface : type.superInterfaces()) {
- if (!existing.contains(superinterface) && !newfound.contains(superinterface)) {
- newfound.add(superinterface);
- collectSuperInterfaces(superinterface, existing, newfound);
- }
- }
- }
-
- /**
- * Add the members of a type to the maps of subtypes, fields, and methods. Add only those
- * which are non-private and which are not overridden by an already-discovered member.
- * For fields, add them all; javac implementation does not take field hiding into account.
- * @param binding the type whose members will be added to the lists
- * @param ignoreVisibility if true, all members will be added regardless of whether they
- * are private, overridden, etc.
- * @param types a map of type simple name to type binding
- * @param fields a list of field bindings
- * @param methods a map of method simple name to set of method bindings with that name
- */
- private void addMembers(ReferenceBinding binding, boolean ignoreVisibility, Map<String, ReferenceBinding> types,
- List<FieldBinding> fields, Map<String, Set<MethodBinding>> methods)
- {
- for (ReferenceBinding subtype : binding.memberTypes()) {
- if (ignoreVisibility || !subtype.isPrivate()) {
- String name = new String(subtype.sourceName());
- if (null == types.get(name)) {
- types.put(name, subtype);
- }
- }
- }
- for (FieldBinding field : binding.fields()) {
- if (ignoreVisibility || !field.isPrivate()) {
- fields.add(field);
- }
- }
- for (MethodBinding method : binding.methods()) {
- if (!method.isSynthetic() && (ignoreVisibility || (!method.isPrivate() && !method.isConstructor()))) {
- String methodName = new String(method.selector);
- Set<MethodBinding> sameNamedMethods = methods.get(methodName);
- if (null == sameNamedMethods) {
- // New method name. Create a set for it and add it to the list.
- // We don't expect many methods with same name, so only 4 slots:
- sameNamedMethods = new HashSet<MethodBinding>(4);
- methods.put(methodName, sameNamedMethods);
- sameNamedMethods.add(method);
- }
- else {
- // We already have a method with this name. Is this method overridden?
- boolean unique = true;
- if (!ignoreVisibility) {
- for (MethodBinding existing : sameNamedMethods) {
- MethodVerifier verifier = _env.getLookupEnvironment().methodVerifier();
- if (verifier.doesMethodOverride(existing, method)) {
- unique = false;
- break;
- }
- }
- }
- if (unique) {
- sameNamedMethods.add(method);
- }
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Elements#getBinaryName(javax.lang.model.element.TypeElement)
- */
- @Override
- public Name getBinaryName(TypeElement type) {
- TypeElementImpl typeElementImpl = (TypeElementImpl) type;
- ReferenceBinding referenceBinding = (ReferenceBinding) typeElementImpl._binding;
- return new NameImpl(
- CharOperation.replaceOnCopy(referenceBinding.constantPoolName(), '/', '.'));
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Elements#getConstantExpression(java.lang.Object)
- */
- @Override
- public String getConstantExpression(Object value) {
- if (!(value instanceof Integer)
- && !(value instanceof Byte)
- && !(value instanceof Float)
- && !(value instanceof Double)
- && !(value instanceof Long)
- && !(value instanceof Short)
- && !(value instanceof Character)
- && !(value instanceof String)
- && !(value instanceof Boolean)) {
- throw new IllegalArgumentException("Not a valid wrapper type : " + value.getClass()); //$NON-NLS-1$
- }
- if (value instanceof Character) {
- StringBuilder builder = new StringBuilder();
- builder.append('\'').append(value).append('\'');
- return String.valueOf(builder);
- }
- return String.valueOf(value);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Elements#getDocComment(javax.lang.model.element.Element)
- */
- @Override
- public String getDocComment(Element e) {
- char[] unparsed = getUnparsedDocComment(e);
- return formatJavadoc(unparsed);
- }
-
- /**
- * Return the entire javadoc comment on e, including the comment characters and whitespace
- * @param e an Element of any sort, possibly with a javadoc comment.
- * @return a String, or null if the comment is not available
- */
- private char[] getUnparsedDocComment(Element e)
- {
- Javadoc javadoc = null;
- ReferenceContext referenceContext = null;
- switch(e.getKind()) {
- case ANNOTATION_TYPE :
- case CLASS :
- case ENUM :
- case INTERFACE :
- TypeElementImpl typeElementImpl = (TypeElementImpl) e;
- ReferenceBinding referenceBinding = (ReferenceBinding)typeElementImpl._binding;
- if (referenceBinding instanceof SourceTypeBinding) {
- SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) referenceBinding;
- referenceContext = sourceTypeBinding.scope.referenceContext;
- javadoc = ((TypeDeclaration) referenceContext).javadoc;
- }
- break;
- case PACKAGE :
- // might need to handle javadoc of package-info.java file
- PackageElementImpl packageElementImpl = (PackageElementImpl) e;
- PackageBinding packageBinding = (PackageBinding) packageElementImpl._binding;
- char[][] compoundName = CharOperation.arrayConcat(packageBinding.compoundName, TypeConstants.PACKAGE_INFO_NAME);
- ReferenceBinding type = this._env.getLookupEnvironment().getType(compoundName);
- if (type != null && type.isValidBinding() && (type instanceof SourceTypeBinding)) {
- SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) type;
- referenceContext = sourceTypeBinding.scope.referenceContext;
- javadoc = ((TypeDeclaration) referenceContext).javadoc;
- }
- break;
- case CONSTRUCTOR :
- case METHOD :
- ExecutableElementImpl executableElementImpl = (ExecutableElementImpl) e;
- MethodBinding methodBinding = (MethodBinding) executableElementImpl._binding;
- AbstractMethodDeclaration sourceMethod = methodBinding.sourceMethod();
- if (sourceMethod != null) {
- javadoc = sourceMethod.javadoc;
- referenceContext = sourceMethod;
- }
- break;
- case ENUM_CONSTANT :
- case FIELD :
- VariableElementImpl variableElementImpl = (VariableElementImpl) e;
- FieldBinding fieldBinding = (FieldBinding) variableElementImpl._binding;
- FieldDeclaration sourceField = fieldBinding.sourceField();
- if (sourceField != null) {
- javadoc = sourceField.javadoc;
- if (fieldBinding.declaringClass instanceof SourceTypeBinding) {
- SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) fieldBinding.declaringClass;
- referenceContext = sourceTypeBinding.scope.referenceContext;
- }
- }
- }
- if (javadoc != null && referenceContext != null) {
- char[] contents = referenceContext.compilationResult().getCompilationUnit().getContents();
- if (contents != null) {
- return CharOperation.subarray(contents, javadoc.sourceStart, javadoc.sourceEnd - 1);
- }
- }
- return null;
- }
-
- /**
- * Strip the comment characters from a javadoc comment. Assume the comment is already
- * missing its closing delimiter.
- *
- * Javac's behavior with regard to tab expansion and trimming of whitespace and
- * asterisks is bizarre and undocumented. We do our best here to emulate it.
- */
- private static String formatJavadoc(char[] unparsed)
- {
- if (unparsed == null || unparsed.length < 5) { // delimiters take 5 chars
- return null;
- }
-
- String[] lines = new String(unparsed).split("\n"); //$NON-NLS-1$
- Matcher delimiterMatcher = INITIAL_DELIMITER.matcher(lines[0]);
- if (!delimiterMatcher.find()) {
- return null;
- }
- int iOpener = delimiterMatcher.end();
- lines[0] = lines[0].substring(iOpener);
- if (lines.length == 1) {
- // single-line comment. Should trim(), but javac doesn't.
- // we should however remove the starting whitespaces
- StringBuilder sb = new StringBuilder();
- char[] chars = lines[0].toCharArray();
- boolean startingWhitespaces = true;
- for (char c : chars) {
- if (Character.isWhitespace(c))
- if (startingWhitespaces) {
- continue;
- } else {
- sb.append(c);
- } else {
- startingWhitespaces = false;
- sb.append(c);
- }
- }
- return sb.toString();
- }
-
- // if the first line ends with spaces after the /** then we want to insert a line separator
- int firstLine = lines[0].trim().length() > 0 ? 0 : 1;
-
- // If the last line is now empty, skip it
- int lastLine = lines[lines.length - 1].trim().length() > 0 ? lines.length - 1 : lines.length - 2;
-
- StringBuilder sb = new StringBuilder();
- if (lines[0].length() != 0 && firstLine == 1) {
- // insert a line separator only if the remaining chars on the line are whitespaces
- sb.append('\n');
- }
- boolean preserveLineSeparator = lines[0].length() == 0;
- for (int line = firstLine; line <= lastLine; ++line) {
- char[] chars = lines[line].toCharArray();
- int starsIndex = getStars(chars);
- int leadingWhitespaces = 0;
- boolean recordLeadingWhitespaces = true;
- for (int i = 0, max = chars.length; i < max; i++) {
- char c = chars[i];
- switch(c) {
- case '\t' :
- if (starsIndex == -1) {
- if (recordLeadingWhitespaces) {
- leadingWhitespaces += 8;
- } else {
- sb.append(c);
- }
- } else if (i >= starsIndex) {
- sb.append(c);
- }
- break;
- case ' ' :
- if (starsIndex == -1) {
- if (recordLeadingWhitespaces) {
- leadingWhitespaces++;
- } else {
- sb.append(c);
- }
- } else if (i >= starsIndex) {
- sb.append(c);
- }
- break;
- default :
- // convert leadingwhitespaces to spaces
- recordLeadingWhitespaces = false;
- if (leadingWhitespaces != 0) {
- int numberOfTabs = leadingWhitespaces / 8;
- if (numberOfTabs != 0) {
- for (int j = 0, max2 = numberOfTabs; j < max2; j++) {
- sb.append(" "); //$NON-NLS-1$
- }
- if ((leadingWhitespaces % 8) >= 1) {
- sb.append(' ');
- }
- } else if (line != 0) {
- // we don't want to preserve the leading spaces for the first line
- for (int j = 0, max2 = leadingWhitespaces; j < max2; j++) {
- sb.append(' ');
- }
- }
- leadingWhitespaces = 0;
- sb.append(c);
- } else if (c != '*' || i > starsIndex) {
- sb.append(c);
- }
- }
- }
-
- // append a newline at the end of each line except the last, even if we skipped the last entirely
- int end = lines.length - 1;
- if (line < end) {
- sb.append('\n');
- } else if (preserveLineSeparator && line == end) {
- sb.append('\n');
- }
- }
- return sb.toString();
- }
-
- /**
- * Returns the index of the last leading stars on this line, -1 if none.
- *
- * @param line the given line
- * @return the computed index
- */
- private static int getStars(char[] line) {
- loop: for (int i = 0, max = line.length; i < max; i++) {
- char c = line[i];
- if (!Character.isWhitespace(c)) {
- if (c == '*') {
- // only whitespaces before the first star
- // consume all stars and return the last index
- for (int j = i + 1; j < max; j++) {
- if (line[j] != '*') {
- return j;
- }
- }
- return max - 1;
- }
- // no need to continue
- break loop;
- }
- }
- return -1;
- }
- /**
- * @return all the annotation instance's explicitly set values, plus default values
- * for all the annotation members that are not explicitly set but that have
- * defaults. By comparison, {@link AnnotationMirror#getElementValues()} only
- * returns the explicitly set values.
- * @see javax.lang.model.util.Elements#getElementValuesWithDefaults(javax.lang.model.element.AnnotationMirror)
- */
- @Override
- public Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValuesWithDefaults(
- AnnotationMirror a) {
- return ((AnnotationMirrorImpl)a).getElementValuesWithDefaults();
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Elements#getName(java.lang.CharSequence)
- */
- @Override
- public Name getName(CharSequence cs) {
- return new NameImpl(cs);
- }
-
- @Override
- public PackageElement getPackageElement(CharSequence name) {
- LookupEnvironment le = _env.getLookupEnvironment();
- if (name.length() == 0) {
- return new PackageElementImpl(_env, le.defaultPackage);
- }
- char[] packageName = name.toString().toCharArray();
- PackageBinding packageBinding = le.createPackage(CharOperation.splitOn('.', packageName));
- if (packageBinding == null) {
- return null;
- }
- return new PackageElementImpl(_env, packageBinding);
- }
-
- @Override
- public PackageElement getPackageOf(Element type) {
- switch(type.getKind()) {
- case ANNOTATION_TYPE :
- case CLASS :
- case ENUM :
- case INTERFACE :
- TypeElementImpl typeElementImpl = (TypeElementImpl) type;
- ReferenceBinding referenceBinding = (ReferenceBinding)typeElementImpl._binding;
- return (PackageElement) _env.getFactory().newElement(referenceBinding.fPackage);
- case PACKAGE :
- return (PackageElement) type;
- case CONSTRUCTOR :
- case METHOD :
- ExecutableElementImpl executableElementImpl = (ExecutableElementImpl) type;
- MethodBinding methodBinding = (MethodBinding) executableElementImpl._binding;
- return (PackageElement) _env.getFactory().newElement(methodBinding.declaringClass.fPackage);
- case ENUM_CONSTANT :
- case FIELD :
- VariableElementImpl variableElementImpl = (VariableElementImpl) type;
- FieldBinding fieldBinding = (FieldBinding) variableElementImpl._binding;
- return (PackageElement) _env.getFactory().newElement(fieldBinding.declaringClass.fPackage);
- case PARAMETER :
- variableElementImpl = (VariableElementImpl) type;
- LocalVariableBinding localVariableBinding = (LocalVariableBinding) variableElementImpl._binding;
- return (PackageElement) _env.getFactory().newElement(localVariableBinding.declaringScope.classScope().referenceContext.binding.fPackage);
- case EXCEPTION_PARAMETER :
- case INSTANCE_INIT :
- case OTHER :
- case STATIC_INIT :
- case TYPE_PARAMETER :
- case LOCAL_VARIABLE :
- return null;
- }
- // unreachable
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Elements#getTypeElement(java.lang.CharSequence)
- */
- @Override
- public TypeElement getTypeElement(CharSequence name) {
- LookupEnvironment le = _env.getLookupEnvironment();
- final char[][] compoundName = CharOperation.splitOn('.', name.toString().toCharArray());
- ReferenceBinding binding = le.getType(compoundName);
- // If we didn't find the binding, maybe it's a nested type;
- // try finding the top-level type and then working downwards.
- if (null == binding) {
- ReferenceBinding topLevelBinding = null;
- int topLevelSegments = compoundName.length;
- while (--topLevelSegments > 0) {
- char[][] topLevelName = new char[topLevelSegments][];
- for (int i = 0; i < topLevelSegments; ++i) {
- topLevelName[i] = compoundName[i];
- }
- topLevelBinding = le.getType(topLevelName);
- if (null != topLevelBinding) {
- break;
- }
- }
- if (null == topLevelBinding) {
- return null;
- }
- binding = topLevelBinding;
- for (int i = topLevelSegments; null != binding && i < compoundName.length; ++i) {
- binding = binding.getMemberType(compoundName[i]);
- }
- }
- if (null == binding) {
- return null;
- }
- return new TypeElementImpl(_env, binding, null);
- }
-
- /* (non-Javadoc)
- * Element A hides element B if: A and B are both fields, both nested types, or both methods; and
- * the enclosing element of B is a superclass or superinterface of the enclosing element of A.
- * See JLS 8.3 (for hiding of fields), 8.4.8.2 (hiding of class methods), and 8.5 (for hiding of member types).
- * @see javax.lang.model.util.Elements#hides(javax.lang.model.element.Element, javax.lang.model.element.Element)
- */
- @Override
- public boolean hides(Element hider, Element hidden) {
- if (hidden == null) {
- // required by API spec
- throw new NullPointerException();
- }
- return ((ElementImpl)hider).hides(hidden);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Elements#isDeprecated(javax.lang.model.element.Element)
- */
- @Override
- public boolean isDeprecated(Element e) {
- if (!(e instanceof ElementImpl)) {
- return false;
- }
- return (((ElementImpl)e)._binding.getAnnotationTagBits() & TagBits.AnnotationDeprecated) != 0;
- }
-
- /* (non-Javadoc)
- * See JLS 8.4.8.1 for discussion of hiding of methods
- * @see javax.lang.model.util.Elements#overrides(javax.lang.model.element.ExecutableElement, javax.lang.model.element.ExecutableElement, javax.lang.model.element.TypeElement)
- */
- @Override
- public boolean overrides(ExecutableElement overrider, ExecutableElement overridden,
- TypeElement type) {
- if (overridden == null || type == null) {
- throw new NullPointerException();
- }
- return ((ExecutableElementImpl)overrider).overrides(overridden, type);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Elements#printElements(java.io.Writer, javax.lang.model.element.Element[])
- */
- @Override
- public void printElements(Writer w, Element... elements) {
- String lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$
- for (Element element : elements) {
- try {
- w.write(element.toString());
- w.write(lineSeparator);
- } catch (IOException e) {
- // ignore
- }
- }
- try {
- w.flush();
- } catch (IOException e) {
- // ignore
- }
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeElement.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeElement.java
deleted file mode 100644
index 0cb1948b0f..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeElement.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.internal.compiler.apt.model;
-
-import java.lang.annotation.Annotation;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ElementVisitor;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.NestingKind;
-import javax.lang.model.element.TypeParameterElement;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.util.Util;
-
-/**
- * Element corresponding to the Error type mirror
- */
-public class ErrorTypeElement extends TypeElementImpl {
-
- ErrorTypeElement(BaseProcessingEnvImpl env) {
- super(env, null, null);
- }
- /* (non-Javadoc)
- * @see javax.lang.model.element.TypeElement#getInterfaces()
- */
- @Override
- public List<? extends TypeMirror> getInterfaces() {
- return Collections.emptyList();
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.element.TypeElement#getNestingKind()
- */
- @Override
- public NestingKind getNestingKind() {
- return NestingKind.TOP_LEVEL;
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.element.TypeElement#getQualifiedName()
- */
- @Override
- public Name getQualifiedName() {
- return new NameImpl(Util.EMPTY_STRING);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.element.TypeElement#getSuperclass()
- */
- @Override
- public TypeMirror getSuperclass() {
- return this._env.getFactory().getNoType(TypeKind.NONE);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.element.TypeElement#getTypeParameters()
- */
- @Override
- public List<? extends TypeParameterElement> getTypeParameters() {
- return Collections.emptyList();
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.element.Element#accept(javax.lang.model.element.ElementVisitor, java.lang.Object)
- */
- @Override
- public <R, P> R accept(ElementVisitor<R, P> v, P p) {
- return v.visitType(this, p);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.element.Element#asType()
- */
- @Override
- public TypeMirror asType() {
- return this._env.getFactory().getErrorType();
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.element.Element#getAnnotation(java.lang.Class)
- */
- @Override
- public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.element.Element#getAnnotationMirrors()
- */
- @Override
- public List<? extends AnnotationMirror> getAnnotationMirrors() {
- return Collections.emptyList();
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.element.Element#getEnclosedElements()
- */
- @Override
- public List<? extends Element> getEnclosedElements() {
- return Collections.emptyList();
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.element.Element#getEnclosingElement()
- */
- @Override
- public Element getEnclosingElement() {
- return this._env.getFactory().newPackageElement(this._env.getLookupEnvironment().defaultPackage);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.element.Element#getKind()
- */
- @Override
- public ElementKind getKind() {
- return ElementKind.CLASS;
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.element.Element#getModifiers()
- */
- @Override
- public Set<Modifier> getModifiers() {
- return Collections.emptySet();
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.element.Element#getSimpleName()
- */
- @Override
- public Name getSimpleName() {
- return new NameImpl(Util.EMPTY_STRING);
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeImpl.java
deleted file mode 100644
index acd75c043b..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeImpl.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.model;
-
-import java.util.Collections;
-import java.util.List;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.type.ErrorType;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.type.TypeVisitor;
-
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-
-/**
- * Implementation of the {@link ErrorType} interface.
- */
-public class ErrorTypeImpl extends DeclaredTypeImpl implements ErrorType {
-
- /* package */ ErrorTypeImpl(BaseProcessingEnvImpl env) {
- super(env, null);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.DeclaredType#asElement()
- */
- @Override
- public Element asElement() {
- return this._env.getFactory().newElement(null);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.DeclaredType#getEnclosingType()
- */
- @Override
- public TypeMirror getEnclosingType() {
- return NoTypeImpl.NO_TYPE_NONE;
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.DeclaredType#getTypeArguments()
- */
- @Override
- public List<? extends TypeMirror> getTypeArguments() {
- return Collections.emptyList();
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.TypeMirror#accept(javax.lang.model.type.TypeVisitor, java.lang.Object)
- */
- @Override
- public <R, P> R accept(TypeVisitor<R, P> v, P p) {
- return v.visitError(this, p);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.TypeMirror#getKind()
- */
- @Override
- public TypeKind getKind() {
- return TypeKind.ERROR;
- }
-
- @Override
- public String toString() {
- return "<any>"; //$NON-NLS-1$
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableElementImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableElementImpl.java
deleted file mode 100644
index 8a250b3a28..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableElementImpl.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ElementVisitor;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.TypeParameterElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.TypeMirror;
-
-import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationHolder;
-import org.eclipse.jdt.internal.compiler.lookup.BinaryLocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodVerifier;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-
-public class ExecutableElementImpl extends ElementImpl implements
- ExecutableElement {
-
- private Name _name = null;
-
- /* package */ ExecutableElementImpl(BaseProcessingEnvImpl env, MethodBinding binding) {
- super(env, binding);
- }
-
- @Override
- public <R, P> R accept(ElementVisitor<R, P> v, P p)
- {
- return v.visitExecutable(this, p);
- }
-
- @Override
- protected AnnotationBinding[] getAnnotationBindings()
- {
- return ((MethodBinding)_binding).getAnnotations();
- }
-
- @Override
- public AnnotationValue getDefaultValue() {
- MethodBinding binding = (MethodBinding)_binding;
- Object defaultValue = binding.getDefaultValue();
- if (defaultValue != null) return new AnnotationValueImpl(_env, defaultValue, binding.returnType);
- return null;
- }
-
- @Override
- public List<? extends Element> getEnclosedElements() {
- return Collections.emptyList();
- }
-
- @Override
- public Element getEnclosingElement() {
- MethodBinding binding = (MethodBinding)_binding;
- if (null == binding.declaringClass) {
- return null;
- }
- return _env.getFactory().newElement(binding.declaringClass);
- }
-
- @Override
- public String getFileName() {
- ReferenceBinding dc = ((MethodBinding)_binding).declaringClass;
- char[] name = dc.getFileName();
- if (name == null)
- return null;
- return new String(name);
- }
-
- @Override
- public ElementKind getKind() {
- MethodBinding binding = (MethodBinding)_binding;
- if (binding.isConstructor()) {
- return ElementKind.CONSTRUCTOR;
- }
- else if (CharOperation.equals(binding.selector, TypeConstants.CLINIT)) {
- return ElementKind.STATIC_INIT;
- }
- else if (CharOperation.equals(binding.selector, TypeConstants.INIT)) {
- return ElementKind.INSTANCE_INIT;
- }
- else {
- return ElementKind.METHOD;
- }
- }
-
- @Override
- public Set<Modifier> getModifiers() {
- MethodBinding binding = (MethodBinding)_binding;
- return Factory.getModifiers(binding.modifiers, getKind());
- }
-
- @Override
- PackageElement getPackage()
- {
- MethodBinding binding = (MethodBinding)_binding;
- if (null == binding.declaringClass) {
- return null;
- }
- return _env.getFactory().newPackageElement(binding.declaringClass.fPackage);
- }
-
- @Override
- public List<? extends VariableElement> getParameters() {
- MethodBinding binding = (MethodBinding)_binding;
- int length = binding.parameters == null ? 0 : binding.parameters.length;
- if (0 != length) {
- AbstractMethodDeclaration methodDeclaration = binding.sourceMethod();
- List<VariableElement> params = new ArrayList<VariableElement>(length);
- if (methodDeclaration != null) {
- for (Argument argument : methodDeclaration.arguments) {
- VariableElement param = new VariableElementImpl(_env, argument.binding);
- params.add(param);
- }
- } else {
- // binary method
- boolean isEnumConstructor = binding.isConstructor()
- && binding.declaringClass.isEnum()
- && binding.declaringClass.isBinaryBinding()
- && ((binding.modifiers & ExtraCompilerModifiers.AccGenericSignature) == 0);
- AnnotationBinding[][] parameterAnnotationBindings = null;
- AnnotationHolder annotationHolder = binding.declaringClass.retrieveAnnotationHolder(binding, false);
- if (annotationHolder != null) {
- parameterAnnotationBindings = annotationHolder.getParameterAnnotations();
- }
- // we need to filter the synthetic arguments
- if (isEnumConstructor) {
- if (length == 2) {
- // the two arguments are only the two synthetic arguments
- return Collections.emptyList();
- }
- for (int i = 2; i < length; i++) {
- TypeBinding typeBinding = binding.parameters[i];
- StringBuilder builder = new StringBuilder("arg");//$NON-NLS-1$
- builder.append(i - 2);
- VariableElement param = new VariableElementImpl(_env,
- new BinaryLocalVariableBinding(
- String.valueOf(builder).toCharArray(),
- typeBinding,
- 0,
- null));
- params.add(param);
- }
- } else {
- int i = 0;
- for (TypeBinding typeBinding : binding.parameters) {
- StringBuilder builder = new StringBuilder("arg");//$NON-NLS-1$
- builder.append(i);
- VariableElement param = new VariableElementImpl(_env,
- new BinaryLocalVariableBinding(
- String.valueOf(builder).toCharArray(),
- typeBinding,
- 0,
- parameterAnnotationBindings != null ? parameterAnnotationBindings[i] : null));
- params.add(param);
- i++;
- }
- }
- }
- return Collections.unmodifiableList(params);
- }
- return Collections.emptyList();
- }
-
- @Override
- public TypeMirror getReturnType() {
- MethodBinding binding = (MethodBinding)_binding;
- if (binding.returnType == null) {
- return null;
- }
- else return _env.getFactory().newTypeMirror(binding.returnType);
- }
-
- @Override
- public Name getSimpleName() {
- MethodBinding binding = (MethodBinding)_binding;
- if (_name == null) {
- _name = new NameImpl(binding.selector);
- }
- return _name;
- }
-
- @Override
- public List<? extends TypeMirror> getThrownTypes() {
- MethodBinding binding = (MethodBinding)_binding;
- if (binding.thrownExceptions.length == 0) {
- return Collections.emptyList();
- }
- List<TypeMirror> list = new ArrayList<TypeMirror>(binding.thrownExceptions.length);
- for (ReferenceBinding exception : binding.thrownExceptions) {
- list.add(_env.getFactory().newTypeMirror(exception));
- }
- return list;
- }
-
- @Override
- public List<? extends TypeParameterElement> getTypeParameters() {
- MethodBinding binding = (MethodBinding)_binding;
- TypeVariableBinding[] variables = binding.typeVariables();
- if (variables.length == 0) {
- return Collections.emptyList();
- }
- List<TypeParameterElement> params = new ArrayList<TypeParameterElement>(variables.length);
- for (TypeVariableBinding variable : variables) {
- params.add(_env.getFactory().newTypeParameterElement(variable, this));
- }
- return Collections.unmodifiableList(params);
- }
-
- @Override
- public boolean hides(Element hidden)
- {
- if (!(hidden instanceof ExecutableElementImpl)) {
- return false;
- }
- MethodBinding hiderBinding = (MethodBinding)_binding;
- MethodBinding hiddenBinding = (MethodBinding)((ExecutableElementImpl)hidden)._binding;
- if (hiderBinding == hiddenBinding) {
- return false;
- }
- if (hiddenBinding.isPrivate()) {
- return false;
- }
- // See JLS 8.4.8: hiding only applies to static methods
- if (!hiderBinding.isStatic() || !hiddenBinding.isStatic()) {
- return false;
- }
- // check names
- if (!CharOperation.equals(hiddenBinding.selector, hiderBinding.selector)) {
- return false;
- }
- // check parameters
- if (!_env.getLookupEnvironment().methodVerifier().isMethodSubsignature(hiderBinding, hiddenBinding)) {
- return false;
- }
- return null != hiderBinding.declaringClass.findSuperTypeOriginatingFrom(hiddenBinding.declaringClass);
- }
-
- @Override
- public boolean isVarArgs() {
- return ((MethodBinding) _binding).isVarargs();
- }
-
- /**
- * Return true if this method overrides {@code overridden} in the context of {@code type}. For
- * instance, consider
- * <pre>
- * interface A { void f(); }
- * class B { void f() {} }
- * class C extends B implements I { }
- * </pre>
- * In the context of B, B.f() does not override A.f(); they are unrelated. But in the context of
- * C, B.f() does override A.f(). That is, the copy of B.f() that C inherits overrides A.f().
- * This is equivalent to considering two questions: first, does C inherit B.f(); if so, does
- * the inherited C.f() override A.f(). If B.f() were private, for instance, then in the context
- * of C it would still not override A.f().
- *
- * @see javax.lang.model.util.Elements#overrides(ExecutableElement, ExecutableElement, TypeElement)
- * @jls3 8.4.8 Inheritance, Overriding, and Hiding
- * @jls3 9.4.1 Inheritance and Overriding
- */
- public boolean overrides(ExecutableElement overridden, TypeElement type)
- {
- MethodBinding overriddenBinding = (MethodBinding)((ExecutableElementImpl) overridden)._binding;
- ReferenceBinding overriderContext = (ReferenceBinding)((TypeElementImpl)type)._binding;
- if ((MethodBinding)_binding == overriddenBinding
- || overriddenBinding.isStatic()
- || overriddenBinding.isPrivate()
- || ((MethodBinding)_binding).isStatic()) {
- return false;
- }
- char[] selector = ((MethodBinding)_binding).selector;
- if (!CharOperation.equals(selector, overriddenBinding.selector))
- return false;
-
- // Construct a binding to the equivalent of this (the overrider) as it would be inherited by 'type'.
- // Can only do this if 'type' is descended from the overrider.
- // Second clause of the AND is required to match a peculiar javac behavior.
- if (null == overriderContext.findSuperTypeOriginatingFrom(((MethodBinding)_binding).declaringClass) &&
- null == ((MethodBinding)_binding).declaringClass.findSuperTypeOriginatingFrom(overriderContext)) {
- return false;
- }
- MethodBinding overriderBinding = new MethodBinding((MethodBinding)_binding, overriderContext);
- if (overriderBinding.isPrivate()) {
- // a private method can never override another method. The other method would either be
- // private itself, in which case it would not be visible; or this would be a restriction
- // of access, which is a compile-time error.
- return false;
- }
-
- TypeBinding match = overriderBinding.declaringClass.findSuperTypeOriginatingFrom(overriddenBinding.declaringClass);
- if (!(match instanceof ReferenceBinding)) return false;
-
- org.eclipse.jdt.internal.compiler.lookup.MethodBinding[] superMethods = ((ReferenceBinding)match).getMethods(selector);
- LookupEnvironment lookupEnvironment = _env.getLookupEnvironment();
- if (lookupEnvironment == null) return false;
- MethodVerifier methodVerifier = lookupEnvironment.methodVerifier();
- for (int i = 0, length = superMethods.length; i < length; i++) {
- if (superMethods[i].original() == overriddenBinding) {
- return methodVerifier.doesMethodOverride(overriderBinding, superMethods[i]);
- }
- }
- return false;
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableTypeImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableTypeImpl.java
deleted file mode 100644
index e9d1cdc4ae..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ExecutableTypeImpl.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.internal.compiler.apt.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.lang.model.type.ExecutableType;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.type.TypeVariable;
-import javax.lang.model.type.TypeVisitor;
-
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-
-/**
- * Implementation of the ExecutableType
- *
- */
-public class ExecutableTypeImpl extends TypeMirrorImpl implements ExecutableType {
-
- public ExecutableTypeImpl(BaseProcessingEnvImpl env, MethodBinding binding) {
- super(env, binding);
- }
- /* (non-Javadoc)
- * @see javax.lang.model.type.ExecutableType#getParameterTypes()
- */
- @Override
- public List<? extends TypeMirror> getParameterTypes() {
- MethodBinding binding = (MethodBinding) this._binding;
- TypeBinding[] parameters = binding.parameters;
- int length = parameters.length;
- boolean isEnumConstructor = binding.isConstructor()
- && binding.declaringClass.isEnum()
- && binding.declaringClass.isBinaryBinding()
- && ((binding.modifiers & ExtraCompilerModifiers.AccGenericSignature) == 0);
- if (isEnumConstructor) {
- if (length == 2) {
- return Collections.emptyList();
- }
- ArrayList<TypeMirror> list = new ArrayList<TypeMirror>();
- for (int i = 2; i < length; i++) {
- list.add(_env.getFactory().newTypeMirror(parameters[i]));
- }
- return Collections.unmodifiableList(list);
- }
- if (length != 0) {
- ArrayList<TypeMirror> list = new ArrayList<TypeMirror>();
- for (TypeBinding typeBinding : parameters) {
- list.add(_env.getFactory().newTypeMirror(typeBinding));
- }
- return Collections.unmodifiableList(list);
- }
- return Collections.emptyList();
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.ExecutableType#getReturnType()
- */
- @Override
- public TypeMirror getReturnType() {
- return _env.getFactory().newTypeMirror(((MethodBinding) this._binding).returnType);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.ExecutableType#getThrownTypes()
- */
- @Override
- public List<? extends TypeMirror> getThrownTypes() {
- ArrayList<TypeMirror> list = new ArrayList<TypeMirror>();
- ReferenceBinding[] thrownExceptions = ((MethodBinding) this._binding).thrownExceptions;
- if (thrownExceptions.length != 0) {
- for (ReferenceBinding referenceBinding : thrownExceptions) {
- list.add(_env.getFactory().newTypeMirror(referenceBinding));
- }
- }
- return Collections.unmodifiableList(list);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.ExecutableType#getTypeVariables()
- */
- @Override
- public List<? extends TypeVariable> getTypeVariables() {
- ArrayList<TypeVariable> list = new ArrayList<TypeVariable>();
- TypeVariableBinding[] typeVariables = ((MethodBinding) this._binding).typeVariables();
- if (typeVariables.length != 0) {
- for (TypeVariableBinding typeVariableBinding : typeVariables) {
- list.add((TypeVariable) _env.getFactory().newTypeMirror(typeVariableBinding));
- }
- }
- return Collections.unmodifiableList(list);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.TypeMirror#accept(javax.lang.model.type.TypeVisitor, java.lang.Object)
- */
- @Override
- public <R, P> R accept(TypeVisitor<R, P> v, P p) {
- return v.visitExecutable(this, p);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.TypeMirror#getKind()
- */
- @Override
- public TypeKind getKind() {
- return TypeKind.EXECUTABLE;
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java
deleted file mode 100644
index 5bf3484cfa..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java
+++ /dev/null
@@ -1,707 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.internal.compiler.apt.model;
-
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeParameterElement;
-import javax.lang.model.type.DeclaredType;
-import javax.lang.model.type.ErrorType;
-import javax.lang.model.type.NoType;
-import javax.lang.model.type.NullType;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
-
-/**
- * Creates javax.lang.model wrappers around JDT internal compiler bindings.
- */
-public class Factory {
-
- // using auto-boxing to take advantage of caching, if any.
- // the dummy value picked here falls within the caching range.
- public static final Byte DUMMY_BYTE = 0;
- public static final Character DUMMY_CHAR = '0';
- public static final Double DUMMY_DOUBLE = 0d;
- public static final Float DUMMY_FLOAT = 0f;
- public static final Integer DUMMY_INTEGER = 0;
- public static final Long DUMMY_LONG = 0l;
- public static final Short DUMMY_SHORT = 0;
-
- private final BaseProcessingEnvImpl _env;
-
- /**
- * This object should only be constructed by the BaseProcessingEnvImpl.
- */
- public Factory(BaseProcessingEnvImpl env) {
- _env = env;
- }
-
- /**
- * Convert an array of compiler annotation bindings into a list of AnnotationMirror
- * @return a non-null, possibly empty, unmodifiable list.
- */
- public List<? extends AnnotationMirror> getAnnotationMirrors(AnnotationBinding[] annotations) {
- if (null == annotations || 0 == annotations.length) {
- return Collections.emptyList();
- }
- List<AnnotationMirror> list = new ArrayList<AnnotationMirror>(annotations.length);
- for (AnnotationBinding annotation : annotations) {
- if (annotation == null) continue;
- list.add(newAnnotationMirror(annotation));
- }
- return Collections.unmodifiableList(list);
- }
-
- private static void appendModifier(Set<Modifier> result, int modifiers, int modifierConstant, Modifier modifier) {
- if ((modifiers & modifierConstant) != 0) {
- result.add(modifier);
- }
- }
-
- private static void decodeModifiers(Set<Modifier> result, int modifiers, int[] checkBits) {
- if (checkBits == null) return;
- for (int i = 0, max = checkBits.length; i < max; i++) {
- switch(checkBits[i]) {
- case ClassFileConstants.AccPublic :
- appendModifier(result, modifiers, checkBits[i], Modifier.PUBLIC);
- break;
- case ClassFileConstants.AccProtected:
- appendModifier(result, modifiers, checkBits[i], Modifier.PROTECTED);
- break;
- case ClassFileConstants.AccPrivate :
- appendModifier(result, modifiers, checkBits[i], Modifier.PRIVATE);
- break;
- case ClassFileConstants.AccAbstract :
- appendModifier(result, modifiers, checkBits[i], Modifier.ABSTRACT);
- break;
- case ClassFileConstants.AccStatic :
- appendModifier(result, modifiers, checkBits[i], Modifier.STATIC);
- break;
- case ClassFileConstants.AccFinal :
- appendModifier(result, modifiers, checkBits[i], Modifier.FINAL);
- break;
- case ClassFileConstants.AccSynchronized :
- appendModifier(result, modifiers, checkBits[i], Modifier.SYNCHRONIZED);
- break;
- case ClassFileConstants.AccNative :
- appendModifier(result, modifiers, checkBits[i], Modifier.NATIVE);
- break;
- case ClassFileConstants.AccStrictfp :
- appendModifier(result, modifiers, checkBits[i], Modifier.STRICTFP);
- break;
- case ClassFileConstants.AccTransient :
- appendModifier(result, modifiers, checkBits[i], Modifier.TRANSIENT);
- break;
- case ClassFileConstants.AccVolatile :
- appendModifier(result, modifiers, checkBits[i], Modifier.VOLATILE);
- break;
- }
- }
- }
-
- public static Object getMatchingDummyValue(final Class<?> expectedType){
- if( expectedType.isPrimitive() ){
- if(expectedType == boolean.class)
- return Boolean.FALSE;
- else if( expectedType == byte.class )
- return DUMMY_BYTE;
- else if( expectedType == char.class )
- return DUMMY_CHAR;
- else if( expectedType == double.class)
- return DUMMY_DOUBLE;
- else if( expectedType == float.class )
- return DUMMY_FLOAT;
- else if( expectedType == int.class )
- return DUMMY_INTEGER;
- else if( expectedType == long.class )
- return DUMMY_LONG;
- else if(expectedType == short.class)
- return DUMMY_SHORT;
- else // expectedType == void.class. can this happen?
- return DUMMY_INTEGER; // anything would work
- }
- else
- return null;
- }
-
- public static Set<Modifier> getModifiers(int modifiers, ElementKind kind) {
- return getModifiers(modifiers, kind, false);
- }
- /**
- * Convert from the JDT's ClassFileConstants flags to the Modifier enum.
- */
- public static Set<Modifier> getModifiers(int modifiers, ElementKind kind, boolean isFromBinary)
- {
- EnumSet<Modifier> result = EnumSet.noneOf(Modifier.class);
- switch(kind) {
- case CONSTRUCTOR :
- case METHOD :
- // modifiers for methods
- decodeModifiers(result, modifiers, new int[] {
- ClassFileConstants.AccPublic,
- ClassFileConstants.AccProtected,
- ClassFileConstants.AccPrivate,
- ClassFileConstants.AccAbstract,
- ClassFileConstants.AccStatic,
- ClassFileConstants.AccFinal,
- ClassFileConstants.AccSynchronized,
- ClassFileConstants.AccNative,
- ClassFileConstants.AccStrictfp
- });
- break;
- case FIELD :
- case ENUM_CONSTANT :
- // for fields
- decodeModifiers(result, modifiers, new int[] {
- ClassFileConstants.AccPublic,
- ClassFileConstants.AccProtected,
- ClassFileConstants.AccPrivate,
- ClassFileConstants.AccStatic,
- ClassFileConstants.AccFinal,
- ClassFileConstants.AccTransient,
- ClassFileConstants.AccVolatile
- });
- break;
- case ENUM :
- if (isFromBinary) {
- decodeModifiers(result, modifiers, new int[] {
- ClassFileConstants.AccPublic,
- ClassFileConstants.AccProtected,
- ClassFileConstants.AccFinal,
- ClassFileConstants.AccPrivate,
- ClassFileConstants.AccAbstract,
- ClassFileConstants.AccStatic,
- ClassFileConstants.AccStrictfp
- });
- } else {
- // enum from source cannot be explicitly abstract
- decodeModifiers(result, modifiers, new int[] {
- ClassFileConstants.AccPublic,
- ClassFileConstants.AccProtected,
- ClassFileConstants.AccFinal,
- ClassFileConstants.AccPrivate,
- ClassFileConstants.AccStatic,
- ClassFileConstants.AccStrictfp
- });
- }
- break;
- case ANNOTATION_TYPE :
- case INTERFACE :
- case CLASS :
- // for type
- decodeModifiers(result, modifiers, new int[] {
- ClassFileConstants.AccPublic,
- ClassFileConstants.AccProtected,
- ClassFileConstants.AccAbstract,
- ClassFileConstants.AccFinal,
- ClassFileConstants.AccPrivate,
- ClassFileConstants.AccStatic,
- ClassFileConstants.AccStrictfp
- });
- }
- return Collections.unmodifiableSet(result);
- }
-
- public AnnotationMirror newAnnotationMirror(AnnotationBinding binding)
- {
- return new AnnotationMirrorImpl(_env, binding);
- }
-
- /**
- * Create a new element that knows what kind it is even if the binding is unresolved.
- */
- public Element newElement(Binding binding, ElementKind kindHint) {
- if (binding == null) {
- return new ErrorTypeElement(this._env);
- }
- switch (binding.kind()) {
- case Binding.FIELD:
- case Binding.LOCAL:
- case Binding.VARIABLE:
- return new VariableElementImpl(_env, (VariableBinding) binding);
- case Binding.TYPE:
- case Binding.GENERIC_TYPE:
- ReferenceBinding referenceBinding = (ReferenceBinding)binding;
- if (referenceBinding.sourceName == TypeConstants.PACKAGE_INFO_NAME) {
- return new PackageElementImpl(_env, referenceBinding.fPackage);
- }
- return new TypeElementImpl(_env, referenceBinding, kindHint);
- case Binding.METHOD:
- return new ExecutableElementImpl(_env, (MethodBinding)binding);
- case Binding.RAW_TYPE:
- case Binding.PARAMETERIZED_TYPE:
- return new TypeElementImpl(_env, ((ParameterizedTypeBinding)binding).genericType(), kindHint);
- case Binding.PACKAGE:
- return new PackageElementImpl(_env, (PackageBinding)binding);
- case Binding.TYPE_PARAMETER:
- return new TypeParameterElementImpl(_env, (TypeVariableBinding)binding);
- // TODO: fill in the rest of these
- case Binding.IMPORT:
- case Binding.ARRAY_TYPE:
- case Binding.BASE_TYPE:
- case Binding.WILDCARD_TYPE:
- case Binding.INTERSECTION_TYPE:
- throw new UnsupportedOperationException("NYI: binding type " + binding.kind()); //$NON-NLS-1$
- }
- return null;
- }
-
- public Element newElement(Binding binding) {
- return newElement(binding, null);
- }
-
- public DeclaredType newDeclaredType(ReferenceBinding binding) {
- switch (binding.kind()) {
- case Binding.WILDCARD_TYPE :
- // JDT wildcard binding is a subclass of reference binding, but in JSR269 they're siblings
- throw new IllegalArgumentException("A wildcard binding can't be turned into a DeclaredType"); //$NON-NLS-1$
- case Binding.INTERSECTION_TYPE :
- // JDT intersection binding is a subclass of reference binding, but in JSR269 they're siblings
- throw new IllegalArgumentException("An intersection binding can't be turned into a DeclaredType"); //$NON-NLS-1$
- }
- return new DeclaredTypeImpl(_env, binding);
- }
-
- /**
- * When an annotation is of unresolved type, its binding won't know that it's an annotation type,
- * so later on if the caller tries to get the type asElement(), and then asks for the ElementKind,
- * they'll get back CLASS rather than ANNOTATION_TYPE. If we know from context that the binding
- * is to an annotation type, calling this method allows us to hint to the underlying TypeElementImpl.
- */
- public DeclaredType newAnnotationType(ReferenceBinding binding) {
- switch (binding.kind()) {
- case Binding.WILDCARD_TYPE :
- // JDT wildcard binding is a subclass of reference binding, but in JSR269 they're siblings
- throw new IllegalArgumentException("A wildcard binding can't be turned into a DeclaredType"); //$NON-NLS-1$
- case Binding.INTERSECTION_TYPE :
- // JDT intersection binding is a subclass of reference binding, but in JSR269 they're siblings
- throw new IllegalArgumentException("An intersection binding can't be turned into a DeclaredType"); //$NON-NLS-1$
- }
- return new DeclaredTypeImpl(_env, binding, ElementKind.ANNOTATION_TYPE);
- }
-
- /**
- * Convenience method - equivalent to {@code (PackageElement)Factory.newElement(binding)}
- */
- public PackageElement newPackageElement(PackageBinding binding)
- {
- return new PackageElementImpl(_env, binding);
- }
-
- public NullType getNullType() {
- return NoTypeImpl.NULL_TYPE;
- }
-
- public NoType getNoType(TypeKind kind)
- {
- switch (kind) {
- case NONE:
- return NoTypeImpl.NO_TYPE_NONE;
- case VOID:
- return NoTypeImpl.NO_TYPE_VOID;
- case PACKAGE:
- return NoTypeImpl.NO_TYPE_PACKAGE;
- default:
- throw new IllegalArgumentException();
- }
- }
-
- /**
- * Get a type mirror object representing the specified primitive type kind.
- * @throw IllegalArgumentException if a non-primitive TypeKind is requested
- */
- public PrimitiveTypeImpl getPrimitiveType(TypeKind kind)
- {
- switch (kind) {
- case BOOLEAN:
- return PrimitiveTypeImpl.BOOLEAN;
- case BYTE:
- return PrimitiveTypeImpl.BYTE;
- case CHAR:
- return PrimitiveTypeImpl.CHAR;
- case DOUBLE:
- return PrimitiveTypeImpl.DOUBLE;
- case FLOAT:
- return PrimitiveTypeImpl.FLOAT;
- case INT:
- return PrimitiveTypeImpl.INT;
- case LONG:
- return PrimitiveTypeImpl.LONG;
- case SHORT:
- return PrimitiveTypeImpl.SHORT;
- default:
- throw new IllegalStateException();
- }
- }
-
- /**
- * Convenience method to get the PrimitiveTypeImpl corresponding to a particular BaseTypeBinding.
- */
- public PrimitiveTypeImpl getPrimitiveType(BaseTypeBinding binding) {
- return getPrimitiveType(PrimitiveTypeImpl.getKind(binding));
- }
-
- /**
- * Given a binding of uncertain type, try to create the right sort of TypeMirror for it.
- */
- public TypeMirror newTypeMirror(Binding binding) {
- switch (binding.kind()) {
- case Binding.FIELD:
- case Binding.LOCAL:
- case Binding.VARIABLE:
- // For variables, return the type of the variable
- return newTypeMirror(((VariableBinding)binding).type);
-
- case Binding.PACKAGE:
- return getNoType(TypeKind.PACKAGE);
-
- case Binding.IMPORT:
- throw new UnsupportedOperationException("NYI: import type " + binding.kind()); //$NON-NLS-1$
-
- case Binding.METHOD:
- return new ExecutableTypeImpl(_env, (MethodBinding) binding);
-
- case Binding.TYPE:
- case Binding.RAW_TYPE:
- case Binding.GENERIC_TYPE:
- case Binding.PARAMETERIZED_TYPE:
- return new DeclaredTypeImpl(_env, (ReferenceBinding)binding);
-
- case Binding.ARRAY_TYPE:
- return new ArrayTypeImpl(_env, (ArrayBinding)binding);
-
- case Binding.BASE_TYPE:
- BaseTypeBinding btb = (BaseTypeBinding)binding;
- switch (btb.id) {
- case TypeIds.T_void:
- return getNoType(TypeKind.VOID);
- case TypeIds.T_null:
- return getNullType();
- default:
- return getPrimitiveType(PrimitiveTypeImpl.getKind((BaseTypeBinding)binding));
- }
-
- case Binding.WILDCARD_TYPE:
- case Binding.INTERSECTION_TYPE: // TODO compatible, but shouldn't it really be an intersection type?
- return new WildcardTypeImpl(_env, (WildcardBinding) binding);
-
- case Binding.TYPE_PARAMETER:
- return new TypeVariableImpl(_env, (TypeVariableBinding) binding);
- }
- return null;
- }
-
- /**
- * @param declaringElement the class, method, etc. that is parameterized by this parameter.
- */
- public TypeParameterElement newTypeParameterElement(TypeVariableBinding variable, Element declaringElement)
- {
- return new TypeParameterElementImpl(_env, variable, declaringElement);
- }
-
- public ErrorType getErrorType() {
- return new ErrorTypeImpl(this._env);
- }
-
- /**
- * This method is derived from code in org.eclipse.jdt.apt.core.
- *
- * This method is designed to be invoked by the invocation handler and anywhere that requires
- * a AnnotationValue (AnnotationMirror member values and default values from annotation member).
- *
- * Regardless of the path, there are common primitive type conversion that needs to take place.
- * The type conversions respect the type widening and narrowing rules from JLS 5.1.2 and 5.1.2.
- *
- * The only question remains is what is the type of the return value when the type conversion fails?
- * When <code>avoidReflectException</code> is set to <code>true</code>
- * Return <code>false</code> if the expected type is <code>boolean</code>
- * Return numeric 0 for all numeric primitive types and '0' for <code>char</code>
- *
- * Otherwise:
- * Return the value unchanged.
- *
- * In the invocation handler case:
- * The value returned by {@link java.lang.reflect.InvocationHandler#invoke}
- * will be converted into the expected type by the {@link java.lang.reflect.Proxy}.
- * If the value and the expected type does not agree, and the value is not null,
- * a ClassCastException will be thrown. A NullPointerException will result if the
- * expected type is a primitive type and the value is null.
- * This behavior causes annotation processors a lot of pain and the decision is
- * to not throw such unchecked exception. In the case where a ClassCastException or
- * NullPointerException will be thrown return some dummy value. Otherwise, return
- * the original value.
- * Chosen dummy values:
- * Return <code>false</code> if the expected type is <code>boolean</code>
- * Return numeric 0 for all numeric primitive types and '0' for <code>char</code>
- *
- * This behavior is triggered by setting <code>avoidReflectException</code> to <code>true</code>
- *
- * Note: the new behavior deviates from what's documented in
- * {@link java.lang.reflect.InvocationHandler#invoke} and also deviates from
- * Sun's implementation.
- *
- * @param value the current value from the annotation instance.
- * @param expectedType the expected type of the value.
- *
- */
- public static Object performNecessaryPrimitiveTypeConversion(
- final Class<?> expectedType,
- final Object value,
- final boolean avoidReflectException)
- {
- assert expectedType.isPrimitive() : "expectedType is not a primitive type: " + expectedType.getName(); //$NON-NLS-1$
- if( value == null)
- return avoidReflectException ? getMatchingDummyValue(expectedType) : null;
- // apply widening conversion based on JLS 5.1.2 and 5.1.3
- final String typeName = expectedType.getName();
- final char expectedTypeChar = typeName.charAt(0);
- final int nameLen = typeName.length();
- // widening byte -> short, int, long, float or double
- // narrowing byte -> char
- if( value instanceof Byte )
- {
- final byte b = ((Byte)value).byteValue();
- switch( expectedTypeChar )
- {
- case 'b':
- if(nameLen == 4) // byte
- return value; // exact match.
- else
- return avoidReflectException ? Boolean.FALSE : value;
- case 'c':
- return new Character((char)b); // narrowing.
- case 'd':
- return new Double(b); // widening.
- case 'f':
- return new Float(b); // widening.
- case 'i':
- return new Integer(b); // widening.
- case 'l':
- return new Long(b); // widening.
- case 's':
- return new Short(b); // widening.
- default:
- throw new IllegalStateException("unknown type " + expectedTypeChar); //$NON-NLS-1$
- }
- }
- // widening short -> int, long, float, or double
- // narrowing short -> byte or char
- else if( value instanceof Short )
- {
- final short s = ((Short)value).shortValue();
- switch( expectedTypeChar )
- {
- case 'b':
- if(nameLen == 4) // byte
- return new Byte((byte)s); // narrowing.
- else
- return avoidReflectException ? Boolean.FALSE : value; // completely wrong.
- case 'c':
- return new Character((char)s); // narrowing.
- case 'd':
- return new Double(s); // widening.
- case 'f':
- return new Float(s); // widening.
- case 'i':
- return new Integer(s); // widening.
- case 'l':
- return new Long(s); // widening.
- case 's':
- return value; // exact match
- default:
- throw new IllegalStateException("unknown type " + expectedTypeChar); //$NON-NLS-1$
- }
- }
- // widening char -> int, long, float, or double
- // narrowing char -> byte or short
- else if( value instanceof Character )
- {
- final char c = ((Character)value).charValue();
- switch( expectedTypeChar )
- {
- case 'b':
- if(nameLen == 4) // byte
- return new Byte((byte)c); // narrowing.
- else
- return avoidReflectException ? Boolean.FALSE : value; // completely wrong.
- case 'c':
- return value; // exact match
- case 'd':
- return new Double(c); // widening.
- case 'f':
- return new Float(c); // widening.
- case 'i':
- return new Integer(c); // widening.
- case 'l':
- return new Long(c); // widening.
- case 's':
- return new Short((short)c); // narrowing.
- default:
- throw new IllegalStateException("unknown type " + expectedTypeChar); //$NON-NLS-1$
- }
- }
-
- // widening int -> long, float, or double
- // narrowing int -> byte, short, or char
- else if( value instanceof Integer )
- {
- final int i = ((Integer)value).intValue();
- switch( expectedTypeChar )
- {
- case 'b':
- if(nameLen == 4) // byte
- return new Byte((byte)i); // narrowing.
- else
- return avoidReflectException ? Boolean.FALSE : value; // completely wrong.
- case 'c':
- return new Character((char)i); // narrowing
- case 'd':
- return new Double(i); // widening.
- case 'f':
- return new Float(i); // widening.
- case 'i':
- return value; // exact match
- case 'l':
- return new Long(i); // widening.
- case 's':
- return new Short((short)i); // narrowing.
- default:
- throw new IllegalStateException("unknown type " + expectedTypeChar); //$NON-NLS-1$
- }
- }
- // widening long -> float or double
- else if( value instanceof Long )
- {
- final long l = ((Long)value).longValue();
- switch( expectedTypeChar )
- {
- case 'b': // both byte and boolean
- case 'c':
- case 'i':
- case 's':
- // completely wrong.
- return avoidReflectException ? getMatchingDummyValue(expectedType) : value;
- case 'd':
- return new Double(l); // widening.
- case 'f':
- return new Float(l); // widening.
- case 'l':
- return value; // exact match.
-
- default:
- throw new IllegalStateException("unknown type " + expectedTypeChar); //$NON-NLS-1$
- }
- }
-
- // widening float -> double
- else if( value instanceof Float )
- {
- final float f = ((Float)value).floatValue();
- switch( expectedTypeChar )
- {
- case 'b': // both byte and boolean
- case 'c':
- case 'i':
- case 's':
- case 'l':
- // completely wrong.
- return avoidReflectException ? getMatchingDummyValue(expectedType) : value;
- case 'd':
- return new Double(f); // widening.
- case 'f':
- return value; // exact match.
- default:
- throw new IllegalStateException("unknown type " + expectedTypeChar); //$NON-NLS-1$
- }
- }
- else if( value instanceof Double ){
- if(expectedTypeChar == 'd' )
- return value; // exact match
- else{
- return avoidReflectException ? getMatchingDummyValue(expectedType) : value; // completely wrong.
- }
- }
- else if( value instanceof Boolean ){
- if( expectedTypeChar == 'b' && nameLen == 7) // "boolean".length() == 7
- return value;
- else
- return avoidReflectException ? getMatchingDummyValue(expectedType) : value; // completely wrong.
- }
- else // can't convert
- return avoidReflectException ? getMatchingDummyValue(expectedType) : value;
- }
-
- /**
- * Set an element of an array to the appropriate dummy value type
- * @param array
- * @param i
- * @param expectedLeafType
- */
- public static void setArrayMatchingDummyValue(Object array, int i, Class<?> expectedLeafType)
- {
- if (boolean.class.equals(expectedLeafType)) {
- Array.setBoolean(array, i, false);
- }
- else if (byte.class.equals(expectedLeafType)) {
- Array.setByte(array, i, DUMMY_BYTE);
- }
- else if (char.class.equals(expectedLeafType)) {
- Array.setChar(array, i, DUMMY_CHAR);
- }
- else if (double.class.equals(expectedLeafType)) {
- Array.setDouble(array, i, DUMMY_DOUBLE);
- }
- else if (float.class.equals(expectedLeafType)) {
- Array.setFloat(array, i, DUMMY_FLOAT);
- }
- else if (int.class.equals(expectedLeafType)) {
- Array.setInt(array, i, DUMMY_INTEGER);
- }
- else if (long.class.equals(expectedLeafType)) {
- Array.setLong(array, i, DUMMY_LONG);
- }
- else if (short.class.equals(expectedLeafType)) {
- Array.setShort(array, i, DUMMY_SHORT);
- }
- else {
- Array.set(array, i, null);
- }
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/IElementInfo.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/IElementInfo.java
deleted file mode 100644
index 40ed3da235..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/IElementInfo.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.compiler.apt.model;
-
-/**
- * Additional information available for Elements that are implemented
- * within the Eclipse APT framework.
- * @see javax.lang.model.Element
- * @since 3.3
- */
-public interface IElementInfo {
- /**
- * Get the project-relative path to the source file that contains this element.
- * If the element is a PackageElement, the "source file" is package-info.java.
- * If the element is not recognized or does not exist in the project for some
- * reason, returns null.
- * @return the project-relative path, or null.
- */
- public String getFileName();
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/NameImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/NameImpl.java
deleted file mode 100644
index 3f9dcc6514..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/NameImpl.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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.internal.compiler.apt.model;
-
-import javax.lang.model.element.Name;
-
-/**
- * A String-based implementation of the type used to return strings in javax.lang.model.
- */
-public class NameImpl implements Name {
-
- private final String _name;
-
- /** nullary constructor is prohibited */
- @SuppressWarnings("unused")
- private NameImpl()
- {
- _name = null;
- }
-
- public NameImpl(CharSequence cs)
- {
- _name = cs.toString();
- }
-
- public NameImpl(char[] chars)
- {
- _name = String.valueOf(chars);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.element.Name#contentEquals(java.lang.CharSequence)
- */
- @Override
- public boolean contentEquals(CharSequence cs) {
- return _name.equals(cs.toString());
- }
-
- /* (non-Javadoc)
- * @see java.lang.CharSequence#charAt(int)
- */
- @Override
- public char charAt(int index) {
- return _name.charAt(index);
- }
-
- /* (non-Javadoc)
- * @see java.lang.CharSequence#length()
- */
- @Override
- public int length() {
- return _name.length();
- }
-
- /* (non-Javadoc)
- * @see java.lang.CharSequence#subSequence(int, int)
- */
- @Override
- public CharSequence subSequence(int start, int end) {
- return _name.subSequence(start, end);
- }
-
- @Override
- public String toString() {
- return _name;
- }
-
- @Override
- public int hashCode() {
- return _name.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final NameImpl other = (NameImpl) obj;
- return _name.equals(other._name);
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/NoTypeImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/NoTypeImpl.java
deleted file mode 100644
index 95a5df3ba5..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/NoTypeImpl.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.compiler.apt.model;
-
-import javax.lang.model.type.NoType;
-import javax.lang.model.type.NullType;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeVisitor;
-
-/**
- * An implementation of NoType, which is used to represent certain psuedo-types.
- * @see NoType.
- */
-public class NoTypeImpl implements NoType, NullType
-{
- private final TypeKind _kind;
-
- public static final NoType NO_TYPE_NONE = new NoTypeImpl(TypeKind.NONE);
- public static final NoType NO_TYPE_VOID = new NoTypeImpl(TypeKind.VOID);
- public static final NoType NO_TYPE_PACKAGE = new NoTypeImpl(TypeKind.PACKAGE);
- public static final NullType NULL_TYPE = new NoTypeImpl(TypeKind.NULL);
-
- private NoTypeImpl(TypeKind kind) {
- _kind = kind;
- }
-
- @Override
- public <R, P> R accept(TypeVisitor<R, P> v, P p)
- {
- switch(this.getKind())
- {
- case NULL :
- return v.visitNull(this, p);
- default:
- return v.visitNoType(this, p);
- }
- }
-
- @Override
- public TypeKind getKind()
- {
- return _kind;
- }
-
- public String toString()
- {
- switch (_kind) {
- default:
- case NONE:
- return "<none>"; //$NON-NLS-1$
- case NULL:
- return "null"; //$NON-NLS-1$
- case VOID:
- return "void"; //$NON-NLS-1$
- case PACKAGE:
- return "package"; //$NON-NLS-1$
- }
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/PackageElementImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/PackageElementImpl.java
deleted file mode 100644
index 7e0e4c8fff..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/PackageElementImpl.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.compiler.apt.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ElementVisitor;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.PackageElement;
-
-import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.batch.FileSystem;
-import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-
-/**
- * Implementation of PackageElement, which represents a package
- */
-public class PackageElementImpl extends ElementImpl implements PackageElement {
-
- PackageElementImpl(BaseProcessingEnvImpl env, PackageBinding binding) {
- super(env, binding);
- }
-
- @Override
- public <R, P> R accept(ElementVisitor<R, P> v, P p)
- {
- return v.visitPackage(this, p);
- }
-
- @Override
- protected AnnotationBinding[] getAnnotationBindings()
- {
- PackageBinding packageBinding = (PackageBinding) this._binding;
- char[][] compoundName = CharOperation.arrayConcat(packageBinding.compoundName, TypeConstants.PACKAGE_INFO_NAME);
- ReferenceBinding type = this._env.getLookupEnvironment().getType(compoundName);
- AnnotationBinding[] annotations = null;
- if (type != null && type.isValidBinding()) {
- annotations = type.getAnnotations();
- }
- return annotations;
- }
-
- @Override
- public List<? extends Element> getEnclosedElements() {
- PackageBinding binding = (PackageBinding)_binding;
- LookupEnvironment environment = binding.environment;
- char[][][] typeNames = null;
- INameEnvironment nameEnvironment = binding.environment.nameEnvironment;
- if (nameEnvironment instanceof FileSystem) {
- typeNames = ((FileSystem) nameEnvironment).findTypeNames(binding.compoundName);
- }
- HashSet<Element> set = new HashSet<Element>();
- if (typeNames != null) {
- for (char[][] typeName : typeNames) {
- ReferenceBinding type = environment.getType(typeName);
- if (type != null && type.isValidBinding()) {
- set.add(_env.getFactory().newElement(type));
- }
- }
- }
- ArrayList<Element> list = new ArrayList<Element>(set.size());
- list.addAll(set);
- return Collections.unmodifiableList(list);
- }
-
- @Override
- public Element getEnclosingElement() {
- // packages have no enclosing element
- return null;
- }
-
- @Override
- public ElementKind getKind() {
- return ElementKind.PACKAGE;
- }
-
- @Override
- PackageElement getPackage()
- {
- return this;
- }
-
- @Override
- public Name getSimpleName() {
- char[][] compoundName = ((PackageBinding)_binding).compoundName;
- int length = compoundName.length;
- if (length == 0) {
- return new NameImpl(CharOperation.NO_CHAR);
- }
- return new NameImpl(compoundName[length - 1]);
- }
-
- @Override
- public Name getQualifiedName() {
- return new NameImpl(CharOperation.concatWith(((PackageBinding)_binding).compoundName, '.'));
- }
-
- @Override
- public boolean isUnnamed() {
- PackageBinding binding = (PackageBinding)_binding;
- return binding.compoundName == CharOperation.NO_CHAR_CHAR;
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/PrimitiveTypeImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/PrimitiveTypeImpl.java
deleted file mode 100644
index 77fe2d7c1a..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/PrimitiveTypeImpl.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.compiler.apt.model;
-
-import javax.lang.model.type.PrimitiveType;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeVisitor;
-
-import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-
-/**
- *
- * @since 3.3
- */
-public class PrimitiveTypeImpl extends TypeMirrorImpl implements PrimitiveType {
-
- public final static PrimitiveTypeImpl BOOLEAN = new PrimitiveTypeImpl(TypeBinding.BOOLEAN);
- public final static PrimitiveTypeImpl BYTE = new PrimitiveTypeImpl(TypeBinding.BYTE);
- public final static PrimitiveTypeImpl CHAR = new PrimitiveTypeImpl(TypeBinding.CHAR);
- public final static PrimitiveTypeImpl DOUBLE = new PrimitiveTypeImpl(TypeBinding.DOUBLE);
- public final static PrimitiveTypeImpl FLOAT = new PrimitiveTypeImpl(TypeBinding.FLOAT);
- public final static PrimitiveTypeImpl INT = new PrimitiveTypeImpl(TypeBinding.INT);
- public final static PrimitiveTypeImpl LONG = new PrimitiveTypeImpl(TypeBinding.LONG);
- public final static PrimitiveTypeImpl SHORT = new PrimitiveTypeImpl(TypeBinding.SHORT);
-
- /**
- * Clients should call {@link Factory#getPrimitiveType(TypeKind)},
- * rather than creating new objects.
- */
- private PrimitiveTypeImpl(BaseTypeBinding binding) {
- // Primitive types do not need an environment!
- super(null, binding);
- }
-
- @Override
- public <R, P> R accept(TypeVisitor<R, P> v, P p)
- {
- return v.visitPrimitive(this, p);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.compiler.apt.model.TypeMirrorImpl#getKind()
- */
- @Override
- public TypeKind getKind() {
- return getKind((BaseTypeBinding)_binding);
- }
-
- public static TypeKind getKind(BaseTypeBinding binding) {
- switch (binding.id) {
- case TypeIds.T_boolean:
- return TypeKind.BOOLEAN;
- case TypeIds.T_byte:
- return TypeKind.BYTE;
- case TypeIds.T_char:
- return TypeKind.CHAR;
- case TypeIds.T_double:
- return TypeKind.DOUBLE;
- case TypeIds.T_float:
- return TypeKind.FLOAT;
- case TypeIds.T_int:
- return TypeKind.INT;
- case TypeIds.T_long:
- return TypeKind.LONG;
- case TypeIds.T_short:
- return TypeKind.SHORT;
- default:
- throw new IllegalArgumentException("BaseTypeBinding of unexpected id " + binding.id); //$NON-NLS-1$
- }
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java
deleted file mode 100644
index f6b65ffad8..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeElementImpl.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ElementVisitor;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.NestingKind;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.TypeParameterElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-
-import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-
-public class TypeElementImpl extends ElementImpl implements TypeElement {
-
- private final ElementKind _kindHint;
-
- /**
- * In general, clients should call {@link Factory#newDeclaredType(ReferenceBinding)} or
- * {@link Factory#newElement(org.eclipse.jdt.internal.compiler.lookup.Binding)} to
- * create new instances.
- */
- TypeElementImpl(BaseProcessingEnvImpl env, ReferenceBinding binding, ElementKind kindHint) {
- super(env, binding);
- _kindHint = kindHint;
- }
-
- @Override
- public <R, P> R accept(ElementVisitor<R, P> v, P p)
- {
- return v.visitType(this, p);
- }
-
- @Override
- protected AnnotationBinding[] getAnnotationBindings()
- {
- return ((ReferenceBinding)_binding).getAnnotations();
- }
-
- @Override
- public List<? extends Element> getEnclosedElements() {
- ReferenceBinding binding = (ReferenceBinding)_binding;
- List<Element> enclosed = new ArrayList<Element>(binding.fieldCount() + binding.methods().length);
- for (MethodBinding method : binding.methods()) {
- ExecutableElement executable = new ExecutableElementImpl(_env, method);
- enclosed.add(executable);
- }
- for (FieldBinding field : binding.fields()) {
- // TODO no field should be excluded according to the JLS
- if (!field.isSynthetic()) {
- VariableElement variable = new VariableElementImpl(_env, field);
- enclosed.add(variable);
- }
- }
- for (ReferenceBinding memberType : binding.memberTypes()) {
- TypeElement type = new TypeElementImpl(_env, memberType, null);
- enclosed.add(type);
- }
- return Collections.unmodifiableList(enclosed);
- }
-
- @Override
- public Element getEnclosingElement() {
- ReferenceBinding binding = (ReferenceBinding)_binding;
- ReferenceBinding enclosingType = binding.enclosingType();
- if (null == enclosingType) {
- // this is a top level type; get its package
- return _env.getFactory().newPackageElement(binding.fPackage);
- }
- else {
- return _env.getFactory().newElement(binding.enclosingType());
- }
- }
-
- @Override
- public String getFileName() {
- char[] name = ((ReferenceBinding)_binding).getFileName();
- if (name == null)
- return null;
- return new String(name);
- }
-
- @Override
- public List<? extends TypeMirror> getInterfaces() {
- ReferenceBinding binding = (ReferenceBinding)_binding;
- if (null == binding.superInterfaces() || binding.superInterfaces().length == 0) {
- return Collections.emptyList();
- }
- List<TypeMirror> interfaces = new ArrayList<TypeMirror>(binding.superInterfaces().length);
- for (ReferenceBinding interfaceBinding : binding.superInterfaces()) {
- TypeMirror interfaceType = _env.getFactory().newTypeMirror(interfaceBinding);
- interfaces.add(interfaceType);
- }
- return Collections.unmodifiableList(interfaces);
- }
-
- @Override
- public ElementKind getKind() {
- if (null != _kindHint) {
- return _kindHint;
- }
- ReferenceBinding refBinding = (ReferenceBinding)_binding;
- // The order of these comparisons is important: e.g., enum is subset of class
- if (refBinding.isEnum()) {
- return ElementKind.ENUM;
- }
- else if (refBinding.isAnnotationType()) {
- return ElementKind.ANNOTATION_TYPE;
- }
- else if (refBinding.isInterface()) {
- return ElementKind.INTERFACE;
- }
- else if (refBinding.isClass()) {
- return ElementKind.CLASS;
- }
- else {
- throw new IllegalArgumentException("TypeElement " + new String(refBinding.shortReadableName()) + //$NON-NLS-1$
- " has unexpected attributes " + refBinding.modifiers); //$NON-NLS-1$
- }
- }
-
- @Override
- public Set<Modifier> getModifiers()
- {
- ReferenceBinding refBinding = (ReferenceBinding)_binding;
- int modifiers = refBinding.modifiers;
- if (refBinding.isInterface() && refBinding.isNestedType()) {
- modifiers |= ClassFileConstants.AccStatic;
- }
- return Factory.getModifiers(modifiers, getKind(), refBinding.isBinaryBinding());
- }
-
- @Override
- public NestingKind getNestingKind() {
- ReferenceBinding refBinding = (ReferenceBinding)_binding;
- if (refBinding.isAnonymousType()) {
- return NestingKind.ANONYMOUS;
- } else if (refBinding.isLocalType()) {
- return NestingKind.LOCAL;
- } else if (refBinding.isMemberType()) {
- return NestingKind.MEMBER;
- }
- return NestingKind.TOP_LEVEL;
- }
-
- @Override
- PackageElement getPackage()
- {
- ReferenceBinding binding = (ReferenceBinding)_binding;
- return _env.getFactory().newPackageElement((PackageBinding)binding.fPackage);
- }
-
- @Override
- public Name getQualifiedName() {
- ReferenceBinding binding = (ReferenceBinding)_binding;
- char[] qName;
- if (binding.isMemberType()) {
- qName = CharOperation.concatWith(binding.enclosingType().compoundName, binding.sourceName, '.');
- CharOperation.replace(qName, '$', '.');
- } else {
- qName = CharOperation.concatWith(binding.compoundName, '.');
- }
- return new NameImpl(qName);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jdt.internal.compiler.apt.model.ElementImpl#getSimpleName()
- * @return last segment of name, e.g. for pa.pb.X.Y return Y.
- */
- @Override
- public Name getSimpleName()
- {
- ReferenceBinding binding = (ReferenceBinding)_binding;
- return new NameImpl(binding.sourceName());
- }
-
- @Override
- public TypeMirror getSuperclass() {
- ReferenceBinding binding = (ReferenceBinding)_binding;
- ReferenceBinding superBinding = binding.superclass();
- if (null == superBinding || binding.isInterface()) {
- return _env.getFactory().getNoType(TypeKind.NONE);
- }
- // superclass of a type must be a DeclaredType
- return _env.getFactory().newDeclaredType(superBinding);
- }
-
- @Override
- public List<? extends TypeParameterElement> getTypeParameters() {
- ReferenceBinding binding = (ReferenceBinding)_binding;
- TypeVariableBinding[] variables = binding.typeVariables();
- if (variables.length == 0) {
- return Collections.emptyList();
- }
- List<TypeParameterElement> params = new ArrayList<TypeParameterElement>(variables.length);
- for (TypeVariableBinding variable : variables) {
- params.add(_env.getFactory().newTypeParameterElement(variable, this));
- }
- return Collections.unmodifiableList(params);
- }
-
- @Override
- public boolean hides(Element hidden)
- {
- if (!(hidden instanceof TypeElementImpl)) {
- return false;
- }
- ReferenceBinding hiddenBinding = (ReferenceBinding)((TypeElementImpl)hidden)._binding;
- if (hiddenBinding.isPrivate()) {
- return false;
- }
- ReferenceBinding hiderBinding = (ReferenceBinding)_binding;
- if (hiddenBinding == hiderBinding) {
- return false;
- }
- if (!hiddenBinding.isMemberType() || !hiderBinding.isMemberType()) {
- return false;
- }
- if (!CharOperation.equals(hiddenBinding.sourceName, hiderBinding.sourceName)) {
- return false;
- }
- return null != hiderBinding.enclosingType().findSuperTypeOriginatingFrom(hiddenBinding.enclosingType());
- }
-
- @Override
- public String toString() {
- ReferenceBinding binding = (ReferenceBinding) this._binding;
- char[] concatWith = CharOperation.concatWith(binding.compoundName, '.');
- if (binding.isNestedType()) {
- CharOperation.replace(concatWith, '$', '.');
- return new String(concatWith);
- }
- return new String(concatWith);
-
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeMirrorImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeMirrorImpl.java
deleted file mode 100644
index 22b7a440f6..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeMirrorImpl.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.compiler.apt.model;
-
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.type.TypeVisitor;
-
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-
-/**
- * Implementation of a TypeMirror. TypeMirror represents a type, including
- * types that have no declaration, such as primitives (int, boolean) and
- * types that are specializations of declarations (List<String>).
- */
-public class TypeMirrorImpl implements TypeMirror {
-
- // Caution: _env will be NULL for PrimitiveTypeImpl.
- protected final BaseProcessingEnvImpl _env;
- protected final Binding _binding;
-
- /* package */ TypeMirrorImpl(BaseProcessingEnvImpl env, Binding binding) {
- _env = env;
- _binding = binding;
- }
-
- /* package */ Binding binding() {
- return _binding;
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.TypeMirror#accept(javax.lang.model.type.TypeVisitor, java.lang.Object)
- */
- @Override
- public <R, P> R accept(TypeVisitor<R, P> v, P p) {
- return v.visit(this, p);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.TypeMirror#getKind()
- */
- @Override
- public TypeKind getKind() {
- switch (_binding.kind()) {
- // case Binding.TYPE:
- // case Binding.RAW_TYPE:
- // case Binding.GENERIC_TYPE:
- // case Binding.PARAMETERIZED_TYPE:
- // handled by DeclaredTypeImpl, etc.
- // case Binding.BASE_TYPE: handled by PrimitiveTypeImpl
- // case Binding.METHOD: handled by ExecutableTypeImpl
- // case Binding.PACKAGE: handled by NoTypeImpl
- // case Binding.WILDCARD_TYPE: handled by WildcardTypeImpl
- // case Binding.ARRAY_TYPE: handled by ArrayTypeImpl
- // case Binding.TYPE_PARAMETER: handled by TypeVariableImpl
- // TODO: fill in the rest of these
- case Binding.FIELD:
- case Binding.LOCAL:
- case Binding.VARIABLE:
- case Binding.IMPORT:
- throw new IllegalArgumentException("Invalid binding kind: " + _binding.kind()); //$NON-NLS-1$
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return new String(_binding.readableName());
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((_binding == null) ? 0 : _binding.hashCode());
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!(obj instanceof TypeMirrorImpl))
- return false;
- final TypeMirrorImpl other = (TypeMirrorImpl) obj;
- return _binding == other._binding;
- }
-
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeParameterElementImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeParameterElementImpl.java
deleted file mode 100644
index c76e4c4805..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeParameterElementImpl.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.compiler.apt.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ElementVisitor;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeParameterElement;
-import javax.lang.model.type.TypeMirror;
-
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-
-/**
- *
- */
-public class TypeParameterElementImpl extends ElementImpl implements TypeParameterElement
-{
- private final Element _declaringElement;
-
- // Cache the bounds, because they're expensive to compute
- private List<? extends TypeMirror> _bounds = null;
-
- /* package */ TypeParameterElementImpl(BaseProcessingEnvImpl env, TypeVariableBinding binding, Element declaringElement) {
- super(env, binding);
- _declaringElement = declaringElement;
- }
-
- /* package */ TypeParameterElementImpl(BaseProcessingEnvImpl env, TypeVariableBinding binding) {
- super(env, binding);
- _declaringElement = _env.getFactory().newElement(binding.declaringElement);
- }
-
- @Override
- public List<? extends TypeMirror> getBounds()
- {
- if (null == _bounds) {
- _bounds = calculateBounds();
- }
- return _bounds;
- }
-
- // This code is drawn from org.eclipse.jdt.core.dom.TypeBinding.getTypeBounds()
- private List<? extends TypeMirror> calculateBounds() {
- TypeVariableBinding typeVariableBinding = (TypeVariableBinding)_binding;
- ReferenceBinding varSuperclass = typeVariableBinding.superclass();
- TypeBinding firstClassOrArrayBound = typeVariableBinding.firstBound;
- int boundsLength = 0;
- if (firstClassOrArrayBound != null) {
- if (firstClassOrArrayBound == varSuperclass) {
- boundsLength++;
- } else if (firstClassOrArrayBound.isArrayType()) { // capture of ? extends/super arrayType
- boundsLength++;
- } else {
- firstClassOrArrayBound = null;
- }
- }
- ReferenceBinding[] superinterfaces = typeVariableBinding.superInterfaces();
- int superinterfacesLength = 0;
- if (superinterfaces != null) {
- superinterfacesLength = superinterfaces.length;
- boundsLength += superinterfacesLength;
- }
- List<TypeMirror> typeBounds = new ArrayList<TypeMirror>(boundsLength);
- if (boundsLength != 0) {
- if (firstClassOrArrayBound != null) {
- TypeMirror typeBinding = _env.getFactory().newTypeMirror(firstClassOrArrayBound);
- if (typeBinding == null) {
- return Collections.emptyList();
- }
- typeBounds.add(typeBinding);
- }
- if (superinterfaces != null) {
- for (int i = 0; i < superinterfacesLength; i++) {
- TypeMirror typeBinding = _env.getFactory().newTypeMirror(superinterfaces[i]);
- if (typeBinding == null) {
- return Collections.emptyList();
- }
- typeBounds.add(typeBinding);
- }
- }
- } else {
- // at least we must add java.lang.Object
- typeBounds.add(_env.getFactory().newTypeMirror(_env.getLookupEnvironment().getType(LookupEnvironment.JAVA_LANG_OBJECT)));
- }
- return Collections.unmodifiableList(typeBounds);
- }
-
- @Override
- public Element getGenericElement()
- {
- return _declaringElement;
- }
-
- @Override
- public <R, P> R accept(ElementVisitor<R, P> v, P p)
- {
- return v.visitTypeParameter(this, p);
- }
-
- /*
- * (non-Javadoc)
- * Java does not currently support annotations on type parameters.
- * @see javax.lang.model.element.Element#getAnnotationMirrors()
- */
- @Override
- protected AnnotationBinding[] getAnnotationBindings()
- {
- return null;
- }
-
- /*
- * (non-Javadoc)
- * Always return an empty list; type parameters do not enclose other elements.
- * @see javax.lang.model.element.Element#getEnclosedElements()
- */
- @Override
- public List<? extends Element> getEnclosedElements()
- {
- return Collections.emptyList();
- }
-
- /*
- * (non-Javadoc)
- * Always return null.
- * @see javax.lang.model.element.Element#getEnclosingElement()
- */
- @Override
- public Element getEnclosingElement()
- {
- return null;
- }
-
- @Override
- public ElementKind getKind()
- {
- return ElementKind.TYPE_PARAMETER;
- }
-
- @Override
- PackageElement getPackage()
- {
- // TODO what is the package of a type parameter?
- return null;
- }
-
- @Override
- public String toString() {
- return new String(_binding.readableName());
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeVariableImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeVariableImpl.java
deleted file mode 100644
index f6f1e6a6e0..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypeVariableImpl.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.internal.compiler.apt.model;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.type.TypeVariable;
-import javax.lang.model.type.TypeVisitor;
-
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-
-/**
- * @author OThomann
- *
- */
-public class TypeVariableImpl extends TypeMirrorImpl implements TypeVariable {
-
- public TypeVariableImpl(BaseProcessingEnvImpl env, TypeVariableBinding binding) {
- super(env, binding);
- }
- /* (non-Javadoc)
- * @see javax.lang.model.type.TypeVariable#asElement()
- */
- @Override
- public Element asElement() {
- return _env.getFactory().newElement(this._binding);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.TypeVariable#getLowerBound()
- */
- @Override
- public TypeMirror getLowerBound() {
- // TODO might be more complex than this
- return this._env.getFactory().getNullType();
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.TypeVariable#getUpperBound()
- */
- @Override
- public TypeMirror getUpperBound() {
- TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this._binding;
- TypeBinding firstBound = typeVariableBinding.firstBound;
- ReferenceBinding[] superInterfaces = typeVariableBinding.superInterfaces;
- if (firstBound == null || superInterfaces.length == 0) {
- // no explicit bound
- return _env.getFactory().newTypeMirror(typeVariableBinding.upperBound());
- }
- if (firstBound != null && superInterfaces.length == 1 && superInterfaces[0] == firstBound) {
- // only one bound that is an interface
- return _env.getFactory().newTypeMirror(typeVariableBinding.upperBound());
- }
- return this._env.getFactory().newDeclaredType((TypeVariableBinding) this._binding);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.TypeMirror#accept(javax.lang.model.type.TypeVisitor, java.lang.Object)
- */
- @Override
- public <R, P> R accept(TypeVisitor<R, P> v, P p) {
- return v.visitTypeVariable(this, p);
- }
-
- @Override
- public TypeKind getKind()
- {
- return TypeKind.TYPEVAR;
- }
-
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypesImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypesImpl.java
deleted file mode 100644
index 69c3f09755..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypesImpl.java
+++ /dev/null
@@ -1,453 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.compiler.apt.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.type.ArrayType;
-import javax.lang.model.type.DeclaredType;
-import javax.lang.model.type.ExecutableType;
-import javax.lang.model.type.NoType;
-import javax.lang.model.type.NullType;
-import javax.lang.model.type.PrimitiveType;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.type.WildcardType;
-import javax.lang.model.util.Types;
-
-import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.ast.Wildcard;
-import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
-
-/**
- * Utilities for working with types (as opposed to elements).
- * There is one of these for every ProcessingEnvironment.
- */
-public class TypesImpl implements Types {
-
- private final BaseProcessingEnvImpl _env;
-
- /*
- * The processing env creates and caches a TypesImpl. Other clients should
- * not create their own; they should ask the env for it.
- */
- public TypesImpl(BaseProcessingEnvImpl env) {
- _env = env;
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#asElement(javax.lang.model.type.TypeMirror)
- */
- @Override
- public Element asElement(TypeMirror t) {
- switch(t.getKind()) {
- case DECLARED :
- case TYPEVAR :
- return _env.getFactory().newElement(((TypeMirrorImpl)t).binding());
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#asMemberOf(javax.lang.model.type.DeclaredType, javax.lang.model.element.Element)
- */
- @Override
- public TypeMirror asMemberOf(DeclaredType containing, Element element) {
- // TODO Auto-generated method stub
-// throw new UnsupportedOperationException("NYI: TypesImpl.asMemberOf(" + containing + ", " + element + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ElementImpl elementImpl = (ElementImpl) element;
- DeclaredTypeImpl declaredTypeImpl = (DeclaredTypeImpl) containing;
- ReferenceBinding referenceBinding = (ReferenceBinding) declaredTypeImpl._binding;
- switch(element.getKind()) {
- case CONSTRUCTOR :
- case METHOD :
- MethodBinding methodBinding = (MethodBinding) elementImpl._binding;
- if (methodBinding.declaringClass != referenceBinding) {
- throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
- }
- for (MethodBinding method : referenceBinding.methods()) {
- if (CharOperation.equals(method.selector, methodBinding.selector)
- && method.areParameterErasuresEqual(methodBinding)) {
- return this._env.getFactory().newTypeMirror(method);
- }
- }
- break;
- case FIELD :
- case ENUM_CONSTANT:
- FieldBinding fieldBinding = (FieldBinding) elementImpl._binding;
- if (fieldBinding.declaringClass != referenceBinding) {
- throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
- }
- for (FieldBinding field : referenceBinding.fields()) {
- if (CharOperation.equals(field.name, fieldBinding.name)) {
- return this._env.getFactory().newTypeMirror(field);
- }
- }
- break;
- case ENUM :
- case ANNOTATION_TYPE :
- case INTERFACE :
- case CLASS :
- ReferenceBinding referenceBinding2 = (ReferenceBinding) elementImpl._binding;
- if (referenceBinding2.enclosingType() != referenceBinding) {
- throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
- }
- for (ReferenceBinding referenceBinding3 : referenceBinding.memberTypes()) {
- if (CharOperation.equals(referenceBinding3.compoundName, referenceBinding3.compoundName)) {
- return this._env.getFactory().newTypeMirror(referenceBinding3);
- }
- }
- break;
- }
- throw new IllegalArgumentException("element is not valid for the containing declared type: element kind " + element.getKind()); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#boxedClass(javax.lang.model.type.PrimitiveType)
- */
- @Override
- public TypeElement boxedClass(PrimitiveType p) {
- PrimitiveTypeImpl primitiveTypeImpl = (PrimitiveTypeImpl) p;
- BaseTypeBinding baseTypeBinding = (BaseTypeBinding)primitiveTypeImpl._binding;
- TypeBinding boxed = _env.getLookupEnvironment().computeBoxingType(baseTypeBinding);
- return (TypeElement) _env.getFactory().newElement(boxed);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#capture(javax.lang.model.type.TypeMirror)
- */
- @Override
- public TypeMirror capture(TypeMirror t) {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("NYI: TypesImpl.capture(...)"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#contains(javax.lang.model.type.TypeMirror, javax.lang.model.type.TypeMirror)
- */
- @Override
- public boolean contains(TypeMirror t1, TypeMirror t2) {
- switch(t1.getKind()) {
- case EXECUTABLE :
- case PACKAGE :
- throw new IllegalArgumentException("Executable and package are illegal argument for Types.contains(..)"); //$NON-NLS-1$
- }
- switch(t2.getKind()) {
- case EXECUTABLE :
- case PACKAGE :
- throw new IllegalArgumentException("Executable and package are illegal argument for Types.contains(..)"); //$NON-NLS-1$
- }
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("NYI: TypesImpl.contains(" + t1 + ", " + t2 + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#directSupertypes(javax.lang.model.type.TypeMirror)
- */
- @Override
- public List<? extends TypeMirror> directSupertypes(TypeMirror t) {
- switch(t.getKind()) {
- case PACKAGE :
- case EXECUTABLE :
- throw new IllegalArgumentException("Invalid type mirror for directSypertypes"); //$NON-NLS-1$
- }
- TypeMirrorImpl typeMirrorImpl = (TypeMirrorImpl) t;
- Binding binding = typeMirrorImpl._binding;
- if (binding instanceof ReferenceBinding) {
- ReferenceBinding referenceBinding = (ReferenceBinding) binding;
- ArrayList<TypeMirror> list = new ArrayList<TypeMirror>();
- ReferenceBinding superclass = referenceBinding.superclass();
- if (superclass != null) {
- list.add(this._env.getFactory().newTypeMirror(superclass));
- }
- for (ReferenceBinding interfaceBinding : referenceBinding.superInterfaces()) {
- list.add(this._env.getFactory().newTypeMirror(interfaceBinding));
- }
- return Collections.unmodifiableList(list);
- }
- return Collections.emptyList();
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#erasure(javax.lang.model.type.TypeMirror)
- */
- @Override
- public TypeMirror erasure(TypeMirror t) {
- TypeMirrorImpl typeMirrorImpl = (TypeMirrorImpl) t;
- Binding binding = typeMirrorImpl._binding;
- if (binding instanceof ReferenceBinding) {
- return _env.getFactory().newTypeMirror(((ReferenceBinding) binding).erasure());
- }
- // TODO should we return null or NoType ?
- throw new UnsupportedOperationException("NYI: TypesImpl.erasure(...) when not a reference binding"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#getArrayType(javax.lang.model.type.TypeMirror)
- */
- @Override
- public ArrayType getArrayType(TypeMirror componentType) {
- TypeMirrorImpl typeMirrorImpl = (TypeMirrorImpl) componentType;
- TypeBinding typeBinding = (TypeBinding) typeMirrorImpl._binding;
- return new ArrayTypeImpl(_env, this._env.getLookupEnvironment().createArrayType(
- typeBinding.leafComponentType(),
- typeBinding.dimensions() + 1));
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#getDeclaredType(javax.lang.model.element.TypeElement, javax.lang.model.type.TypeMirror[])
- */
- @Override
- public DeclaredType getDeclaredType(TypeElement typeElem, TypeMirror... typeArgs) {
- int typeArgsLength = typeArgs.length;
- TypeElementImpl typeElementImpl = (TypeElementImpl) typeElem;
- ReferenceBinding referenceBinding = (ReferenceBinding) typeElementImpl._binding;
- TypeVariableBinding[] typeVariables = referenceBinding.typeVariables();
- int typeVariablesLength = typeVariables.length;
- if (typeArgsLength == 0) {
- if (referenceBinding.isGenericType()) {
- // must return a raw type
- return _env.getFactory().newDeclaredType(this._env.getLookupEnvironment().createRawType(referenceBinding, null));
- }
- return (DeclaredType)typeElem.asType();
- } else if (typeArgsLength != typeVariablesLength) {
- throw new IllegalArgumentException("Number of typeArguments doesn't match the number of formal parameters of typeElem"); //$NON-NLS-1$
- }
- TypeBinding[] typeArguments = new TypeBinding[typeArgsLength];
- for (int i = 0; i < typeArgsLength; i++) {
- TypeMirrorImpl typeMirrorImpl = (TypeMirrorImpl) typeArgs[i];
- Binding binding = typeMirrorImpl._binding;
- if (!(binding instanceof ReferenceBinding)) {
- throw new IllegalArgumentException("Invalid type for a type arguments : " + typeMirrorImpl); //$NON-NLS-1$
- }
- typeArguments[i] = (ReferenceBinding) binding;
- }
- return _env.getFactory().newDeclaredType(
- this._env.getLookupEnvironment().createParameterizedType(referenceBinding, typeArguments, null));
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#getDeclaredType(javax.lang.model.type.DeclaredType, javax.lang.model.element.TypeElement, javax.lang.model.type.TypeMirror[])
- */
- @Override
- public DeclaredType getDeclaredType(DeclaredType containing, TypeElement typeElem,
- TypeMirror... typeArgs) {
- int typeArgsLength = typeArgs.length;
- TypeElementImpl typeElementImpl = (TypeElementImpl) typeElem;
- ReferenceBinding referenceBinding = (ReferenceBinding) typeElementImpl._binding;
- TypeVariableBinding[] typeVariables = referenceBinding.typeVariables();
- int typeVariablesLength = typeVariables.length;
- DeclaredTypeImpl declaredTypeImpl = (DeclaredTypeImpl) containing;
- ReferenceBinding enclosingType = (ReferenceBinding) declaredTypeImpl._binding;
- if (typeArgsLength == 0) {
- if (referenceBinding.isGenericType()) {
- // must return a raw type
- return _env.getFactory().newDeclaredType(this._env.getLookupEnvironment().createRawType(referenceBinding, enclosingType));
- }
- // TODO (see how to create a member type binding
- throw new UnsupportedOperationException("NYI: TypesImpl.getDeclaredType(...) for member types"); //$NON-NLS-1$
- } else if (typeArgsLength != typeVariablesLength) {
- throw new IllegalArgumentException("Number of typeArguments doesn't match the number of formal parameters of typeElem"); //$NON-NLS-1$
- }
- TypeBinding[] typeArguments = new TypeBinding[typeArgsLength];
- for (int i = 0; i < typeArgsLength; i++) {
- TypeMirrorImpl typeMirrorImpl = (TypeMirrorImpl) typeArgs[i];
- Binding binding = typeMirrorImpl._binding;
- if (!(binding instanceof ReferenceBinding)) {
- throw new IllegalArgumentException("Invalid type for a type arguments : " + typeMirrorImpl); //$NON-NLS-1$
- }
- typeArguments[i] = (ReferenceBinding) binding;
- }
- return _env.getFactory().newDeclaredType(
- this._env.getLookupEnvironment().createParameterizedType(referenceBinding, typeArguments, enclosingType));
- }
-
- @Override
- public NoType getNoType(TypeKind kind) {
- return _env.getFactory().getNoType(kind);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#getNullType()
- */
- @Override
- public NullType getNullType() {
- return _env.getFactory().getNullType();
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#getPrimitiveType(javax.lang.model.type.TypeKind)
- */
- @Override
- public PrimitiveType getPrimitiveType(TypeKind kind) {
- return _env.getFactory().getPrimitiveType(kind);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#getWildcardType(javax.lang.model.type.TypeMirror, javax.lang.model.type.TypeMirror)
- */
- @Override
- public WildcardType getWildcardType(TypeMirror extendsBound, TypeMirror superBound) {
- if (extendsBound != null && superBound != null) {
- throw new IllegalArgumentException("Extends and super bounds cannot be set at the same time"); //$NON-NLS-1$
- }
- if (extendsBound != null) {
- TypeMirrorImpl extendsBoundMirrorType = (TypeMirrorImpl) extendsBound;
- TypeBinding typeBinding = (TypeBinding) extendsBoundMirrorType._binding;
- return new WildcardTypeImpl(_env, this._env.getLookupEnvironment().createWildcard(
- null,
- 0,
- typeBinding,
- null,
- Wildcard.EXTENDS));
- }
- if (superBound != null) {
- TypeMirrorImpl superBoundMirrorType = (TypeMirrorImpl) superBound;
- TypeBinding typeBinding = (TypeBinding) superBoundMirrorType._binding;
- return new WildcardTypeImpl(_env, this._env.getLookupEnvironment().createWildcard(
- null,
- 0,
- typeBinding,
- null,
- Wildcard.SUPER));
- }
- return new WildcardTypeImpl(_env, this._env.getLookupEnvironment().createWildcard(
- null,
- 0,
- null,
- null,
- Wildcard.UNBOUND));
- }
-
- /**
- * @return true if a value of type t1 can be assigned to a variable of type t2, i.e., t2 = t1.
- */
- @Override
- public boolean isAssignable(TypeMirror t1, TypeMirror t2) {
- if (!(t1 instanceof TypeMirrorImpl) || !(t2 instanceof TypeMirrorImpl)) {
- return false;
- }
- Binding b1 = ((TypeMirrorImpl)t1).binding();
- Binding b2 = ((TypeMirrorImpl)t2).binding();
- if (!(b1 instanceof TypeBinding) || !(b2 instanceof TypeBinding)) {
- // package, method, import, etc.
- throw new IllegalArgumentException();
- }
- if (((TypeBinding)b1).isCompatibleWith((TypeBinding)b2)) {
- return true;
- }
-
- TypeBinding convertedType = _env.getLookupEnvironment().computeBoxingType((TypeBinding)b1);
- return null != convertedType && convertedType.isCompatibleWith((TypeBinding)b2);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#isSameType(javax.lang.model.type.TypeMirror, javax.lang.model.type.TypeMirror)
- */
- @Override
- public boolean isSameType(TypeMirror t1, TypeMirror t2) {
- if (t1.getKind() == TypeKind.WILDCARD || t2.getKind() == TypeKind.WILDCARD) {
- // Wildcard types are never equal, according to the spec of this method
- return false;
- }
- if (t1 == t2) {
- return true;
- }
- if (!(t1 instanceof TypeMirrorImpl) || !(t2 instanceof TypeMirrorImpl)) {
- return false;
- }
- Binding b1 = ((TypeMirrorImpl)t1).binding();
- Binding b2 = ((TypeMirrorImpl)t2).binding();
- return b1 == b2;
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.util.Types#isSubsignature(javax.lang.model.type.ExecutableType, javax.lang.model.type.ExecutableType)
- */
- @Override
- public boolean isSubsignature(ExecutableType m1, ExecutableType m2) {
- MethodBinding methodBinding1 = (MethodBinding) ((ExecutableTypeImpl) m1)._binding;
- MethodBinding methodBinding2 = (MethodBinding) ((ExecutableTypeImpl) m2)._binding;
- if (!CharOperation.equals(methodBinding1.selector, methodBinding2.selector))
- return false;
- return methodBinding1.areParameterErasuresEqual(methodBinding2) && methodBinding1.areTypeVariableErasuresEqual(methodBinding2);
- }
-
- /**
- * @return true if t1 is a subtype of t2, or if t1 == t2.
- */
- @Override
- public boolean isSubtype(TypeMirror t1, TypeMirror t2) {
- if (t1 instanceof NoTypeImpl) {
- if (t2 instanceof NoTypeImpl) {
- return ((NoTypeImpl) t1).getKind() == ((NoTypeImpl) t2).getKind();
- }
- return false;
- } else if (t2 instanceof NoTypeImpl) {
- return false;
- }
- if (!(t1 instanceof TypeMirrorImpl) || !(t2 instanceof TypeMirrorImpl)) {
- return false;
- }
- if (t1 == t2) {
- return true;
- }
- Binding b1 = ((TypeMirrorImpl)t1).binding();
- Binding b2 = ((TypeMirrorImpl)t2).binding();
- if (b1 == b2) {
- return true;
- }
- if (!(b1 instanceof TypeBinding) || !(b2 instanceof TypeBinding)) {
- // package, method, import, etc.
- return false;
- }
- if (b1.kind() == Binding.BASE_TYPE || b2.kind() == Binding.BASE_TYPE) {
- if (b1.kind() != b2.kind()) {
- return false;
- }
- else {
- // for primitives, compatibility implies subtype
- return ((TypeBinding)b1).isCompatibleWith((TypeBinding)b2);
- }
- }
- // TODO: array types and reference types
- throw new UnsupportedOperationException("NYI: TypesImpl.isSubtype(TypeMirror, TypeMirror) for array and reference types"); //$NON-NLS-1$
- }
-
- @Override
- public PrimitiveType unboxedType(TypeMirror t) {
- if (!(((TypeMirrorImpl)t)._binding instanceof ReferenceBinding)) {
- // Not an unboxable type - could be primitive, array, not a type at all, etc.
- throw new IllegalArgumentException("Given type mirror cannot be unboxed"); //$NON-NLS-1$
- }
- ReferenceBinding boxed = (ReferenceBinding)((TypeMirrorImpl)t)._binding;
- TypeBinding unboxed = _env.getLookupEnvironment().computeBoxingType(boxed);
- if (unboxed.kind() != Binding.BASE_TYPE) {
- // No boxing conversion was found
- throw new IllegalArgumentException();
- }
- return _env.getFactory().getPrimitiveType((BaseTypeBinding)unboxed);
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java
deleted file mode 100644
index ab78231508..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.internal.compiler.apt.model;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ElementVisitor;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.VariableElement;
-
-import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
-import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
-
-/**
- * Implementation of VariableElement, which represents a a field, enum constant,
- * method or constructor parameter, local variable, or exception parameter.
- */
-public class VariableElementImpl extends ElementImpl implements VariableElement {
-
- /**
- * @param binding might be a FieldBinding (for a field) or a LocalVariableBinding (for a method param)
- */
- VariableElementImpl(BaseProcessingEnvImpl env, VariableBinding binding) {
- super(env, binding);
- }
-
- @Override
- public <R, P> R accept(ElementVisitor<R, P> v, P p)
- {
- return v.visitVariable(this, p);
- }
-
- @Override
- protected AnnotationBinding[] getAnnotationBindings()
- {
- return ((VariableBinding)_binding).getAnnotations();
- }
-
- @Override
- public Object getConstantValue() {
- VariableBinding variableBinding = (VariableBinding) _binding;
- Constant constant = variableBinding.constant();
- if (constant == null || constant == Constant.NotAConstant) return null;
- TypeBinding type = variableBinding.type;
- switch (type.id) {
- case TypeIds.T_boolean:
- return constant.booleanValue();
- case TypeIds.T_byte:
- return constant.byteValue();
- case TypeIds.T_char:
- return constant.charValue();
- case TypeIds.T_double:
- return constant.doubleValue();
- case TypeIds.T_float:
- return constant.floatValue();
- case TypeIds.T_int:
- return constant.intValue();
- case TypeIds.T_JavaLangString:
- return constant.stringValue();
- case TypeIds.T_long:
- return constant.longValue();
- case TypeIds.T_short:
- return constant.shortValue();
- }
- return null;
- }
-
- @Override
- public List<? extends Element> getEnclosedElements() {
- return Collections.emptyList();
- }
-
- @Override
- public Element getEnclosingElement() {
- if (_binding instanceof FieldBinding) {
- return _env.getFactory().newElement(((FieldBinding)_binding).declaringClass);
- }
- else if (_binding instanceof LocalVariableBinding){
- //TODO: return enclosing method binding
- throw new UnsupportedOperationException("NYI: VariableElementImpl.getEnclosingElement()"); //$NON-NLS-1$
- }
- return null;
- }
-
- @Override
- public ElementKind getKind() {
- if (_binding instanceof FieldBinding) {
- if (((FieldBinding)_binding).declaringClass.isEnum()) {
- return ElementKind.ENUM_CONSTANT;
- }
- else {
- return ElementKind.FIELD;
- }
- }
- else {
- return ElementKind.PARAMETER;
- }
- }
-
- @Override
- public Set<Modifier> getModifiers()
- {
- if (_binding instanceof VariableBinding) {
- return Factory.getModifiers(((VariableBinding)_binding).modifiers, getKind());
- }
- return Collections.emptySet();
- }
-
- @Override
- PackageElement getPackage()
- {
- if (_binding instanceof FieldBinding) {
- PackageBinding pkgBinding = ((FieldBinding)_binding).declaringClass.fPackage;
- return _env.getFactory().newPackageElement(pkgBinding);
- }
- else {
- // TODO: what is the package of a method parameter?
- throw new UnsupportedOperationException("NYI: VariableElmentImpl.getPackage() for method parameter"); //$NON-NLS-1$
- }
- }
-
- @Override
- public Name getSimpleName() {
- return new NameImpl(((VariableBinding)_binding).name);
- }
-
- @Override
- public boolean hides(Element hiddenElement)
- {
- if (_binding instanceof FieldBinding) {
- if (!(((ElementImpl)hiddenElement)._binding instanceof FieldBinding)) {
- return false;
- }
- FieldBinding hidden = (FieldBinding)((ElementImpl)hiddenElement)._binding;
- if (hidden.isPrivate()) {
- return false;
- }
- FieldBinding hider = (FieldBinding)_binding;
- if (hidden == hider) {
- return false;
- }
- if (!CharOperation.equals(hider.name, hidden.name)) {
- return false;
- }
- return null != hider.declaringClass.findSuperTypeOriginatingFrom(hidden.declaringClass);
- }
- // TODO: should we implement hides() for method parameters?
- return false;
- }
-
- @Override
- public String toString() {
- return new String(((VariableBinding) _binding).name);
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/WildcardTypeImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/WildcardTypeImpl.java
deleted file mode 100644
index bdb946e194..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/WildcardTypeImpl.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jdt.internal.compiler.apt.model;
-
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.type.TypeVisitor;
-import javax.lang.model.type.WildcardType;
-
-import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
-import org.eclipse.jdt.internal.compiler.ast.Wildcard;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
-
-/**
- * Implementation of the WildcardType
- */
-public class WildcardTypeImpl extends TypeMirrorImpl implements WildcardType {
-
- public WildcardTypeImpl(BaseProcessingEnvImpl env, WildcardBinding binding) {
- super(env, binding);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.WildcardType#getExtendsBound()
- */
- @Override
- public TypeMirror getExtendsBound() {
- WildcardBinding wildcardBinding = (WildcardBinding) this._binding;
- if (wildcardBinding.boundKind != Wildcard.EXTENDS) return null;
- TypeBinding bound = wildcardBinding.bound;
- if (bound == null) return null;
- return _env.getFactory().newTypeMirror(bound);
- }
-
- /* (non-Javadoc)
- * @see javax.lang.model.type.TypeMirror#getKind()
- */
- @Override
- public TypeKind getKind() {
- return TypeKind.WILDCARD;
- }
- /* (non-Javadoc)
- * @see javax.lang.model.type.WildcardType#getSuperBound()
- */
- @Override
- public TypeMirror getSuperBound() {
- WildcardBinding wildcardBinding = (WildcardBinding) this._binding;
- if (wildcardBinding.boundKind != Wildcard.SUPER) return null;
- TypeBinding bound = wildcardBinding.bound;
- if (bound == null) return null;
- return _env.getFactory().newTypeMirror(bound);
- }
-
- @Override
- public <R, P> R accept(TypeVisitor<R, P> v, P p) {
- return v.visitWildcard(this, p);
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/Archive.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/Archive.java
deleted file mode 100644
index c87652354a..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/Archive.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Set;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
-import java.util.zip.ZipFile;
-
-/**
- * Used as a zip file cache.
- */
-public class Archive {
-
- public static final Archive UNKNOWN_ARCHIVE = new Archive();
-
- ZipFile zipFile;
- File file;
- protected Hashtable<String, ArrayList<String>> packagesCache;
-
- private Archive() {
- }
-
- public Archive(File file) throws ZipException, IOException {
- this.file = file;
- this.zipFile = new ZipFile(file);
- initialize();
- }
-
- private void initialize() {
- // initialize packages
- this.packagesCache = new Hashtable<String, ArrayList<String>>();
- nextEntry : for (Enumeration<? extends ZipEntry> e = this.zipFile.entries(); e.hasMoreElements(); ) {
- String fileName = ((ZipEntry) e.nextElement()).getName();
-
- // add the package name & all of its parent packages
- int last = fileName.lastIndexOf('/');
- // extract the package name
- String packageName = fileName.substring(0, last + 1);
- String typeName = fileName.substring(last + 1);
- ArrayList<String> types = this.packagesCache.get(packageName);
- if (types == null) {
- // might be empty if this is a directory entry
- if (typeName.length() == 0) {
- continue nextEntry;
- }
- types = new ArrayList<String>();
- types.add(typeName);
- this.packagesCache.put(packageName, types);
- } else {
- types.add(typeName);
- }
- }
- }
-
- public ArchiveFileObject getArchiveFileObject(String entryName, Charset charset) {
- return new ArchiveFileObject(this.file, this.zipFile, entryName, charset);
- }
-
- public boolean contains(String entryName) {
- return this.zipFile.getEntry(entryName) != null;
- }
-
- public Set<String> allPackages() {
- if (this.packagesCache == null) {
- this.initialize();
- }
- return this.packagesCache.keySet();
- }
-
- public ArrayList<String> getTypes(String packageName) {
- // package name is expected to ends with '/'
- return this.packagesCache.get(packageName);
- }
-
- public void flush() {
- this.packagesCache = null;
- }
-
- public void close() {
- try {
- if (this.zipFile != null) this.zipFile.close();
- this.packagesCache = null;
- } catch (IOException e) {
- // ignore
- }
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/ArchiveFileObject.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/ArchiveFileObject.java
deleted file mode 100644
index e79ed81168..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/ArchiveFileObject.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.charset.Charset;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.NestingKind;
-import javax.tools.JavaFileObject;
-
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
-
-/**
- * Implementation of a Java file object that corresponds to an entry in a zip/jar file
- */
-public class ArchiveFileObject implements JavaFileObject {
- private ZipEntry zipEntry;
- private ZipFile zipFile;
- private String entryName;
- private File file;
- private Charset charset;
-
- public ArchiveFileObject(File file, ZipFile zipFile, String entryName, Charset charset) {
- this.zipFile = zipFile;
- this.zipEntry = zipFile.getEntry(entryName);
- this.entryName = entryName;
- this.file = file;
- this.charset = charset;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileObject#getAccessLevel()
- */
- public Modifier getAccessLevel() {
- // cannot express multiple modifier
- if (getKind() != Kind.CLASS) {
- return null;
- }
- ClassFileReader reader = null;
- try {
- reader = ClassFileReader.read(this.zipFile, this.entryName);
- } catch (ClassFormatException e) {
- // ignore
- } catch (IOException e) {
- // ignore
- }
- if (reader == null) {
- return null;
- }
- final int accessFlags = reader.accessFlags();
- if ((accessFlags & ClassFileConstants.AccPublic) != 0) {
- return Modifier.PUBLIC;
- }
- if ((accessFlags & ClassFileConstants.AccAbstract) != 0) {
- return Modifier.ABSTRACT;
- }
- if ((accessFlags & ClassFileConstants.AccFinal) != 0) {
- return Modifier.FINAL;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileObject#getKind()
- */
- public Kind getKind() {
- String name = this.entryName.toLowerCase();
- if (name.endsWith(Kind.CLASS.extension)) {
- return Kind.CLASS;
- } else if (name.endsWith(Kind.SOURCE.extension)) {
- return Kind.SOURCE;
- } else if (name.endsWith(Kind.HTML.extension)) {
- return Kind.HTML;
- }
- return Kind.OTHER;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileObject#getNestingKind()
- */
- public NestingKind getNestingKind() {
- switch(getKind()) {
- case SOURCE :
- return NestingKind.TOP_LEVEL;
- case CLASS :
- ClassFileReader reader = null;
- try {
- reader = ClassFileReader.read(this.zipFile, this.entryName);
- } catch (ClassFormatException e) {
- // ignore
- } catch (IOException e) {
- // ignore
- }
- if (reader == null) {
- return null;
- }
- if (reader.isAnonymous()) {
- return NestingKind.ANONYMOUS;
- }
- if (reader.isLocal()) {
- return NestingKind.LOCAL;
- }
- if (reader.isMember()) {
- return NestingKind.MEMBER;
- }
- return NestingKind.TOP_LEVEL;
- default:
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileObject#isNameCompatible(java.lang.String, javax.tools.JavaFileObject.Kind)
- */
- public boolean isNameCompatible(String simpleName, Kind kind) {
- return this.zipEntry.getName().endsWith(simpleName + kind.extension);
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#delete()
- */
- public boolean delete() {
- throw new UnsupportedOperationException();
- }
-
- public boolean equals(Object o) {
- if (!(o instanceof ArchiveFileObject)) {
- return false;
- }
- ArchiveFileObject archiveFileObject = (ArchiveFileObject) o;
- return archiveFileObject.toUri().equals(this.toUri());
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#getCharContent(boolean)
- */
- public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
- if (getKind() == Kind.SOURCE) {
- return Util.getCharContents(this, ignoreEncodingErrors, org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(this.zipEntry, this.zipFile), this.charset.toString());
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#getLastModified()
- */
- public long getLastModified() {
- return this.zipEntry.getTime(); // looks the closest from the last modification
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#getName()
- */
- public String getName() {
- return this.zipEntry.getName();
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openInputStream()
- */
- public InputStream openInputStream() throws IOException {
- return this.zipFile.getInputStream(this.zipEntry);
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openOutputStream()
- */
- public OutputStream openOutputStream() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openReader(boolean)
- */
- public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openWriter()
- */
- public Writer openWriter() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#toUri()
- */
- public URI toUri() {
- try {
- return new URI("jar:" + this.file.toURI().getPath() + "!" + this.zipEntry.getName()); //$NON-NLS-1$//$NON-NLS-2$
- } catch (URISyntaxException e) {
- return null;
- }
- }
-
-
- @Override
- public String toString() {
- return this.file.getAbsolutePath() + "[" + this.zipEntry.getName() + "]";//$NON-NLS-1$//$NON-NLS-2$
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java
deleted file mode 100644
index f758444e15..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java
+++ /dev/null
@@ -1,1145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.nio.charset.Charset;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.zip.ZipException;
-
-import javax.tools.FileObject;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.StandardLocation;
-import javax.tools.JavaFileObject.Kind;
-
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.core.compiler.InvalidInputException;
-import org.eclipse.jdt.internal.compiler.batch.FileSystem;
-import org.eclipse.jdt.internal.compiler.batch.Main;
-import org.eclipse.jdt.internal.compiler.batch.Main.ResourceBundleFactory;
-import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
-import org.eclipse.jdt.internal.compiler.env.AccessRule;
-import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
-
-/**
- * Implementation of the Standard Java File Manager
- */
-public class EclipseFileManager implements StandardJavaFileManager {
- private static final String NO_EXTENSION = "";//$NON-NLS-1$
- static final int HAS_EXT_DIRS = 1;
- static final int HAS_BOOTCLASSPATH = 2;
- static final int HAS_ENDORSED_DIRS = 4;
- static final int HAS_PROCESSORPATH = 8;
-
- Map<File, Archive> archivesCache;
- Charset charset;
- Locale locale;
- Map<String, Iterable<? extends File>> locations;
- int flags;
- public ResourceBundle bundle;
-
- public EclipseFileManager(Locale locale, Charset charset) {
- this.locale = locale == null ? Locale.getDefault() : locale;
- this.charset = charset == null ? Charset.defaultCharset() : charset;
- this.locations = new HashMap<String, Iterable<? extends File>>();
- this.archivesCache = new HashMap<File, Archive>();
- try {
- this.setLocation(StandardLocation.PLATFORM_CLASS_PATH, getDefaultBootclasspath());
- Iterable<? extends File> defaultClasspath = getDefaultClasspath();
- this.setLocation(StandardLocation.CLASS_PATH, defaultClasspath);
- this.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH, defaultClasspath);
- } catch (IOException e) {
- // ignore
- }
- try {
- this.bundle = ResourceBundleFactory.getBundle(this.locale);
- } catch(MissingResourceException e) {
- System.out.println("Missing resource : " + Main.bundleName.replace('.', '/') + ".properties for locale " + locale); //$NON-NLS-1$//$NON-NLS-2$
- }
- }
-
- private void addFiles(File[][] jars, ArrayList<File> files) {
- if (jars != null) {
- for (File[] currentJars : jars) {
- if (currentJars != null) {
- for (File currentJar : currentJars) {
- if (currentJar.exists()) {
- files.add(currentJar);
- }
- }
- }
- }
- }
- }
-
-
- private void addFilesFrom(File javaHome, String propertyName, String defaultPath, ArrayList<File> files) {
- String extdirsStr = System.getProperty(propertyName);
- File[] directoriesToCheck = null;
- if (extdirsStr == null) {
- if (javaHome != null) {
- directoriesToCheck = new File[] { new File(javaHome, defaultPath) };
- }
- } else {
- StringTokenizer tokenizer = new StringTokenizer(extdirsStr, File.pathSeparator);
- ArrayList<String> paths = new ArrayList<String>();
- while (tokenizer.hasMoreTokens()) {
- paths.add(tokenizer.nextToken());
- }
- if (paths.size() != 0) {
- directoriesToCheck = new File[paths.size()];
- for (int i = 0; i < directoriesToCheck.length; i++) {
- directoriesToCheck[i] = new File(paths.get(i));
- }
- }
- }
- if (directoriesToCheck != null) {
- addFiles(Main.getLibrariesFiles(directoriesToCheck), files);
- }
-
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileManager#close()
- */
- public void close() throws IOException {
- this.locations = null;
- for (Archive archive : archivesCache.values()) {
- archive.close();
- }
- }
-
- private void collectAllMatchingFiles(File file, String normalizedPackageName, Set<Kind> kinds, boolean recurse, ArrayList<JavaFileObject> collector) {
- if (!isArchive(file)) {
- // we must have a directory
- File currentFile = new File(file, normalizedPackageName);
- if (!currentFile.exists()) return;
- String path;
- try {
- path = currentFile.getCanonicalPath();
- } catch (IOException e) {
- return;
- }
- if (File.separatorChar == '/') {
- if (!path.endsWith(normalizedPackageName)) return;
- } else if (!path.endsWith(normalizedPackageName.replace('/', File.separatorChar))) return;
- File[] files = currentFile.listFiles();
- if (files != null) {
- // this was a directory
- for (File f : files) {
- if (f.isDirectory() && recurse) {
- collectAllMatchingFiles(file, normalizedPackageName + '/' + f.getName(), kinds, recurse, collector);
- } else {
- final Kind kind = getKind(f);
- if (kinds.contains(kind)) {
- collector.add(new EclipseFileObject(normalizedPackageName + currentFile.getName(), currentFile.toURI(), kind, this.charset));
- }
- }
- }
- }
- // currentFile is not a directory
- // check if it matches the criteria
- final Kind kind = getKind(file);
- if (kinds.contains(kind)) {
- collector.add(new EclipseFileObject(normalizedPackageName + currentFile.getName(), currentFile.toURI(), kind, this.charset));
- }
- } else {
- Archive archive = this.getArchive(file);
- String key = normalizedPackageName;
- if (!normalizedPackageName.endsWith("/")) {//$NON-NLS-1$
- key += '/';
- }
- // we have an archive file
- if (recurse) {
- for (String packageName : archive.allPackages()) {
- if (packageName.startsWith(key)) {
- ArrayList<String> types = archive.getTypes(packageName);
- if (types != null) {
- for (String typeName : types) {
- final Kind kind = getKind(getExtension(typeName));
- if (kinds.contains(kind)) {
- collector.add(archive.getArchiveFileObject(packageName + typeName, this.charset));
- }
- }
- }
- }
- }
- } else {
- ArrayList<String> types = archive.getTypes(key);
- if (types != null) {
- for (String typeName : types) {
- final Kind kind = getKind(typeName);
- if (kinds.contains(kind)) {
- collector.add(archive.getArchiveFileObject(normalizedPackageName + typeName, this.charset));
- }
- }
- }
- }
- }
- }
-
- private Iterable<? extends File> concatFiles(Iterable<? extends File> iterable, Iterable<? extends File> iterable2) {
- ArrayList<File> list = new ArrayList<File>();
- if (iterable2 == null) return iterable;
- for (Iterator<? extends File> iterator = iterable.iterator(); iterator.hasNext(); ) {
- list.add(iterator.next());
- }
- for (Iterator<? extends File> iterator = iterable2.iterator(); iterator.hasNext(); ) {
- list.add(iterator.next());
- }
- return list;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileManager#flush()
- */
- public void flush() throws IOException {
- for (Archive archive : archivesCache.values()) {
- archive.flush();
- }
- }
-
- private Archive getArchive(File f) {
- // check the archive (jar/zip) cache
- Archive archive = this.archivesCache.get(f);
- if (archive == null) {
- // create a new archive
- if (f.exists()) {
- try {
- archive = new Archive(f);
- } catch (ZipException e) {
- // ignore
- } catch (IOException e) {
- // ignore
- }
- if (archive != null) {
- this.archivesCache.put(f, archive);
- } else {
- this.archivesCache.put(f, Archive.UNKNOWN_ARCHIVE);
- }
- } else {
- this.archivesCache.put(f, Archive.UNKNOWN_ARCHIVE);
- }
- }
- return archive;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileManager#getClassLoader(javax.tools.JavaFileManager.Location)
- */
- public ClassLoader getClassLoader(Location location) {
- Iterable<? extends File> files = getLocation(location);
- if (files == null) {
- // location is unknown
- return null;
- }
- ArrayList<URL> allURLs = new ArrayList<URL>();
- for (File f : files) {
- try {
- allURLs.add(f.toURI().toURL());
- } catch (MalformedURLException e) {
- // the url is malformed - this should not happen
- throw new RuntimeException(e);
- }
- }
- URL[] result = new URL[allURLs.size()];
- return new URLClassLoader(allURLs.toArray(result), getClass().getClassLoader());
- }
-
- private Iterable<? extends File> getPathsFrom(String path) {
- ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
- ArrayList<File> files = new ArrayList<File>();
- try {
- this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.toString(), false, false);
- } catch (InvalidInputException e) {
- return null;
- }
- for (FileSystem.Classpath classpath : paths) {
- files.add(new File(classpath.getPath()));
- }
- return files;
- }
-
- Iterable<? extends File> getDefaultBootclasspath() {
- ArrayList<File> files = new ArrayList<File>();
- String javaversion = System.getProperty("java.version");//$NON-NLS-1$
- if (javaversion != null && !javaversion.startsWith("1.6")) { //$NON-NLS-1$
- // wrong jdk - 1.6 is required
- return null;
- }
-
- /*
- * Handle >= JDK 1.6
- */
- String javaHome = System.getProperty("java.home"); //$NON-NLS-1$
- File javaHomeFile = null;
- if (javaHome != null) {
- javaHomeFile = new File(javaHome);
- if (!javaHomeFile.exists())
- javaHomeFile = null;
- }
-
- addFilesFrom(javaHomeFile, "java.endorsed.dirs", "/lib/endorsed", files);//$NON-NLS-1$//$NON-NLS-2$
- if (javaHomeFile != null) {
- File[] directoriesToCheck = null;
- if (System.getProperty("os.name").startsWith("Mac")) {//$NON-NLS-1$//$NON-NLS-2$
- directoriesToCheck = new File[] { new File(javaHomeFile, "../Classes"), //$NON-NLS-1$
- };
- } else {
- directoriesToCheck = new File[] { new File(javaHomeFile, "lib") //$NON-NLS-1$
- };
- }
- File[][] jars = Main.getLibrariesFiles(directoriesToCheck);
- addFiles(jars, files);
- }
- addFilesFrom(javaHomeFile, "java.ext.dirs", "/lib/ext", files);//$NON-NLS-1$//$NON-NLS-2$
- return files;
- }
-
- Iterable<? extends File> getDefaultClasspath() {
- // default classpath
- ArrayList<File> files = new ArrayList<File>();
- String classProp = System.getProperty("java.class.path"); //$NON-NLS-1$
- if ((classProp == null) || (classProp.length() == 0)) {
- return null;
- } else {
- StringTokenizer tokenizer = new StringTokenizer(classProp, File.pathSeparator);
- String token;
- while (tokenizer.hasMoreTokens()) {
- token = tokenizer.nextToken();
- File file = new File(token);
- if (file.exists()) {
- files.add(file);
- }
- }
- }
- return files;
- }
-
- private Iterable<? extends File> getEndorsedDirsFrom(String path) {
- ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
- ArrayList<File> files = new ArrayList<File>();
- try {
- this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.toString(), false, false);
- } catch (InvalidInputException e) {
- return null;
- }
- for (FileSystem.Classpath classpath : paths) {
- files.add(new File(classpath.getPath()));
- }
- return files;
- }
-
- private Iterable<? extends File> getExtdirsFrom(String path) {
- ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
- ArrayList<File> files = new ArrayList<File>();
- try {
- this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.toString(), false, false);
- } catch (InvalidInputException e) {
- return null;
- }
- for (FileSystem.Classpath classpath : paths) {
- files.add(new File(classpath.getPath()));
- }
- return files;
- }
-
- private String getExtension(File file) {
- String name = file.getName();
- return getExtension(name);
- }
- private String getExtension(String name) {
- int index = name.lastIndexOf('.');
- if (index == -1) {
- return NO_EXTENSION;
- }
- return name.substring(index);
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileManager#getFileForInput(javax.tools.JavaFileManager.Location, java.lang.String, java.lang.String)
- */
- public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException {
- Iterable<? extends File> files = getLocation(location);
- if (files == null) {
- throw new IllegalArgumentException("Unknown location : " + location);//$NON-NLS-1$
- }
- String normalizedFileName = normalized(packageName) + '/' + relativeName.replace('\\', '/');
- for (File file : files) {
- if (file.isDirectory()) {
- // handle directory
- File f = new File(file, normalizedFileName);
- if (f.exists()) {
- return new EclipseFileObject(packageName + File.separator + relativeName, f.toURI(), getKind(f), this.charset);
- } else {
- continue; // go to next entry in the location
- }
- } else if (isArchive(file)) {
- // handle archive file
- Archive archive = getArchive(file);
- if (archive != Archive.UNKNOWN_ARCHIVE) {
- if (archive.contains(normalizedFileName)) {
- return archive.getArchiveFileObject(normalizedFileName, this.charset);
- }
- }
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileManager#getFileForOutput(javax.tools.JavaFileManager.Location, java.lang.String, java.lang.String, javax.tools.FileObject)
- */
- public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling)
- throws IOException {
- Iterable<? extends File> files = getLocation(location);
- if (files == null) {
- throw new IllegalArgumentException("Unknown location : " + location);//$NON-NLS-1$
- }
- final Iterator<? extends File> iterator = files.iterator();
- if (iterator.hasNext()) {
- File file = iterator.next();
- String normalizedFileName = normalized(packageName) + '/' + relativeName.replace('\\', '/');
- File f = new File(file, normalizedFileName);
- return new EclipseFileObject(packageName + File.separator + relativeName, f.toURI(), getKind(f), this.charset);
- } else {
- throw new IllegalArgumentException("location is empty : " + location);//$NON-NLS-1$
- }
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileManager#getJavaFileForInput(javax.tools.JavaFileManager.Location, java.lang.String, javax.tools.JavaFileObject.Kind)
- */
- public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException {
- if (kind != Kind.CLASS && kind != Kind.SOURCE) {
- throw new IllegalArgumentException("Invalid kind : " + kind);//$NON-NLS-1$
- }
- Iterable<? extends File> files = getLocation(location);
- if (files == null) {
- throw new IllegalArgumentException("Unknown location : " + location);//$NON-NLS-1$
- }
- String normalizedFileName = normalized(className);
- normalizedFileName += kind.extension;
- for (File file : files) {
- if (file.isDirectory()) {
- // handle directory
- File f = new File(file, normalizedFileName);
- if (f.exists()) {
- return new EclipseFileObject(className, f.toURI(), kind, this.charset);
- } else {
- continue; // go to next entry in the location
- }
- } else if (isArchive(file)) {
- // handle archive file
- Archive archive = getArchive(file);
- if (archive != Archive.UNKNOWN_ARCHIVE) {
- if (archive.contains(normalizedFileName)) {
- return archive.getArchiveFileObject(normalizedFileName, this.charset);
- }
- }
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileManager#getJavaFileForOutput(javax.tools.JavaFileManager.Location, java.lang.String, javax.tools.JavaFileObject.Kind, javax.tools.FileObject)
- */
- public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling)
- throws IOException {
- if (kind != Kind.CLASS && kind != Kind.SOURCE) {
- throw new IllegalArgumentException("Invalid kind : " + kind);//$NON-NLS-1$
- }
- Iterable<? extends File> files = getLocation(location);
- if (files == null) {
- if (!location.equals(StandardLocation.CLASS_OUTPUT)
- && !location.equals(StandardLocation.SOURCE_OUTPUT))
- throw new IllegalArgumentException("Unknown location : " + location);//$NON-NLS-1$
- // we will use either the sibling or user.dir
- if (sibling != null) {
- String normalizedFileName = normalized(className);
- int index = normalizedFileName.lastIndexOf('/');
- if (index != -1) {
- normalizedFileName = normalizedFileName.substring(index + 1);
- }
- normalizedFileName += kind.extension;
- URI uri = sibling.toUri();
- URI uri2 = null;
- try {
- String path = uri.getPath();
- index = path.lastIndexOf('/');
- if (index != -1) {
- path = path.substring(0, index + 1);
- path += normalizedFileName;
- }
- uri2 = new URI(uri.getScheme(), uri.getHost(), path, uri.getFragment());
- } catch (URISyntaxException e) {
- throw new IllegalArgumentException("invalid sibling");//$NON-NLS-1$
- }
- return new EclipseFileObject(className, uri2, kind, this.charset);
- } else {
- String normalizedFileName = normalized(className);
- int index = normalizedFileName.lastIndexOf('/');
- if (index != -1) {
- normalizedFileName = normalizedFileName.substring(index + 1);
- }
- normalizedFileName += kind.extension;
- File f = new File(System.getProperty("user.dir"), normalizedFileName);//$NON-NLS-1$
- return new EclipseFileObject(className, f.toURI(), kind, this.charset);
- }
- }
- final Iterator<? extends File> iterator = files.iterator();
- if (iterator.hasNext()) {
- File file = iterator.next();
- String normalizedFileName = normalized(className);
- normalizedFileName += kind.extension;
- File f = new File(file, normalizedFileName);
- return new EclipseFileObject(className, f.toURI(), kind, this.charset);
- } else {
- throw new IllegalArgumentException("location is empty : " + location);//$NON-NLS-1$
- }
- }
-
- /* (non-Javadoc)
- * @see javax.tools.StandardJavaFileManager#getJavaFileObjects(java.io.File[])
- */
- public Iterable<? extends JavaFileObject> getJavaFileObjects(File... files) {
- return getJavaFileObjectsFromFiles(Arrays.asList(files));
- }
-
- /* (non-Javadoc)
- * @see javax.tools.StandardJavaFileManager#getJavaFileObjects(java.lang.String[])
- */
- public Iterable<? extends JavaFileObject> getJavaFileObjects(String... names) {
- return getJavaFileObjectsFromStrings(Arrays.asList(names));
- }
-
- /* (non-Javadoc)
- * @see javax.tools.StandardJavaFileManager#getJavaFileObjectsFromFiles(java.lang.Iterable)
- */
- public Iterable<? extends JavaFileObject> getJavaFileObjectsFromFiles(Iterable<? extends File> files) {
- ArrayList<JavaFileObject> javaFileArrayList = new ArrayList<JavaFileObject>();
- for (File f : files) {
- javaFileArrayList.add(new EclipseFileObject(f.getAbsolutePath(), f.toURI(), getKind(f), this.charset));
- }
- return javaFileArrayList;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.StandardJavaFileManager#getJavaFileObjectsFromStrings(java.lang.Iterable)
- */
- public Iterable<? extends JavaFileObject> getJavaFileObjectsFromStrings(Iterable<String> names) {
- ArrayList<File> files = new ArrayList<File>();
- for (String name : names) {
- files.add(new File(name));
- }
- return getJavaFileObjectsFromFiles(files);
- }
-
- public Kind getKind(File f) {
- return getKind(getExtension(f));
- }
-
- private Kind getKind(String extension) {
- if (Kind.CLASS.extension.equals(extension)) {
- return Kind.CLASS;
- } else if (Kind.SOURCE.extension.equals(extension)) {
- return Kind.SOURCE;
- } else if (Kind.HTML.extension.equals(extension)) {
- return Kind.HTML;
- }
- return Kind.OTHER;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.StandardJavaFileManager#getLocation(javax.tools.JavaFileManager.Location)
- */
- public Iterable<? extends File> getLocation(Location location) {
- if (this.locations == null) return null;
- return this.locations.get(location.getName());
- }
-
- private Iterable<? extends File> getOutputDir(String string) {
- if ("none".equals(string)) {//$NON-NLS-1$
- return null;
- }
- File file = new File(string);
- if (file.exists() && !file.isDirectory()) {
- throw new IllegalArgumentException("file : " + file.getAbsolutePath() + " is not a directory");//$NON-NLS-1$//$NON-NLS-2$
- }
- ArrayList<File> list = new ArrayList<File>(1);
- list.add(file);
- return list;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileManager#handleOption(java.lang.String, java.util.Iterator)
- */
- public boolean handleOption(String current, Iterator<String> remaining) {
- try {
- if ("-bootclasspath".equals(current)) {//$NON-NLS-1$
- remaining.remove(); // remove the current option
- if (remaining.hasNext()) {
- final Iterable<? extends File> bootclasspaths = getPathsFrom(remaining.next());
- if (bootclasspaths != null) {
- Iterable<? extends File> iterable = getLocation(StandardLocation.PLATFORM_CLASS_PATH);
- if ((this.flags & HAS_ENDORSED_DIRS) == 0
- && (this.flags & HAS_EXT_DIRS) == 0) {
- // override default bootclasspath
- setLocation(StandardLocation.PLATFORM_CLASS_PATH, bootclasspaths);
- } else if ((this.flags & HAS_ENDORSED_DIRS) != 0) {
- // endorseddirs have been processed first
- setLocation(StandardLocation.PLATFORM_CLASS_PATH,
- concatFiles(iterable, bootclasspaths));
- } else {
- // extdirs have been processed first
- setLocation(StandardLocation.PLATFORM_CLASS_PATH,
- prependFiles(iterable, bootclasspaths));
- }
- }
- remaining.remove();
- this.flags |= HAS_BOOTCLASSPATH;
- return true;
- } else {
- throw new IllegalArgumentException();
- }
- }
- if ("-classpath".equals(current) || "-cp".equals(current)) {//$NON-NLS-1$//$NON-NLS-2$
- remaining.remove(); // remove the current option
- if (remaining.hasNext()) {
- final Iterable<? extends File> classpaths = getPathsFrom(remaining.next());
- if (classpaths != null) {
- Iterable<? extends File> iterable = getLocation(StandardLocation.CLASS_PATH);
- if (iterable != null) {
- setLocation(StandardLocation.CLASS_PATH,
- concatFiles(iterable, classpaths));
- } else {
- setLocation(StandardLocation.CLASS_PATH, classpaths);
- }
- if ((this.flags & HAS_PROCESSORPATH) == 0) {
- setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH, classpaths);
- }
- }
- remaining.remove();
- return true;
- } else {
- throw new IllegalArgumentException();
- }
- }
- if ("-encoding".equals(current)) {//$NON-NLS-1$
- remaining.remove(); // remove the current option
- if (remaining.hasNext()) {
- this.charset = Charset.forName(remaining.next());
- remaining.remove();
- return true;
- } else {
- throw new IllegalArgumentException();
- }
- }
- if ("-sourcepath".equals(current)) {//$NON-NLS-1$
- remaining.remove(); // remove the current option
- if (remaining.hasNext()) {
- final Iterable<? extends File> sourcepaths = getPathsFrom(remaining.next());
- if (sourcepaths != null) setLocation(StandardLocation.SOURCE_PATH, sourcepaths);
- remaining.remove();
- return true;
- } else {
- throw new IllegalArgumentException();
- }
- }
- if ("-extdirs".equals(current)) {//$NON-NLS-1$
- remaining.remove(); // remove the current option
- if (remaining.hasNext()) {
- Iterable<? extends File> iterable = getLocation(StandardLocation.PLATFORM_CLASS_PATH);
- setLocation(StandardLocation.PLATFORM_CLASS_PATH,
- concatFiles(iterable, getExtdirsFrom(remaining.next())));
- remaining.remove();
- this.flags |= HAS_EXT_DIRS;
- return true;
- } else {
- throw new IllegalArgumentException();
- }
- }
- if ("-endorseddirs".equals(current)) {//$NON-NLS-1$
- remaining.remove(); // remove the current option
- if (remaining.hasNext()) {
- Iterable<? extends File> iterable = getLocation(StandardLocation.PLATFORM_CLASS_PATH);
- setLocation(StandardLocation.PLATFORM_CLASS_PATH,
- prependFiles(iterable, getEndorsedDirsFrom(remaining.next())));
- remaining.remove();
- this.flags |= HAS_ENDORSED_DIRS;
- return true;
- } else {
- throw new IllegalArgumentException();
- }
- }
- if ("-d".equals(current)) { //$NON-NLS-1$
- remaining.remove(); // remove the current option
- if (remaining.hasNext()) {
- final Iterable<? extends File> outputDir = getOutputDir(remaining.next());
- if (outputDir != null) {
- setLocation(StandardLocation.CLASS_OUTPUT, outputDir);
- }
- remaining.remove();
- return true;
- } else {
- throw new IllegalArgumentException();
- }
- }
- if ("-s".equals(current)) { //$NON-NLS-1$
- remaining.remove(); // remove the current option
- if (remaining.hasNext()) {
- final Iterable<? extends File> outputDir = getOutputDir(remaining.next());
- if (outputDir != null) {
- setLocation(StandardLocation.SOURCE_OUTPUT, outputDir);
- }
- remaining.remove();
- return true;
- } else {
- throw new IllegalArgumentException();
- }
- }
- if ("-processorpath".equals(current)) {//$NON-NLS-1$
- remaining.remove(); // remove the current option
- if (remaining.hasNext()) {
- final Iterable<? extends File> processorpaths = getPathsFrom(remaining.next());
- if (processorpaths != null) {
- setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH, processorpaths);
- }
- remaining.remove();
- this.flags |= HAS_PROCESSORPATH;
- return true;
- } else {
- throw new IllegalArgumentException();
- }
- }
- } catch (IOException e) {
- // ignore
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileManager#hasLocation(javax.tools.JavaFileManager.Location)
- */
- public boolean hasLocation(Location location) {
- return this.locations != null && this.locations.containsKey(location.getName());
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileManager#inferBinaryName(javax.tools.JavaFileManager.Location, javax.tools.JavaFileObject)
- */
- public String inferBinaryName(Location location, JavaFileObject file) {
- String name = file.getName();
- JavaFileObject javaFileObject = null;
- int index = name.lastIndexOf('.');
- if (index != -1) {
- name = name.substring(0, index);
- }
- try {
- javaFileObject = getJavaFileForInput(location, name, file.getKind());
- } catch (IOException e) {
- // ignore
- }
- if (javaFileObject == null) {
- return null;
- }
- return normalized(name);
- }
-
- private boolean isArchive(File f) {
- String extension = getExtension(f);
- return extension.equalsIgnoreCase(".jar") || extension.equalsIgnoreCase(".zip");//$NON-NLS-1$//$NON-NLS-2$
- }
-
- /* (non-Javadoc)
- * @see javax.tools.StandardJavaFileManager#isSameFile(javax.tools.FileObject, javax.tools.FileObject)
- */
- public boolean isSameFile(FileObject fileObject1, FileObject fileObject2) {
- // EclipseFileManager creates only EcliseFileObject
- if (!(fileObject1 instanceof EclipseFileObject)) throw new IllegalArgumentException("Unsupported file object class : " + fileObject1.getClass());//$NON-NLS-1$
- if (!(fileObject2 instanceof EclipseFileObject)) throw new IllegalArgumentException("Unsupported file object class : " + fileObject2.getClass());//$NON-NLS-1$
- return fileObject1.equals(fileObject2);
- }
- /* (non-Javadoc)
- * @see javax.tools.OptionChecker#isSupportedOption(java.lang.String)
- */
- public int isSupportedOption(String option) {
- return Options.processOptionsFileManager(option);
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileManager#list(javax.tools.JavaFileManager.Location, java.lang.String, java.util.Set, boolean)
- */
- public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse)
- throws IOException {
-
- Iterable<? extends File> allFilesInLocations = getLocation(location);
- if (allFilesInLocations == null) {
- throw new IllegalArgumentException("Unknown location : " + location);//$NON-NLS-1$
- }
-
- ArrayList<JavaFileObject> collector = new ArrayList<JavaFileObject>();
- String normalizedPackageName = normalized(packageName);
- for (File file : allFilesInLocations) {
- collectAllMatchingFiles(file, normalizedPackageName, kinds, recurse, collector);
- }
- return collector;
- }
-
- private String normalized(String className) {
- char[] classNameChars = className.toCharArray();
- for (int i = 0, max = classNameChars.length; i < max; i++) {
- switch(classNameChars[i]) {
- case '\\' :
- classNameChars[i] = '/';
- break;
- case '.' :
- classNameChars[i] = '/';
- }
- }
- return new String(classNameChars);
- }
-
- private Iterable<? extends File> prependFiles(Iterable<? extends File> iterable,
- Iterable<? extends File> iterable2) {
- if (iterable2 == null) return iterable;
- ArrayList<File> list = new ArrayList<File>();
- for (Iterator<? extends File> iterator = iterable2.iterator(); iterator.hasNext(); ) {
- list.add(iterator.next());
- }
- for (Iterator<? extends File> iterator = iterable.iterator(); iterator.hasNext(); ) {
- list.add(iterator.next());
- }
- return list;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.StandardJavaFileManager#setLocation(javax.tools.JavaFileManager.Location, java.lang.Iterable)
- */
- public void setLocation(Location location, Iterable<? extends File> path) throws IOException {
- if (path != null) {
- if (location.isOutputLocation()) {
- // output location
- int count = 0;
- for (Iterator<? extends File> iterator = path.iterator(); iterator.hasNext(); ) {
- iterator.next();
- count++;
- }
- if (count != 1) {
- throw new IllegalArgumentException("output location can only have one path");//$NON-NLS-1$
- }
- }
- this.locations.put(location.getName(), path);
- }
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale == null ? Locale.getDefault() : locale;
- try {
- this.bundle = ResourceBundleFactory.getBundle(this.locale);
- } catch(MissingResourceException e) {
- System.out.println("Missing resource : " + Main.bundleName.replace('.', '/') + ".properties for locale " + locale); //$NON-NLS-1$//$NON-NLS-2$
- throw e;
- }
- }
-
- @SuppressWarnings("unchecked")
- public void processPathEntries(final int defaultSize, final ArrayList paths,
- final String currentPath, String customEncoding, boolean isSourceOnly,
- boolean rejectDestinationPathOnJars)
- throws InvalidInputException {
- String currentClasspathName = null;
- String currentDestinationPath = null;
- ArrayList currentRuleSpecs = new ArrayList(defaultSize);
- StringTokenizer tokenizer = new StringTokenizer(currentPath,
- File.pathSeparator + "[]", true); //$NON-NLS-1$
- ArrayList tokens = new ArrayList();
- while (tokenizer.hasMoreTokens()) {
- tokens.add(tokenizer.nextToken());
- }
- // state machine
- final int start = 0;
- final int readyToClose = 1;
- // 'path' 'path1[rule];path2'
- final int readyToCloseEndingWithRules = 2;
- // 'path[rule]' 'path1;path2[rule]'
- final int readyToCloseOrOtherEntry = 3;
- // 'path[rule];' 'path;' 'path1;path2;'
- final int rulesNeedAnotherRule = 4;
- // 'path[rule1;'
- final int rulesStart = 5;
- // 'path[' 'path1;path2['
- final int rulesReadyToClose = 6;
- // 'path[rule' 'path[rule1;rule2'
- final int destinationPathReadyToClose = 7;
- // 'path[-d bin'
- final int readyToCloseEndingWithDestinationPath = 8;
- // 'path[-d bin]' 'path[rule][-d bin]'
- final int destinationPathStart = 9;
- // 'path[rule]['
- final int bracketOpened = 10;
- // '.*[.*'
- final int bracketClosed = 11;
- // '.*([.*])+'
-
- final int error = 99;
- int state = start;
- String token = null;
- int cursor = 0, tokensNb = tokens.size(), bracket = -1;
- while (cursor < tokensNb && state != error) {
- token = (String) tokens.get(cursor++);
- if (token.equals(File.pathSeparator)) {
- switch (state) {
- case start:
- case readyToCloseOrOtherEntry:
- case bracketOpened:
- break;
- case readyToClose:
- case readyToCloseEndingWithRules:
- case readyToCloseEndingWithDestinationPath:
- state = readyToCloseOrOtherEntry;
- addNewEntry(paths, currentClasspathName, currentRuleSpecs,
- customEncoding, currentDestinationPath, isSourceOnly,
- rejectDestinationPathOnJars);
- currentRuleSpecs.clear();
- break;
- case rulesReadyToClose:
- state = rulesNeedAnotherRule;
- break;
- case destinationPathReadyToClose:
- throw new InvalidInputException(
- this.bind("configure.incorrectDestinationPathEntry", //$NON-NLS-1$
- currentPath));
- case bracketClosed:
- cursor = bracket + 1;
- state = rulesStart;
- break;
- default:
- state = error;
- }
- } else if (token.equals("[")) { //$NON-NLS-1$
- switch (state) {
- case start:
- currentClasspathName = ""; //$NON-NLS-1$
- case readyToClose:
- bracket = cursor - 1;
- case bracketClosed:
- state = bracketOpened;
- break;
- case readyToCloseEndingWithRules:
- state = destinationPathStart;
- break;
- case readyToCloseEndingWithDestinationPath:
- state = rulesStart;
- break;
- case bracketOpened:
- default:
- state = error;
- }
- } else if (token.equals("]")) { //$NON-NLS-1$
- switch (state) {
- case rulesReadyToClose:
- state = readyToCloseEndingWithRules;
- break;
- case destinationPathReadyToClose:
- state = readyToCloseEndingWithDestinationPath;
- break;
- case bracketOpened:
- state = bracketClosed;
- break;
- case bracketClosed:
- default:
- state = error;
- }
- } else {
- // regular word
- switch (state) {
- case start:
- case readyToCloseOrOtherEntry:
- state = readyToClose;
- currentClasspathName = token;
- break;
- case rulesStart:
- if (token.startsWith("-d ")) { //$NON-NLS-1$
- if (currentDestinationPath != null) {
- throw new InvalidInputException(
- this.bind("configure.duplicateDestinationPathEntry", //$NON-NLS-1$
- currentPath));
- }
- currentDestinationPath = token.substring(3).trim();
- state = destinationPathReadyToClose;
- break;
- } // else we proceed with a rule
- case rulesNeedAnotherRule:
- if (currentDestinationPath != null) {
- throw new InvalidInputException(
- this.bind("configure.accessRuleAfterDestinationPath", //$NON-NLS-1$
- currentPath));
- }
- state = rulesReadyToClose;
- currentRuleSpecs.add(token);
- break;
- case destinationPathStart:
- if (!token.startsWith("-d ")) { //$NON-NLS-1$
- state = error;
- } else {
- currentDestinationPath = token.substring(3).trim();
- state = destinationPathReadyToClose;
- }
- break;
- case bracketClosed:
- for (int i = bracket; i < cursor ; i++) {
- currentClasspathName += (String) tokens.get(i);
- }
- state = readyToClose;
- break;
- case bracketOpened:
- break;
- default:
- state = error;
- }
- }
- if (state == bracketClosed && cursor == tokensNb) {
- cursor = bracket + 1;
- state = rulesStart;
- }
- }
- switch(state) {
- case readyToCloseOrOtherEntry:
- break;
- case readyToClose:
- case readyToCloseEndingWithRules:
- case readyToCloseEndingWithDestinationPath:
- addNewEntry(paths, currentClasspathName, currentRuleSpecs,
- customEncoding, currentDestinationPath, isSourceOnly,
- rejectDestinationPathOnJars);
- break;
- case bracketOpened:
- case bracketClosed:
- default :
- // we go on anyway
- }
- }
- @SuppressWarnings("unchecked")
- protected void addNewEntry(ArrayList paths, String currentClasspathName,
- ArrayList currentRuleSpecs, String customEncoding,
- String destPath, boolean isSourceOnly,
- boolean rejectDestinationPathOnJars) throws InvalidInputException {
-
- int rulesSpecsSize = currentRuleSpecs.size();
- AccessRuleSet accessRuleSet = null;
- if (rulesSpecsSize != 0) {
- AccessRule[] accessRules = new AccessRule[currentRuleSpecs.size()];
- boolean rulesOK = true;
- Iterator i = currentRuleSpecs.iterator();
- int j = 0;
- while (i.hasNext()) {
- String ruleSpec = (String) i.next();
- char key = ruleSpec.charAt(0);
- String pattern = ruleSpec.substring(1);
- if (pattern.length() > 0) {
- switch (key) {
- case '+':
- accessRules[j++] = new AccessRule(pattern
- .toCharArray(), 0);
- break;
- case '~':
- accessRules[j++] = new AccessRule(pattern
- .toCharArray(),
- IProblem.DiscouragedReference);
- break;
- case '-':
- accessRules[j++] = new AccessRule(pattern
- .toCharArray(),
- IProblem.ForbiddenReference);
- break;
- case '?':
- accessRules[j++] = new AccessRule(pattern
- .toCharArray(),
- IProblem.ForbiddenReference, true/*keep looking for accessible type*/);
- break;
- default:
- rulesOK = false;
- }
- } else {
- rulesOK = false;
- }
- }
- if (rulesOK) {
- accessRuleSet = new AccessRuleSet(accessRules, AccessRestriction.COMMAND_LINE, currentClasspathName);
- } else {
- return;
- }
- }
- if (Main.NONE.equals(destPath)) {
- destPath = Main.NONE; // keep == comparison valid
- }
- if (rejectDestinationPathOnJars && destPath != null &&
- (currentClasspathName.endsWith(".jar") || //$NON-NLS-1$
- currentClasspathName.endsWith(".zip"))) { //$NON-NLS-1$
- throw new InvalidInputException(
- this.bind("configure.unexpectedDestinationPathEntryFile", //$NON-NLS-1$
- currentClasspathName));
- }
- FileSystem.Classpath currentClasspath = FileSystem.getClasspath(
- currentClasspathName,
- customEncoding,
- isSourceOnly,
- accessRuleSet,
- destPath);
- if (currentClasspath != null) {
- paths.add(currentClasspath);
- }
- }
- /*
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given string.
- */
- private String bind(String id, String binding) {
- return bind(id, new String[] { binding });
- }
-
- /*
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given string values.
- */
- private String bind(String id, String[] arguments) {
- if (id == null)
- return "No message available"; //$NON-NLS-1$
- String message = null;
- try {
- message = this.bundle.getString(id);
- } catch (MissingResourceException e) {
- // If we got an exception looking for the message, fail gracefully by just returning
- // the id we were looking for. In most cases this is semi-informative so is not too bad.
- return "Missing message: " + id + " in: " + Main.bundleName; //$NON-NLS-2$ //$NON-NLS-1$
- }
- return MessageFormat.format(message, (Object[]) arguments);
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileObject.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileObject.java
deleted file mode 100644
index 8bec3fbc5f..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileObject.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * IBM Corporation - initial API and implementation
- * Walter Harley - Patch for ensuring the parent folders are created
- *******************************************************************************/
-
-package org.eclipse.jdt.internal.compiler.apt.util;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.URI;
-import java.nio.charset.Charset;
-
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.NestingKind;
-import javax.tools.SimpleJavaFileObject;
-
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
-
-/**
- * Implementation of a Java file object that corresponds to a file on the file system
- */
-public class EclipseFileObject extends SimpleJavaFileObject {
- private File f;
- private Charset charset;
- private boolean parentsExist; // parent directories exist
-
- public EclipseFileObject(String className, URI uri, Kind kind, Charset charset) {
- super(uri, kind);
- this.f = new File(this.uri);
- this.charset = charset;
- this.parentsExist = false;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileObject#getAccessLevel()
- */
- public Modifier getAccessLevel() {
- // cannot express multiple modifier
- if (getKind() != Kind.CLASS) {
- return null;
- }
- ClassFileReader reader = null;
- try {
- reader = ClassFileReader.read(this.f);
- } catch (ClassFormatException e) {
- // ignore
- } catch (IOException e) {
- // ignore
- }
- if (reader == null) {
- return null;
- }
- final int accessFlags = reader.accessFlags();
- if ((accessFlags & ClassFileConstants.AccPublic) != 0) {
- return Modifier.PUBLIC;
- }
- if ((accessFlags & ClassFileConstants.AccAbstract) != 0) {
- return Modifier.ABSTRACT;
- }
- if ((accessFlags & ClassFileConstants.AccFinal) != 0) {
- return Modifier.FINAL;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.tools.JavaFileObject#getNestingKind()
- */
- public NestingKind getNestingKind() {
- switch(kind) {
- case SOURCE :
- return NestingKind.TOP_LEVEL;
- case CLASS :
- ClassFileReader reader = null;
- try {
- reader = ClassFileReader.read(this.f);
- } catch (ClassFormatException e) {
- // ignore
- } catch (IOException e) {
- // ignore
- }
- if (reader == null) {
- return null;
- }
- if (reader.isAnonymous()) {
- return NestingKind.ANONYMOUS;
- }
- if (reader.isLocal()) {
- return NestingKind.LOCAL;
- }
- if (reader.isMember()) {
- return NestingKind.MEMBER;
- }
- return NestingKind.TOP_LEVEL;
- default:
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#delete()
- */
- public boolean delete() {
- return this.f.delete();
- }
-
- public boolean equals(Object o) {
- if (!(o instanceof EclipseFileObject)) {
- return false;
- }
- EclipseFileObject eclipseFileObject = (EclipseFileObject) o;
- return eclipseFileObject.toUri().equals(this.uri);
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#getCharContent(boolean)
- */
- public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
- return Util.getCharContents(this, ignoreEncodingErrors, org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(this.f), this.charset.toString());
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#getLastModified()
- */
- public long getLastModified() {
- return this.f.lastModified();
- }
-
- public String getName() {
- return this.f.getPath();
- }
-
- public int hashCode() {
- return f.hashCode();
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openInputStream()
- */
- public InputStream openInputStream() throws IOException {
- // TODO (olivier) should be used buffered input stream
- return new FileInputStream(this.f);
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openOutputStream()
- */
- public OutputStream openOutputStream() throws IOException {
- ensureParentDirectoriesExist();
- return new FileOutputStream(this.f);
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openReader(boolean)
- */
- public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
- return new FileReader(this.f);
- }
-
- /* (non-Javadoc)
- * @see javax.tools.FileObject#openWriter()
- */
- public Writer openWriter() throws IOException {
- ensureParentDirectoriesExist();
- return new FileWriter(this.f);
- }
-
- @Override
- public String toString() {
- return this.f.getAbsolutePath();
- }
-
- private void ensureParentDirectoriesExist() throws IOException {
- if (!this.parentsExist) {
- File parent = f.getParentFile();
- if (parent != null && !parent.exists()) {
- if (!parent.mkdirs()) {
- // could have been concurrently created
- if (!parent.exists() || !parent.isDirectory())
- throw new IOException("Unable to create parent directories for " + f); //$NON-NLS-1$
- }
- }
- this.parentsExist = true;
- }
- }
-
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/ManyToMany.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/ManyToMany.java
deleted file mode 100644
index 62e1a12556..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/ManyToMany.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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
- * (originally in org.eclipse.jdt.apt.core)
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.util;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Manage a Map<T1, Set<T2>>, with reverse links so that it is possible to
- * efficiently find all T1s that have a particular T2 associated with them.
- * Access to the map is synchronized, so that it is possible to read and
- * write simultaneously from multiple threads.
- * <p>
- * The map permits the null value for keys nor for value elements.
- * <p>
- * Design invariants preserved by all operations on this map are as follows:
- * <ul>
- * <li> If a key exists, it has at least one value associated with it; that is,
- * for all k such that null != containsKey(k), getValues(k) returns a non-empty
- * set.</li>
- * <li> If a value exists, it has at least one key associated with it; that is,
- * for all v such that null != containsValue(v), getKeys(v) returns a non-empty
- * set.</li>
- */
-public class ManyToMany<T1, T2> {
-
- private final Map<T1, Set<T2>> _forward = new HashMap<T1, Set<T2>>();
- private final Map<T2, Set<T1>> _reverse = new HashMap<T2, Set<T1>>();
- private boolean _dirty = false;
-
- /**
- * Empty all maps. If the maps previously contained entries,
- * this will set the dirty bit.
- * @return true if the maps contained any entries prior to being cleared
- */
- public synchronized boolean clear() {
- boolean hadContent = !_forward.isEmpty() || !_reverse.isEmpty();
- _reverse.clear();
- _forward.clear();
- _dirty |= hadContent;
- return hadContent;
- }
-
- /**
- * Sets the dirty bit to false. Internal operations do not use the dirty
- * bit; clearing it will not affect behavior of the map. It's just there
- * for the convenience of callers who don't want to keep track of every
- * put() and remove().
- */
- public synchronized void clearDirtyBit() {
- _dirty = false;
- }
-
- /**
- * Equivalent to keySet().contains(key).
- * @return true if the map contains the specified key.
- */
- public synchronized boolean containsKey(T1 key) {
- return _forward.containsKey(key);
- }
-
- /**
- * Is there a key that is mapped to the specified value?
- * Search within the forward map.
- * @return true if such a key exists
- */
- public synchronized boolean containsKeyValuePair(T1 key, T2 value) {
- Set<T2> values = _forward.get(key);
- if (null == values) {
- return false;
- }
- return values.contains(value);
- }
-
- /**
- * Equivalent to values().contains(value).
- * @return true if the map contains the specified value (regardless
- * of what key it might be associated with).
- */
- public synchronized boolean containsValue(T2 value) {
- return _reverse.containsKey(value);
- }
-
- /**
- * Search the reverse map for all keys that have been associated with
- * a particular value.
- * @return the set of keys that are associated with the specified value,
- * or an empty set if the value does not exist in the map.
- */
- public synchronized Set<T1> getKeys(T2 value) {
- Set<T1> keys = _reverse.get(value);
- if (null == keys) {
- return Collections.emptySet();
- }
- return new HashSet<T1>(keys);
- }
-
- /**
- * Search the forward map for all values associated with a particular key.
- * Returns a copy of the set of values.
- * @return a copy of the set of values that are associated with the
- * specified key, or an empty set if the key does not exist in the map.
- */
- public synchronized Set<T2> getValues(T1 key) {
- Set<T2> values = _forward.get(key);
- if (null == values) {
- return Collections.emptySet();
- }
- return new HashSet<T2>(values);
- }
-
- /**
- * @return a copy of the set of all keys (that is, all items of type T1).
- * If the maps are empty, the returned set will be empty, not null. The
- * returned set can be modified by the caller without affecting the map.
- * @see #getValueSet()
- */
- public synchronized Set<T1> getKeySet() {
- Set<T1> keys = new HashSet<T1>(_forward.keySet());
- return keys;
- }
-
- /**
- * @return a copy of the set of all values (that is, all items of type T2).
- * If the maps are empty, the returned set will be empty, not null. The
- * returned set can be modified by the caller without affecting the map.
- * @see #getKeySet()
- */
- public synchronized Set<T2> getValueSet() {
- Set<T2> values = new HashSet<T2>(_reverse.keySet());
- return values;
- }
-
- /**
- * Return the state of the dirty bit. All operations that change the state
- * of the maps, including @see #clear(), set the dirty bit if any content actually
- * changed. The only way to clear the dirty bit is to call @see #clearDirtyBit().
- * @return true if the map content has changed since it was created or since
- * the last call to clearDirtyBit().
- * @see #clearDirtyBit()
- */
- public synchronized boolean isDirty() {
- return _dirty;
- }
-
- /**
- * Check whether <code>key</code> has an association to any values other
- * than <code>value</code> - that is, whether the same key has been added
- * with multiple values. Equivalent to asking whether the intersection of
- * <code>getValues(key)</code> and the set containing <code>value</code> is
- * non-empty.
- * @return true iff <code>key</code> is in the map and is associated
- * with values other than <code>value</code>.
- * @see #valueHasOtherKeys(Object, Object)
- */
- public synchronized boolean keyHasOtherValues(T1 key, T2 value) {
- Set<T2> values = _forward.get(key);
- if (values == null)
- return false;
- int size = values.size();
- if (size == 0)
- return false;
- else if (size > 1)
- return true;
- else // size == 1
- return !values.contains(value);
- }
-
- /**
- * Associate the specified value with the key. Adds the entry
- * to both the forward and reverse maps. Adding the same value
- * twice to a particular key has no effect. Because this is a
- * many-to-many map, adding a new value for an existing key does
- * not change the existing association, it adds a new one.
- * @param key can be null
- * @param value can be null
- * @return true if the key/value pair did not exist prior to being added
- */
- public synchronized boolean put(T1 key, T2 value) {
- // Add to forward map
- Set<T2> values = _forward.get(key);
- if (null == values) {
- values = new HashSet<T2>();
- _forward.put(key, values);
- }
- boolean added = values.add(value);
- _dirty |= added;
-
- // Add to reverse map
- Set<T1> keys = _reverse.get(value);
- if (null == keys) {
- keys = new HashSet<T1>();
- _reverse.put(value, keys);
- }
- keys.add(key);
-
- assert checkIntegrity();
- return added;
- }
-
- /**
- * Remove a particular key-value association. This is the inverse
- * of put(key, value). If the key does not exist, or the value
- * does not exist, or the association does not exist, this call
- * has no effect.
- * @return true if the key/value pair existed in the map prior to removal
- */
- public synchronized boolean remove(T1 key, T2 value) {
- Set<T2> values = _forward.get(key);
- if (values == null) {
- assert checkIntegrity();
- return false;
- }
- boolean removed = values.remove(value);
- if (values.isEmpty()) {
- _forward.remove(key);
- }
- if (removed) {
- _dirty = true;
- // it existed, so we need to remove from reverse map as well
- Set<T1> keys = _reverse.get(value);
- keys.remove(key);
- if (keys.isEmpty()) {
- _reverse.remove(value);
- }
- }
- assert checkIntegrity();
- return removed;
- }
-
- /**
- * Remove the key and its associated key/value entries.
- * Calling removeKey(k) is equivalent to calling remove(k,v)
- * for every v in getValues(k).
- * @return true if the key existed in the map prior to removal
- */
- public synchronized boolean removeKey(T1 key) {
- // Remove all back-references to key.
- Set<T2> values = _forward.get(key);
- if (null == values) {
- // key does not exist in map.
- assert checkIntegrity();
- return false;
- }
- for (T2 value : values) {
- Set<T1> keys = _reverse.get(value);
- if (null != keys) {
- keys.remove(key);
- if (keys.isEmpty()) {
- _reverse.remove(value);
- }
- }
- }
- // Now remove the forward references from key.
- _forward.remove(key);
- _dirty = true;
- assert checkIntegrity();
- return true;
- }
-
- /**
- * Remove the value and its associated key/value entries.
- * Calling removeValue(v) is equivalent to calling remove(k,v)
- * for every k in getKeys(v).
- * @return true if the value existed in the map prior to removal.
- */
- public synchronized boolean removeValue(T2 value) {
- // Remove any forward references to value
- Set<T1> keys = _reverse.get(value);
- if (null == keys) {
- // value does not exist in map.
- assert checkIntegrity();
- return false;
- }
- for (T1 key : keys) {
- Set<T2> values = _forward.get(key);
- if (null != values) {
- values.remove(value);
- if (values.isEmpty()) {
- _forward.remove(key);
- }
- }
- }
- // Now remove the reverse references from value.
- _reverse.remove(value);
- _dirty = true;
- assert checkIntegrity();
- return true;
- }
-
- /**
- * Check whether <code>value</code> has an association from any keys other
- * than <code>key</code> - that is, whether the same value has been added
- * with multiple keys. Equivalent to asking whether the intersection of
- * <code>getKeys(value)</code> and the set containing <code>key</code> is
- * non-empty.
- * @return true iff <code>value</code> is in the map and is associated
- * with keys other than <code>key</code>.
- * @see #keyHasOtherValues(Object, Object)
- */
- public synchronized boolean valueHasOtherKeys(T2 value, T1 key) {
- Set<T1> keys = _reverse.get(key);
- if (keys == null)
- return false;
- int size = keys.size();
- if (size == 0)
- return false;
- else if (size > 1)
- return true;
- else // size == 1
- return !keys.contains(key);
- }
-
- /**
- * Check the integrity of the internal data structures. This is intended to
- * be called within an assert, so that if asserts are disabled the integrity
- * checks will not cause a performance impact.
- * @return true if everything is okay.
- * @throws IllegalStateException if there is a problem.
- */
- private boolean checkIntegrity() {
- // For every T1->T2 mapping in the forward map, there should be a corresponding
- // T2->T1 mapping in the reverse map.
- for (Map.Entry<T1, Set<T2>> entry : _forward.entrySet()) {
- Set<T2> values = entry.getValue();
- if (values.isEmpty()) {
- throw new IllegalStateException("Integrity compromised: forward map contains an empty set"); //$NON-NLS-1$
- }
- for (T2 value : values) {
- Set<T1> keys = _reverse.get(value);
- if (null == keys || !keys.contains(entry.getKey())) {
- throw new IllegalStateException("Integrity compromised: forward map contains an entry missing from reverse map: " + value); //$NON-NLS-1$
- }
- }
- }
- // And likewise in the other direction.
- for (Map.Entry<T2, Set<T1>> entry : _reverse.entrySet()) {
- Set<T1> keys = entry.getValue();
- if (keys.isEmpty()) {
- throw new IllegalStateException("Integrity compromised: reverse map contains an empty set"); //$NON-NLS-1$
- }
- for (T1 key : keys) {
- Set<T2> values = _forward.get(key);
- if (null == values || !values.contains(entry.getKey())) {
- throw new IllegalStateException("Integrity compromised: reverse map contains an entry missing from forward map: " + key); //$NON-NLS-1$
- }
- }
- }
- return true;
- }
-
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/Options.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/Options.java
deleted file mode 100644
index f9795cf189..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/Options.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.util;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-/**
- * Class used to handle options in the EclipseFileManager and the EclipseCompiler
- */
-public final class Options {
- private static final Set<String> ZERO_ARGUMENT_OPTIONS;
- private static final Set<String> ONE_ARGUMENT_OPTIONS;
- private static final Set<String> FILE_MANAGER_OPTIONS;
- static {
- ZERO_ARGUMENT_OPTIONS = new HashSet<String>();
- ZERO_ARGUMENT_OPTIONS.add("-progress");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-proceedOnError");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-time");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-v");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-version");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-showversion");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-deprecation");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-help");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-?");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-help:warn");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-?:warn");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-noExit");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-verbose");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-referenceInfo");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-inlineJSR");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-g");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-g:none");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-nowarn");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-warn:none");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-preserveAllLocals");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-enableJavadoc");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-Xemacs");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-X");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-O");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-1.3");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-1.4");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-1.5");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-5");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-5.0");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-1.6");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-6");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-6.0");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-proc:only");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-proc:none");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-XprintProcessorInfo");//$NON-NLS-1$
- ZERO_ARGUMENT_OPTIONS.add("-XprintRounds");//$NON-NLS-1$
-
- FILE_MANAGER_OPTIONS = new HashSet<String>();
- FILE_MANAGER_OPTIONS.add("-bootclasspath");//$NON-NLS-1$
- FILE_MANAGER_OPTIONS.add("-encoding");//$NON-NLS-1$
- FILE_MANAGER_OPTIONS.add("-d");//$NON-NLS-1$
- FILE_MANAGER_OPTIONS.add("-classpath");//$NON-NLS-1$
- FILE_MANAGER_OPTIONS.add("-cp");//$NON-NLS-1$
- FILE_MANAGER_OPTIONS.add("-sourcepath");//$NON-NLS-1$
- FILE_MANAGER_OPTIONS.add("-extdirs");//$NON-NLS-1$
- FILE_MANAGER_OPTIONS.add("-endorseddirs");//$NON-NLS-1$
- FILE_MANAGER_OPTIONS.add("-s");//$NON-NLS-1$
- FILE_MANAGER_OPTIONS.add("-processorpath");//$NON-NLS-1$
-
- ONE_ARGUMENT_OPTIONS = new HashSet<String>();
- ONE_ARGUMENT_OPTIONS.addAll(FILE_MANAGER_OPTIONS);
- ONE_ARGUMENT_OPTIONS.add("-log");//$NON-NLS-1$
- ONE_ARGUMENT_OPTIONS.add("-repeat");//$NON-NLS-1$
- ONE_ARGUMENT_OPTIONS.add("-maxProblems");//$NON-NLS-1$
- ONE_ARGUMENT_OPTIONS.add("-source");//$NON-NLS-1$
- ONE_ARGUMENT_OPTIONS.add("-target");//$NON-NLS-1$
- ONE_ARGUMENT_OPTIONS.add("-processor");//$NON-NLS-1$
- ONE_ARGUMENT_OPTIONS.add("-classNames");//$NON-NLS-1$
- }
- public static int processOptionsFileManager(String option) {
- if (option == null) return -1;
- if (FILE_MANAGER_OPTIONS.contains(option)) {
- return 1;
- }
- return -1;
- }
-
- public static int processOptions(String option) {
- if (option == null) return -1;
- if (ZERO_ARGUMENT_OPTIONS.contains(option)) {
- return 0;
- }
- if (ONE_ARGUMENT_OPTIONS.contains(option)) {
- return 1;
- }
- if (option.startsWith("-g")) { //$NON-NLS-1$
- int length = option.length();
- if (length > 3) {
- StringTokenizer tokenizer =
- new StringTokenizer(option.substring(3, option.length()), ",");//$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- if ("vars".equals(token) || "lines".equals(token) || "source".equals(token)) {//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- continue;
- }
- return -1;
- }
- return 0;
- }
- return -1;
- }
- if (option.startsWith("-warn")) {//$NON-NLS-1$
- int length = option.length();
- if (length <= 6) {
- return -1;
- }
- int warnTokenStart;
- switch (option.charAt(6)) {
- case '+' :
- warnTokenStart = 7;
- break;
- case '-' :
- warnTokenStart = 7;
- break;
- default:
- warnTokenStart = 6;
- }
-
- StringTokenizer tokenizer =
- new StringTokenizer(option.substring(warnTokenStart, option.length()), ","); //$NON-NLS-1$
- int tokenCounter = 0;
-
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- tokenCounter++;
- if ("constructorName".equals(token)//$NON-NLS-1$
- || token.equals("pkgDefaultMethod")//$NON-NLS-1$
- || token.equals("packageDefaultMethod")//$NON-NLS-1$
- || token.equals("maskedCatchBlock")//$NON-NLS-1$
- || token.equals("maskedCatchBlocks")//$NON-NLS-1$
- || token.equals("deprecation")//$NON-NLS-1$
- || token.equals("allDeprecation")//$NON-NLS-1$
- || token.equals("unusedLocal")//$NON-NLS-1$
- || token.equals("unusedLocals")//$NON-NLS-1$
- || token.equals("unusedArgument")//$NON-NLS-1$
- || token.equals("unusedArguments")//$NON-NLS-1$
- || token.equals("unusedImport")//$NON-NLS-1$
- || token.equals("unusedImports")//$NON-NLS-1$
- || token.equals("unusedPrivate")//$NON-NLS-1$
- || token.equals("unusedLabel")//$NON-NLS-1$
- || token.equals("localHiding")//$NON-NLS-1$
- || token.equals("fieldHiding")//$NON-NLS-1$
- || token.equals("specialParamHiding")//$NON-NLS-1$
- || token.equals("conditionAssign")//$NON-NLS-1$
- || token.equals("syntheticAccess")//$NON-NLS-1$
- || token.equals("synthetic-access")//$NON-NLS-1$
- || token.equals("nls")//$NON-NLS-1$
- || token.equals("staticReceiver")//$NON-NLS-1$
- || token.equals("indirectStatic")//$NON-NLS-1$
- || token.equals("noEffectAssign")//$NON-NLS-1$
- || token.equals("intfNonInherited")//$NON-NLS-1$
- || token.equals("interfaceNonInherited")//$NON-NLS-1$
- || token.equals("charConcat")//$NON-NLS-1$
- || token.equals("noImplicitStringConversion")//$NON-NLS-1$
- || token.equals("semicolon")//$NON-NLS-1$
- || token.equals("serial")//$NON-NLS-1$
- || token.equals("emptyBlock")//$NON-NLS-1$
- || token.equals("uselessTypeCheck")//$NON-NLS-1$
- || token.equals("unchecked")//$NON-NLS-1$
- || token.equals("unsafe")//$NON-NLS-1$
- || token.equals("raw")//$NON-NLS-1$
- || token.equals("finalBound")//$NON-NLS-1$
- || token.equals("suppress")//$NON-NLS-1$
- || token.equals("warningToken")//$NON-NLS-1$
- || token.equals("unnecessaryElse")//$NON-NLS-1$
- || token.equals("javadoc")//$NON-NLS-1$
- || token.equals("allJavadoc")//$NON-NLS-1$
- || token.equals("assertIdentifier")//$NON-NLS-1$
- || token.equals("enumIdentifier")//$NON-NLS-1$
- || token.equals("finally")//$NON-NLS-1$
- || token.equals("unusedThrown")//$NON-NLS-1$
- || token.equals("unqualifiedField")//$NON-NLS-1$
- || token.equals("unqualified-field-access")//$NON-NLS-1$
- || token.equals("typeHiding")//$NON-NLS-1$
- || token.equals("varargsCast")//$NON-NLS-1$
- || token.equals("null")//$NON-NLS-1$
- || token.equals("boxing")//$NON-NLS-1$
- || token.equals("over-ann")//$NON-NLS-1$
- || token.equals("dep-ann")//$NON-NLS-1$
- || token.equals("intfAnnotation")//$NON-NLS-1$
- || token.equals("enumSwitch")//$NON-NLS-1$
- || token.equals("incomplete-switch")//$NON-NLS-1$
- || token.equals("hiding")//$NON-NLS-1$
- || token.equals("static-access")//$NON-NLS-1$
- || token.equals("unused")//$NON-NLS-1$
- || token.equals("paramAssign")//$NON-NLS-1$
- || token.equals("discouraged")//$NON-NLS-1$
- || token.equals("forbidden")//$NON-NLS-1$
- || token.equals("fallthrough")) {//$NON-NLS-1$
- continue;
- } else if (token.equals("tasks")) {//$NON-NLS-1$
- String taskTags = "";//$NON-NLS-1$
- int start = token.indexOf('(');
- int end = token.indexOf(')');
- if (start >= 0 && end >= 0 && start < end){
- taskTags = token.substring(start+1, end).trim();
- taskTags = taskTags.replace('|',',');
- }
- if (taskTags.length() == 0){
- return -1;
- }
- continue;
- } else {
- return -1;
- }
- }
- if (tokenCounter == 0) {
- return -1;
- } else {
- return 0;
- }
- }
- if (option.startsWith("-J")//$NON-NLS-1$
- || option.startsWith("-X")//$NON-NLS-1$
- || option.startsWith("-A")) {//$NON-NLS-1$
- return 0;
- }
- return -1;
- }
-}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/Util.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/Util.java
deleted file mode 100644
index 2559ceecf5..0000000000
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/Util.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.compiler.apt.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CoderResult;
-import java.nio.charset.CodingErrorAction;
-import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.UnsupportedCharsetException;
-import java.util.ArrayList;
-
-import javax.tools.FileObject;
-
-/**
- * Util class that defines helper methods to read class contents with handling of wrong encoding
- *
- */
-public final class Util {
- public static String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
-
- public static class EncodingError {
- int position;
- int length;
- public EncodingError(int position, int length) {
- this.position = position;
- this.length = length;
- }
-
- public String getSource(char[] unitSource) {
- //extra from the source the innacurate token
- //and "highlight" it using some underneath ^^^^^
- //put some context around too.
-
- //this code assumes that the font used in the console is fixed size
-
- //sanity .....
- int startPosition = this.position;
- int endPosition = this.position + this.length - 1;
-
- if ((startPosition > endPosition)
- || ((startPosition < 0) && (endPosition < 0))
- || unitSource.length == 0)
- return "No source available"; //$NON-NLS-1$
-
- StringBuffer errorBuffer = new StringBuffer();
- errorBuffer.append('\t');
-
- char c;
- final char SPACE = ' ';
- final char MARK = '^';
- final char TAB = '\t';
- //the next code tries to underline the token.....
- //it assumes (for a good display) that token source does not
- //contain any \r \n. This is false on statements !
- //(the code still works but the display is not optimal !)
-
- // expand to line limits
- int length = unitSource.length, begin, end;
- for (begin = startPosition >= length ? length - 1 : startPosition; begin > 0; begin--) {
- if ((c = unitSource[begin - 1]) == '\n' || c == '\r') break;
- }
- for (end = endPosition >= length ? length - 1 : endPosition ; end+1 < length; end++) {
- if ((c = unitSource[end + 1]) == '\r' || c == '\n') break;
- }
-
- // trim left and right spaces/tabs
- while ((c = unitSource[begin]) == ' ' || c == '\t') begin++;
- //while ((c = unitSource[end]) == ' ' || c == '\t') end--; TODO (philippe) should also trim right, but all tests are to be updated
-
- // copy source
- errorBuffer.append(unitSource, begin, end-begin+1);
- errorBuffer.append(Util.LINE_SEPARATOR).append("\t"); //$NON-NLS-1$
-
- // compute underline
- for (int i = begin; i <startPosition; i++) {
- errorBuffer.append((unitSource[i] == TAB) ? TAB : SPACE);
- }
- for (int i = startPosition; i <= (endPosition >= length ? length - 1 : endPosition); i++) {
- errorBuffer.append(MARK);
- }
- return errorBuffer.toString();
- }
- }
- public static class EncodingErrorCollector {
- ArrayList<EncodingError> encodingErrors = new ArrayList<EncodingError>();
- FileObject fileObject;
- String encoding;
-
- public EncodingErrorCollector(FileObject fileObject, String encoding) {
- this.fileObject = fileObject;
- this.encoding = encoding;
- }
- public void collect(int position, int length) {
- this.encodingErrors.add(new EncodingError(position, length));
- }
- public void reportAllEncodingErrors(String string) {
- // this is where the encoding errors should be reported
- char[] unitSource = string.toCharArray();
- for (EncodingError error : this.encodingErrors) {
- System.err.println(this.fileObject.getName() + " Unmappable character for encoding " + this.encoding);//$NON-NLS-1$
- System.err.println(error.getSource(unitSource));
- }
- }
- }
-
- public static char[] getInputStreamAsCharArray(InputStream stream, int length, String encoding) throws IOException {
- Charset charset = null;
- try {
- charset = Charset.forName(encoding);
- } catch (IllegalCharsetNameException e) {
- System.err.println("Illegal charset name : " + encoding); //$NON-NLS-1$
- return null;
- } catch(UnsupportedCharsetException e) {
- System.err.println("Unsupported charset : " + encoding); //$NON-NLS-1$
- return null;
- }
- CharsetDecoder charsetDecoder = charset.newDecoder();
- charsetDecoder.onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE);
- byte[] contents = org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsByteArray(stream, length);
- ByteBuffer byteBuffer = ByteBuffer.allocate(contents.length);
- byteBuffer.put(contents);
- byteBuffer.flip();
- return charsetDecoder.decode(byteBuffer).array();
- }
-
- public static CharSequence getCharContents(FileObject fileObject, boolean ignoreEncodingErrors, byte[] contents, String encoding) throws IOException {
- if (contents == null) return null;
- Charset charset = null;
- try {
- charset = Charset.forName(encoding);
- } catch (IllegalCharsetNameException e) {
- System.err.println("Illegal charset name : " + encoding); //$NON-NLS-1$
- return null;
- } catch(UnsupportedCharsetException e) {
- System.err.println("Unsupported charset : " + encoding); //$NON-NLS-1$
- return null;
- }
- CharsetDecoder charsetDecoder = charset.newDecoder();
- ByteBuffer byteBuffer = ByteBuffer.allocate(contents.length);
- byteBuffer.put(contents);
- byteBuffer.flip();
- if (ignoreEncodingErrors) {
- charsetDecoder.onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE);
- return charsetDecoder.decode(byteBuffer);
- } else {
- charsetDecoder.onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);
- CharBuffer out = CharBuffer.allocate(contents.length);
- CoderResult result = null;
- String replacement = charsetDecoder.replacement();
- int replacementLength = replacement.length();
- EncodingErrorCollector collector = null;
- while (true) {
- result = charsetDecoder.decode(byteBuffer, out, true);
- if (result.isMalformed() || result.isUnmappable()) {
- /* treat the error
- * The wrong input character is at out.position
- */
- if (collector == null) {
- collector = new EncodingErrorCollector(fileObject, encoding);
- }
- reportEncodingError(collector, out.position(), result.length());
- if ((out.position() + replacementLength) >= out.capacity()) {
- // resize
- CharBuffer temp = CharBuffer.allocate(out.capacity() * 2);
- out.flip();
- temp.put(out);
- out = temp;
- }
- out.append(replacement);
- byteBuffer.position(byteBuffer.position() + result.length());
- continue;
- }
- if (result.isOverflow()) {
- CharBuffer temp = CharBuffer.allocate(out.capacity() * 2);
- out.flip();
- temp.put(out);
- out = temp;
- } else {
- break;
- }
- }
- out.flip();
- if (collector != null) {
- collector.reportAllEncodingErrors(out.toString());
- }
- return out;
- }
- }
-
- private static void reportEncodingError(EncodingErrorCollector collector, int position, int length) {
- collector.collect(position, -length);
- }
-}
-
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index 68b86baae4..b4e20bf700 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -42,7 +42,7 @@
<hr><h1>
Eclipse Platform Build Notes<br>
Java Development Tooling Core</h1>
-Eclipse SDK 3.4M6 - %date% - 3.4 MILESTONE 6
+Eclipse SDK 3.4M6 - March 5, 2008 - 3.4 MILESTONE 6
<br>Project org.eclipse.jdt.core v_843
(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_843">cvs</a>).
<h2>What's new in this drop</h2>

Back to the top