Lines 23-28
Link Here
|
23 |
import org.eclipse.core.resources.IResourceChangeEvent; |
23 |
import org.eclipse.core.resources.IResourceChangeEvent; |
24 |
import org.eclipse.core.resources.IResourceChangeListener; |
24 |
import org.eclipse.core.resources.IResourceChangeListener; |
25 |
import org.eclipse.core.resources.IResourceDelta; |
25 |
import org.eclipse.core.resources.IResourceDelta; |
|
|
26 |
import org.eclipse.core.resources.IWorkspaceDescription; |
26 |
import org.eclipse.core.resources.IncrementalProjectBuilder; |
27 |
import org.eclipse.core.resources.IncrementalProjectBuilder; |
27 |
import org.eclipse.core.runtime.CoreException; |
28 |
import org.eclipse.core.runtime.CoreException; |
28 |
import org.eclipse.core.runtime.IPath; |
29 |
import org.eclipse.core.runtime.IPath; |
Lines 11453-11456
Link Here
|
11453 |
} |
11454 |
} |
11454 |
} |
11455 |
} |
11455 |
|
11456 |
|
|
|
11457 |
/** |
11458 |
* @bug 304841: [search] NPE in IndexSelector.initializeIndexLocations |
11459 |
* @test Ensure that no NPE occurs when searching for a reference in a CU without primary type |
11460 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=304841" |
11461 |
*/ |
11462 |
public void testBug304841() throws Exception { |
11463 |
boolean autoBuild = getWorkspace().isAutoBuilding(); |
11464 |
IWorkspaceDescription preferences = getWorkspace().getDescription(); |
11465 |
try { |
11466 |
// ensure that the workspace auto-build is ON |
11467 |
preferences.setAutoBuilding(true); |
11468 |
getWorkspace().setDescription(preferences); |
11469 |
|
11470 |
// create test case |
11471 |
IJavaProject project = createJavaProject("P"); |
11472 |
createFolder("/P/p"); |
11473 |
createFile( |
11474 |
"/P/p/Hello.java", |
11475 |
"package p;\n" + |
11476 |
"class One {\n" + |
11477 |
"}\n" + |
11478 |
"class Two {\n" + |
11479 |
"}\n" |
11480 |
); |
11481 |
createFile( |
11482 |
"/P/p/Ref.java", |
11483 |
"package p;\n" + |
11484 |
"class Three {\n" + |
11485 |
" Two two;\n" + |
11486 |
"}\n" |
11487 |
); |
11488 |
waitUntilIndexesReady(); |
11489 |
|
11490 |
// perform search |
11491 |
final ICompilationUnit cu = getCompilationUnit("/P/p/Hello.java"); |
11492 |
IType type = cu.getType("Two"); |
11493 |
SearchPattern pattern = SearchPattern.createPattern(type, REFERENCES); |
11494 |
MatchLocator.setFocus(pattern, type); |
11495 |
new SearchEngine().search( |
11496 |
pattern, |
11497 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
11498 |
SearchEngine.createJavaSearchScope(new IJavaElement[] { project }), |
11499 |
this.resultCollector, |
11500 |
null |
11501 |
); |
11502 |
assertSearchResults( |
11503 |
"p/Ref.java p.Three.two [Two] EXACT_MATCH" |
11504 |
); |
11505 |
} finally { |
11506 |
preferences.setAutoBuilding(autoBuild); |
11507 |
getWorkspace().setDescription(preferences); |
11508 |
deleteProject("P"); |
11509 |
} |
11510 |
} |
11456 |
} |
11511 |
} |