View | Details | Raw Unified | Return to bug 86167 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-1 / +3 lines)
Lines 393-399 Link Here
393
		if (recipient != null) {
393
		if (recipient != null) {
394
			switch (recipient.kind()) {
394
			switch (recipient.kind()) {
395
				case Binding.PACKAGE :
395
				case Binding.PACKAGE :
396
					// TODO (philippe) need support for package annotations
396
					PackageBinding packageBinding = (PackageBinding) recipient;
397
					if ((packageBinding.tagBits & TagBits.AnnotationResolved) != 0) return;
398
					packageBinding.tagBits |= TagBits.AnnotationResolved;
397
					break;
399
					break;
398
				case Binding.TYPE :
400
				case Binding.TYPE :
399
				case Binding.GENERIC_TYPE :
401
				case Binding.GENERIC_TYPE :
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java (-1 / +1 lines)
Lines 237-243 Link Here
237
				// tag bits onto recipient
237
				// tag bits onto recipient
238
				switch (this.recipient.kind()) {
238
				switch (this.recipient.kind()) {
239
					case Binding.PACKAGE :
239
					case Binding.PACKAGE :
240
						// TODO (philippe) need support for package annotations
240
						((PackageBinding)this.recipient).tagBits |= tagBits;
241
						break;
241
						break;
242
					case Binding.TYPE :
242
					case Binding.TYPE :
243
					case Binding.GENERIC_TYPE :
243
					case Binding.GENERIC_TYPE :
(-)compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java (-6 / +21 lines)
Lines 19-27 Link Here
19
public class CompilationUnitDeclaration
19
public class CompilationUnitDeclaration
20
	extends ASTNode
20
	extends ASTNode
21
	implements ProblemSeverities, ReferenceContext {
21
	implements ProblemSeverities, ReferenceContext {
22
	
22
23
	private static final char[] PACKAGE_INFO_FILE_NAME = "package-info.java".toCharArray(); //$NON-NLS-1$
24
		
25
	public ImportReference currentPackage;
23
	public ImportReference currentPackage;
26
	public ImportReference[] imports;
24
	public ImportReference[] imports;
27
	public TypeDeclaration[] types;
25
	public TypeDeclaration[] types;
Lines 175-180 Link Here
175
			}
173
			}
176
			return;
174
			return;
177
		}
175
		}
176
		if (this.isPackageInfo()) {
177
			types[0].annotations = this.currentPackage.annotations;
178
		}
178
		try {
179
		try {
179
			if (types != null) {
180
			if (types != null) {
180
				for (int i = 0, count = types.length; i < count; i++)
181
				for (int i = 0, count = types.length; i < count; i++)
Lines 214-219 Link Here
214
		return (currentPackage == null) && (imports == null) && (types == null);
215
		return (currentPackage == null) && (imports == null) && (types == null);
215
	}
216
	}
216
217
218
	public boolean isPackageInfo() {
219
		return CharOperation.equals(this.getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME)
220
			&& this.currentPackage != null
221
			&& this.currentPackage.annotations != null;
222
	}
223
	
217
	public boolean hasErrors() {
224
	public boolean hasErrors() {
218
		return this.ignoreFurtherInvestigation;
225
		return this.ignoreFurtherInvestigation;
219
	}
226
	}
Lines 269-285 Link Here
269
	}
276
	}
270
277
271
	public void resolve() {
278
	public void resolve() {
279
		int startingTypeIndex = 0;
272
		if (this.currentPackage != null) {
280
		if (this.currentPackage != null) {
273
			if (this.currentPackage.annotations != null) {
281
			if (this.currentPackage.annotations != null) {
274
				if (!CharOperation.endsWith(getFileName(), PACKAGE_INFO_FILE_NAME)) {
282
				if (CharOperation.equals(this.getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME)) {
283
					// resolve annotations
284
					final TypeDeclaration syntheticTypeDeclaration = types[0];
285
					syntheticTypeDeclaration.resolve(this.scope);
286
					resolveAnnotations(syntheticTypeDeclaration.staticInitializerScope, this.currentPackage.annotations, this.scope.fPackage);
287
					// set the synthetic bit
288
					syntheticTypeDeclaration.binding.modifiers |= AccSynthetic;
289
					startingTypeIndex = 1;
290
				} else {
275
					scope.problemReporter().invalidFileNameForPackageAnnotations(this.currentPackage.annotations[0]);
291
					scope.problemReporter().invalidFileNameForPackageAnnotations(this.currentPackage.annotations[0]);
276
				}
292
				}
277
				// (TODO) resolve annotations
278
			}
293
			}
279
		}
294
		}
280
		try {
295
		try {
281
			if (types != null) {
296
			if (types != null) {
282
				for (int i = 0, count = types.length; i < count; i++) {
297
				for (int i = startingTypeIndex, count = types.length; i < count; i++) {
283
					types[i].resolve(scope);
298
					types[i].resolve(scope);
284
				}
299
				}
285
			}
300
			}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java (+2 lines)
Lines 15-20 Link Here
15
import org.eclipse.jdt.internal.compiler.util.HashtableOfType;
15
import org.eclipse.jdt.internal.compiler.util.HashtableOfType;
16
16
17
public class PackageBinding extends Binding implements TypeConstants {
17
public class PackageBinding extends Binding implements TypeConstants {
18
	public long tagBits = 0; // See values in the interface TagBits below
19
	
18
	public char[][] compoundName;
20
	public char[][] compoundName;
19
	PackageBinding parent;
21
	PackageBinding parent;
20
	public LookupEnvironment environment;
22
	public LookupEnvironment environment;
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java (+3 lines)
Lines 143-146 Link Here
143
	char[] SYNTHETIC_OUTER_LOCAL_PREFIX = "val$".toCharArray(); //$NON-NLS-1$
143
	char[] SYNTHETIC_OUTER_LOCAL_PREFIX = "val$".toCharArray(); //$NON-NLS-1$
144
	char[] SYNTHETIC_ENCLOSING_INSTANCE_PREFIX = "this$".toCharArray(); //$NON-NLS-1$
144
	char[] SYNTHETIC_ENCLOSING_INSTANCE_PREFIX = "this$".toCharArray(); //$NON-NLS-1$
145
	char[] SYNTHETIC_ACCESS_METHOD_PREFIX =  "access$".toCharArray(); //$NON-NLS-1$
145
	char[] SYNTHETIC_ACCESS_METHOD_PREFIX =  "access$".toCharArray(); //$NON-NLS-1$
146
	
147
	// synthetic package-info name
148
	public static final char[] PACKAGE_INFO_NAME = "package-info".toCharArray(); //$NON-NLS-1$	
146
}
149
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-3 / +24 lines)
Lines 31-36 Link Here
31
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
31
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
32
import org.eclipse.jdt.internal.compiler.lookup.Binding;
32
import org.eclipse.jdt.internal.compiler.lookup.Binding;
33
import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
33
import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
34
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
34
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
35
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
35
import org.eclipse.jdt.internal.compiler.parser.diagnose.DiagnoseParser;
36
import org.eclipse.jdt.internal.compiler.parser.diagnose.DiagnoseParser;
36
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
37
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
Lines 183-189 Link Here
183
	public JavadocParser javadocParser;
184
	public JavadocParser javadocParser;
184
	// used for recovery
185
	// used for recovery
185
	protected int lastJavadocEnd;
186
	protected int lastJavadocEnd;
186
187
	
187
	static {
188
	static {
188
		try{
189
		try{
189
			initTables();
190
			initTables();
Lines 3483-3488 Link Here
3483
	// InternalCompilationUnit ::= PackageDeclaration
3484
	// InternalCompilationUnit ::= PackageDeclaration
3484
	// InternalCompilationUnit ::= PackageDeclaration ImportDeclarations ReduceImports
3485
	// InternalCompilationUnit ::= PackageDeclaration ImportDeclarations ReduceImports
3485
	// InternalCompilationUnit ::= ImportDeclarations ReduceImports
3486
	// InternalCompilationUnit ::= ImportDeclarations ReduceImports
3487
	if (this.compilationUnit.isPackageInfo()) {
3488
		this.compilationUnit.types = new TypeDeclaration[1];
3489
		// create a fake interface declaration
3490
		TypeDeclaration declaration = new TypeDeclaration(compilationUnit.compilationResult);
3491
		declaration.name = TypeConstants.PACKAGE_INFO_NAME;
3492
		declaration.modifiers = AccDefault | AccInterface;
3493
		this.compilationUnit.types[0] = declaration;
3494
	}
3486
}
3495
}
3487
protected void consumeInternalCompilationUnitWithTypes() {
3496
protected void consumeInternalCompilationUnitWithTypes() {
3488
	// InternalCompilationUnit ::= PackageDeclaration ImportDeclarations ReduceImports TypeDeclarations
3497
	// InternalCompilationUnit ::= PackageDeclaration ImportDeclarations ReduceImports TypeDeclarations
Lines 3492-3499 Link Here
3492
	// consume type declarations
3501
	// consume type declarations
3493
	int length;
3502
	int length;
3494
	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
3503
	if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
3495
		this.astPtr -= length;
3504
		if (this.compilationUnit.isPackageInfo()) {
3496
		System.arraycopy(this.astStack, this.astPtr + 1, this.compilationUnit.types = new TypeDeclaration[length], 0, length);
3505
			this.compilationUnit.types = new TypeDeclaration[length + 1];
3506
			this.astPtr -= length;
3507
			System.arraycopy(this.astStack, this.astPtr + 1, this.compilationUnit.types, 1, length);
3508
			// create a fake interface declaration
3509
			TypeDeclaration declaration = new TypeDeclaration(compilationUnit.compilationResult);
3510
			declaration.name = TypeConstants.PACKAGE_INFO_NAME;
3511
			declaration.modifiers = AccDefault | AccInterface;
3512
			this.compilationUnit.types[0] = declaration;
3513
		} else {
3514
			this.compilationUnit.types = new TypeDeclaration[length];
3515
			this.astPtr -= length;
3516
			System.arraycopy(this.astStack, this.astPtr + 1, this.compilationUnit.types, 0, length);
3517
		}
3497
	}
3518
	}
3498
}
3519
}
3499
protected void consumeInvalidConstructorDeclaration() {
3520
protected void consumeInvalidConstructorDeclaration() {
(-)dom/org/eclipse/jdt/core/dom/ASTConverter.java (-1 / +10 lines)
Lines 20-25 Link Here
20
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.OperationCanceledException;
21
import org.eclipse.core.runtime.OperationCanceledException;
22
import org.eclipse.jdt.core.JavaCore;
22
import org.eclipse.jdt.core.JavaCore;
23
import org.eclipse.jdt.core.compiler.CharOperation;
23
import org.eclipse.jdt.core.compiler.IProblem;
24
import org.eclipse.jdt.core.compiler.IProblem;
24
import org.eclipse.jdt.core.compiler.InvalidInputException;
25
import org.eclipse.jdt.core.compiler.InvalidInputException;
25
import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
26
import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
Lines 45-50 Link Here
45
import org.eclipse.jdt.internal.compiler.env.IGenericType;
46
import org.eclipse.jdt.internal.compiler.env.IGenericType;
46
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
47
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
47
import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
48
import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
49
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
48
import org.eclipse.jdt.internal.compiler.parser.Scanner;
50
import org.eclipse.jdt.internal.compiler.parser.Scanner;
49
import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
51
import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
50
52
Lines 1144-1150 Link Here
1144
		if (types != null) {
1146
		if (types != null) {
1145
			int typesLength = types.length;
1147
			int typesLength = types.length;
1146
			for (int i = 0; i < typesLength; i++) {
1148
			for (int i = 0; i < typesLength; i++) {
1147
				ASTNode type = convert(types[i]);
1149
				org.eclipse.jdt.internal.compiler.ast.TypeDeclaration declaration = types[i];
1150
				if (CharOperation.equals(declaration.name, TypeConstants.PACKAGE_INFO_NAME)) {
1151
					continue;
1152
				}
1153
				ASTNode type = convert(declaration);
1148
				if (type == null) {
1154
				if (type == null) {
1149
					compilationUnit.setFlags(compilationUnit.getFlags() | ASTNode.MALFORMED);
1155
					compilationUnit.setFlags(compilationUnit.getFlags() | ASTNode.MALFORMED);
1150
				} else {
1156
				} else {
Lines 2203-2208 Link Here
2203
		}
2209
		}
2204
		if (statement instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
2210
		if (statement instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
2205
			ASTNode result = convert((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) statement);
2211
			ASTNode result = convert((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) statement);
2212
			if (result == null) {
2213
				return createFakeEmptyStatement(statement);
2214
			}
2206
			switch(result.getNodeType()) {
2215
			switch(result.getNodeType()) {
2207
				case ASTNode.ENUM_DECLARATION:
2216
				case ASTNode.ENUM_DECLARATION:
2208
					switch(this.ast.apiLevel) {
2217
					switch(this.ast.apiLevel) {
(-)model/org/eclipse/jdt/internal/compiler/SourceElementParser.java (+4 lines)
Lines 765-770 Link Here
765
					notifySourceElementRequestor(importRef, false);
765
					notifySourceElementRequestor(importRef, false);
766
				}
766
				}
767
			} else { // instanceof TypeDeclaration
767
			} else { // instanceof TypeDeclaration
768
				TypeDeclaration typeDeclaration = (TypeDeclaration) node;
769
				if (CharOperation.equals(typeDeclaration.name, TypeConstants.PACKAGE_INFO_NAME)) {
770
					continue;
771
				}
768
				notifySourceElementRequestor((TypeDeclaration)node, sourceType == null, null);
772
				notifySourceElementRequestor((TypeDeclaration)node, sourceType == null, null);
769
			}
773
			}
770
		}
774
		}

Return to bug 86167