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 390-396 Link Here
390
		if (recipient != null) {
390
		if (recipient != null) {
391
			switch (recipient.kind()) {
391
			switch (recipient.kind()) {
392
				case Binding.PACKAGE :
392
				case Binding.PACKAGE :
393
					// TODO (philippe) need support for package annotations
393
					PackageBinding packageBinding = (PackageBinding) recipient;
394
					if ((packageBinding.tagBits & TagBits.AnnotationResolved) != 0) return;
395
					packageBinding.tagBits |= TagBits.AnnotationResolved;
394
					break;
396
					break;
395
				case Binding.TYPE :
397
				case Binding.TYPE :
396
				case Binding.GENERIC_TYPE :
398
				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 (-2 / +18 lines)
Lines 175-180 Link Here
175
			}
175
			}
176
			return;
176
			return;
177
		}
177
		}
178
		if (this.currentPackage != null) {
179
			if (this.currentPackage.annotations != null) {
180
				types[0].annotations = this.currentPackage.annotations;
181
			}
182
		}
178
		try {
183
		try {
179
			if (types != null) {
184
			if (types != null) {
180
				for (int i = 0, count = types.length; i < count; i++)
185
				for (int i = 0, count = types.length; i < count; i++)
Lines 269-285 Link Here
269
	}
274
	}
270
275
271
	public void resolve() {
276
	public void resolve() {
277
		int startingTypeIndex = 0;
272
		if (this.currentPackage != null) {
278
		if (this.currentPackage != null) {
273
			if (this.currentPackage.annotations != null) {
279
			if (this.currentPackage.annotations != null) {
274
				if (!CharOperation.endsWith(getFileName(), PACKAGE_INFO_FILE_NAME)) {
280
				if (!CharOperation.endsWith(getFileName(), PACKAGE_INFO_FILE_NAME)) {
275
					scope.problemReporter().invalidFileNameForPackageAnnotations(this.currentPackage.annotations[0]);
281
					scope.problemReporter().invalidFileNameForPackageAnnotations(this.currentPackage.annotations[0]);
276
				}
282
				}
277
				// (TODO) resolve annotations
283
				// resolve annotations
284
				if (types.length > 0) {
285
					final TypeDeclaration syntheticTypeDeclaration = types[0];
286
					if (CharOperation.equals(syntheticTypeDeclaration.name, TypeConstants.PACKAGE_INFO_NAME)) {
287
						syntheticTypeDeclaration.resolve(this.scope);
288
						resolveAnnotations(syntheticTypeDeclaration.staticInitializerScope, this.currentPackage.annotations, this.scope.fPackage);
289
						// set the synthetic bit
290
						syntheticTypeDeclaration.binding.modifiers |= AccSynthetic;
291
						startingTypeIndex = 1;
292
					}
293
				}
278
			}
294
			}
279
		}
295
		}
280
		try {
296
		try {
281
			if (types != null) {
297
			if (types != null) {
282
				for (int i = 0, count = types.length; i < count; i++) {
298
				for (int i = startingTypeIndex, count = types.length; i < count; i++) {
283
					types[i].resolve(scope);
299
					types[i].resolve(scope);
284
				}
300
				}
285
			}
301
			}
(-)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 (-2 / +21 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.astLengthPtr >= 0) {
3488
		int length;
3489
		if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
3490
			this.compilationUnit.types = new TypeDeclaration[length];
3491
			this.astPtr -= length;
3492
			System.arraycopy(this.astStack, this.astPtr + 1, this.compilationUnit.types, 0, length);
3493
		}
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) {
3504
		if (this.astLengthPtr >= 0) {
3505
			// check for the fake type package-info
3506
			length += this.astLengthStack[this.astLengthPtr--];
3507
		}
3508
		this.compilationUnit.types = new TypeDeclaration[length];
3495
		this.astPtr -= length;
3509
		this.astPtr -= length;
3496
		System.arraycopy(this.astStack, this.astPtr + 1, this.compilationUnit.types = new TypeDeclaration[length], 0, length);
3510
		System.arraycopy(this.astStack, this.astPtr + 1, this.compilationUnit.types, 0, length);
3497
	}
3511
	}
3498
}
3512
}
3499
protected void consumeInvalidConstructorDeclaration() {
3513
protected void consumeInvalidConstructorDeclaration() {
Lines 4221-4226 Link Here
4221
			length);
4235
			length);
4222
		impt.declarationSourceStart = packageModifiersSourceStart;
4236
		impt.declarationSourceStart = packageModifiersSourceStart;
4223
		intPtr--; // we don't need the position of the 'package keyword
4237
		intPtr--; // we don't need the position of the 'package keyword
4238
		// create a fake interface declaration
4239
		TypeDeclaration declaration = new TypeDeclaration(compilationUnit.compilationResult);
4240
		declaration.name = TypeConstants.PACKAGE_INFO_NAME;
4241
		declaration.modifiers = AccDefault | AccInterface;
4242
		pushOnAstStack(declaration);
4224
	} else {
4243
	} else {
4225
		impt.declarationSourceStart = this.intStack[this.intPtr--];
4244
		impt.declarationSourceStart = this.intStack[this.intPtr--];
4226
	}
4245
	}
(-)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 1141-1147 Link Here
1141
		if (types != null) {
1143
		if (types != null) {
1142
			int typesLength = types.length;
1144
			int typesLength = types.length;
1143
			for (int i = 0; i < typesLength; i++) {
1145
			for (int i = 0; i < typesLength; i++) {
1144
				ASTNode type = convert(types[i]);
1146
				org.eclipse.jdt.internal.compiler.ast.TypeDeclaration declaration = types[i];
1147
				if (CharOperation.equals(declaration.name, TypeConstants.PACKAGE_INFO_NAME)) {
1148
					continue;
1149
				}
1150
				ASTNode type = convert(declaration);
1145
				if (type == null) {
1151
				if (type == null) {
1146
					compilationUnit.setFlags(compilationUnit.getFlags() | ASTNode.MALFORMED);
1152
					compilationUnit.setFlags(compilationUnit.getFlags() | ASTNode.MALFORMED);
1147
				} else {
1153
				} else {
Lines 2200-2205 Link Here
2200
		}
2206
		}
2201
		if (statement instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
2207
		if (statement instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
2202
			ASTNode result = convert((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) statement);
2208
			ASTNode result = convert((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) statement);
2209
			if (result == null) {
2210
				return createFakeEmptyStatement(statement);
2211
			}
2203
			switch(result.getNodeType()) {
2212
			switch(result.getNodeType()) {
2204
				case ASTNode.ENUM_DECLARATION:
2213
				case ASTNode.ENUM_DECLARATION:
2205
					switch(this.ast.apiLevel) {
2214
					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