Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 189884 Details for
Bug 337868
[compiler][model] incomplete support for package-info.java when using SearchableEnvironment
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
additional test & fix
Bug_337868_part2.patch (text/plain), 7.34 KB, created by
Stephan Herrmann
on 2011-02-26 19:40:46 EST
(
hide
)
Description:
additional test & fix
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2011-02-26 19:40:46 EST
Size:
7.34 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/NameLookup.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java,v >retrieving revision 1.128 >diff -u -r1.128 NameLookup.java >--- model/org/eclipse/jdt/internal/core/NameLookup.java 11 May 2010 18:47:09 -0000 1.128 >+++ model/org/eclipse/jdt/internal/core/NameLookup.java 27 Feb 2011 00:24:28 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 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 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann - contribution for bug 337868 - [compiler][model] incomplete support for package-info.java when using SearchableEnvironment > *******************************************************************************/ > package org.eclipse.jdt.internal.core; > >@@ -31,6 +32,7 @@ > import org.eclipse.jdt.internal.compiler.env.AccessRestriction; > import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; > import org.eclipse.jdt.internal.compiler.env.IBinaryType; >+import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; > import org.eclipse.jdt.internal.compiler.parser.ScannerHelper; > import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt; > import org.eclipse.jdt.internal.compiler.util.SuffixConstants; >@@ -1194,7 +1196,13 @@ > return true; // don't continue with compilation unit > } > } else if (object instanceof IType[]) { >- if (object == NO_TYPES) return true; // all types where deleted -> type is hidden >+ if (object == NO_TYPES) { >+ // all types where deleted -> type is hidden, OR it is the fake type package-info >+ String packageInfoName = String.valueOf(TypeConstants.PACKAGE_INFO_NAME); >+ if (packageInfoName.equals(name)) >+ requestor.acceptType(pkg.getCompilationUnit(packageInfoName.concat(SUFFIX_STRING_java)).getType(name)); >+ return true; >+ } > IType[] topLevelTypes = (IType[]) object; > for (int i = 0, length = topLevelTypes.length; i < length; i++) { > if (requestor.isCanceled()) >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java,v >retrieving revision 1.73 >diff -u -r1.73 CompilationUnitTests.java >--- src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java 25 Feb 2011 13:55:38 -0000 1.73 >+++ src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java 27 Feb 2011 00:24:33 -0000 >@@ -486,40 +486,98 @@ > * Ensure that package level annotation is evaluated during AST creation. > */ > public void testDeprecatedFlag10() throws CoreException { >- createFolder("/P/src/p2"); >- >- createFile( >- "/P/src/p2/package-info.java", >- "@java.lang.Deprecated package p2;\n" >- ); >+ try { >+ createFolder("/P/src/p2"); > >- // workaround for missing type in jclMin: >- createFolder("/P/src/java/lang"); >- createFile( >- "/P/src/java/lang/Deprecated.java", >- "package java.lang;\n" + >- "@Retention(RetentionPolicy.RUNTIME)\n" + >- "public @interface Deprecated {\n" + >- "}\n" >- ); >+ createFile( >+ "/P/src/p2/package-info.java", >+ "@java.lang.Deprecated package p2;\n" >+ ); >+ >+ // workaround for missing type in jclMin: >+ createFolder("/P/src/java/lang"); >+ createFile( >+ "/P/src/java/lang/Deprecated.java", >+ "package java.lang;\n" + >+ "@Retention(RetentionPolicy.RUNTIME)\n" + >+ "public @interface Deprecated {\n" + >+ "}\n" >+ ); >+ >+ createFile("/P/src/p2/C.java", >+ "package p2;\n" + >+ "public class C {}\n"); >+ >+ createFile("/P/src/p/D.java", >+ "package p;\n" + >+ "public class D extends p2.C {}\n"); >+ ICompilationUnit cuD = getCompilationUnit("/P/src/p/D.java"); >+ >+ ASTParser parser = ASTParser.newParser(AST.JLS3); >+ parser.setProject(this.testProject); >+ parser.setSource(cuD); >+ parser.setResolveBindings(true); >+ org.eclipse.jdt.core.dom.CompilationUnit cuAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null); >+ IProblem[] problems = cuAST.getProblems(); >+ assertEquals("Should have 1 problem", 1, problems.length); >+ assertEquals("Should have a deprecation warning", "The type C is deprecated", problems[0].getMessage()); >+ } finally { >+ deleteFile("/P/src/p/D.java"); >+ deleteFolder("/P/src/p2"); >+ deleteFolder("/P/src/java/lang"); >+ } >+} > >- createFile("/P/src/p2/C.java", >- "package p2;\n" + >- "public class C {}\n"); >+/* >+ * Bug 337868 - [compiler][model] incomplete support for package-info.java when using SearchableEnvironment >+ * Ensure that package level annotation is evaluated during AST creation. >+ * a working copy for package-info exists and must be used. >+ */ >+public void testDeprecatedFlag11() throws CoreException { >+ try { >+ createFolder("/P/src/p2"); > >- createFile("/P/src/p/D.java", >- "package p;\n" + >- "public class D extends p2.C {}\n"); >- ICompilationUnit cuD = getCompilationUnit("/P/src/p/D.java"); >+ createFile( >+ "/P/src/p2/package-info.java", >+ "@java.lang.Deprecated package p2;\n" >+ ); >+ WorkingCopyOwner myWCOwner = newWorkingCopyOwner(null); >+ getCompilationUnit("/P/src/p2/package-info.java").getWorkingCopy(myWCOwner, null); >+ >+ >+ // workaround for missing type in jclMin: >+ createFolder("/P/src/java/lang"); >+ createFile( >+ "/P/src/java/lang/Deprecated.java", >+ "package java.lang;\n" + >+ "@Retention(RetentionPolicy.RUNTIME)\n" + >+ "public @interface Deprecated {\n" + >+ "}\n" >+ ); >+ >+ createFile("/P/src/p2/C.java", >+ "package p2;\n" + >+ "public class C {}\n"); > >- ASTParser parser = ASTParser.newParser(AST.JLS3); >- parser.setProject(this.testProject); >- parser.setSource(cuD); >- parser.setResolveBindings(true); >- org.eclipse.jdt.core.dom.CompilationUnit cuAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null); >- IProblem[] problems = cuAST.getProblems(); >- assertEquals("Should have 1 problem", 1, problems.length); >- assertEquals("Should have a deprecation warning", "The type C is deprecated", problems[0].getMessage()); >+ createFile("/P/src/p/D.java", >+ "package p;\n" + >+ "public class D extends p2.C {}\n"); >+ ICompilationUnit cuD = getCompilationUnit("/P/src/p/D.java"); >+ >+ ASTParser parser = ASTParser.newParser(AST.JLS3); >+ parser.setWorkingCopyOwner(myWCOwner); >+ parser.setProject(this.testProject); >+ parser.setSource(cuD); >+ parser.setResolveBindings(true); >+ org.eclipse.jdt.core.dom.CompilationUnit cuAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null); >+ IProblem[] problems = cuAST.getProblems(); >+ assertEquals("Should have 1 problem", 1, problems.length); >+ assertEquals("Should have a deprecation warning", "The type C is deprecated", problems[0].getMessage()); >+ } finally { >+ deleteFile("/P/src/p/D.java"); >+ deleteFolder("/P/src/p2"); >+ deleteFolder("/P/src/java/lang"); >+ } > } > /* > * Ensures that the primary type of a cu can be found.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 337868
:
189521
| 189884