Index: compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java,v retrieving revision 1.36 diff -u -r1.36 ASTNode.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 23 Feb 2005 02:47:28 -0000 1.36 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 24 Feb 2005 19:57:31 -0000 @@ -390,7 +390,9 @@ if (recipient != null) { switch (recipient.kind()) { case Binding.PACKAGE : - // TODO (philippe) need support for package annotations + PackageBinding packageBinding = (PackageBinding) recipient; + if ((packageBinding.tagBits & TagBits.AnnotationResolved) != 0) return; + packageBinding.tagBits |= TagBits.AnnotationResolved; break; case Binding.TYPE : case Binding.GENERIC_TYPE : Index: compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java,v retrieving revision 1.35 diff -u -r1.35 Annotation.java --- compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java 23 Feb 2005 02:47:28 -0000 1.35 +++ compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java 24 Feb 2005 19:57:31 -0000 @@ -237,7 +237,7 @@ // tag bits onto recipient switch (this.recipient.kind()) { case Binding.PACKAGE : - // TODO (philippe) need support for package annotations + ((PackageBinding)this.recipient).tagBits |= tagBits; break; case Binding.TYPE : case Binding.GENERIC_TYPE : Index: compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java,v retrieving revision 1.41 diff -u -r1.41 CompilationUnitDeclaration.java --- compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java 23 Feb 2005 03:40:28 -0000 1.41 +++ compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java 24 Feb 2005 19:57:31 -0000 @@ -175,6 +175,11 @@ } return; } + if (this.currentPackage != null) { + if (this.currentPackage.annotations != null) { + types[0].annotations = this.currentPackage.annotations; + } + } try { if (types != null) { for (int i = 0, count = types.length; i < count; i++) @@ -269,17 +274,28 @@ } public void resolve() { + int startingTypeIndex = 0; if (this.currentPackage != null) { if (this.currentPackage.annotations != null) { if (!CharOperation.endsWith(getFileName(), PACKAGE_INFO_FILE_NAME)) { scope.problemReporter().invalidFileNameForPackageAnnotations(this.currentPackage.annotations[0]); } - // (TODO) resolve annotations + // resolve annotations + if (types.length > 0) { + final TypeDeclaration syntheticTypeDeclaration = types[0]; + if (CharOperation.equals(syntheticTypeDeclaration.name, TypeConstants.PACKAGE_INFO_NAME)) { + syntheticTypeDeclaration.resolve(this.scope); + resolveAnnotations(syntheticTypeDeclaration.staticInitializerScope, this.currentPackage.annotations, this.scope.fPackage); + // set the synthetic bit + syntheticTypeDeclaration.binding.modifiers |= AccSynthetic; + startingTypeIndex = 1; + } + } } } try { if (types != null) { - for (int i = 0, count = types.length; i < count; i++) { + for (int i = startingTypeIndex, count = types.length; i < count; i++) { types[i].resolve(scope); } } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java,v retrieving revision 1.33 diff -u -r1.33 PackageBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java 23 Feb 2005 02:47:30 -0000 1.33 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java 24 Feb 2005 19:57:31 -0000 @@ -15,6 +15,8 @@ import org.eclipse.jdt.internal.compiler.util.HashtableOfType; public class PackageBinding extends Binding implements TypeConstants { + public long tagBits = 0; // See values in the interface TagBits below + public char[][] compoundName; PackageBinding parent; public LookupEnvironment environment; Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java,v retrieving revision 1.35 diff -u -r1.35 TypeConstants.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java 23 Feb 2005 02:47:30 -0000 1.35 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java 24 Feb 2005 19:57:31 -0000 @@ -143,4 +143,7 @@ char[] SYNTHETIC_OUTER_LOCAL_PREFIX = "val$".toCharArray(); //$NON-NLS-1$ char[] SYNTHETIC_ENCLOSING_INSTANCE_PREFIX = "this$".toCharArray(); //$NON-NLS-1$ char[] SYNTHETIC_ACCESS_METHOD_PREFIX = "access$".toCharArray(); //$NON-NLS-1$ + + // synthetic package-info name + public static final char[] PACKAGE_INFO_NAME = "package-info".toCharArray(); //$NON-NLS-1$ } Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v retrieving revision 1.284 diff -u -r1.284 Parser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 23 Feb 2005 02:47:58 -0000 1.284 +++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 24 Feb 2005 19:57:32 -0000 @@ -31,6 +31,7 @@ import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; import org.eclipse.jdt.internal.compiler.lookup.Binding; import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers; +import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; import org.eclipse.jdt.internal.compiler.lookup.TypeIds; import org.eclipse.jdt.internal.compiler.parser.diagnose.DiagnoseParser; import org.eclipse.jdt.internal.compiler.problem.AbortCompilation; @@ -183,7 +184,7 @@ public JavadocParser javadocParser; // used for recovery protected int lastJavadocEnd; - + static { try{ initTables(); @@ -3483,6 +3484,14 @@ // InternalCompilationUnit ::= PackageDeclaration // InternalCompilationUnit ::= PackageDeclaration ImportDeclarations ReduceImports // InternalCompilationUnit ::= ImportDeclarations ReduceImports + if (this.astLengthPtr >= 0) { + int length; + if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) { + this.compilationUnit.types = new TypeDeclaration[length]; + this.astPtr -= length; + System.arraycopy(this.astStack, this.astPtr + 1, this.compilationUnit.types, 0, length); + } + } } protected void consumeInternalCompilationUnitWithTypes() { // InternalCompilationUnit ::= PackageDeclaration ImportDeclarations ReduceImports TypeDeclarations @@ -3492,8 +3501,13 @@ // consume type declarations int length; if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) { + if (this.astLengthPtr >= 0) { + // check for the fake type package-info + length += this.astLengthStack[this.astLengthPtr--]; + } + this.compilationUnit.types = new TypeDeclaration[length]; this.astPtr -= length; - System.arraycopy(this.astStack, this.astPtr + 1, this.compilationUnit.types = new TypeDeclaration[length], 0, length); + System.arraycopy(this.astStack, this.astPtr + 1, this.compilationUnit.types, 0, length); } } protected void consumeInvalidConstructorDeclaration() { @@ -4221,6 +4235,11 @@ length); impt.declarationSourceStart = packageModifiersSourceStart; intPtr--; // we don't need the position of the 'package keyword + // create a fake interface declaration + TypeDeclaration declaration = new TypeDeclaration(compilationUnit.compilationResult); + declaration.name = TypeConstants.PACKAGE_INFO_NAME; + declaration.modifiers = AccDefault | AccInterface; + pushOnAstStack(declaration); } else { impt.declarationSourceStart = this.intStack[this.intPtr--]; } Index: dom/org/eclipse/jdt/core/dom/ASTConverter.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java,v retrieving revision 1.195 diff -u -r1.195 ASTConverter.java --- dom/org/eclipse/jdt/core/dom/ASTConverter.java 23 Feb 2005 02:47:27 -0000 1.195 +++ dom/org/eclipse/jdt/core/dom/ASTConverter.java 24 Feb 2005 19:57:32 -0000 @@ -20,6 +20,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.core.compiler.InvalidInputException; import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; @@ -45,6 +46,7 @@ import org.eclipse.jdt.internal.compiler.env.IGenericType; import org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers; +import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; import org.eclipse.jdt.internal.compiler.parser.Scanner; import org.eclipse.jdt.internal.compiler.parser.TerminalTokens; @@ -1141,7 +1143,11 @@ if (types != null) { int typesLength = types.length; for (int i = 0; i < typesLength; i++) { - ASTNode type = convert(types[i]); + org.eclipse.jdt.internal.compiler.ast.TypeDeclaration declaration = types[i]; + if (CharOperation.equals(declaration.name, TypeConstants.PACKAGE_INFO_NAME)) { + continue; + } + ASTNode type = convert(declaration); if (type == null) { compilationUnit.setFlags(compilationUnit.getFlags() | ASTNode.MALFORMED); } else { @@ -2200,6 +2206,9 @@ } if (statement instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) { ASTNode result = convert((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) statement); + if (result == null) { + return createFakeEmptyStatement(statement); + } switch(result.getNodeType()) { case ASTNode.ENUM_DECLARATION: switch(this.ast.apiLevel) { Index: model/org/eclipse/jdt/internal/compiler/SourceElementParser.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java,v retrieving revision 1.41 diff -u -r1.41 SourceElementParser.java --- model/org/eclipse/jdt/internal/compiler/SourceElementParser.java 23 Feb 2005 02:47:29 -0000 1.41 +++ model/org/eclipse/jdt/internal/compiler/SourceElementParser.java 24 Feb 2005 19:57:32 -0000 @@ -765,6 +765,10 @@ notifySourceElementRequestor(importRef, false); } } else { // instanceof TypeDeclaration + TypeDeclaration typeDeclaration = (TypeDeclaration) node; + if (CharOperation.equals(typeDeclaration.name, TypeConstants.PACKAGE_INFO_NAME)) { + continue; + } notifySourceElementRequestor((TypeDeclaration)node, sourceType == null, null); } }