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 161283 Details for
Bug 304841
[search] NPE in IndexSelector.initializeIndexLocations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
New proposed patch
v01.txt (text/plain), 5.33 KB, created by
Frederic Fusier
on 2010-03-08 07:47:04 EST
(
hide
)
Description:
New proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2010-03-08 07:47:04 EST
Size:
5.33 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/internal/core/search/IndexSelector.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IndexSelector.java,v >retrieving revision 1.45 >diff -u -r1.45 IndexSelector.java >--- search/org/eclipse/jdt/internal/core/search/IndexSelector.java 15 Feb 2010 20:20:02 -0000 1.45 >+++ search/org/eclipse/jdt/internal/core/search/IndexSelector.java 8 Mar 2010 12:46:28 -0000 >@@ -194,14 +194,16 @@ > char[][] focusQualifiedName = null; > if (isAutoBuilding && focus instanceof IJavaProject) { > IJavaElement javaElement = this.pattern.focus; >- while (javaElement != null && !(javaElement instanceof ICompilationUnit) && !(javaElement instanceof IClassFile)) { >+ while (javaElement != null && !(javaElement instanceof ITypeRoot)) { > javaElement = javaElement.getParent(); > } > if (javaElement != null) { >- ICompilationUnit compilationUnit = (ICompilationUnit) javaElement; >- char[][] qualifiedName = CharOperation.splitOn('.', compilationUnit.findPrimaryType().getFullyQualifiedName().toCharArray()); >- char[][][] qualifiedNames = ReferenceCollection.internQualifiedNames(new char[][][] {qualifiedName}); >- focusQualifiedName = qualifiedNames[0]; >+ IType primaryType = ((ITypeRoot) javaElement).findPrimaryType(); >+ if (primaryType != null) { >+ char[][] qualifiedName = CharOperation.splitOn('.', primaryType.getFullyQualifiedName().toCharArray()); >+ char[][][] qualifiedNames = ReferenceCollection.internQualifiedNames(new char[][][] {qualifiedName}); >+ focusQualifiedName = qualifiedNames[0]; >+ } > } > } > >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v >retrieving revision 1.190 >diff -u -r1.190 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 14 Jan 2010 14:24:06 -0000 1.190 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 8 Mar 2010 12:46:31 -0000 >@@ -23,6 +23,7 @@ > import org.eclipse.core.resources.IResourceChangeEvent; > import org.eclipse.core.resources.IResourceChangeListener; > import org.eclipse.core.resources.IResourceDelta; >+import org.eclipse.core.resources.IWorkspaceDescription; > import org.eclipse.core.resources.IncrementalProjectBuilder; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IPath; >@@ -11453,4 +11454,83 @@ > } > } > >+/** >+ * @bug 304841: [search] NPE in IndexSelector.initializeIndexLocations >+ * @test Ensure that no NPE occurs when searching for a reference in a CU without primary type >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=304841" >+ */ >+public void testBug304841() throws Exception { >+ boolean autoBuild = getWorkspace().isAutoBuilding(); >+ IWorkspaceDescription preferences = getWorkspace().getDescription(); >+ try { >+ // ensure that the workspace auto-build is ON >+ preferences.setAutoBuilding(true); >+ getWorkspace().setDescription(preferences); >+ >+ // create test case >+ IJavaProject project = createJavaProject("P"); >+ createFolder("/P/p"); >+ createFile( >+ "/P/p/Hello.java", >+ "package p;\n" + >+ "class One {\n" + >+ "}\n" + >+ "class Two {\n" + >+ "}\n" >+ ); >+ createFile( >+ "/P/p/Ref.java", >+ "package p;\n" + >+ "class Three {\n" + >+ " Two two;\n" + >+ "}\n" >+ ); >+ waitUntilIndexesReady(); >+ >+ // perform search >+ final ICompilationUnit cu = getCompilationUnit("/P/p/Hello.java"); >+ IType type = cu.getType("Two"); >+ SearchPattern pattern = SearchPattern.createPattern(type, REFERENCES); >+ MatchLocator.setFocus(pattern, type); >+ new SearchEngine().search( >+ pattern, >+ new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, >+ SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), >+ this.resultCollector, >+ null >+ ); >+ assertSearchResults( >+ "p/Ref.java p.Three.two [Two] EXACT_MATCH" >+ ); >+ } finally { >+ preferences.setAutoBuilding(autoBuild); >+ getWorkspace().setDescription(preferences); >+ deleteProject("P"); >+ } >+} >+public void testBug304841b() throws Exception { >+ boolean autoBuild = getWorkspace().isAutoBuilding(); >+ IWorkspaceDescription preferences = getWorkspace().getDescription(); >+ try { >+ // ensure that the workspace auto-build is ON >+ preferences.setAutoBuilding(true); >+ getWorkspace().setDescription(preferences); >+ >+ // perform search >+ IType type = getClassFile("/JavaSearchBugs/lib/Bug148380.class").getType(); >+ SearchPattern pattern = SearchPattern.createPattern(type, REFERENCES); >+ MatchLocator.setFocus(pattern, type); >+ new SearchEngine().search( >+ pattern, >+ new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, >+ getJavaSearchScope(), >+ this.resultCollector, >+ null >+ ); >+ assertSearchResults(""); // No expected results, only verify that no CCE occurs >+ } finally { >+ preferences.setAutoBuilding(autoBuild); >+ getWorkspace().setDescription(preferences); >+ } >+} > } >\ No newline at end of file
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 304841
:
161273
| 161283