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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/NameLookup.java (-2 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann - contribution for bug 337868 - [compiler][model] incomplete support for package-info.java when using SearchableEnvironment
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core;
12
package org.eclipse.jdt.internal.core;
12
13
Lines 31-36 Link Here
31
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
32
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
32
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
33
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
33
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
34
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
35
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
34
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
36
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
35
import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt;
37
import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt;
36
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
38
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
Lines 1194-1200 Link Here
1194
						return true; // don't continue with compilation unit
1196
						return true; // don't continue with compilation unit
1195
					}
1197
					}
1196
				} else if (object instanceof IType[]) {
1198
				} else if (object instanceof IType[]) {
1197
					if (object == NO_TYPES) return true; // all types where deleted -> type is hidden
1199
					if (object == NO_TYPES) {
1200
						// all types where deleted -> type is hidden, OR it is the fake type package-info
1201
						String packageInfoName = String.valueOf(TypeConstants.PACKAGE_INFO_NAME);
1202
						if (packageInfoName.equals(name))
1203
							requestor.acceptType(pkg.getCompilationUnit(packageInfoName.concat(SUFFIX_STRING_java)).getType(name));
1204
						return true;
1205
					}
1198
					IType[] topLevelTypes = (IType[]) object;
1206
					IType[] topLevelTypes = (IType[]) object;
1199
					for (int i = 0, length = topLevelTypes.length; i < length; i++) {
1207
					for (int i = 0, length = topLevelTypes.length; i < length; i++) {
1200
						if (requestor.isCanceled())
1208
						if (requestor.isCanceled())
(-)src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java (-30 / +88 lines)
Lines 486-525 Link Here
486
 * Ensure that package level annotation is evaluated during AST creation.
486
 * Ensure that package level annotation is evaluated during AST creation.
487
 */
487
 */
488
public void testDeprecatedFlag10() throws CoreException {
488
public void testDeprecatedFlag10() throws CoreException {
489
	createFolder("/P/src/p2");
489
	try {
490
490
		createFolder("/P/src/p2");
491
	createFile(
492
			"/P/src/p2/package-info.java",
493
			"@java.lang.Deprecated package p2;\n"
494
		);
495
	
491
	
496
	// workaround for missing type in jclMin:
492
		createFile(
497
	createFolder("/P/src/java/lang");
493
				"/P/src/p2/package-info.java",
498
	createFile(
494
				"@java.lang.Deprecated package p2;\n"
499
			"/P/src/java/lang/Deprecated.java",
495
			);
500
			"package java.lang;\n" +
496
		
501
			"@Retention(RetentionPolicy.RUNTIME)\n" + 
497
		// workaround for missing type in jclMin:
502
			"public @interface Deprecated {\n" + 
498
		createFolder("/P/src/java/lang");
503
			"}\n"
499
		createFile(
504
		);
500
				"/P/src/java/lang/Deprecated.java",
501
				"package java.lang;\n" +
502
				"@Retention(RetentionPolicy.RUNTIME)\n" + 
503
				"public @interface Deprecated {\n" + 
504
				"}\n"
505
			);
506
	
507
		createFile("/P/src/p2/C.java", 
508
				"package p2;\n" +
509
				"public class C {}\n");
510
	
511
		createFile("/P/src/p/D.java", 
512
				"package p;\n" +
513
				"public class D extends p2.C {}\n");
514
		ICompilationUnit cuD = getCompilationUnit("/P/src/p/D.java");
515
		
516
		ASTParser parser = ASTParser.newParser(AST.JLS3);
517
		parser.setProject(this.testProject);
518
		parser.setSource(cuD);
519
		parser.setResolveBindings(true);
520
		org.eclipse.jdt.core.dom.CompilationUnit cuAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null);
521
		IProblem[] problems = cuAST.getProblems();
522
		assertEquals("Should have 1 problem", 1, problems.length);
523
		assertEquals("Should have a deprecation warning", "The type C is deprecated", problems[0].getMessage());
524
	} finally {
525
		deleteFile("/P/src/p/D.java");
526
		deleteFolder("/P/src/p2");
527
		deleteFolder("/P/src/java/lang");
528
	}
529
}
505
530
506
	createFile("/P/src/p2/C.java", 
531
/*
507
			"package p2;\n" +
532
 * Bug 337868 - [compiler][model] incomplete support for package-info.java when using SearchableEnvironment 
508
			"public class C {}\n");
533
 * Ensure that package level annotation is evaluated during AST creation. 
534
 * a working copy for package-info exists and must be used.
535
 */
536
public void testDeprecatedFlag11() throws CoreException {
537
	try {
538
		createFolder("/P/src/p2");
509
539
510
	createFile("/P/src/p/D.java", 
540
		createFile(
511
			"package p;\n" +
541
				"/P/src/p2/package-info.java",
512
			"public class D extends p2.C {}\n");
542
				"@java.lang.Deprecated package p2;\n"
513
	ICompilationUnit cuD = getCompilationUnit("/P/src/p/D.java");
543
			);
544
		WorkingCopyOwner myWCOwner = newWorkingCopyOwner(null);
545
		getCompilationUnit("/P/src/p2/package-info.java").getWorkingCopy(myWCOwner, null);
546
547
548
		// workaround for missing type in jclMin:
549
		createFolder("/P/src/java/lang");
550
		createFile(
551
				"/P/src/java/lang/Deprecated.java",
552
				"package java.lang;\n" +
553
				"@Retention(RetentionPolicy.RUNTIME)\n" +
554
				"public @interface Deprecated {\n" +
555
				"}\n"
556
			);
557
	
558
		createFile("/P/src/p2/C.java",
559
				"package p2;\n" +
560
				"public class C {}\n");
514
	
561
	
515
	ASTParser parser = ASTParser.newParser(AST.JLS3);
562
		createFile("/P/src/p/D.java",
516
	parser.setProject(this.testProject);
563
				"package p;\n" +
517
	parser.setSource(cuD);
564
				"public class D extends p2.C {}\n");
518
	parser.setResolveBindings(true);
565
		ICompilationUnit cuD = getCompilationUnit("/P/src/p/D.java");
519
	org.eclipse.jdt.core.dom.CompilationUnit cuAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null);
566
520
	IProblem[] problems = cuAST.getProblems();
567
		ASTParser parser = ASTParser.newParser(AST.JLS3);
521
	assertEquals("Should have 1 problem", 1, problems.length);
568
		parser.setWorkingCopyOwner(myWCOwner);
522
	assertEquals("Should have a deprecation warning", "The type C is deprecated", problems[0].getMessage());
569
		parser.setProject(this.testProject);
570
		parser.setSource(cuD);
571
		parser.setResolveBindings(true);
572
		org.eclipse.jdt.core.dom.CompilationUnit cuAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null);
573
		IProblem[] problems = cuAST.getProblems();
574
		assertEquals("Should have 1 problem", 1, problems.length);
575
		assertEquals("Should have a deprecation warning", "The type C is deprecated", problems[0].getMessage());
576
	} finally {
577
		deleteFile("/P/src/p/D.java");
578
		deleteFolder("/P/src/p2");
579
		deleteFolder("/P/src/java/lang");
580
	}
523
}
581
}
524
/*
582
/*
525
 * Ensures that the primary type of a cu can be found.
583
 * Ensures that the primary type of a cu can be found.

Return to bug 337868