Lines 1356-1362
Link Here
|
1356 |
} |
1356 |
} |
1357 |
/** |
1357 |
/** |
1358 |
* Method declaration in hierarchy test. |
1358 |
* Method declaration in hierarchy test. |
1359 |
* Explicitly request behavior pre https://bugs.eclipse.org/bugs/show_bug.cgi?id=215139 |
|
|
1360 |
*/ |
1359 |
*/ |
1361 |
public void testMethodDeclaration04() throws CoreException { // was testMethodDeclarationInHierarchyScope1 |
1360 |
public void testMethodDeclaration04() throws CoreException { // was testMethodDeclarationInHierarchyScope1 |
1362 |
IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X"); |
1361 |
IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X"); |
Lines 1365-1388
Link Here
|
1365 |
"foo", |
1364 |
"foo", |
1366 |
METHOD, |
1365 |
METHOD, |
1367 |
DECLARATIONS, |
1366 |
DECLARATIONS, |
1368 |
SearchEngine.createHierarchyScope(null, type, false, true, null), |
|
|
1369 |
this.resultCollector); |
1370 |
assertSearchResults( |
1371 |
"src/p/X.java void p.X.foo(int, String, X) [foo]\n" + |
1372 |
"src/p/Z.java void p.Z.foo(int, String, X) [foo]", |
1373 |
this.resultCollector); |
1374 |
} |
1375 |
/** |
1376 |
* Method declaration in hierarchy test. |
1377 |
* After https://bugs.eclipse.org/bugs/show_bug.cgi?id=215139 result contains more types. |
1378 |
*/ |
1379 |
public void testMethodDeclaration04a() throws CoreException { // was testMethodDeclarationInHierarchyScope1 |
1380 |
IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X"); |
1381 |
|
1382 |
search( |
1383 |
"foo", |
1384 |
METHOD, |
1385 |
DECLARATIONS, |
1386 |
SearchEngine.createHierarchyScope(type), |
1367 |
SearchEngine.createHierarchyScope(type), |
1387 |
this.resultCollector); |
1368 |
this.resultCollector); |
1388 |
assertSearchResults( |
1369 |
assertSearchResults( |
Lines 2450-2456
Link Here
|
2450 |
ICompilationUnit cuB = this. getCompilationUnit("JavaSearch", "src", "a10", "B.java"); |
2431 |
ICompilationUnit cuB = this. getCompilationUnit("JavaSearch", "src", "a10", "B.java"); |
2451 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2432 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2452 |
IType type = cuC.getType("C"); |
2433 |
IType type = cuC.getType("C"); |
2453 |
IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); |
2434 |
IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null); |
2454 |
|
2435 |
|
2455 |
// don't include super-classes: |
2436 |
// don't include super-classes: |
2456 |
assertFalse("a10.A should not be included in hierarchy scope", scope.encloses(cuB.getType("A"))); |
2437 |
assertFalse("a10.A should not be included in hierarchy scope", scope.encloses(cuB.getType("A"))); |
Lines 2464-2474
Link Here
|
2464 |
public void testSearchScope07() throws CoreException { |
2445 |
public void testSearchScope07() throws CoreException { |
2465 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2446 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2466 |
IType type = cuC.getType("C"); |
2447 |
IType type = cuC.getType("C"); |
2467 |
IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); |
2448 |
IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null); |
2468 |
|
2449 |
|
2469 |
// don't include focus type: |
2450 |
// don't include focus type: |
2470 |
assertFalse("a10.C should be not included in hierarchy scope", scope.encloses(type)); |
2451 |
assertFalse("a10.C should not be included in hierarchy scope", scope.encloses(type)); |
2471 |
assertFalse("a10/C.java should be included in hierarchy scope", scope.encloses(cuC.getUnderlyingResource().getFullPath().toString())); |
2452 |
assertFalse("a10/C.java should not be included in hierarchy scope", scope.encloses(cuC.getUnderlyingResource().getFullPath().toString())); |
|
|
2453 |
} |
2454 |
/** |
2455 |
* Hierarchy scope test. |
2456 |
* test for enhancement bug 215139 encloses(): find only subtypes. |
2457 |
* also test enhancement bug 295894: include focus type. |
2458 |
*/ |
2459 |
public void testSearchScope07a() throws CoreException { |
2460 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2461 |
IType type = cuC.getType("C"); |
2462 |
IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, true, null); |
2463 |
|
2464 |
// include focus type: |
2465 |
assertTrue("a10.C should be included in hierarchy scope", scope.encloses(type)); |
2466 |
assertTrue("a10/C.java should be included in hierarchy scope", scope.encloses(cuC.getUnderlyingResource().getFullPath().toString())); |
2472 |
} |
2467 |
} |
2473 |
/** |
2468 |
/** |
2474 |
* Hierarchy scope test. |
2469 |
* Hierarchy scope test. |
Lines 2479-2485
Link Here
|
2479 |
ICompilationUnit cuD = this. getCompilationUnit("JavaSearch", "src", "a10", "D.java"); |
2474 |
ICompilationUnit cuD = this. getCompilationUnit("JavaSearch", "src", "a10", "D.java"); |
2480 |
ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); |
2475 |
ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); |
2481 |
IType type = cuC.getType("C"); |
2476 |
IType type = cuC.getType("C"); |
2482 |
IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); |
2477 |
IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null); |
2483 |
|
2478 |
|
2484 |
// regular sub-types: |
2479 |
// regular sub-types: |
2485 |
assertTrue("a10.D should be included in hierarchy scope", scope.encloses(cuD.getType("D"))); |
2480 |
assertTrue("a10.D should be included in hierarchy scope", scope.encloses(cuD.getType("D"))); |
Lines 2496-2502
Link Here
|
2496 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2491 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2497 |
ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); |
2492 |
ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); |
2498 |
IType type = cuC.getType("C"); |
2493 |
IType type = cuC.getType("C"); |
2499 |
IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); |
2494 |
IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null); |
2500 |
|
2495 |
|
2501 |
// sub-type is a nested type: |
2496 |
// sub-type is a nested type: |
2502 |
assertTrue("a10.H$I should be included in hierarchy scope", scope.encloses(cuE.getType("H").getType("I"))); |
2497 |
assertTrue("a10.H$I should be included in hierarchy scope", scope.encloses(cuE.getType("H").getType("I"))); |
Lines 2509-2541
Link Here
|
2509 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2504 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2510 |
ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); |
2505 |
ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); |
2511 |
IType type = cuC.getType("C"); |
2506 |
IType type = cuC.getType("C"); |
2512 |
IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); |
2507 |
IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null); |
2513 |
|
2508 |
|
2514 |
// member of a sub-type: |
2509 |
// member of a sub-type: |
2515 |
assertFalse("a10.F$G should not be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G"))); |
2510 |
assertFalse("a10.F$G should not be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G"))); |
2516 |
} |
2511 |
} |
2517 |
/** |
2512 |
/** |
2518 |
* Hierarchy scope test. |
2513 |
* Hierarchy scope test. |
2519 |
* (test for enhancement bug 215139 encloses(): find only subtypes and their member types). |
|
|
2520 |
*/ |
2521 |
public void testSearchScope11() throws CoreException { |
2522 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2523 |
ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); |
2524 |
IType type = cuC.getType("C"); |
2525 |
IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, false, null); |
2526 |
|
2527 |
// member of a sub-type: |
2528 |
assertTrue("a10.F$G should be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G"))); |
2529 |
} |
2530 |
/** |
2531 |
* Hierarchy scope test. |
2532 |
* (test for enhancement bug 215139 encloses(): find only subtypes). |
2514 |
* (test for enhancement bug 215139 encloses(): find only subtypes). |
2533 |
*/ |
2515 |
*/ |
2534 |
public void testSearchScope12() throws CoreException { |
2516 |
public void testSearchScope12() throws CoreException { |
2535 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2517 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2536 |
ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); |
2518 |
ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); |
2537 |
IType type = cuC.getType("C"); |
2519 |
IType type = cuC.getType("C"); |
2538 |
IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); |
2520 |
IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null); |
2539 |
|
2521 |
|
2540 |
// enclosing of a sub-type: |
2522 |
// enclosing of a sub-type: |
2541 |
assertFalse("a10.H should not be included in hierarchy scope", scope.encloses(cuE.getType("H"))); |
2523 |
assertFalse("a10.H should not be included in hierarchy scope", scope.encloses(cuE.getType("H"))); |
Lines 2548-2554
Link Here
|
2548 |
public void testSearchScope13() throws CoreException { |
2530 |
public void testSearchScope13() throws CoreException { |
2549 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2531 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2550 |
IType type = cuC.getType("C"); |
2532 |
IType type = cuC.getType("C"); |
2551 |
IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); |
2533 |
IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null); |
2552 |
|
2534 |
|
2553 |
search("**", TYPE, DECLARATIONS, scope); |
2535 |
search("**", TYPE, DECLARATIONS, scope); |
2554 |
assertSearchResults( |
2536 |
assertSearchResults( |
Lines 2565-2571
Link Here
|
2565 |
public void testSearchScope14() throws CoreException { |
2547 |
public void testSearchScope14() throws CoreException { |
2566 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2548 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2567 |
IType type = cuC.getType("C"); |
2549 |
IType type = cuC.getType("C"); |
2568 |
IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, /*onlySubTypes*/false, true, null); |
2550 |
IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, /*onlySubTypes*/false, true, null); |
2569 |
|
2551 |
|
2570 |
search("**", TYPE, DECLARATIONS, scope); |
2552 |
search("**", TYPE, DECLARATIONS, scope); |
2571 |
assertSearchResults( |
2553 |
assertSearchResults( |
Lines 2581-2620
Link Here
|
2581 |
} |
2563 |
} |
2582 |
/** |
2564 |
/** |
2583 |
* Hierarchy scope test. |
2565 |
* Hierarchy scope test. |
2584 |
* (test for enhancement bug 215139 search: find only subtypes - different call chain). |
2566 |
* test for enhancement bug 215139 search: find only subtypes - disabled, |
|
|
2567 |
* also test enhancement bug 295894: exclude focus type. |
2585 |
*/ |
2568 |
*/ |
2586 |
public void testSearchScope15() throws CoreException { |
2569 |
public void testSearchScope14a() throws CoreException { |
2587 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2570 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2588 |
IType type = cuC.getType("C"); |
2571 |
IType type = cuC.getType("C"); |
2589 |
IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); |
2572 |
IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, /*onlySubTypes*/false, false, null); |
2590 |
TypeNameMatchCollector collector = new TypeNameMatchCollector() { |
2573 |
|
2591 |
public String toString(){ |
2574 |
search("**", TYPE, DECLARATIONS, scope); |
2592 |
return toFullyQualifiedNamesString(); |
2575 |
assertSearchResults( |
2593 |
} |
2576 |
"src/a10/B.java a10.A [A]\n" + |
2594 |
}; |
2577 |
"src/a10/B.java a10.B [B]\n" + |
2595 |
new SearchEngine().searchAllTypeNames( |
2578 |
"src/a10/D.java a10.D [D]\n" + |
2596 |
null, |
2579 |
"src/a10/E.java a10.E [E]\n" + |
2597 |
null, |
2580 |
"src/a10/E.java a10.F [F]\n" + |
2598 |
scope, |
2581 |
"src/a10/E.java a10.H$I [I]\n" + |
2599 |
collector, |
2582 |
getExternalJCLPathString() + " java.lang.Object" |
2600 |
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, |
2583 |
); |
2601 |
null); |
|
|
2602 |
String expected = |
2603 |
"a10.D\n" + |
2604 |
"a10.E\n" + |
2605 |
"a10.F\n" + |
2606 |
"a10.H$I"; |
2607 |
assertTrue("We should get some types!", collector.size() > 0); |
2608 |
assertEquals("Found types sound not to be correct", expected, collector.toString()); |
2609 |
} |
2584 |
} |
2610 |
/** |
2585 |
/** |
2611 |
* Hierarchy scope test. |
2586 |
* Hierarchy scope test. |
2612 |
* (test for enhancement bug 215139 search: find only subtypes plus member & enclosing types - different call chain). |
2587 |
* (test for enhancement bug 215139 search: find only subtypes - different call chain). |
2613 |
*/ |
2588 |
*/ |
2614 |
public void testSearchScope16() throws CoreException { |
2589 |
public void testSearchScope15() throws CoreException { |
2615 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2590 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2616 |
IType type = cuC.getType("C"); |
2591 |
IType type = cuC.getType("C"); |
2617 |
IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, false, null); |
2592 |
IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null); |
2618 |
TypeNameMatchCollector collector = new TypeNameMatchCollector() { |
2593 |
TypeNameMatchCollector collector = new TypeNameMatchCollector() { |
2619 |
public String toString(){ |
2594 |
public String toString(){ |
2620 |
return toFullyQualifiedNamesString(); |
2595 |
return toFullyQualifiedNamesString(); |
Lines 2631-2638
Link Here
|
2631 |
"a10.D\n" + |
2606 |
"a10.D\n" + |
2632 |
"a10.E\n" + |
2607 |
"a10.E\n" + |
2633 |
"a10.F\n" + |
2608 |
"a10.F\n" + |
2634 |
"a10.F$G\n" + |
|
|
2635 |
"a10.H\n" + |
2636 |
"a10.H$I"; |
2609 |
"a10.H$I"; |
2637 |
assertTrue("We should get some types!", collector.size() > 0); |
2610 |
assertTrue("We should get some types!", collector.size() > 0); |
2638 |
assertEquals("Found types sound not to be correct", expected, collector.toString()); |
2611 |
assertEquals("Found types sound not to be correct", expected, collector.toString()); |
Lines 2645-2669
Link Here
|
2645 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2618 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2646 |
ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); |
2619 |
ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); |
2647 |
IType type = cuC.getType("C"); |
2620 |
IType type = cuC.getType("C"); |
2648 |
IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); |
2621 |
IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null); |
2649 |
|
2622 |
|
2650 |
// method of a member of a sub-type: |
2623 |
// method of a member of a sub-type: |
2651 |
assertFalse("a10.F$G.m() should not be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G").getMethod("m", new String[0]))); |
2624 |
assertFalse("a10.F$G.m() should not be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G").getMethod("m", new String[0]))); |
2652 |
} |
2625 |
} |
2653 |
/** |
2626 |
/** |
2654 |
* Hierarchy scope test. |
|
|
2655 |
* (test for enhancement bug 215139 encloses(method): find only subtypes but also member types). |
2656 |
*/ |
2657 |
public void testSearchScope18() throws CoreException { |
2658 |
ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); |
2659 |
ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); |
2660 |
IType type = cuC.getType("C"); |
2661 |
IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, false, null); |
2662 |
|
2663 |
// method of a member of a sub-type: |
2664 |
assertTrue("a10.F$G.m() should be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G").getMethod("m", new String[0]))); |
2665 |
} |
2666 |
/** |
2667 |
* Simple type declaration test. |
2627 |
* Simple type declaration test. |
2668 |
*/ |
2628 |
*/ |
2669 |
public void testTypeDeclaration01() throws CoreException { // was testSimpleTypeDeclaration |
2629 |
public void testTypeDeclaration01() throws CoreException { // was testSimpleTypeDeclaration |