Skip to main content
summaryrefslogtreecommitdiffstats
blob: 49119344155f64424b684ab3295030f7b37d1a99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
/*******************************************************************************
 * Copyright (c) 2000, 2019 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Stephan Herrmann - Contribution for bug 215139
 *******************************************************************************/
package org.eclipse.jdt.core.tests.model;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Hashtable;

import junit.framework.Test;

import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.search.*;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.core.JavaModelStatus;

/**
 * Tests the Java search engine where results are JavaElements and source positions.
 */
@SuppressWarnings({"rawtypes", "unchecked"})
public class JavaSearchTests extends AbstractJavaSearchTests {

public JavaSearchTests(String name) {
	super(name);
}
public static Test suite() {
	return buildModelTestSuite(JavaSearchTests.class);
}
// Use this static initializer to specify subset for tests
// All specified tests which do not belong to the class are skipped...
static {
//	org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true;
//	TESTS_PREFIX =  "testPackageDeclaration";
//	TESTS_NAMES = new String[] { "testMethodReference17" };
//	TESTS_NUMBERS = new int[] { 113671 };
//	TESTS_RANGE = new int[] { 16, -1 };
}

/* (non-Javadoc)
 * @see org.eclipse.jdt.core.tests.model.AbstractJavaModelTests#copyDirectory(java.io.File, java.io.File)
 */
protected void copyDirectory(File sourceDir, File targetDir) throws IOException {
	if (!targetDir.exists()) {
		super.copyDirectory(sourceDir, targetDir);
	}
}

/* (non-Javadoc)
 * @see org.eclipse.jdt.core.tests.model.SuiteOfTestCases#setUpSuite()
 */
public void setUpSuite() throws Exception {
	super.setUpSuite();

	if (JAVA_PROJECT == null) {
		JAVA_PROJECT = setUpJavaProject("JavaSearch");
		setUpJavaProject("JavaSearch15", "1.5");
	}
}
public void tearDownSuite() throws Exception {
	if (JAVA_SEARCH_SUITES == null) {
		deleteProject("JavaSearch");
		deleteProject("JavaSearch15");
	} else {
		JAVA_SEARCH_SUITES.remove(getClass());
		if (JAVA_SEARCH_SUITES.size() == 0) {
			deleteProject("JavaSearch");
			deleteProject("JavaSearch15");
		}
	}

	super.tearDownSuite();
}
/**
 * Simple constructor declaration test.
 */
public void testConstructorDeclaration01() throws CoreException { // was testSimpleConstructorDeclaration
	IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
	IMethod constructor = type.getMethod("A", new String[] {"QX;"});
	search(
		constructor,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults("src/p/A.java p.A(X) [A]", this.resultCollector);
}
/**
 * Constructor declaration in jar file test.
 */
public void testConstructorDeclaration02() throws CoreException { // was testConstructorDeclarationInJar
	IType type = getClassFile("JavaSearch", "MyJar.jar", "p1", "A.class").getType();
	IMethod method = type.getMethod("A", new String[] {"Ljava.lang.String;"});
	search(
		method,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"MyJar.jar p1.A(java.lang.String) [No source]",
		this.resultCollector);
}
/**
 * Simple constructor reference test.
 */
public void testConstructorReference01() throws CoreException { // was testSimpleConstructorReference1
	IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
	IMethod constructor = type.getMethod("A", new String[] {"QX;"});
	search(
		constructor,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/Test.java void Test.main(String[]) [new p.A(y)]",
		this.resultCollector);
}
/**
 * Simple constructor reference test.
 */
public void testConstructorReference02() throws CoreException { // was testSimpleConstructorReference2
	search(
		"p.A(X)",
		CONSTRUCTOR,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/Test.java void Test.main(String[]) [new p.A(y)]",
		this.resultCollector);
}
/**
 * Constructor reference using an explicit constructor call.
 */
public void testConstructorReference03() throws CoreException { // was testConstructorReferenceExplicitConstructorCall1
	IType type = getCompilationUnit("JavaSearch", "src", "p", "Y.java").getType("Y");
	IMethod method = type.getMethod("Y", new String[] {"I"});
	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p/Z.java p.Z(int) [super(i);]",
		this.resultCollector);
}
/**
 * Constructor reference using an explicit constructor call.
 */
public void testConstructorReference04() throws CoreException { // was testConstructorReferenceExplicitConstructorCall2
	IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
	IMethod method = type.getMethod("X", new String[] {"I"});
	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p/Y.java p.Y(int) [super(i);]\n" +
		"src/p/Y.java p.Y(boolean) [super(1);]",
		this.resultCollector);
}
/**
 * Constructor reference using an implicit constructor call.
 * (regression test for bug 23112 search: need a way to search for references to the implicit non-arg constructor)
 */
public void testConstructorReference05() throws CoreException { // was testConstructorReferenceImplicitConstructorCall1
	IType type = getCompilationUnit("JavaSearch", "src", "c7", "X.java").getType("X");
	IMethod method = type.getMethod("X", new String[] {});
	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/c7/Y.java c7.Y() [Y]",
		this.resultCollector);
}
/**
 * Constructor reference using an implicit constructor call.
 * (regression test for bug 23112 search: need a way to search for references to the implicit non-arg constructor)
 */
public void testConstructorReference06() throws CoreException { // was testConstructorReferenceImplicitConstructorCall2
	search(
		"c8.X()",
		CONSTRUCTOR,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/c8/Y.java c8.Y [Y]",
		this.resultCollector);
}
/**
 * Constructor reference in a field initializer.
 * (regression test for PR 1GKZ8VZ: ITPJCORE:WINNT - Search - did not find references to member constructor)
 */
public void testConstructorReference07() throws CoreException { // was testConstructorReferenceInFieldInitializer
	IType type = getCompilationUnit("JavaSearch", "src", "", "A.java").getType("A").getType("Inner");
	IMethod method = type.getMethod("Inner", new String[] {"I"});
	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/A.java A.field [new Inner(1)]\n" +
		"src/A.java A.field [new Inner(2)]",
		this.resultCollector);
}
/**
 * Constructor reference in case of default constructor of member type
 * (regression test for bug 43276)
 */
public void testConstructorReference08() throws CoreException { // was testConstructorReferenceDefaultConstructorOfMemberClass
	search(
		"c10.X.Inner()",
		CONSTRUCTOR,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/c10/X.java c10.B() [new X().super();]",
		this.resultCollector);
}
/*
 * Generic constructor reference
 */
public void testConstructorReference09() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15/src/p2/X.java").getType("X");
	IMethod method = type.getMethod("X", new String[] {"QE;"});
	search(
		method,
		REFERENCES,
		ERASURE_RULE,
		getJavaSearchScope15(),
		this.resultCollector);
	assertSearchResults(
		"src/p2/Y.java Object p2.Y.foo() [new X<Object>(this)]",
		this.resultCollector);
}
/**
 * Constructor reference using an implicit constructor call.
 * (regression test for bug 23112 search: need a way to search for references to the implicit non-arg constructor)
 */
public void testConstructorReference10() throws CoreException { // was testConstructorReferenceImplicitConstructorCall2
	this.resultCollector.showSynthetic();
	search(
		"c11.A()",
		CONSTRUCTOR,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/c11/A.java c11.A1 [A1] SYNTHETIC\n" +
		"src/c11/A.java c11.A2() [A2] SYNTHETIC\n" +
		"src/c11/A.java c11.A3() [super();]",
		this.resultCollector);
}
/**
 * CoreException thrown during accept.
 * (regression test for PR #1G3UI7A)
 */
public void testCoreException() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
	SearchRequestor result = new SearchRequestor() {
		public void acceptSearchMatch(SearchMatch match) throws CoreException {
			throw new CoreException(new JavaModelStatus(-1, "test"));
		}
	};
	try {
		search(
			type,
			DECLARATIONS,
			getJavaSearchScope(),
			result);
	} catch (CoreException e) {
		assertEquals("Unexpected CoreException has been thrown", "test", e.getStatus().getMessage());
		return;
	}
	assertTrue("CoreException should have been thrown", false);
}
/**
 * Declaration of accessed fields test.
 * (regression test for bug 6538 searchDeclarationsOf* incorrect)
 */
public void testDeclarationOfAccessedFields1() throws CoreException {
	IMethod method =
		getCompilationUnit("JavaSearch", "src", "a5", "B.java").
			getType("C").getMethod("i", new String[] {});
	searchDeclarationsOfAccessedFields(
		method,
		this.resultCollector
	);
	assertSearchResults(
		"",
		this.resultCollector);
}
/**
 * Declaration of accessed fields test.
 * (regression test for bug 6538 searchDeclarationsOf* incorrect)
 */
public void testDeclarationOfAccessedFields2() throws CoreException {
	IMethod method =
		getCompilationUnit("JavaSearch", "src", "a6", "A.java").
			getType("B").getMethod("m", new String[] {});
	searchDeclarationsOfAccessedFields(
		method,
		this.resultCollector
	);
	assertSearchResults(
		"src/a6/A.java a6.B.f [f]",
		this.resultCollector);
}
/**
 * Declaration of accessed fields test.
 * (regression test for bug 10386 NPE in MatchLocator.lookupType)
 */
public void testDeclarationOfAccessedFields3() throws CoreException {
	IMethod method =
		getCompilationUnit("JavaSearch", "src", "b6", "A.java").
			getType("A").getMethod("foo", new String[] {});
	searchDeclarationsOfAccessedFields(
		method,
		this.resultCollector
	);
	assertSearchResults(
		"src/b6/A.java b6.A.field [field]",
		this.resultCollector);
}
/**
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=328554
 */
public void testDeclarationOfAccessedFields4() throws CoreException {
	IMethod method =
		getCompilationUnit("JavaSearch", "src", "b10", "A.java").
			getType("A").getMethod("foo", new String[] {});
	searchDeclarationsOfAccessedFields(
		method,
		this.resultCollector
	);
	assertSearchResults(
		"",
		this.resultCollector);
}
/**
 * Declaration of referenced types test.
 */
public void testDeclarationOfReferencedTypes01() throws CoreException {
	IMethod method =
		getCompilationUnit("JavaSearch", "src", "a3", "References.java").
			getType("References").getMethod("foo", new String[] {});
	searchDeclarationsOfReferencedTypes(
		method,
		this.resultCollector
	);
	assertSearchResults(
		"src/a3/X.java a3.X [X]\n" +
		"src/a3/Z.java a3.Z [Z]\n" +
		"src/a3/b/A.java a3.b.A [A]\n" +
		"src/a3/b/A.java a3.b.A$B$C [C]\n" +
		"src/a3/b/A.java a3.b.A$B [B]\n" +
		getExternalJCLPathString() + " java.lang.Object\n" +
		"src/a3/Y.java a3.Y [Y]\n" +
		"src/a3/b/B.java a3.b.B [B]",
		this.resultCollector);
}
/**
 * Declaration of referenced types test.
 * (Regression test for bug 6779 searchDeclarationsOfReferencedTyped - missing exception types)
 */
public void testDeclarationOfReferencedTypes02() throws CoreException {
	IMethod method =
		getCompilationUnit("JavaSearch", "src", "a7", "X.java").
			getType("X").getMethod("foo", new String[] {});
	searchDeclarationsOfReferencedTypes(
		method,
		this.resultCollector
	);
	assertSearchResults(
		"src/a7/X.java a7.MyException [MyException]",
		this.resultCollector);
}
/**
 * Declaration of referenced types test.
 * (Regression test for bug 12649 Missing import after move  )
 */
public void testDeclarationOfReferencedTypes03() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch", "src", "c1", "A.java");
	searchDeclarationsOfReferencedTypes(
		unit,
		this.resultCollector
	);
	assertSearchResults(
		"src/c1/I.java c1.I [I]",
		this.resultCollector);
}
/**
 * Declaration of referenced types test.
 * (Regression test for bug 12649 Missing import after move  )
 */
public void testDeclarationOfReferencedTypes04() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch", "src", "c1", "B.java");
	searchDeclarationsOfReferencedTypes(
		unit,
		this.resultCollector
	);
	assertSearchResults(
		"src/c1/I.java c1.I [I]",
		this.resultCollector);
}
/**
 * Declaration of referenced types test.
 * (Regression test for bug 18418 search: searchDeclarationsOfReferencedTypes reports import declarations)
 */
public void testDeclarationOfReferencedTypes05() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch", "src", "c2", "A.java");
	searchDeclarationsOfReferencedTypes(
		unit,
		this.resultCollector
	);
	assertSearchResults(
		"src/c3/C.java c3.C [C]",
		this.resultCollector);
}
/**
 * Declaration of referenced types test.
 * (Regression test for bug 24934 Move top level doesn't optimize the imports[refactoring])
 */
public void testDeclarationOfReferencedTypes06() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch", "src", "d1", "X.java");
	IType innerType = unit.getType("X").getType("Inner");
	searchDeclarationsOfReferencedTypes(
		innerType,
		this.resultCollector
	);
	assertSearchResults(
		"src/d2/Y.java d2.Y [Y]",
		this.resultCollector);
}
/**
 * Declaration of referenced types test.
 * (Regression test for bug 37438 searchenging NPE in searchDeclarationsOfReferencedTypes
)
 */
public void testDeclarationOfReferencedTypes07() throws CoreException {
	IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "r7");
	boolean iae = false;
	try {
		searchDeclarationsOfReferencedTypes(
			pkg,
			this.resultCollector
		);
	} catch (IllegalArgumentException exception) {
		assertSearchResults("");
		iae = true;
	}
	assertTrue("We should get an IAE!", iae);
}

/**
 * Declaration of referenced types test.
 * (Regression test for bug 47787 IJavaSearchResultCollector.aboutToStart() and done() not called)
 */
public void testDeclarationOfReferencedTypes08() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch", "src", "r7", "A.java");
	JavaSearchResultCollector result = new JavaSearchResultCollector() {
	    public void beginReporting() {
	        addLine("Starting search...");
        }
	    public void endReporting() {
	        addLine("Done searching.");
        }
	};
	searchDeclarationsOfReferencedTypes(unit, result);
	assertSearchResults(
		"Starting search...\n"+
		"Done searching.",
		result);
}

/**
 * Declaration of referenced types test.
 * (Regression test for bug 68862 [1.5] ClassCastException when moving a a java file
)
 */
public void testDeclarationOfReferencedTypes09() throws CoreException {
	ICompilationUnit cu = getCompilationUnit("JavaSearch15/src/p3/X.java");
	JavaSearchResultCollector result = new JavaSearchResultCollector() {
	    public void beginReporting() {
	        addLine("Starting search...");
        }
	    public void endReporting() {
	        addLine("Done searching.");
        }
	};
	searchDeclarationsOfReferencedTypes(
		cu,
		result
	);
	assertSearchResults(
		"Starting search...\n" +
		getExternalJCLPathString("1.5") + " java.lang.Object\n" +
		"Done searching.",
		result);
}
/**
 * Simple declarations of sent messages test.
 */
public void testDeclarationsOfSentMessages01() throws CoreException { // was testSimpleDeclarationsOfSentMessages
	ICompilationUnit cu = getCompilationUnit("JavaSearch", "src", "", "Test.java");
	searchDeclarationsOfSentMessages(
		cu,
		this.resultCollector);
	assertSearchResults(
		"src/p/X.java void p.X.foo(int, String, X) [foo(int i, String s, X x)]\n" +
		"src/p/Y.java void p.Y.bar() [bar()]\n" +
		"src/p/Z.java void p.Z.foo(int, String, X) [foo(int i, String s, X x)]\n" +
		"src/p/A.java void p.A.foo(int, String, X) [foo(int i, String s, X x)]",
		this.resultCollector);
}

/**
 * Declaration of sent messages test.
 * (regression test for bug 6538 searchDeclarationsOf* incorrect)
 */
public void testDeclarationsOfSentMessages02() throws CoreException { // was testDeclarationOfSentMessages
	IMethod method =
		getCompilationUnit("JavaSearch", "src", "a5", "B.java").
			getType("C").getMethod("i", new String[] {});
	searchDeclarationsOfSentMessages(
		method,
		this.resultCollector
	);
	assertSearchResults(
		"",
		this.resultCollector);
}

/*
 * Ensures that a method declaration in an external library folder can be found
 */
public void testExternalFolder1() throws CoreException {
	try {
		createExternalFolder("externalLib");
		Util.compile(
			new String[] {
				"p/X.java",
				"package p;\n" +
				"public class X {\n" +
				"  public void foo() {\n" +
				"  }\n" +
				"}"
			},
			new HashMap(),
			getExternalResourcePath("externalLib")
		);
		createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, "");
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaProject[] {getJavaProject("P")});
		search("foo", METHOD, DECLARATIONS, scope);
		assertSearchResults(
			getExternalPath() + "externalLib void p.X.foo()",
			this.resultCollector);
	} finally {
		deleteProject("P");
		deleteExternalResource("externalLib");
	}
}

/*
 * Ensures that search all type names returns the types in an external library folder
 */
public void testExternalFolder2() throws CoreException {
	try {
		createExternalFolder("externalLib");
		Util.compile(
			new String[] {
				"p/ExternalType.java",
				"package p;\n" +
				"public class ExternalType {\n" +
				"}"
			},
			new HashMap(),
			getExternalResourcePath("externalLib")
		);
		createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, "");

		TypeNameMatchCollector collector = new TypeNameMatchCollector();
		new SearchEngine(this.workingCopies).searchAllTypeNames(
			null,
			SearchPattern.R_EXACT_MATCH,
			"ExternalType".toCharArray(),
			SearchPattern.R_EXACT_MATCH,
			TYPE,
			SearchEngine.createJavaSearchScope(new IJavaProject[] {getJavaProject("P")}),
			collector,
			IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
			null
		);
		assertSearchResults(
			"ExternalType (not open) [in ExternalType.class [in p [in "+ getExternalPath() + "externalLib]]]",
			collector
		);
	} finally {
		deleteProject("P");
		deleteExternalResource("externalLib");
	}

}

/*
 * Ensures that search all type names returns the types in an external library folder
 * when using a workspace scope
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=229304 )
 */
public void testExternalFolder3() throws CoreException {
	try {
		createExternalFolder("externalLib");
		Util.compile(
			new String[] {
				"p/ExternalType229304.java",
				"package p;\n" +
				"public class ExternalType229304 {\n" +
				"}"
			},
			new HashMap(),
			getExternalResourcePath("externalLib")
		);
		createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib")}, "");

		TypeNameMatchCollector collector = new TypeNameMatchCollector();
		new SearchEngine(this.workingCopies).searchAllTypeNames(
			null,
			SearchPattern.R_EXACT_MATCH,
			"ExternalType229304".toCharArray(),
			SearchPattern.R_EXACT_MATCH,
			TYPE,
			SearchEngine.createWorkspaceScope(),
			collector,
			IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
			null
		);
		assertSearchResults(
			"ExternalType229304 (not open) [in ExternalType229304.class [in p [in "+ getExternalPath() + "externalLib]]]",
			collector
		);
	} finally {
		deleteProject("P");
		deleteExternalResource("externalLib");
	}

}

/*
 * Ensures that a method declaration in an external ZIP archive can be found
 */
public void testZIPArchive1() throws Exception {
	try {
		createJar(
			new String[] {
				"p/X.java",
				"package p;\n" +
				"public class X {\n" +
				"  public void foo() {\n" +
				"  }\n" +
				"}"
			},
			getExternalResourcePath("externalLib.abc"));
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "");
		refreshExternalArchives(p);
		waitUntilIndexesReady();

		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaProject[] {getJavaProject("P")});
		search("foo", METHOD, DECLARATIONS, scope);
		assertSearchResults(
			getExternalPath() + "externalLib.abc void p.X.foo()",
			this.resultCollector);
	} finally {
		deleteExternalResource("externalLib.abc");
		deleteProject("P");
	}
}

/*
 * Ensures that search all type names returns the types in an external ZIP archive
 */
public void testZIPArchive2() throws Exception {
	try {
		IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, "");
		createJar(
			new String[] {
				"p/ExternalType.java",
				"package p;\n" +
				"public class ExternalType {\n" +
				"}"
			},
			getExternalResourcePath("externalLib.abc"));
		refreshExternalArchives(p);
		waitUntilIndexesReady();

		TypeNameMatchCollector collector = new TypeNameMatchCollector();
		new SearchEngine(this.workingCopies).searchAllTypeNames(
			null,
			SearchPattern.R_EXACT_MATCH,
			"ExternalType".toCharArray(),
			SearchPattern.R_EXACT_MATCH,
			TYPE,
			SearchEngine.createJavaSearchScope(new IJavaProject[] {getJavaProject("P")}),
			collector,
			IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
			null
		);
		assertSearchResults(
			"ExternalType (not open) [in ExternalType.class [in p [in "+ getExternalPath() + "externalLib.abc]]]",
			collector
		);
	} finally {
		deleteExternalResource("externalLib.abc");
		deleteProject("P");
	}

}

/**
 * Simple field declaration test.
 */
public void testFieldDeclaration01() throws CoreException { // was testSimpleFieldDeclaration
	IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
	IField field = type.getField("x");
	search(
		field,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p/A.java p.A.x [x]",
		this.resultCollector);
}
/**
 * Field declaration in jar file test.
 */
public void testFieldDeclaration02() throws CoreException { // was testFieldDeclarationInJar
	IType type = getClassFile("JavaSearch", "MyJar.jar", "p1", "A.class").getType();
	IField field = type.getField("field");
	search(
		field,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"MyJar.jar p1.A.field [No source]",
		this.resultCollector);
}


/**
 * Field declaration with array type test.
 * (regression test for PR 1GKEG73: ITPJCORE:WIN2000 - search (136): missing field declaration)
 */
public void testFieldDeclaration03() throws CoreException { // was testFieldDeclarationArrayType
	IType type = getCompilationUnit("JavaSearch", "src", "", "B.java").getType("B");
	IField field = type.getField("open");
	search(
		field,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/B.java B.open [open]",
		this.resultCollector);
}
/**
 * Field declaration with wild card test.
 * (regression test for bug 21763 Problem in Java search [search]  )
 */
public void testFieldDeclaration04() throws CoreException { // was testFieldDeclarationWithWildCard
	search(
		"class*path",
		FIELD,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/c5/Test.java c5.Test.class_path [class_path]",
		this.resultCollector);
}
/**
 * Field reference test.
 * (regression test for bug #3433 search: missing field occurrecnces (1GKZ8J6))
 */
public void testFieldReference01() throws CoreException { // was testFieldReference
	IType type = getCompilationUnit("JavaSearch", "src", "p8", "A.java").getType("A");
	IField field = type.getField("g");
	search(
		field,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p8/A.java void p8.A.m() [g]\n" +
		"src/p8/A.java void p8.B.m() [g]",
		this.resultCollector);
}
/**
 * Field reference test.
 * (regression test for PR 1GK8TXE: ITPJCORE:WIN2000 - search: missing field reference)
 */
public void testFieldReference02() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "p9", "X.java").getType("X");
	IField field = type.getField("f");
	search(
		field,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p9/X.java void p9.X.m() [f]",
		this.resultCollector);
}
/**
 * Field reference test.
 * (regression test for bug 5821 Refactor > Rename renames local variable instead of member in case of name clash  )
 */
public void testFieldReference03() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "q8", "EclipseTest.java").getType("EclipseTest");
	IField field = type.getField("test");
	this.resultCollector.showPotential(false);
	search(field, REFERENCES, getJavaSearchScope());
	assertSearchResults(
		"src/q8/EclipseTest.java void q8.EclipseTest.main(String[]) [test]"
	);
}
/**
 * Field reference test.
 * (regression test for bug 5923 Search for "length" field refs finds [].length)
 */
public void testFieldReference04() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "a2", "X.java").getType("X");
	IField field = type.getField("length");
	search(
		field,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/a2/X.java void a2.X.foo() [length]",
		this.resultCollector);
}
/**
 * Field reference test.
 * (regression test for bug 7987 Field reference search should do lookup in 1.4 mode)
 */
public void testFieldReference05() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "b1", "A.java").getType("A");
	IField field = type.getField("x");

	// Set 1.4 compliance level (no constant yet)
	Hashtable options = JavaCore.getOptions();
	String currentOption = (String)options.get("org.eclipse.jdt.core.compiler.compliance");
	options.put("org.eclipse.jdt.core.compiler.compliance", "1.4");
	JavaCore.setOptions(options);

	try {
		search(
			field,
			REFERENCES,
			getJavaSearchScope(),
			this.resultCollector);
		assertSearchResults(
			"src/b1/B.java void b1.B.foo() [x]",
			this.resultCollector);
	} finally {
		// Restore compliance level
		options.put("org.eclipse.jdt.core.compiler.compliance", currentOption);
		JavaCore.setOptions(options);
	}
}
/**
 * Field reference test.
 * (regression test for bug 20693 Finding references to variables does not find all occurances)
 */
public void testFieldReference06() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "c4", "X.java").getType("X");
	IField field = type.getField("x");
	search(
		field,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/c4/X.java int c4.X.foo() [x]",
		this.resultCollector);
}
/**
 * Field reference test.
 * (regression test for bug 61017 Refactoring - test case that results in uncompilable source)
 */
public void testFieldReference07() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "s5", "A.java").getType("A");
	IField field = type.getField("b");
	search(
		field,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/s5/A.java void s5.A.method() [b]",
		this.resultCollector);
}
/**
 * Simple field reference test.
 */
public void testFieldReference08() throws CoreException { // was testSimpleFieldReference
	IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
	IField field = type.getField("x");
	search(
		field,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/Test.java void Test.main(String[]) [x]\n" +
		"src/p/A.java p.A(X) [x]",
		this.resultCollector);
}
/**
 * Simple field read access reference test.
 */
public void testFieldReference09() throws CoreException { // was testSimpleReadFieldReference
	IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
	IField field = type.getField("x");
	search(
		field,
		READ_ACCESSES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/Test.java void Test.main(String[]) [x]",
		this.resultCollector);
}
/**
 * Simple write field access reference test.
 */
public void testFieldReference10() throws CoreException { // was testSimpleWriteFieldReference
	IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
	IField field = type.getField("x");
	search(
		field,
		WRITE_ACCESSES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p/A.java p.A(X) [x]",
		this.resultCollector);
}
/**
 * Multiple field references in one ast test.
 * (regression test for PR 1GD79XM: ITPJCORE:WINNT - Search - search for field references - not all found)
 */
public void testFieldReference11() throws CoreException { // was testMultipleFieldReference
	IType type = getCompilationUnit("JavaSearch", "src", "p5", "A.java").getType("A");
	IField field = type.getField("x");
	search(
		field,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p5/A.java void p5.A.k() [x]\n" +
		"src/p5/A.java void p5.A.k() [x]\n" +
		"src/p5/A.java void p5.A.k() [x]",
		this.resultCollector);
}
/**
 * Static field reference test.
 * (regression test for PR #1G2P5EP)
 */
public void testFieldReference12() throws CoreException { // was testStaticFieldReference
	IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
	IField field = type.getField("DEBUG");
	search(
		field,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p/A.java void p.A.foo() [DEBUG]",
		this.resultCollector);
}
/**
 * Field reference in inner class test.
 * (regression test for PR 1GL11J6: ITPJCORE:WIN2000 - search: missing field references (nested types))
 */
public void testFieldReference13() throws CoreException { // was testFieldReferenceInInnerClass
	IType type = getCompilationUnit("JavaSearch", "src", "", "O.java").getType("O");
	IField field = type.getField("y");
	search(
		field,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/O.java void O$I.y() [y]",
		this.resultCollector);
}
/**
 * Field reference in anonymous class test.
 * (regression test for PR 1GL12XE: ITPJCORE:WIN2000 - search: missing field references in inner class)
 */
public void testFieldReference14() throws CoreException { // was testFieldReferenceInAnonymousClass
	IType type = getCompilationUnit("JavaSearch", "src", "", "D.java").getType("D");
	IField field = type.getField("h");
	search(
		field,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/D.java void void D.g():<anonymous>#1.run() [h]",
		this.resultCollector);
}
/**
 * Field reference through subclass test.
 * (regression test for PR 1GKB9YH: ITPJCORE:WIN2000 - search for field refs - incorrect results)
 */
public void testFieldReference15() throws CoreException { // was testFieldReferenceThroughSubclass
	IType type = getCompilationUnit("JavaSearch", "src", "p6", "A.java").getType("A");
	IField field = type.getField("f");
	search(
		field,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p6/A.java void p6.A.m() [f]\n" +
		"src/p6/A.java void p6.B.m() [f]\n" +
		"src/p6/A.java void p6.B.m() [f]",
		this.resultCollector);

	type = getCompilationUnit("JavaSearch", "src", "p6", "A.java").getType("AA");
	field = type.getField("f");
	this.resultCollector = new JavaSearchResultCollector();
	search(
		field,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p6/A.java void p6.B.m() [f]",
		this.resultCollector);

}
/**
 * Read and write access reference in compound expression test.
 * (regression test for bug 6158 Search - Prefix and postfix expression not found as write reference)
 */
public void testFieldReference16() throws CoreException { // was testReadWriteFieldReferenceInCompoundExpression
	IType type = getCompilationUnit("JavaSearch", "src", "a4", "X.java").getType("X");
	IField field = type.getField("field");

	// Read reference
	search(
		field,
		READ_ACCESSES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/a4/X.java void a4.X.foo() [field]",
		this.resultCollector);

	// Write reference
	this.resultCollector = new JavaSearchResultCollector();
	search(
		field,
		WRITE_ACCESSES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/a4/X.java void a4.X.foo() [field]",
		this.resultCollector);
}
/**
 * Write access reference in a qualified name reference test.
 * (regression test for bug 7344 Search - write acces give wrong result)
 */
public void testFieldReference17() throws CoreException { // was testReadWriteAccessInQualifiedNameReference
	IType type = getCompilationUnit("JavaSearch", "src", "a8", "A.java").getType("A");
	IField field = type.getField("a");
	search(
		field,
		WRITE_ACCESSES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"",
		this.resultCollector);
}
/**
 * Field reference in brackets test.
 * (regression test for bug 23329 search: incorrect range for type references in brackets)
 */
public void testFieldReference18() throws CoreException { // was testFieldReferenceInBrackets
	IType type = getCompilationUnit("JavaSearch", "src", "s3", "A.java").getType("A");
	IField field = type.getField("field");
	search(
		field,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/s3/A.java int s3.A.bar() [field]",
		this.resultCollector);
}

/**
 * Accurate field reference test.
 */
public void testFieldReference19() throws CoreException { // was testAccurateFieldReference1
	search(
		"d6.X.CONSTANT",
		FIELD,
		REFERENCES,
		SearchEngine.createJavaSearchScope(new IJavaElement[] {
			getPackageFragment("JavaSearch", "src", "d6")
		}),
		this.resultCollector);
	assertSearchResults(
		"src/d6/Y.java d6.Y.T [CONSTANT]",
		this.resultCollector);
}
/**
 * Field reference inside/outside doc comment.
 */
public void testFieldReference20() throws CoreException { // was testFieldReferenceInOutDocComment
	IType type = getCompilationUnit("JavaSearch", "src", "s4", "X.java").getType("X");
	IField field = type.getField("x");
	this.resultCollector.showInsideDoc();
	search(field, REFERENCES, getJavaSearchScope(), this.resultCollector);
	assertSearchResults(
		"src/s4/X.java int s4.X.foo() [x] OUTSIDE_JAVADOC\n" +
		"src/s4/X.java void s4.X.bar() [x] INSIDE_JAVADOC",
		this.resultCollector);
}
/**
 * Interface implementors test.
 */
public void testInterfaceImplementors1() throws CoreException { // was testInterfaceImplementors
	// implementors of an interface
	IType type = getCompilationUnit("JavaSearch", "src", "p", "I.java").getType("I");
	search(
		type,
		IMPLEMENTORS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/InterfaceImplementors.java InterfaceImplementors [p.I]\n" +
		"src/p/X.java p.X [I]",
		this.resultCollector);

	/**
	 * Implementors of a class should now give a match
	 * Bug 1G5HBQA: "ITPJUI:WINNT - Search - search for implementors of a class finds subclasses" is cancelled
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=124645"
	 */
	type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
	this.resultCollector = new JavaSearchResultCollector();
	search(
		type,
		IMPLEMENTORS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p/Y.java p.Y [X]",
		this.resultCollector);
}
/**
 * Interface implementors test.
 * (regression test for bug 22102 Not all implementors found for IPartListener)
 */
public void testInterfaceImplementors2() throws CoreException {
	// implementors of an interface
	IType type = getCompilationUnit("JavaSearch", "src", "r2", "I.java").getType("I");
	search(
		type,
		IMPLEMENTORS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/r2/X.java r2.X.field:<anonymous>#1 [I]",
		this.resultCollector);
}
/*
 * Local variable declaration test.
 * (SingleNameReference)
 */
public void testLocalVariableDeclaration1() throws CoreException {
	ILocalVariable localVar = getLocalVariable("/JavaSearch/src/f1/X.java", "var1 = 1;", "var1");
	search(
		localVar,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/f1/X.java void f1.X.foo1().var1 [var1]",
		this.resultCollector);
}
/*
 * Local variable declaration test.
 * (QualifiedNameReference)
 */
public void testLocalVariableDeclaration2() throws CoreException {
	ILocalVariable localVar = getLocalVariable("/JavaSearch/src/f1/X.java", "var2 = new X();", "var2");
	search(
		localVar,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/f1/X.java void f1.X.foo2().var2 [var2]",
		this.resultCollector);
}
/**
 * @bug 207257: [search] SearchEngine returns incorrectly typed SearchMatch when searching for local variable declarations
 * @test The accepted match should be a {@link LocalVariableDeclarationMatch}
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=207257"
 */
public void testLocalVariableDeclaration_Bug207257() throws CoreException {
	ILocalVariable localVar = getLocalVariable("/JavaSearch/src/f1/X.java", "var1 = 1;", "var1");
	search(
		localVar,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertEquals("Invalid Search Match class", LocalVariableDeclarationMatch.class, this.resultCollector.match.getClass());
}
/*
 * Local variable occurrences test.
 * (SingleNameReference)
 */
public void testLocalVariableOccurrences1() throws CoreException {
	ILocalVariable localVar = getLocalVariable("/JavaSearch/src/f1/X.java", "var1 = 1;", "var1");
	search(
		localVar,
		ALL_OCCURRENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/f1/X.java void f1.X.foo1().var1 [var1]\n" +
		"src/f1/X.java void f1.X.foo1() [var1]",
		this.resultCollector);
}
/*
 * Local variable occurences test.
 * (QualifiedNameReference)
 */
public void testLocalVariableOccurrences2() throws CoreException {
	ILocalVariable localVar = getLocalVariable("/JavaSearch/src/f1/X.java", "var2 = new X();", "var2");
	search(
		localVar,
		ALL_OCCURRENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/f1/X.java void f1.X.foo2().var2 [var2]\n" +
		"src/f1/X.java void f1.X.foo2() [var2]",
		this.resultCollector);
}
/*
 * Local variable reference test.
 * (SingleNameReference)
 */
public void testLocalVariableReference1() throws CoreException {
	ILocalVariable localVar = getLocalVariable("/JavaSearch/src/f1/X.java", "var1 = 1;", "var1");
	search(
		localVar,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/f1/X.java void f1.X.foo1() [var1]",
		this.resultCollector);
}
/*
 * Local variable reference test.
 * (QualifiedNameReference)
 */
public void testLocalVariableReference2() throws CoreException {
	ILocalVariable localVar = getLocalVariable("/JavaSearch/src/f1/X.java", "var2 = new X();", "var2");
	search(
		localVar,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/f1/X.java void f1.X.foo2() [var2]",
		this.resultCollector);
}
/*
 * Local variable reference test.
 * (regression test for bug 48725 Cannot search for local vars in jars.)
 */
public void testLocalVariableReference3() throws CoreException {
    IClassFile classFile = getClassFile("JavaSearch", "test48725.jar", "p48725", "X.class");
	ILocalVariable localVar = (ILocalVariable) codeSelect(classFile, "local = 1;", "local")[0];
	search(
		localVar,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"test48725.jar int p48725.<anonymous>.bar()",
		this.resultCollector);
}
/**
 * Simple method declaration test.
 */
public void testMethodDeclaration01() throws CoreException { // was testSimpleMethodDeclaration
	IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
	IMethod method = type.getMethod("foo", new String[] {"I", "QString;", "QX;"});

	search(
		method,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p/X.java void p.X.foo(int, String, X) [foo]\n" +
		"src/p/Z.java void p.Z.foo(int, String, X) [foo]",
		this.resultCollector);
}
/**
 * Method declaration test.
 * (regression test for bug 38568 Search for method declarations fooled by array types)
 */
public void testMethodDeclaration02() throws CoreException { // was testMethodDeclaration
	IType type = getCompilationUnit("JavaSearch", "src", "e2", "X.java").getType("X");

	search(
		"foo(String, String)",
		METHOD,
		DECLARATIONS,
		SearchEngine.createJavaSearchScope(new IJavaElement[] {type}),
		this.resultCollector);
	assertSearchResults(
		"src/e2/X.java void e2.X.foo(String, String) [foo]",
		this.resultCollector);
}


/**
 * Inner method declaration test.
 */
public void testMethodDeclaration03() throws CoreException { // was testInnerMethodDeclaration
	IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X").getType("Inner");
	IMethod method = type.getMethod("foo", new String[] {});

	search(
		method,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p/X.java String p.X$Inner.foo() [foo]",
		this.resultCollector);
}
/**
 * Method declaration in hierarchy test.
 */
public void testMethodDeclaration04() throws CoreException { // was testMethodDeclarationInHierarchyScope1
	IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");

	search(
		"foo",
		METHOD,
		DECLARATIONS,
		SearchEngine.createHierarchyScope(type),
		this.resultCollector);
	assertSearchResults(
		"src/p/X.java void p.X.foo(int, String, X) [foo]\n" +
		"src/p/X.java String p.X$Inner.foo() [foo]\n" +
		"src/p/Z.java void p.Z.foo(int, String, X) [foo]",
		this.resultCollector);
}
/**
 * Method declaration in hierarchy that contains elements in external jar.
 * (regression test for PR #1G2E4F1)
 */
public void testMethodDeclaration05() throws CoreException { // was testMethodDeclarationInHierarchyScope2
	IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
	IMethod method = type.getMethod("foo", new String[] {"I", "QString;", "QX;"});

	search(
		method,
		DECLARATIONS,
		SearchEngine.createHierarchyScope(type),
		this.resultCollector);
	assertSearchResults(
		"src/p/X.java void p.X.foo(int, String, X) [foo]\n" +
		"src/p/Z.java void p.Z.foo(int, String, X) [foo]",
		this.resultCollector);
}
/**
 * Method declaration in hierarchy on a secondary type.
 */
public void testMethodDeclaration06() throws CoreException { // was testMethodDeclarationInHierarchyScope3
	IType type = getCompilationUnit("JavaSearch", "src", "d3", "A.java").getType("B");
	IMethod method = type.getMethod("foo", new String[] {});

	search(
		method,
		DECLARATIONS,
		SearchEngine.createHierarchyScope(type),
		this.resultCollector);
	assertSearchResults(
		"src/d3/A.java void d3.B.foo() [foo]",
		this.resultCollector);
}
/**
 * Method declaration in package test.
 * (regression tets for PR #1G2KA97)
 */
public void testMethodDeclaration07() throws CoreException { // was testMethodDeclarationInPackageScope
	IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type.getPackageFragment()});

	search(
		"main(String[])",
		METHOD,
		DECLARATIONS,
		scope,
		this.resultCollector);
	assertSearchResults(
		"src/p/A.java void p.A.main(String[]) [main]",
		this.resultCollector);
}
/**
 * Method declaration in jar file test.
 */
public void testMethodDeclaration08() throws CoreException { // was testMethodDeclarationInJar
	IType type = getClassFile("JavaSearch", "MyJar.jar", "p1", "A.class").getType();
	IMethod method = type.getMethod("foo", new String[] {"Ljava.lang.String;"});

	search(
		method,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"MyJar.jar boolean p1.A.foo(java.lang.String) [No source]",
		this.resultCollector);
}
/**
 * Method declaration in field initialzer.
 * (regression test for bug 24346 Method declaration not found in field initializer  )
 */
public void testMethodDeclaration09() throws CoreException { // was testMethodDeclarationInInitializer

	search(
		"foo24346",
		METHOD,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/c6/X.java void c6.X.x:<anonymous>#1.foo24346() [foo24346]",
		this.resultCollector);
}
/*
 * Method declaration with a missing return type.
 * (regression test for bug 43080 NPE when searching in CU with incomplete method declaration)
 */
public void testMethodDeclaration10() throws CoreException { // was testMethodDeclarationNoReturnType
	IType type = getCompilationUnit("JavaSearch", "src", "e8", "A.java").getType("A");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type.getPackageFragment()});

	search(
		"m() int",
		METHOD,
		DECLARATIONS,
		scope,
		this.resultCollector);
	assertSearchResults(
		"src/e8/A.java void e8.A.m() [m]",
		this.resultCollector);
}
/**
 * Method declaration with source folder as java search scope.
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=92210"
 */
public void testMethodDeclaration11() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch", "otherSrc()", "", "X92210.java");
	assertNotNull("Should have found an unit", unit);
	IJavaElement root = unit.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
	assertNotNull("Should have found package fragment root", root);
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {root});

	search(
		"foo",
		METHOD,
		DECLARATIONS,
		scope,
		this.resultCollector);
	assertSearchResults(
		"otherSrc()/X92210.java void X92210.foo() [foo]",
		this.resultCollector);
}
/**
 * Method reference test.
 * (regression test for bug 5068 search: missing method reference)
 */
public void testMethodReference01() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "q5", "AQ.java").getType("I");
	IMethod method = type.getMethod("k", new String[] {});

	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/q5/AQ.java void q5.T.m() [k()]",
		this.resultCollector);
}
/**
 * Method reference test.
 * (regression test for bug 5069 search: method reference in super missing)
 */
public void testMethodReference02() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "q6", "CD.java").getType("AQ");
	IMethod method = type.getMethod("k", new String[] {});

	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/q6/CD.java void q6.AQE.k() [k()]",
		this.resultCollector);
}
/**
 * Method reference test.
 * (regression test for bug 5070 search: missing interface method reference  )
 */
public void testMethodReference03() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "q7", "AQ.java").getType("I");
	IMethod method = type.getMethod("k", new String[] {});

	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/q7/AQ.java void q7.D.h() [k()]",
		this.resultCollector);
}
/**
 * Method reference test.
 * (regression test for bug 8928 Unable to find references or declarations of methods that use static inner classes in the signature)
 */
public void testMethodReference04() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "b2", "Y.java").getType("Y");
	IMethod method = type.getMethod("foo", new String[] {"QX.Inner;"});

	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/b2/Z.java void b2.Z.bar() [foo(inner)]",
		this.resultCollector);
}
/**
 * Method reference test.
 * (regression test for bug 49120 search doesn't find references to anonymous inner methods)
 */
public void testMethodReference05() throws CoreException {
	IType type = getCompilationUnit("JavaSearch/src/e9/A.java").getType("A").getMethod("foo", new String[] {}).getType("", 1);
	IMethod method = type.getMethod("bar", new String[] {});

	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/e9/A.java void e9.A.foo() [bar()]",
		this.resultCollector);
}
/*
 * Method reference in second anonymous and second local type of a method test.
 */
public void testMethodReference06() throws CoreException {
	IMethod method= getCompilationUnit("JavaSearch/src/f3/X.java").getType("X").getMethod("bar", new String[] {});

	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/f3/X.java void void f3.X.foo():<anonymous>#2.foobar() [bar()]\n" +
		"src/f3/X.java void void f3.X.foo():Y#2.foobar() [bar()]",
		this.resultCollector);
}
/**
 * Simple method reference test.
 */
public void testMethodReference07() throws CoreException { // was testSimpleMethodReference
	IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
	IMethod method = type.getMethod("foo", new String[] {"I", "QString;", "QX;"});

	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/Test.java void Test.main(String[]) [foo(1, \"a\", y)]\n" +
		// since bug 160301 fix, subclass overridden method calls are not reported
		//"src/Test.java void Test.main(String[]) [foo(1, \"a\", z)]\n" +
		"src/p/Z.java void p.Z.foo(int, String, X) [foo(i, s, new Y(true))]",
		this.resultCollector);
}
/**
 * Static method reference test.
 */
public void testMethodReference08() throws CoreException { // was testStaticMethodReference1
	IType type = getCompilationUnit("JavaSearch", "src", "p", "Y.java").getType("Y");
	IMethod method = type.getMethod("bar", new String[] {});

	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/Test.java void Test.main(String[]) [bar()]",
		this.resultCollector);
}
/**
 * Static method reference test.
 */
public void testMethodReference09() throws CoreException { // was testStaticMethodReference2
	IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
	IMethod method = type.getMethod("bar", new String[] {});

	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"",
		this.resultCollector);
}
/**
 * Inner method reference test.
 */
public void testMethodReference10() throws CoreException { // was testInnerMethodReference
	IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X").getType("Inner");
	IMethod method = type.getMethod("foo", new String[] {});

	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p/A.java void p.A.foo(int, String, X) [foo()]",
		this.resultCollector);
}
/**
 * Method reference through super test.
 */
public void testMethodReference11() throws CoreException { // was testMethodReferenceThroughSuper
	IType type = getCompilationUnit("JavaSearch", "src", "sd", "AQ.java").getType("AQ");
	IMethod method = type.getMethod("k", new String[] {});

	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/sd/AQ.java void sd.AQE.k() [k()]",
		this.resultCollector);
}
/**
 * Method reference in inner class test.
 */
public void testMethodReference12() throws CoreException { // was testMethodReferenceInInnerClass
	IType type = getCompilationUnit("JavaSearch", "src", "", "CA.java").getType("CA");
	IMethod method = type.getMethod("m", new String[] {});

	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/CA.java void CA$CB.f() [m()]\n" +
		"src/CA.java void CA$CB$CC.f() [m()]",
		this.resultCollector);
}
/**
 * Method reference in anonymous class test.
 * (regression test for PR 1GGNOTF: ITPJCORE:WINNT - Search doesn't find method referenced in anonymous inner class)
 */
public void testMethodReference13() throws CoreException { // was testMethodReferenceInAnonymousClass
	IType type = getCompilationUnit("JavaSearch", "src", "", "PR_1GGNOTF.java").getType("PR_1GGNOTF");
	IMethod method = type.getMethod("method", new String[] {});

	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/PR_1GGNOTF.java void void PR_1GGNOTF.method2():<anonymous>#1.run() [method()]",
		this.resultCollector);
}
/**
 * Method reference through array test.
 * (regression test for 1GHDA2V: ITPJCORE:WINNT - ClassCastException when doing a search)
 */
public void testMethodReference14() throws CoreException { // was testMethodReferenceThroughArray
	IType type = getClassFile("JavaSearch", getExternalJCLPathString(), "java.lang", "Object.class").getType();
	IMethod method = type.getMethod("clone", new String[] {});

	search(
		method,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/E.java Object E.foo() [clone()]",
		this.resultCollector);
}
/**
 * Method reference inside/outside doc comment.
 */
public void testMethodReference15() throws CoreException { // was testMethodReferenceInOutDocComment
	IType type = getCompilationUnit("JavaSearch", "src", "s4", "X.java").getType("X");
	IMethod method = type.getMethod("foo", new String[] {});
	this.resultCollector.showInsideDoc();
	search(method, REFERENCES, getJavaSearchScope(), this.resultCollector);
	assertSearchResults(
		"src/s4/X.java void s4.X.bar() [foo()] INSIDE_JAVADOC\n" +
		"src/s4/X.java void s4.X.fred() [foo()] OUTSIDE_JAVADOC",
		this.resultCollector);
}
/*
 * Generic method reference.
 */
public void testMethodReference16() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15/src/p2/X.java").getType("X");
	IMethod method = type.getMethod("foo", new String[] {"QE;"});
	search(method, REFERENCES, ERASURE_RULE, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/p2/Y.java void p2.Y.bar() [foo(this)]",
		this.resultCollector);
}
/**
 * Bug 111416: [search] wrong potential matches on a static method open
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=111416"
 */
public void testMethodReference17() throws CoreException {
	IType type = getCompilationUnit("JavaSearch/src/b111416/X.java").getType("X");
	IMethod method = type.getMethod("open", new String[] {"QString;"});
	this.resultCollector.showAccuracy(true);
	search(method, REFERENCES, ERASURE_RULE, getJavaSearchScope(), this.resultCollector);
	assertSearchResults(
		"src/b111416/X.java void b111416.X.foo() [open(\"\")] EXACT_MATCH",
		this.resultCollector);
}
/**
 * OrPattern test.
 * (regression test for bug 5862 search : too many matches on search with OrPattern)
 */
public void testOrPattern() throws CoreException {
	IMethod leftMethod = getCompilationUnit("JavaSearch", "src", "q9", "I.java")
		.getType("I").getMethod("m", new String[] {});
	SearchPattern leftPattern = createPattern(leftMethod, ALL_OCCURRENCES);
	IMethod rightMethod = getCompilationUnit("JavaSearch", "src", "q9", "I.java")
		.getType("A1").getMethod("m", new String[] {});
	SearchPattern rightPattern = createPattern(rightMethod, ALL_OCCURRENCES);
	SearchPattern orPattern = SearchPattern.createOrPattern(leftPattern, rightPattern);
	this.resultCollector.showAccuracy(true);
	search(
		orPattern,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/e8/A.java void e8.A.m() [m] POTENTIAL_MATCH\n" +
		"src/q9/I.java void q9.I.m() [m] EXACT_MATCH\n" +
		"src/q9/I.java void q9.A1.m() [m] EXACT_MATCH",
		this.resultCollector);
}
/**
 * Simple package declaration test.
 */
public void testPackageDeclaration1() throws CoreException { // was testSimplePackageDeclaration
	IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "p");
	search(
		pkg,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p p",
		this.resultCollector);
}

/**
 * Various package declarations test.
 */
public void testPackageDeclaration2() throws CoreException { // was testVariousPackageDeclarations
	JavaSearchResultCollector packageCollector = new JavaSearchResultCollector(true);
	search(
		"p3*",
		PACKAGE,
		DECLARATIONS,
		getJavaSearchScope(),
		packageCollector);
	assertSearchResults(
		"src/p3 p3\n" +
		"src/p3/p2 p3.p2\n" +
		"src/p3/p2/p p3.p2.p",
		packageCollector);
}
/**
 * Package declaration test.
 * (regression test for bug 62698 NPE while searching for declaration of binary package)
 */
public void testPackageDeclaration3() throws CoreException { // was testPackageDeclaration
	IPackageFragment pkg = getPackageFragment("JavaSearch", getExternalJCLPathString(), "java.lang");

	search(
		pkg,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		getExternalJCLPath() + " java.lang",
		this.resultCollector);
}
/**
 * Package declaration with corrupt jar on the classpath test.
 * (regression test for bug 75561 Rename package results in I/O exception)
 */
public void testPackageDeclaration4() throws CoreException {
	IJavaProject project = getJavaProject("JavaSearch");
	IClasspathEntry[] originalCP = project.getRawClasspath();
	try {
		// add corrupt.jar to classpath
		int cpLength = originalCP.length;
		IClasspathEntry[] newCP = new IClasspathEntry[cpLength+1];
		System.arraycopy(originalCP, 0, newCP, 0, cpLength);
		newCP[cpLength] = JavaCore.newLibraryEntry(new Path("/JavaSearch/corrupt.jar"), null, null);
		project.setRawClasspath(newCP, null);
		search("r9",
			PACKAGE,
			DECLARATIONS,
			getJavaSearchScope(),
			this.resultCollector);
		assertSearchResults(
			"src/r9 r9",
			this.resultCollector);
	} finally {
		project.setRawClasspath(originalCP, null);
	}
}
/**
 * Bug 73551: NPE while searching package declaration
 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=73551"
 */
public void testPackageDeclarationBug73551() throws CoreException {
	JavaSearchResultCollector result = new JavaSearchResultCollector();
	result.showAccuracy(true);
	IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "p71267", "Test.java").getPackageDeclaration("p71267");
	search(packDecl, DECLARATIONS, getJavaSearchScope(),  result);
	assertSearchResults(
		"src/p71267/Test.java p71267 [No source] EXACT_MATCH",
		result);
}
/**
 * Bug 117020: [search] Search for '*' does not report empty packages
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=117020"
 */
public void testPackageDeclarationBug117020() throws CoreException {
	IFolder srcFolder = getFolder(new Path("/JavaSearch/src"));
	IPackageFragmentRoot srcRoot = JAVA_PROJECT.getPackageFragmentRoot(srcFolder);
	IPackageFragment test = null;
	try {
		test = srcRoot.createPackageFragment("b117020", true, null);
		JavaSearchResultCollector result = new JavaSearchResultCollector();
		result.showAccuracy(true);
		search(test, DECLARATIONS, getJavaSearchScope(),  result);
		assertSearchResults(
			"src/b117020 b117020 EXACT_MATCH",
			result);
	}
	catch (JavaModelException jme) {
		// give up
	}
	finally {
		if (test != null && test.exists()) {
			test.delete(true, null);
		}
	}
}
public void testPackageDeclarationBug183062a() throws CoreException {
	JavaSearchResultCollector packageCollector = new JavaSearchResultCollector(true);
	search("j?",
		PACKAGE,
		DECLARATIONS,
		getJavaSearchScope(),
		packageCollector);
	assertSearchResults(
		"src/j1 j1\n" +
		"src/j2 j2\n" +
		"src/j3 j3\n" +
		"src/j4 j4\n" +
		"src/j5 j5\n" +
		"src/j6 j6\n" +
		"src/j7 j7\n" +
		"test47909.jar j3 [No source]",
		packageCollector);
}
public void testPackageDeclarationBug183062b() throws CoreException {
	JavaSearchResultCollector packageCollector = new JavaSearchResultCollector(true);
	search("j*",
		PACKAGE,
		DECLARATIONS,
		getJavaSearchScope(),
		packageCollector);
	assertSearchResults(
		""+ getExternalJCLPathString() + " java\n" +
		""+ getExternalJCLPathString() + " java.io\n" +
		""+ getExternalJCLPathString() + " java.lang\n" +
		"src/j1 j1\n" +
		"src/j2 j2\n" +
		"src/j3 j3\n" +
		"src/j4 j4\n" +
		"src/j5 j5\n" +
		"src/j6 j6\n" +
		"src/j7 j7\n" +
		"src/j7/qua j7.qua\n" +
		"src/j7/qua/li j7.qua.li\n" +
		"src/j7/qua/li/fied j7.qua.li.fied\n" +
		"test47909.jar j3 [No source]",
		packageCollector);
}
public void testPackageDeclarationBug183062c() throws CoreException {
	JavaSearchResultCollector packageCollector = new JavaSearchResultCollector(true);
	search("j7.*",
		PACKAGE,
		DECLARATIONS,
		getJavaSearchScope(),
		packageCollector);
	assertSearchResults(
		"src/j7/qua j7.qua\n" +
		"src/j7/qua/li j7.qua.li\n" +
		"src/j7/qua/li/fied j7.qua.li.fied",
		packageCollector);
}
public void testPackageDeclarationBug183062d() throws CoreException {
	JavaSearchResultCollector packageCollector = new JavaSearchResultCollector(true);
	search("j7.*.*",
		PACKAGE,
		DECLARATIONS,
		getJavaSearchScope(),
		packageCollector);
	assertSearchResults(
		"src/j7/qua/li j7.qua.li\n" +
		"src/j7/qua/li/fied j7.qua.li.fied",
		packageCollector);
}
public void testPackageDeclarationBug183062e() throws CoreException {
	JavaSearchResultCollector packageCollector = new JavaSearchResultCollector(true);
	search("????.????",
		PACKAGE,
		DECLARATIONS,
		getJavaSearchScope(),
		packageCollector);
	assertSearchResults(
		""+ getExternalJCLPathString() + " java.lang",
		packageCollector);
}
/**
 * Package reference test.
 * (regression test for PR 1GK90H4: ITPJCORE:WIN2000 - search: missing package reference)
 */
public void testPackageReference1() throws CoreException {
	IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "q2");

	search(
		pkg,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/q1/B.java void q1.B.m(AA) [q2]",
		this.resultCollector);
}
/**
 * Package reference test.
 * (regression test for bug 17906 Rename package fails when inner classes are imported)
 */
public void testPackageReference2() throws CoreException {
	IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "b8");

	search(
		pkg,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/b9/Foo.java [b8]",
		this.resultCollector);
}
/**
 * Package reference in jar test.
 * (regression test for bug 47989 Exception when searching for IPackageFragment "java.util.zip")
 */
public void testPackageReference3() throws CoreException {
	IPackageFragment pkg = getPackageFragment("JavaSearch", "test47989.jar", "p1");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {pkg.getParent()});

	search(
		pkg,
		REFERENCES,
		scope,
		this.resultCollector);
	assertSearchResults(
		"test47989.jar java.lang.Object p2.Y.foo()",
		this.resultCollector);
}
/**
 * Simple package reference test.
 */
public void testPackageReference4() throws CoreException { // was testSimplePackageReference
	IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "p");

	search(
		pkg,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/InterfaceImplementors.java InterfaceImplementors [p]\n" +
		"src/Test.java void Test.main(String[]) [p]\n" +
		"src/Test.java void Test.main(String[]) [p]\n" +
		"src/Test.java void Test.main(String[]) [p]\n" +
		"src/Test.java void Test.main(String[]) [p]\n" +
		"src/Test.java void Test.main(String[]) [p]\n" +
		"src/Test.java void Test.main(String[]) [p]\n" +
		"src/Test.java void Test.main(String[]) [p]\n" +
		"src/TypeReferenceInImport/X.java [p]",
		this.resultCollector);
}
/**
 * Various package reference test.
 */
public void testPackageReference5() throws CoreException { // was testVariousPackageReference
	IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "p3.p2.p");

	search(
		pkg,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/PackageReference/A.java [p3.p2.p]\n" +
		"src/PackageReference/B.java [p3.p2.p]\n" +
		"src/PackageReference/C.java PackageReference.C [p3.p2.p]\n" +
		"src/PackageReference/D.java PackageReference.D.x [p3.p2.p]\n" +
		"src/PackageReference/E.java PackageReference.E.x [p3.p2.p]\n" +
		"src/PackageReference/F.java p3.p2.p.X PackageReference.F.foo() [p3.p2.p]\n" +
		"src/PackageReference/G.java void PackageReference.G.foo(p3.p2.p.X) [p3.p2.p]\n" +
		"src/PackageReference/H.java void PackageReference.H.foo() [p3.p2.p]\n" +
		"src/PackageReference/I.java void PackageReference.I.foo() [p3.p2.p]\n" +
		"src/PackageReference/J.java void PackageReference.J.foo() [p3.p2.p]",
		this.resultCollector);
}
/**
 * Regression test for 1GBK7B2: ITPJCORE:WINNT - package references: could be more precise
 */
public void testPackageReference6() throws CoreException { // was testAccuratePackageReference
	IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "p3.p2");

	search(
		pkg,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/PackageReference/K.java [p3.p2]",
		this.resultCollector);
}
/**
 * Test pattern match package references
 */
public void testPackageReference7() throws CoreException { // was testPatternMatchPackageReference

	search(
		"*p2.*",
		PACKAGE,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/PackageReference/A.java [p3.p2.p]\n" +
		"src/PackageReference/B.java [p3.p2.p]\n" +
		"src/PackageReference/C.java PackageReference.C [p3.p2.p]\n" +
		"src/PackageReference/D.java PackageReference.D.x [p3.p2.p]\n" +
		"src/PackageReference/E.java PackageReference.E.x [p3.p2.p]\n" +
		"src/PackageReference/F.java p3.p2.p.X PackageReference.F.foo() [p3.p2.p]\n" +
		"src/PackageReference/G.java void PackageReference.G.foo(p3.p2.p.X) [p3.p2.p]\n" +
		"src/PackageReference/H.java void PackageReference.H.foo() [p3.p2.p]\n" +
		"src/PackageReference/I.java void PackageReference.I.foo() [p3.p2.p]\n" +
		"src/PackageReference/J.java void PackageReference.J.foo() [p3.p2.p]",
		this.resultCollector);
}
/**
 * Test pattern match package references
 * Just verify that there's no ArrayOutOfBoundException to validate fix for
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=64421
 */
public void testPackageReference8() throws CoreException { // was testPatternMatchPackageReference2

	search(
		"*",
		PACKAGE,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	this.resultCollector.toString();
}
/**
 * Test that we find potential matches in binaries even if we can't resolve the entire
 * class file.
 * (Regression test for 1G4IN3E: ITPJCORE:WINNT - AbortCompilation using J9 to search for class declaration)
 */
public void testSearchFieldInBinaryWithResolution() throws CoreException {
	IClasspathEntry[] classpath = JAVA_PROJECT.getRawClasspath();
	try {
		// add AbortCompilation.jar to classpath
		int length = classpath.length;
		IClasspathEntry[] newClasspath = new IClasspathEntry[length+1];
		System.arraycopy(classpath, 0, newClasspath, 0, length);
		newClasspath[length] = JavaCore.newLibraryEntry(new Path("/JavaSearch/AbortCompilation.jar"), null, null);
		JAVA_PROJECT.setRawClasspath(newClasspath, null);

		// potential match for a field declaration
		this.resultCollector.showAccuracy(true);
		search("MissingFieldType.*", FIELD, DECLARATIONS,  getJavaSearchScope());
		assertSearchResults(
			"AbortCompilation.jar AbortCompilation.MissingFieldType.field [No source] EXACT_MATCH\n" +
			"AbortCompilation.jar AbortCompilation.MissingFieldType.missing [No source] EXACT_MATCH\n" +
			"AbortCompilation.jar AbortCompilation.MissingFieldType.otherField [No source] EXACT_MATCH"
		);
	} finally {
		// reset classpath
		JAVA_PROJECT.setRawClasspath(classpath, null);
	}
}
// bug 186333: Pattern which does not resolve should find all the matches exact
public void testSearchFieldInBinaryNoResolution() throws CoreException {
	IClasspathEntry[] classpath = JAVA_PROJECT.getRawClasspath();
	try {
		// add AbortCompilation.jar to classpath
		int length = classpath.length;
		IClasspathEntry[] newClasspath = new IClasspathEntry[length+1];
		System.arraycopy(classpath, 0, newClasspath, 0, length);
		newClasspath[length] = JavaCore.newLibraryEntry(new Path("/JavaSearch/AbortCompilation.jar"), null, null);
		JAVA_PROJECT.setRawClasspath(newClasspath, null);

		// exact match for a field declaration
		JavaSearchResultCollector collector = new JavaSearchResultCollector() {
			public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException {
	            IField field = (IField) searchMatch.getElement();
	            if (field.getDeclaringType().getElementName().equals("MissingFieldType")) {
		            super.acceptSearchMatch(searchMatch);
	            }
            }
		};
		collector.showAccuracy(true);
		search("*", FIELD, DECLARATIONS,  getJavaSearchScope(), collector);
		assertSearchResults(
			"AbortCompilation.jar AbortCompilation.MissingFieldType.field [No source] EXACT_MATCH\n" +
			"AbortCompilation.jar AbortCompilation.MissingFieldType.missing [No source] EXACT_MATCH\n" +
			"AbortCompilation.jar AbortCompilation.MissingFieldType.otherField [No source] EXACT_MATCH",
			collector
		);
	} finally {
		// reset classpath
		JAVA_PROJECT.setRawClasspath(classpath, null);
	}
}
/**
 * Test that we find potential matches in binaries even if we can't resolve the entire
 * class file.
 * (Regression test for 1G4IN3E: ITPJCORE:WINNT - AbortCompilation using J9 to search for class declaration)
 */
public void testSearchMethodInBinaryWithResolution() throws CoreException {
	IClasspathEntry[] classpath = JAVA_PROJECT.getRawClasspath();
	try {
		// add AbortCompilation.jar to classpath
		int length = classpath.length;
		IClasspathEntry[] newClasspath = new IClasspathEntry[length+1];
		System.arraycopy(classpath, 0, newClasspath, 0, length);
		newClasspath[length] = JavaCore.newLibraryEntry(new Path("/JavaSearch/AbortCompilation.jar"), null, null);
		JAVA_PROJECT.setRawClasspath(newClasspath, null);

		// potential match for a method declaration
		this.resultCollector.showAccuracy(true);
		search("MissingArgumentType.foo*", METHOD, DECLARATIONS, getJavaSearchScope());
		assertSearchResults(
			"AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo() [No source] EXACT_MATCH\n" +
			"AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo(java.util.EventListener) [No source] EXACT_MATCH\n" +
			"AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo2() [No source] EXACT_MATCH"
		);
	} finally {
		// reset classpath
		JAVA_PROJECT.setRawClasspath(classpath, null);
	}
}
// bug 186333: Pattern which does not resolve should find all the matches exact
public void testSearchMethodInBinaryNoResolution() throws CoreException {
	IClasspathEntry[] classpath = JAVA_PROJECT.getRawClasspath();
	try {
		// add AbortCompilation.jar to classpath
		int length = classpath.length;
		IClasspathEntry[] newClasspath = new IClasspathEntry[length+1];
		System.arraycopy(classpath, 0, newClasspath, 0, length);
		newClasspath[length] = JavaCore.newLibraryEntry(new Path("/JavaSearch/AbortCompilation.jar"), null, null);
		JAVA_PROJECT.setRawClasspath(newClasspath, null);

		// exact match for a method declaration
		JavaSearchResultCollector collector = new JavaSearchResultCollector() {
			public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException {
	            IMethod method = (IMethod) searchMatch.getElement();
	            if (method.getDeclaringType().getElementName().equals("MissingArgumentType")) {
		            super.acceptSearchMatch(searchMatch);
	            }
            }
		};
		collector.showAccuracy(true);
		search("*", METHOD, DECLARATIONS,  getJavaSearchScope(), collector);
		assertSearchResults(
			"AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo() [No source] EXACT_MATCH\n" +
			"AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo(java.util.EventListener) [No source] EXACT_MATCH\n" +
			"AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo2() [No source] EXACT_MATCH\n" +
			"AbortCompilation.jar AbortCompilation.MissingArgumentType() [No source] EXACT_MATCH",
			collector
		);
	} finally {
		// reset classpath
		JAVA_PROJECT.setRawClasspath(classpath, null);
	}
}
/**
 * Test that we find potential matches in binaries even if we can't resolve the entire
 * class file.
 * (Regression test for 1G4IN3E: ITPJCORE:WINNT - AbortCompilation using J9 to search for class declaration)
 */
public void testSearchTypesInBinaryWithResolution() throws CoreException {
	IClasspathEntry[] classpath = JAVA_PROJECT.getRawClasspath();
	try {
		// add AbortCompilation.jar to classpath
		int length = classpath.length;
		IClasspathEntry[] newClasspath = new IClasspathEntry[length+1];
		System.arraycopy(classpath, 0, newClasspath, 0, length);
		newClasspath[length] = JavaCore.newLibraryEntry(new Path("/JavaSearch/AbortCompilation.jar"), null, null);
		JAVA_PROJECT.setRawClasspath(newClasspath, null);

		// exact match for a type declaration
		this.resultCollector.showAccuracy(true);
		search("AbortCompilation.*Missing*", TYPE, DECLARATIONS,  getJavaSearchScope());
		assertSearchResults(
			"AbortCompilation.jar AbortCompilation.EnclosingType$MissingEnclosingType [No source] EXACT_MATCH\n" +
			"AbortCompilation.jar AbortCompilation.MissingArgumentType [No source] EXACT_MATCH\n" +
			"AbortCompilation.jar AbortCompilation.MissingFieldType [No source] EXACT_MATCH"
		);
	} finally {
		// reset classpath
		JAVA_PROJECT.setRawClasspath(classpath, null);
	}
}
public void testSearchTypeInBinaryNoResolution() throws CoreException {
	IClasspathEntry[] classpath = JAVA_PROJECT.getRawClasspath();
	try {
		// add AbortCompilation.jar to classpath
		int length = classpath.length;
		IClasspathEntry[] newClasspath = new IClasspathEntry[length+1];
		System.arraycopy(classpath, 0, newClasspath, 0, length);
		newClasspath[length] = JavaCore.newLibraryEntry(new Path("/JavaSearch/AbortCompilation.jar"), null, null);
		JAVA_PROJECT.setRawClasspath(newClasspath, null);

		// exact match for a type declaration
		this.resultCollector.showAccuracy(true);
		search("Missing*", TYPE, DECLARATIONS,  getJavaSearchScope());
		assertSearchResults(
			"AbortCompilation.jar AbortCompilation.EnclosingType$MissingEnclosingType [No source] EXACT_MATCH\n" +
			"AbortCompilation.jar AbortCompilation.MissingArgumentType [No source] EXACT_MATCH\n" +
			"AbortCompilation.jar AbortCompilation.MissingFieldType [No source] EXACT_MATCH"
		);
	} finally {
		// reset classpath
		JAVA_PROJECT.setRawClasspath(classpath, null);
	}
}
/**
 * Hierarchy scope test.
 * (regression test for bug 3445 search: type hierarchy scope incorrect (1GLC8VS))
 */
public void testSearchScope01() throws CoreException { // was testHierarchyScope
	ICompilationUnit cu = this. getCompilationUnit("JavaSearch", "src", "a9", "A.java");
	IType type = cu.getType("C");
	IJavaSearchScope scope = SearchEngine.createHierarchyScope(type);
	assertTrue("a9.C should be included in hierarchy scope", scope.encloses(type));
	assertTrue("a9.A should be included in hierarchy scope", scope.encloses(cu.getType("A")));
	assertTrue("a9.B should be included in hierarchy scope", scope.encloses(cu.getType("B")));
	assertTrue("a9/A.java should be included in hierarchy scope", scope.encloses(cu.getUnderlyingResource().getFullPath().toString()));
}
/**
 * Sub-cu java search scope test.
 * (regression test for bug 9041 search: cannot create a sub-cu scope)
 */
public void testSearchScope02() throws CoreException { // was testSubCUSearchScope1
	IType type = getCompilationUnit("JavaSearch", "src", "b3", "X.java").getType("X");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type});

	search(
		type,
		REFERENCES,
		scope,
		this.resultCollector);
	assertSearchResults(
		"src/b3/X.java b3.X.field [X]\n" +
		"src/b3/X.java Object b3.X.foo() [X]\n" +
		"src/b3/X.java b3.X$Y.field2 [X]\n" +
		"src/b3/X.java Object b3.X$Y.foo2() [X]",
		this.resultCollector);
}
/**
 * Sub-cu java search scope test.
 * (regression test for bug 9041 search: cannot create a sub-cu scope)
 */
public void testSearchScope03() throws CoreException { // was testSubCUSearchScope2
	IType type = getCompilationUnit("JavaSearch", "src", "b3", "X.java").getType("X");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type.getField("field")});

	search(
		type,
		REFERENCES,
		scope,
		this.resultCollector);
	assertSearchResults(
		"src/b3/X.java b3.X.field [X]",
		this.resultCollector);
}
/**
 * Sub-cu java search scope test.
 * (regression test for bug 9041 search: cannot create a sub-cu scope)
 */
public void testSearchScope04() throws CoreException { // was testSubCUSearchScope3
	IType type = getCompilationUnit("JavaSearch", "src", "b3", "X.java").getType("X");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type.getType("Y")});

	search(
		type,
		REFERENCES,
		scope,
		this.resultCollector);
	assertSearchResults(
		"src/b3/X.java b3.X$Y.field2 [X]\n" +
		"src/b3/X.java Object b3.X$Y.foo2() [X]",
		this.resultCollector);
}
/**
 * Java search scope on java element in external jar test.
 */
public void testSearchScope05() throws CoreException, IOException { // was testExternalJarScope
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	File workspaceLocation = new File(workspace.getRoot().getLocation().toOSString());
	File minimalJar = new File(workspaceLocation, "JavaSearch/MyJar.jar");
	File externalJar = new File(workspaceLocation.getParentFile().getCanonicalFile(), "MyJar.jar"); // canonicalize the external path as this is not done on case sensitive platforms when creating a new lib entry
	IJavaProject project = getJavaProject("JavaSearch");
	IClasspathEntry[] classpath = project.getRawClasspath();
	try {
		copy(minimalJar, externalJar);
		int length = classpath.length;
		IClasspathEntry[] newClasspath = new IClasspathEntry[length];
		System.arraycopy(classpath, 0, newClasspath, 0, length-1);
		String externalPath = externalJar.getAbsolutePath();
		newClasspath[length-1] = JavaCore.newLibraryEntry(new Path(externalPath), new Path(externalPath), null, false);
		project.setRawClasspath(newClasspath, null);

		IPackageFragment pkg = getPackageFragment("JavaSearch", externalPath, "p0");
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {pkg});

		search(
			"X",
			TYPE,
			DECLARATIONS,
			scope,
			this.resultCollector);
		assertSearchResults(
			externalJar + " p0.X",
			this.resultCollector);

		IOrdinaryClassFile classFile = pkg.getOrdinaryClassFile("X.class");
		scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {classFile});
		this.resultCollector = new JavaSearchResultCollector();
		search(
			classFile.getType(),
			DECLARATIONS,
			scope,
			this.resultCollector);
		assertSearchResults(
			externalJar.getCanonicalPath()+ " p0.X",
			this.resultCollector);

	} finally {
		Util.delete(externalJar);
		project.setRawClasspath(classpath, null);
	}

}
/**
 * Hierarchy scope test.
 * (test for enhancement bug 215139 encloses(): find only subtypes).
 */
public void testSearchScope06() throws CoreException {
    	ICompilationUnit cuB = this. getCompilationUnit("JavaSearch", "src", "a10", "B.java");
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
        IType type = cuC.getType("C");
        IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null);

        // don't include super-classes:
        assertFalse("a10.A should not be included in hierarchy scope", scope.encloses(cuB.getType("A")));
        assertFalse("a10.B should not be included in hierarchy scope", scope.encloses(cuB.getType("B")));
        assertFalse("a10/B.java should not be included in hierarchy scope", scope.encloses(cuB.getUnderlyingResource().getFullPath().toString()));
}
/**
 * Hierarchy scope test.
 * (test for enhancement bug 215139 encloses(): find only subtypes).
 */
public void testSearchScope07() throws CoreException {
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
        IType type = cuC.getType("C");
        IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null);

        // don't include focus type:
        assertFalse("a10.C should not be included in hierarchy scope", scope.encloses(type));
        assertFalse("a10/C.java should not be included in hierarchy scope", scope.encloses(cuC.getUnderlyingResource().getFullPath().toString()));
}
/**
 * Hierarchy scope test.
 * test for enhancement bug 215139 encloses(): find only subtypes.
 * also test enhancement bug 295894: include focus type.
 */
public void testSearchScope07a() throws CoreException {
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
        IType type = cuC.getType("C");
        IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, true, null);

        // include focus type:
        assertTrue("a10.C should be included in hierarchy scope", scope.encloses(type));
        assertTrue("a10/C.java should be included in hierarchy scope", scope.encloses(cuC.getUnderlyingResource().getFullPath().toString()));
}
/**
 * Hierarchy scope test.
 * (test for enhancement bug 215139 encloses(): find only subtypes).
 */
public void testSearchScope08() throws CoreException {
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
        ICompilationUnit cuD = this. getCompilationUnit("JavaSearch", "src", "a10", "D.java");
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
        IType type = cuC.getType("C");
        IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null);

        // regular sub-types:
        assertTrue("a10.D should be included in hierarchy scope", scope.encloses(cuD.getType("D")));
        assertTrue("a10/D.java should be included in hierarchy scope", scope.encloses(cuD.getUnderlyingResource().getFullPath().toString()));

        assertTrue("a10.E should be included in hierarchy scope", scope.encloses(cuE.getType("E")));
        assertTrue("a10.F should be included in hierarchy scope", scope.encloses(cuE.getType("F")));
}
/**
 * Hierarchy scope test.
 * (test for enhancement bug 215139 encloses(): find only subtypes).
 */
public void testSearchScope09() throws CoreException {
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
        IType type = cuC.getType("C");
        IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null);

        // sub-type is a nested type:
        assertTrue("a10.H$I should be included in hierarchy scope", scope.encloses(cuE.getType("H").getType("I")));
}
/**
 * Hierarchy scope test.
 * (test for enhancement bug 215139 encloses(): find only subtypes).
 */
public void testSearchScope10() throws CoreException {
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
        IType type = cuC.getType("C");
        IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null);

        // member of a sub-type:
        assertFalse("a10.F$G should not be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G")));
}
/**
 * Hierarchy scope test.
 * (test for enhancement bug 215139 encloses(): find only subtypes).
 */
public void testSearchScope12() throws CoreException {
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
        IType type = cuC.getType("C");
        IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null);

        // enclosing of a sub-type:
        assertFalse("a10.H should not be included in hierarchy scope", scope.encloses(cuE.getType("H")));
        assertTrue("a10/E.java should be included in hierarchy scope", scope.encloses(cuE.getUnderlyingResource().getFullPath().toString()));
}
/**
 * Hierarchy scope test.
 * (test for enhancement bug 215139 search: find only subtypes).
 */
public void testSearchScope13() throws CoreException {
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
        IType type = cuC.getType("C");
        IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null);

        search("**", TYPE, DECLARATIONS, scope);
        assertSearchResults(
        		"src/a10/D.java a10.D [D]\n" +
        		"src/a10/E.java a10.E [E]\n" +
        		"src/a10/E.java a10.F [F]\n" +
        		"src/a10/E.java a10.H$I [I]"
        		);
}
/**
 * Hierarchy scope test.
 * (test for enhancement bug 215139 search: find only subtypes - disabled).
 */
public void testSearchScope14() throws CoreException {
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
        IType type = cuC.getType("C");
        IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, /*onlySubTypes*/false, true, null);

        search("**", TYPE, DECLARATIONS, scope);
        assertSearchResults(
        		"src/a10/B.java a10.A [A]\n" +
        		"src/a10/B.java a10.B [B]\n" +
        		"src/a10/C.java a10.C [C]\n" +
        		"src/a10/D.java a10.D [D]\n" +
        		"src/a10/E.java a10.E [E]\n" +
        		"src/a10/E.java a10.F [F]\n" +
        		"src/a10/E.java a10.H$I [I]\n" +
        		getExternalJCLPathString() + " java.lang.Object"
        		);
}
/**
 * Hierarchy scope test.
 * test for enhancement bug 215139 search: find only subtypes - disabled,
 * also test enhancement bug 295894: exclude focus type.
 */
public void testSearchScope14a() throws CoreException {
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
        IType type = cuC.getType("C");
        IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, /*onlySubTypes*/false, false, null);

        search("**", TYPE, DECLARATIONS, scope);
        assertSearchResults(
        		"src/a10/B.java a10.A [A]\n" +
        		"src/a10/B.java a10.B [B]\n" +
        		"src/a10/D.java a10.D [D]\n" +
        		"src/a10/E.java a10.E [E]\n" +
        		"src/a10/E.java a10.F [F]\n" +
        		"src/a10/E.java a10.H$I [I]\n" +
        		getExternalJCLPathString() + " java.lang.Object"
        		);
}
/**
 * Hierarchy scope test.
 * (test for enhancement bug 215139 search: find only subtypes - different call chain).
 */
public void testSearchScope15() throws CoreException {
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
        IType type = cuC.getType("C");
        IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null);
    	TypeNameMatchCollector collector = new TypeNameMatchCollector() {
    		public String toString(){
    			return toFullyQualifiedNamesString();
    		}
    	};
    	new SearchEngine().searchAllTypeNames(
    		null,
    		null,
    		scope,
    		collector,
    		IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
    		null);
    	String expected =
    			"a10.D\n" +
    			"a10.E\n" +
    			"a10.F\n" +
    			"a10.H$I";
    	assertTrue("We should get some types!", collector.size() > 0);
    	assertEquals("Found types sound not to be correct", expected, collector.toString());
}
/**
 * Hierarchy scope test.
 * (test for enhancement bug 215139 encloses(method): find only subtypes).
 */
public void testSearchScope17() throws CoreException {
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
        IType type = cuC.getType("C");
        IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null);

        // method of a member of a sub-type:
        assertFalse("a10.F$G.m() should not be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G").getMethod("m", new String[0])));
}
/**
 * Simple type declaration test.
 */
public void testTypeDeclaration01() throws CoreException { // was testSimpleTypeDeclaration
	IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");

	search(
		type,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults("src/p/X.java p.X [X]", this.resultCollector);
}
/**
 * Type declaration test.
 * (generic type)
 */
public void testTypeDeclaration02() throws CoreException {
	IPackageFragment pkg = getPackageFragment("JavaSearch15", "src", "p1");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {pkg});

	search(
		"Y",
		TYPE,
		DECLARATIONS,
		scope,
		this.resultCollector);
	assertSearchResults(
		"src/p1/Y.java p1.Y [Y]",
		this.resultCollector);
}
/**
 * Type declaration test.
 * (regression test for bug 29524 Search for declaration via patterns adds '"*")
 */
public void testTypeDeclaration03() throws CoreException { // was testTypeDeclaration
	IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "d8");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {pkg});

	search(
		"A",
		TYPE,
		DECLARATIONS,
		scope,
		this.resultCollector);
	assertSearchResults("src/d8/A.java d8.A [A]", this.resultCollector);
}
/**
 * Type declaration in jar file test.
 */
public void testTypeDeclaration04() throws CoreException { // was testTypeDeclarationInJar
	IType type = getClassFile("JavaSearch", "MyJar.jar", "p1", "A.class").getType();

	search(
		type,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"MyJar.jar p1.A [No source]",
		this.resultCollector);
}
/**
 * Type declaration in jar file and in anonymous class test.
 * (regression test for 20631 Declaration of local binary type not found)
 */
public void testTypeDeclaration05() throws CoreException { // was testTypeDeclarationInJar2
	IPackageFragmentRoot root = getPackageFragmentRoot("JavaSearch", "test20631.jar");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {root});

	search(
		"Y",
		TYPE,
		DECLARATIONS,
		scope,
		this.resultCollector);
	assertSearchResults(
		"test20631.jar Y",
		this.resultCollector);
}
/**
 * Type declaration using a package scope test.
 * (check that subpackages are not included)
 */
public void testTypeDeclaration06() throws CoreException { // was testTypeDeclarationInPackageScope
	IType type = getCompilationUnit("JavaSearch", "src", "p3", "X.java").getType("X");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type.getPackageFragment()});

	search(
		"X",
		TYPE,
		DECLARATIONS,
		scope,
		this.resultCollector);
	assertSearchResults(
		"src/p3/X.java p3.X [X]",
		this.resultCollector);
}
/**
 * Type declaration using a binary package scope test.
 * (check that subpackages are not included)
 */
public void testTypeDeclaration07() throws CoreException { // was testTypeDeclarationInPackageScope2
	IType type = getClassFile("JavaSearch", "MyJar.jar", "p0", "X.class").getType();
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type.getPackageFragment()});

	search(
		"X",
		TYPE,
		DECLARATIONS,
		scope,
		this.resultCollector);
	assertSearchResults(
		"MyJar.jar p0.X [No source]",
		this.resultCollector);
}
/**
 * Member type declaration test.
 * (regression test for bug 9992 Member class declaration not found)
 */
public void testTypeDeclaration08() throws CoreException { // was testMemberTypeDeclaration
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[]{
		getPackageFragment("JavaSearch", "src", "b4")
	});

	search(
		"*.A.B",
		TYPE,
		DECLARATIONS,
		scope,
		this.resultCollector);
	assertSearchResults(
		"src/b4/A.java b4.A$B [B]",
		this.resultCollector);
}
/**
 * Test pattern match type declaration
 * (regression test for bug 17210 No match found when query contains '?')
 */
public void testTypeDeclaration09() throws CoreException {

	search(
		"X?Z",
		TYPE,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults("src/r5/XYZ.java r5.XYZ [XYZ]", this.resultCollector);
}
/**
 * Long declaration (>255) test.
 * (regression test for bug 25859 Error doing Java Search)
 */
public void testTypeDeclaration10() throws CoreException { // was testLongDeclaration

	search(
		"AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyz",
		TYPE,
		DECLARATIONS,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/c9/X.java c9.AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyz [AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyz]",
		this.resultCollector);
}
/*
 * Local type declaration test.
 */
public void testTypeDeclaration11() throws CoreException { // was testLocalTypeDeclaration1
	IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "f2");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {pkg});

	search(
		"Y",
		TYPE,
		DECLARATIONS,
		scope,
		this.resultCollector);
	assertSearchResults(
		"src/f2/X.java Object f2.X.foo1():Y#1 [Y]",
		this.resultCollector);
}
/*
 * Local type declaration test.
 */
public void testTypeDeclaration12() throws CoreException { // was testLocalTypeDeclaration2
	IType type = getCompilationUnit("JavaSearch/src/f2/X.java").getType("X").getMethod("foo1", new String[0]).getType("Y", 1);

	IJavaSearchScope scope = SearchEngine.createWorkspaceScope();

	search(
		type,
		DECLARATIONS,
		scope,
		this.resultCollector);
	assertSearchResults(
		"src/f2/X.java Object f2.X.foo1():Y#1 [Y]",
		this.resultCollector);
}
/**
 * Type ocurrence test.
 * (regression test for PR 1GKAQJS: ITPJCORE:WIN2000 - search: incorrect results for nested types)
 */
public void testTypeOccurence1() throws CoreException { // was testTypeOccurence
	IType type = getCompilationUnit("JavaSearch", "src", "r", "A.java").getType("A").getType("X");

	search(
		type,
		ALL_OCCURRENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/r/A.java A r.A.m() [X]\n" +
		"src/r/A.java r.A$X [X]\n" +
		"src/r/A.java r.A$X(X) [X]\n" +
		"src/r/A.java r.A$X(X) [X]\n" +
		"src/r/A.java r.B.ax [A.X]\n" +
		"src/r/A.java r.B.ax [X]",
		this.resultCollector);
}
/**
 * Type ocuurence in unresolvable import test.
 * (regression test for bug 37166 NPE in SearchEngine when matching type against ProblemReferenceBinding )
 */
public void testTypeOccurence2() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "r8", "B.java").getType("B");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type.getPackageFragment()});

	search(
		type,
		ALL_OCCURRENCES,
		scope,
		this.resultCollector);
	assertSearchResults(
		"src/r8/A.java [B]",
		this.resultCollector);
}
/**
 * Type occurences test.
 * Ensures that correct positions are reported for an inner type reference using a ALL_OCCURENCES pattern
 */
public void testTypeOccurence3() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "e4", "A.java").getType("A").getType("Inner");

	search(
		type,
		ALL_OCCURRENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/e4/A.java e4.A$Inner [Inner]\n" +
		"src/e5/A1.java [e4.A.Inner]\n" +
		"src/e5/A1.java e5.A1.a [e4.A.Inner]\n" +
		"src/e5/A1.java e5.A1.a1 [e4.A.Inner]\n" +
		"src/e5/A1.java e5.A1.a2 [Inner]\n" +
		"src/e5/A1.java e5.A1.a3 [Inner]",
		this.resultCollector);
}
/**
 * Type name with $ ocurrence test.
 * (regression test for bug 3310 Smoke 124: Compile errors introduced with rename refactoring (1GFBK2G))
 */
public void testTypeOccurence4() throws CoreException { // was testTypeOccurenceWithDollar
	IType type = getCompilationUnit("JavaSearch", "src", "q3", "A$B.java").getType("A$B");

	search(
		type,
		ALL_OCCURRENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/q3/A$B.java q3.A$B [A$B]\n" +
		"src/q4/C.java Object q4.C.foo() [q3.A$B]",
		this.resultCollector);
}
/**
 * Type reference test.
 * (Regression test for PR 1GK7K17: ITPJCORE:WIN2000 - search: missing type reference)
 */
public void testTypeReference01() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "", "X.java").getType("X");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/X.java AA() [X]",
		this.resultCollector);
}
/**
 * Type reference test.
 * (Regression test for bug 29516 SearchEngine regressions in 20030114)
 */
public void testTypeReference02() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "src", "d7", "A.java").getType("A");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/d7/A.java d7.A.A [A]\n" +
		"src/d7/A.java A d7.A.A(A) [A]\n" +
		"src/d7/A.java A d7.A.A(A) [A]",
		this.resultCollector);
}
/**
 * Type reference test.
 * (Regression test for bug 31985 NPE searching non-qualified and case insensitive type ref)
 */
public void testTypeReference03() throws CoreException {
	SearchPattern pattern = createPattern("x31985", TYPE, REFERENCES, false);

	this.resultCollector.showAccuracy(true);
	search(
		pattern,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/e3/X31985.java e3.X31985.CONSTANT [X31985] EXACT_MATCH\n" +
		"src/e3/Y31985.java Object e3.Y31985.foo() [X31985] EXACT_MATCH",
		this.resultCollector);
}
/**
 * Type reference test.
 * (Regression test for bug 31997 Refactoring d.n. work for projects with brackets in name.)
 */
public void testTypeReference04() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "otherSrc()", "", "X31997.java").getType("X31997");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"otherSrc()/Y31997.java Y31997 [X31997]",
		this.resultCollector);
}
/**
 * Type reference test.
 * (Regression test for bug 48261 Search does not show results)
 */
public void testTypeReference05() throws CoreException {
	IType type = getCompilationUnit("JavaSearch", "test48261.jar", "p", "X.java").getType("X");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type.getPackageFragment().getParent()});

	search(
		type,
		REFERENCES,
		scope,
		this.resultCollector);
	assertSearchResults(
		"test48261.jar p.X$Y(java.lang.String)",
		this.resultCollector);
}
/**
 * Type reference test
 * (in a generic type)
 */
public void testTypeReference06() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15/src/p1/X.java").getType("X");

	search(
		type,
		REFERENCES,
		getJavaSearchScope15("p1", true),
		this.resultCollector);
	assertSearchResults(
		"src/p1/Y.java Object p1.Y.foo() [X]",
		this.resultCollector);
}
/**
 * Simple type reference test.
 */
public void testTypeReference07() throws CoreException { // was testTypeDeclaration01
	IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p/A.java p.A.x [X]\n" +
		"src/p/A.java p.A(X) [X]\n" +
		"src/p/A.java void p.A.foo(int, String, X) [X]\n" +
		"src/p/X.java p.X() [X]\n" +
		"src/p/X.java void p.X.foo(int, String, X) [X]\n" +
		"src/p/Y.java p.Y [X]\n" +
		"src/p/Z.java void p.Z.foo(int, String, X) [X]",
		this.resultCollector);
}
/**
 * Type reference in initializer test.
 * (regression test for PR #1G4GO4O)
 */
public void testTypeReference08() throws CoreException { // was testTypeReferenceInInitializer
	IType type = getCompilationUnit("JavaSearch", "src", "", "Test.java").getType("Test");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/Test.java Test.static {} [Test]\n" +
		"src/Test.java Test.static {} [Test]\n" +
		"src/Test.java Test.{} [Test]",
		this.resultCollector);
}
/**
 * Type reference as a single name reference test.
 */
public void testTypeReference09() throws CoreException { // was testTypeReferenceAsSingleNameReference
	IType type = getCompilationUnit("JavaSearch", "src", "", "TypeReferenceAsSingleNameReference.java").getType("TypeReferenceAsSingleNameReference");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/TypeReferenceAsSingleNameReference.java void TypeReferenceAsSingleNameReference.hasReference() [TypeReferenceAsSingleNameReference]\n" +
		"src/TypeReferenceAsSingleNameReference.java void TypeReferenceAsSingleNameReference.hasReference() [TypeReferenceAsSingleNameReference]",
		this.resultCollector);
}
/**
 * Member type reference test.
 */
public void testTypeReference10() throws CoreException { // was testMemberTypeReference
	// references to second level member type

	this.resultCollector.showAccuracy(true);
	search(
		"BMember",
		TYPE,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"References to type BMember",
		"src/MemberTypeReference/Azz.java void MemberTypeReference.Azz.poo() [BMember] EXACT_MATCH\n" +
		"src/MemberTypeReference/Azz.java MemberTypeReference.Azz$AzzMember [BMember] EXACT_MATCH\n" +
		"src/MemberTypeReference/Azz.java MemberTypeReference.X.val [BMember] EXACT_MATCH\n" +
		"src/MemberTypeReference/B.java void MemberTypeReference.B.foo() [BMember] EXACT_MATCH",
		this.resultCollector);

	// references to first level member type
	this.resultCollector = new JavaSearchResultCollector();
	this.resultCollector.showAccuracy(true);
	search(
		"AzzMember",
		TYPE,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"References to type AzzMember",
		"src/MemberTypeReference/Azz.java MemberTypeReference.X.val [AzzMember] EXACT_MATCH\n" +
		"src/MemberTypeReference/B.java void MemberTypeReference.B.foo() [AzzMember] EXACT_MATCH",
		this.resultCollector);

	// no reference to a field with same name as member type
	this.resultCollector = new JavaSearchResultCollector();
	this.resultCollector.showAccuracy(true);
	search(
		"BMember",
		FIELD,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"References to field BMember",
		"",
		this.resultCollector);
}
/**
 * Member type reference test.
 * (regression test for PR 1GL0MN9: ITPJCORE:WIN2000 - search: not consistent results for nested types)
 */
public void testTypeReference11() throws CoreException { // was testMemberTypeReference2
	IType type = getCompilationUnit("JavaSearch", "src", "a", "A.java").getType("A").getType("X");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/a/A.java a.B.ax [A.X]\n" +
		"src/a/A.java a.B.sx [S.X]",
		this.resultCollector);
}
/**
 * Member type named "Object" reference test.
 * (regression test for 1G4GHPS: ITPJUI:WINNT - Strange error message in search)
 */
public void testTypeReference12() throws CoreException { // was testObjectMemberTypeReference
	IType type = getCompilationUnit("JavaSearch", "src", "ObjectMemberTypeReference", "A.java")
		.getType("A")
		.getType("Object");

	this.resultCollector.showAccuracy(true);
	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/ObjectMemberTypeReference/A.java void ObjectMemberTypeReference.A.foo() [Object] EXACT_MATCH",
		this.resultCollector);
}
/**
 * Type reference inside a qualified name reference test.
 * (Regression test for PR #1G4TSC0)
 */
public void testTypeReference13() throws CoreException { // was testTypeReferenceInQualifiedNameReference
	IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/Test.java void Test.main(String[]) [p.A]\n" +
		"src/Test.java void Test.main(String[]) [p.A]\n" +
		"src/p/A.java void p.A.foo() [A]",
		this.resultCollector);
}
/**
 * Type reference inside a qualified name reference test.
 * (Regression test for PR #1GLBP65)
 */
public void testTypeReference14() throws CoreException { // was testTypeReferenceInQualifiedNameReference2
	IType type = getCompilationUnit("JavaSearch", "src", "p4", "A.java").getType("A");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p4/A.java p4.A.A [A]\n" +
		"src/p4/A.java p4.X [p4.A]\n" +
		"src/p4/A.java void p4.X.x() [p4.A]",
		this.resultCollector);
}
/**
 * Type reference inside a qualified name reference test.
 * (Regression test for PR 1GL9UMH: ITPJCORE:WIN2000 - search: missing type occurrences)
 */
public void testTypeReference15() throws CoreException { // was testTypeReferenceInQualifiedNameReference3
	IType type = getCompilationUnit("JavaSearch", "src", "", "W.java").getType("W");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/W.java int W.m() [W]",
		this.resultCollector);
}
/**
 * Type reference inside a qualified name reference test.
 * (Regression test for bug 16751 Renaming a class doesn't update all references  )
 */
public void testTypeReference16() throws CoreException { // was testTypeReferenceInQualifiedNameReference4
	IType type = getCompilationUnit("JavaSearch", "src", "b7", "X.java").getType("SubClass");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/b7/X.java void b7.Test.main(String[]) [SubClass]",
		this.resultCollector);
}
/**
 * Type reference in a folder that is not in the classpath.
 * (regression test for PR #1G5N8KS)
 */
public void testTypeReference17() throws CoreException { // was testTypeReferenceNotInClasspath
	IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/p/A.java p.A.x [X]\n" +
		"src/p/A.java p.A(X) [X]\n" +
		"src/p/A.java void p.A.foo(int, String, X) [X]\n" +
		"src/p/X.java p.X() [X]\n" +
		"src/p/X.java void p.X.foo(int, String, X) [X]\n" +
		"src/p/Y.java p.Y [X]\n" +
		"src/p/Z.java void p.Z.foo(int, String, X) [X]",
		this.resultCollector);
}
/**
 * Type reference inside an argument, a return type or a field type.
 * (Regression test for PR #1GA7QA1)
 */
public void testTypeReference18() throws CoreException { // was testVariousTypeReferences
	IType type = getCompilationUnit("JavaSearch", "src", "NoReference", "A.java").getType("A");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"", // no reference should be found
		this.resultCollector);
}
/**
 * Type reference in import test.
 * (regression test for PR #1GA7PAS)
 */
public void testTypeReference19() throws CoreException { // was testTypeReferenceInImport
	IType type = getCompilationUnit("JavaSearch", "src", "p2", "Z.java").getType("Z");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/TypeReferenceInImport/X.java [p2.Z]",
		this.resultCollector);
}
/**
 * Type reference in import test.
 * (regression test for bug 23077 search: does not find type references in some imports)
 */
public void testTypeReference20() throws CoreException { // was testTypeReferenceInImport2
	IType type = getCompilationUnit("JavaSearch", "src", "r6", "A.java").getType("A");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/r6/B.java [r6.A]\n" +
		"src/r6/B.java [r6.A]\n" +
		"src/r6/B.java [r6.A]\n" +
		"src/r6/B.java [r6.A]\n" +
		"src/r6/B.java [r6.A]\n" +
		"src/r6/B.java [r6.A]",
		this.resultCollector);
}
/**
 * Type reference in array test.
 * (regression test for PR #1GAL424)
 */
public void testTypeReference21() throws CoreException { // was testTypeReferenceInArray
	IType type = getCompilationUnit("JavaSearch", "src", "TypeReferenceInArray", "A.java").getType("A");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/TypeReferenceInArray/A.java TypeReferenceInArray.A.a [A]\n" +
		"src/TypeReferenceInArray/A.java TypeReferenceInArray.A.b [TypeReferenceInArray.A]",
		this.resultCollector);
}
/**
 * Type reference in array test.
 * (regression test for bug 3230 Search - Too many type references for query ending with * (1GAZVGI)  )
 */
public void testTypeReference22() throws CoreException { // was testTypeReferenceInArray2
	IType type = getCompilationUnit("JavaSearch", "src", "s1", "X.java").getType("X");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/s1/Y.java s1.Y.f [X]",
		this.resultCollector);
}
/**
 * Negative type reference test.
 * (regression test for 1G52F7P: ITPJCORE:WINNT - Search - finds bogus references to class)
 */
public void testTypeReference23() throws CoreException { // testNegativeTypeReference
	IType type = getCompilationUnit("JavaSearch", "src", "p7", "A.java").getType("A");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"",
		this.resultCollector);
}
/**
 * Type reference in a throw clause test.
 * (Regression test for bug 6779 searchDeclarationsOfReferencedTyped - missing exception types)
 */
public void testTypeReference24() throws CoreException { // was testTypeReferenceInThrows
	IType type = getCompilationUnit("JavaSearch", "src", "a7", "X.java").getType("MyException");

	this.resultCollector.showAccuracy(true);
	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/a7/X.java void a7.X.foo() [MyException] EXACT_MATCH",
		this.resultCollector);
}
/**
 * Type reference test.
 * (Regression test for bug 9642 Search - missing inaccurate type matches)
 */
public void testTypeReference25() throws CoreException { // was testInnacurateTypeReference1

	search(
		"Zork",
		TYPE,
		REFERENCES,
		SearchEngine.createJavaSearchScope(new IJavaElement[] {
			getPackageFragment("JavaSearch", "src", "b5")
		}),
		this.resultCollector);
	assertSearchResults(
		"src/b5/A.java [Zork]\n" +
		"src/b5/A.java b5.A.{} [Zork]\n" +
		"src/b5/A.java b5.A.{} [Zork]\n" +
		"src/b5/A.java b5.A.{} [Zork]",
		this.resultCollector);
}
/**
 * Type reference test.
 * (Regression test for bug 9642 Search - missing inaccurate type matches)
 */
public void testTypeReference26() throws CoreException { // was testInnacurateTypeReference2

	this.resultCollector.showAccuracy(true);
	this.resultCollector.showSelection();
	search(
		"p.Zork",
		TYPE,
		REFERENCES,
		SearchEngine.createJavaSearchScope(new IJavaElement[] {
			getPackageFragment("JavaSearch", "src", "b5")
		}),
		this.resultCollector);
	assertSearchResults(
			"src/b5/A.java b5.A.{} [    !|Zork|![] zork = new Zork[0];] POTENTIAL_MATCH\n" +
			"src/b5/A.java b5.A.{} [    Zork[] zork = new !|Zork|![0];] POTENTIAL_MATCH\n" +
			"src/b5/A.java b5.A.{} [    int i = !|Zork|!.foo;] POTENTIAL_MATCH",
		this.resultCollector);
}
/**
 * Type reference test.
 * (Regression test for bug 21485  NPE when doing a reference search to a package)
 */
public void testTypeReference27() throws CoreException { // was testInnacurateTypeReference3
	IType type = getCompilationUnit("JavaSearch", "src", "r3", "A21485.java").getType("A21485");

	this.resultCollector.showAccuracy(true);
	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/r4/B21485.java [r3.A21485] EXACT_MATCH\n" +
		"src/r4/B21485.java r4.B21485 [A21485] POTENTIAL_MATCH",
		this.resultCollector);
}
/**
 * Type reference in cast test.
 * (regression test for bug 23329 search: incorrect range for type references in brackets)
 */
public void testTypeReference28() throws CoreException { // was testTypeReferenceInCast
	IType type = getCompilationUnit("JavaSearch", "src", "s3", "A.java").getType("B");

	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/s3/A.java Object s3.A.foo() [B]",
		this.resultCollector);
}
/**
 * Test pattern match type reference in binary
 * (regression test for bug 24741 Search does not find patterned type reference in binary project  )
 */
public void testTypeReference29() throws CoreException { // was testPatternMatchTypeReference

	search(
		"p24741.*",
		TYPE,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"test24741.jar q24741.B",
		this.resultCollector);
}
/**
 * Type reference test (not case sensitive)
 */
public void testTypeReference30() throws CoreException { // was testTypeReferenceNotCaseSensitive
	IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "d4");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {pkg});
	SearchPattern pattern = createPattern("Y", TYPE, REFERENCES, false);

	search(
		pattern,
		scope,
		this.resultCollector);
	assertSearchResults(
		"src/d4/X.java Object d4.X.foo() [Y]",
		this.resultCollector);
}
/**
 * Type reference test.
 */
public void testTypeReference31() throws CoreException { // was testAccurateTypeReference

	search(
		"d5.X",
		TYPE,
		REFERENCES,
		SearchEngine.createJavaSearchScope(new IJavaElement[] {
			getPackageFragment("JavaSearch", "src", "d5")
		}),
		this.resultCollector);
	assertSearchResults(
		"src/d5/Y.java d5.Y.T [d5.X]\n" +
		"src/d5/Y.java d5.Y.c [d5.X]\n" +
		"src/d5/Y.java d5.Y.o [d5.X]",
		this.resultCollector);
}
/**
 * Type reference in hierarchy test.
 * (regression test for bug 28236 Search for refs to class in hierarchy matches class outside hierarchy )
 */
public void testTypeReference32() throws CoreException { // was testTypeReferenceInHierarchy
	IType type = getCompilationUnit("JavaSearch", "src", "d9.p1", "A.java").getType("A");

	IJavaSearchScope scope = SearchEngine.createHierarchyScope(type);
	search(
		type,
		REFERENCES,
		scope,
		this.resultCollector);
	assertSearchResults(
		"",
		this.resultCollector);
}
/**
 * Type reference with recovery test.
 * (Regression test for bug 29366 Search reporting invalid inaccurate match )
 */
public void testTypeReference33() throws CoreException { // was testTypeReferenceWithRecovery
	IType type = getCompilationUnit("JavaSearch", "src", "e1", "A29366.java").getType("A29366");

	this.resultCollector.showAccuracy(true);
	search(
		type,
		REFERENCES,
		getJavaSearchScope(),
		this.resultCollector);
	assertSearchResults(
		"src/e1/A29366.java void e1.A29366.foo() [A29366] EXACT_MATCH",
		this.resultCollector);
}
/**
 * Type reference with problem test.
 * (Regression test for bug 36479 Rename operation during refactoring fails)
 */
public void testTypeReference34() throws CoreException { // was testTypeReferenceWithProblem
	IType type = getCompilationUnit("JavaSearch", "src", "e6", "A.java").getType("A");

	this.resultCollector.showAccuracy(true);
	search(
		"B36479",
		TYPE,
		REFERENCES,
		SearchEngine.createJavaSearchScope(new IJavaElement[] {type}),
		this.resultCollector);
	assertSearchResults(
		"src/e6/A.java Object e6.A.foo() [B36479] POTENTIAL_MATCH",
		this.resultCollector);
}
/**
 * Type reference with corrupt jar on the classpath test.
 * (Regression test for bug 39831 Search finds only "inexact" matches)
 */
public void testTypeReference35() throws CoreException { // was testTypeReferenceWithCorruptJar
	IJavaProject project = getJavaProject("JavaSearch");
	IClasspathEntry[] originalCP = project.getRawClasspath();
	try {
		// add corrupt.jar to classpath
		int cpLength = originalCP.length;
		IClasspathEntry[] newCP = new IClasspathEntry[cpLength+1];
		System.arraycopy(originalCP, 0, newCP, 0, cpLength);
		newCP[cpLength] = JavaCore.newLibraryEntry(new Path("/JavaSearch/corrupt.jar"), null, null);
		project.setRawClasspath(newCP, null);

		IType type = getCompilationUnit("JavaSearch", "src", "e7", "A.java").getType("A");

		this.resultCollector.showAccuracy(true);
		search(
			type,
			REFERENCES,
			SearchEngine.createJavaSearchScope(new IJavaElement[] {project}),
			this.resultCollector);
		assertSearchResults(
			"src/e7/A.java e7.A.a [A] EXACT_MATCH",
			this.resultCollector);
	} finally {
		project.setRawClasspath(originalCP, null);
	}
}
/*
 * Local type reference test.
 */
public void testTypeReference36() throws CoreException { // was testLocalTypeReference1
	IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "f2");
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {pkg});

	this.resultCollector.showSelection();
	search(
		"Y",
		TYPE,
		REFERENCES,
		scope,
		this.resultCollector);
	assertSearchResults(
		"src/f2/X.java Object f2.X.foo1() [		return new !|Y|!();]",
		this.resultCollector);
}
/*
 * Local type reference test.
 */
public void testTypeReference37() throws CoreException { // was testLocalTypeReference2
	IType type = getCompilationUnit("JavaSearch/src/f2/X.java").getType("X");
	IMethod method = type.getMethod("foo1", new String[0]);
	IType localType = method.getType("Y", 1);

	IJavaSearchScope scope = SearchEngine.createWorkspaceScope();

	this.resultCollector.showSelection();
	search(
		localType,
		REFERENCES,
		scope,
		this.resultCollector);
	assertSearchResults(
		"src/f2/X.java Object f2.X.foo1() [		return new !|Y|!();]",
		this.resultCollector);
}
/**
 * Type reference inside/outside doc comment.
 */
public void testTypeReference38() throws CoreException { // was testTypeReferenceInOutDocComment
	IType type = getCompilationUnit("JavaSearch", "src", "s4", "X.java").getType("X");
	this.resultCollector.showInsideDoc();
	search(type, REFERENCES, getJavaSearchScope(), this.resultCollector);
	assertSearchResults(
		"src/s4/X.java void s4.X.bar() [X] INSIDE_JAVADOC\n" +
		"src/s4/X.java void s4.X.bar() [X] INSIDE_JAVADOC\n" +
		"src/s4/X.java void s4.X.bar() [X] INSIDE_JAVADOC\n" +
		"src/s4/X.java void s4.X.fred() [X] OUTSIDE_JAVADOC",
		this.resultCollector);
}

/**
 * Search for enumerations
 */
public void testEnum01() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "e1", "Team.java").getType("Team");
	search(type, REFERENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/a1/Author.java [e1.Team]\n" +
		"src/a1/Author.java [e1.Team]\n" +
		"src/a1/Author.java Team[] a1.Author.name() [Team]\n" +
		"src/a1/Test.java [e1.Team]\n" +
		"src/e1/Test.java void e1.Test.main(String[]) [Team]\n" +
		"src/e1/Test.java void e1.Test.main(String[]) [Team]\n" +
		"src/e1/Test.java Location e1.Test.location(Team) [Team]",
		this.resultCollector);
}
public void testEnum02() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "e1", "Team.java").getType("Team");
	IMethod method = type.getMethod("Team", new String[0]);
	search(method, REFERENCES, getJavaSearchScope15("e1", false), this.resultCollector);
	assertSearchResults(
		"src/e1/Team.java e1.Team.FREDERIC [FREDERIC]",
		this.resultCollector);
}
public void testEnum03() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "e1", "Team.java").getType("Team");
	IMethod method = type.getMethod("Team", new String[] { "I" });
	search(method, REFERENCES, getJavaSearchScope15("e1", false), this.resultCollector);
	assertSearchResults(
		"src/e1/Team.java e1.Team.PHILIPPE [PHILIPPE(37)]\n" +
		"src/e1/Team.java e1.Team.DAVID [DAVID(27)]\n" +
		"src/e1/Team.java e1.Team.JEROME [JEROME(33)]\n" +
		"src/e1/Team.java e1.Team.OLIVIER [OLIVIER(35)]\n" +
		"src/e1/Team.java e1.Team.KENT [KENT(40)]",
		this.resultCollector);
}
public void testEnum04() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "e1", "Team.java").getType("Team");
	IMethod method = type.getMethod("age", new String[0]);
	search(method, REFERENCES, getJavaSearchScope15("e1", false), this.resultCollector);
	assertSearchResults(
		"src/e1/Test.java void e1.Test.main(String[]) [age()]",
		this.resultCollector);
}
public void testEnum05() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "e1", "Team.java").getType("Team");
	IMethod method = type.getMethod("isManager", new String[0]);
	search(method, ALL_OCCURRENCES, getJavaSearchScope15("e1", false), this.resultCollector);
	assertSearchResults(
		"src/e1/Team.java boolean e1.Team.PHILIPPE:<anonymous>#1.isManager() [isManager]\n" +
		"src/e1/Team.java boolean e1.Team.isManager() [isManager]\n" +
		"src/e1/Test.java void e1.Test.main(String[]) [isManager()]",
		this.resultCollector);
}
public void testEnum06() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "e1", "Team.java").getType("Team");
	IMethod method = type.getMethod("setRole", new String[] { "Z" });
	search(method, REFERENCES, getJavaSearchScope15("e1", false), this.resultCollector);
	assertSearchResults(
		"src/e1/Test.java void e1.Test.main(String[]) [setRole(t.isManager())]",
		this.resultCollector);
}
/**
 * Search method with varargs
 */
public void testVarargs01() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "v1", "X.java").getType("X");
	IMethod method = type.getMethod("vargs", new String[] { "I", "I" });
	search(method, ALL_OCCURRENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/v1/X.java void v1.X.vargs(int, int) [vargs]\n" +
		"src/v1/X.java void v1.X.bar() [vargs(1, 2)]",
		this.resultCollector);
}
public void testVarargs02() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "v1", "X.java").getType("X");
	IMethod method = type.getMethod("vargs", new String[] { "I", "[I" });
	search(method, ALL_OCCURRENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/v1/X.java void v1.X.vargs(int, int ...) [vargs]\n" +
		"src/v1/X.java void v1.X.bar() [vargs(1, 2, 3)]\n" +
		"src/v1/X.java void v1.X.bar() [vargs(1, 2, 3, 4, 5, 6)]",
		this.resultCollector);
}
public void testVarargs03() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "v1", "X.java").getType("X");
	IMethod method = type.getMethod("vargs", new String[] { "[QString;" });
	search(method, ALL_OCCURRENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/v1/X.java void v1.X.vargs(String ...) [vargs]\n" +
		"src/v1/X.java void v1.X.bar() [vargs(\"x\", \"a\",\"'b\", \"c\")]",
		this.resultCollector);
}
public void testVarargs04() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "v1", "X.java").getType("X");
	IMethod method = type.getMethod("vargs", new String[] { "QString;", "[Z" });
	search(method, ALL_OCCURRENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/v1/X.java void v1.X.vargs(String, boolean ...) [vargs]\n" +
		"src/v1/X.java void v1.X.bar() [vargs(\"x\", false, true)]",
		this.resultCollector);
}
public void testVarargs05() throws CoreException {
	search("vargs", METHOD, DECLARATIONS, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/v1/X.java void v1.X.vargs(int, int) [vargs]\n" +
		"src/v1/X.java void v1.X.vargs(int, int ...) [vargs]\n" +
		"src/v1/X.java void v1.X.vargs(String ...) [vargs]\n" +
		"src/v1/X.java void v1.X.vargs(String, boolean ...) [vargs]",
		this.resultCollector);
}
public void testVarargs06() throws CoreException {
	search("vargs", METHOD, REFERENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/v1/X.java void v1.X.bar() [vargs(1, 2)]\n" +
		"src/v1/X.java void v1.X.bar() [vargs(1, 2, 3)]\n" +
		"src/v1/X.java void v1.X.bar() [vargs(1, 2, 3, 4, 5, 6)]\n" +
		"src/v1/X.java void v1.X.bar() [vargs(\"x\", \"a\",\"\'b\", \"c\")]\n" +
		"src/v1/X.java void v1.X.bar() [vargs(\"x\", false, true)]",
		this.resultCollector);
}
/**
 * Search for annotations
 */
public void testAnnotationType01() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "a1", "Author.java").getType("Author");
	search(type, REFERENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/a1/Test.java a1.Test [Author]\n" +
		"src/a1/Test.java a1.Test.t [Author]\n" +
		"src/a1/Test.java void a1.Test.foo() [Author]",
		this.resultCollector);
}
public void testAnnotationType02() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "a1", "Test.java");
	IType type = selectType(unit, "Author");
	search(type, DECLARATIONS, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/a1/Author.java a1.Author [Author]",
		this.resultCollector);
}

/**
 * Search for auto-boxing
 */
public void testAutoBoxing01() throws CoreException {
	this.workingCopies = new ICompilationUnit[1];
	this.workingCopies[0] = getWorkingCopy("/JavaSearch15/src/p/X.java",
		"package p;\n" +
		"public class X {\n" +
		"	void foo(int x) {}\n" +
		"	void bar() {\n" +
		"		foo(new Integer(0));\n" +
		"	}\n" +
		"}\n"
		);
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(this.workingCopies);
	IMethod method = this.workingCopies[0].getType("X").getMethod("foo", new String[] { "I" });
	search(method, REFERENCES, scope);
	assertSearchResults(
		"src/p/X.java void p.X.bar() [foo(new Integer(0))]"
	);
}

/**
 * Search for type parameters
 */
/*
 * Type type parameters
 */
public void testTypeParameterTypes01() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.m.def", "Single.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "T");
	search(typeParam, REFERENCES, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/m/def/Single.java void g5.m.def.Single.standard(T) [T]\n" +
		"src/g5/m/def/Single.java T g5.m.def.Single.generic(U) [T]\n" +
		"src/g5/m/def/Single.java Single<T> g5.m.def.Single.returnParamType() [T]\n" +
		"src/g5/m/def/Single.java Single<T> g5.m.def.Single.returnParamType() [T]\n" +
		"src/g5/m/def/Single.java void g5.m.def.Single.paramTypesArgs(Single<T>) [T]\n" +
		"src/g5/m/def/Single.java Single<T> g5.m.def.Single.complete(U, Single<T>) [T]\n" +
		"src/g5/m/def/Single.java Single<T> g5.m.def.Single.complete(U, Single<T>) [T]\n" +
		"src/g5/m/def/Single.java Single<T> g5.m.def.Single.complete(U, Single<T>) [T]"
	);
}
public void testTypeParameterTypes02() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.m.def", "Single.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "T", 3); // return type of returnParamType() method
	search(typeParam, DECLARATIONS, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/m/def/Single.java g5.m.def.Single [T]"
	);
}
public void testTypeParameterTypes03() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.m.def", "Single.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "T", 4); // type argument of Single<T>
	search(typeParam, ALL_OCCURRENCES, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/m/def/Single.java g5.m.def.Single [T]\n" +
		"src/g5/m/def/Single.java void g5.m.def.Single.standard(T) [T]\n" +
		"src/g5/m/def/Single.java T g5.m.def.Single.generic(U) [T]\n" +
		"src/g5/m/def/Single.java Single<T> g5.m.def.Single.returnParamType() [T]\n" +
		"src/g5/m/def/Single.java Single<T> g5.m.def.Single.returnParamType() [T]\n" +
		"src/g5/m/def/Single.java void g5.m.def.Single.paramTypesArgs(Single<T>) [T]\n" +
		"src/g5/m/def/Single.java Single<T> g5.m.def.Single.complete(U, Single<T>) [T]\n" +
		"src/g5/m/def/Single.java Single<T> g5.m.def.Single.complete(U, Single<T>) [T]\n" +
		"src/g5/m/def/Single.java Single<T> g5.m.def.Single.complete(U, Single<T>) [T]"
	);
}
public void testTypeParameterTypes04() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.m.def", "Multiple.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "T3");
	search(typeParam, REFERENCES, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/m/def/Multiple.java void g5.m.def.Multiple.standard(T1, T2, T3) [T3]\n" +
		"src/g5/m/def/Multiple.java Multiple<T1,T2,T3> g5.m.def.Multiple.returnParamType() [T3]\n" +
		"src/g5/m/def/Multiple.java Multiple<T1,T2,T3> g5.m.def.Multiple.returnParamType() [T3]\n" +
		"src/g5/m/def/Multiple.java void g5.m.def.Multiple.paramTypesArgs(Single<T1>, Single<T2>, Single<T3>, Multiple<T1,T2,T3>) [T3]\n" +
		"src/g5/m/def/Multiple.java void g5.m.def.Multiple.paramTypesArgs(Single<T1>, Single<T2>, Single<T3>, Multiple<T1,T2,T3>) [T3]\n" +
		"src/g5/m/def/Multiple.java Multiple<T1,T2,T3> g5.m.def.Multiple.complete(U1, U2, U3, Multiple<T1,T2,T3>) [T3]\n" +
		"src/g5/m/def/Multiple.java Multiple<T1,T2,T3> g5.m.def.Multiple.complete(U1, U2, U3, Multiple<T1,T2,T3>) [T3]\n" +
		"src/g5/m/def/Multiple.java Multiple<T1,T2,T3> g5.m.def.Multiple.complete(U1, U2, U3, Multiple<T1,T2,T3>) [T3]"
	);
}
public void testTypeParameterTypes05() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.m.def", "Multiple.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "T1", 2); // return type of returnParamType() method
	search(typeParam, DECLARATIONS, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/m/def/Multiple.java g5.m.def.Multiple [T1]"
	);
}
public void testTypeParameterTypes06() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.m.def", "Multiple.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "T2", 3); // type argument of Multiple<T1,T2,T3>
	search(typeParam, ALL_OCCURRENCES, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/m/def/Multiple.java g5.m.def.Multiple [T2]\n" +
		"src/g5/m/def/Multiple.java void g5.m.def.Multiple.standard(T1, T2, T3) [T2]\n" +
		"src/g5/m/def/Multiple.java Multiple<T1,T2,T3> g5.m.def.Multiple.returnParamType() [T2]\n" +
		"src/g5/m/def/Multiple.java Multiple<T1,T2,T3> g5.m.def.Multiple.returnParamType() [T2]\n" +
		"src/g5/m/def/Multiple.java void g5.m.def.Multiple.paramTypesArgs(Single<T1>, Single<T2>, Single<T3>, Multiple<T1,T2,T3>) [T2]\n" +
		"src/g5/m/def/Multiple.java void g5.m.def.Multiple.paramTypesArgs(Single<T1>, Single<T2>, Single<T3>, Multiple<T1,T2,T3>) [T2]\n" +
		"src/g5/m/def/Multiple.java Multiple<T1,T2,T3> g5.m.def.Multiple.complete(U1, U2, U3, Multiple<T1,T2,T3>) [T2]\n" +
		"src/g5/m/def/Multiple.java Multiple<T1,T2,T3> g5.m.def.Multiple.complete(U1, U2, U3, Multiple<T1,T2,T3>) [T2]\n" +
		"src/g5/m/def/Multiple.java Multiple<T1,T2,T3> g5.m.def.Multiple.complete(U1, U2, U3, Multiple<T1,T2,T3>) [T2]"
	);
}
/*
 * Methods type parameters
 */
public void testTypeParameterMethods01() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.m.def", "Single.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "U");
	search(typeParam, REFERENCES, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/m/def/Single.java T g5.m.def.Single.generic(U) [U]"
	);
}
public void testTypeParameterMethods02() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.m.def", "Single.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "U", 2); // argument of generic method
	search(typeParam, DECLARATIONS, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/m/def/Single.java T g5.m.def.Single.generic(U) [U]"
	);
}
public void testTypeParameterMethods03() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.m.def", "Single.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "U", 4); // argument of complete method
	search(typeParam, ALL_OCCURRENCES, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/m/def/Single.java Single<T> g5.m.def.Single.complete(U, Single<T>) [U]\n" +
		"src/g5/m/def/Single.java Single<T> g5.m.def.Single.complete(U, Single<T>) [U]"
	);
}
public void testTypeParameterMethods04() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.m.def", "Multiple.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "U3", 3); // type parameter of complete method (extends)
	search(typeParam, REFERENCES, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/m/def/Multiple.java Multiple<T1,T2,T3> g5.m.def.Multiple.complete(U1, U2, U3, Multiple<T1,T2,T3>) [U3]"
	);
}
public void testTypeParameterMethods05() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.m.def", "Multiple.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "U1", 2); // argument of generic method
	search(typeParam, DECLARATIONS, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/m/def/Multiple.java T1 g5.m.def.Multiple.generic(U1, U2, U3) [U1]"
	);
}
public void testTypeParameterMethods06() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.m.def", "Multiple.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "U2", 4); // argument of complete method
	search(typeParam, ALL_OCCURRENCES, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/m/def/Multiple.java Multiple<T1,T2,T3> g5.m.def.Multiple.complete(U1, U2, U3, Multiple<T1,T2,T3>) [U2]\n" +
		"src/g5/m/def/Multiple.java Multiple<T1,T2,T3> g5.m.def.Multiple.complete(U1, U2, U3, Multiple<T1,T2,T3>) [U2]"
	);
}
/*
 * Constructors type parameters
 */
public void testTypeParameterConstructors01() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.c.def", "Single.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "U");
	search(typeParam, REFERENCES, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/c/def/Single.java g5.c.def.Single(T, U) [U]"
	);
}
public void testTypeParameterConstructors02() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.c.def", "Single.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "U");
	// TODO (frederic) use following line instead when bug 83438 will be fixed
	// ITypeParameter typeParam = selectTypeParameter(unit, "U", 2); // argument of generic method
	search(typeParam, DECLARATIONS, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/c/def/Single.java g5.c.def.Single(T, U) [U]"
	);
}
public void testTypeParameterConstructors03() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.c.def", "Single.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "U");
	// TODO (frederic) use following line instead when bug 83438 will be fixed
	//ITypeParameter typeParam = selectTypeParameter(unit, "U", 4); // argument of complete method
	search(typeParam, ALL_OCCURRENCES, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/c/def/Single.java g5.c.def.Single(T, U) [U]\n" +
		"src/g5/c/def/Single.java g5.c.def.Single(T, U) [U]"
	);
}
public void testTypeParameterConstructors04() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.c.def", "Multiple.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "U3", 3); // type parameter of complete method (extends)
	search(typeParam, REFERENCES, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/c/def/Multiple.java g5.c.def.Multiple(U1, U2, U3, Multiple<T1,T2,T3>) [U3]"
	);
}
public void testTypeParameterConstructors05() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.c.def", "Multiple.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "U1");
	// TODO (frederic) use following line instead when bug 83438 will be fixed
	//ITypeParameter typeParam = selectTypeParameter(unit, "U1", 2); // argument of generic method
	search(typeParam, DECLARATIONS, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/c/def/Multiple.java g5.c.def.Multiple(Multiple<T1,T2,T3>, U1, U2, U3) [U1]"
	);
}
public void testTypeParameterConstructors06() throws CoreException {
	ICompilationUnit unit = getCompilationUnit("JavaSearch15", "src", "g5.c.def", "Multiple.java");
	ITypeParameter typeParam = selectTypeParameter(unit, "U2", 3);
	// TODO (frederic) use following line instead when bug 83438 will be fixed
	//ITypeParameter typeParam = selectTypeParameter(unit, "U2", 4); // argument of complete method
	search(typeParam, ALL_OCCURRENCES, getJavaSearchScope15());
	assertSearchResults(
		"src/g5/c/def/Multiple.java g5.c.def.Multiple(U1, U2, U3, Multiple<T1,T2,T3>) [U2]\n" +
		"src/g5/c/def/Multiple.java g5.c.def.Multiple(U1, U2, U3, Multiple<T1,T2,T3>) [U2]"
	);
}

/**
 * Test static import
 */
// for fields
public void testStaticImportField01() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "s1.pack.age", "S.java").getType("S");
	search(type, REFERENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/s1/A.java [s1.pack.age.S]\n" +
		"src/s1/A.java [s1.pack.age.S]\n" +
		"src/s1/A.java [s1.pack.age.S]\n" +
		"src/s1/B.java [s1.pack.age.S]\n" +
		"src/s1/B.java [s1.pack.age.S]\n" +
		"src/s1/C.java [s1.pack.age.S]\n" +
		"src/s1/C.java [s1.pack.age.S]\n" +
		"src/s1/D.java [s1.pack.age.S]"
	);
}
public void testStaticImportField02() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "s1.pack.age", "S.java").getType("S");
	IField field = type.getField("out");
	search(field, REFERENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/s1/A.java [out]\n" +
		"src/s1/B.java void s1.B.foo() [out]\n" +
		"src/s1/C.java [out]\n" +
		"src/s1/C.java void s1.C.foo() [out]"
	);
}
public void testStaticImportField03() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "s1.pack.age", "S.java").getType("S");
	IType member = type.getType("M");
	search(member, REFERENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/s1/A.java [s1.pack.age.S.M]\n" +
		"src/s1/B.java [s1.pack.age.S.M]\n" +
		"src/s1/C.java [s1.pack.age.S.M]\n" +
		"src/s1/D.java [s1.pack.age.S.M]\n" +
		"src/s1/D.java void s1.D.foo() [M]\n" +
		"src/s1/D.java void s1.D.foo() [M]"
	);
}
public void testStaticImportField04() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "s1.pack.age", "S.java").getType("S");
	IType member = type.getType("M");
	IField field = member.getField("in");
	search(field, REFERENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/s1/A.java [in]\n" +
		"src/s1/B.java void s1.B.foo() [in]\n" +
		"src/s1/C.java [in]\n" +
		"src/s1/C.java void s1.C.foo() [in]\n" +
		"src/s1/D.java void s1.D.foo() [in]"
	);
}
// for methods
public void testStaticImportMethod01() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "s2.pack.age", "S.java").getType("S");
	search(type, REFERENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/s2/A.java [s2.pack.age.S]\n" +
		"src/s2/A.java [s2.pack.age.S]\n" +
		"src/s2/A.java [s2.pack.age.S]\n" +
		"src/s2/B.java [s2.pack.age.S]\n" +
		"src/s2/B.java [s2.pack.age.S]\n" +
		"src/s2/C.java [s2.pack.age.S]\n" +
		"src/s2/C.java [s2.pack.age.S]\n" +
		"src/s2/D.java [s2.pack.age.S]"
	);
}
public void testStaticImportMethod02() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "s2.pack.age", "S.java").getType("S");
	IMethod method = type.getMethod("out", new String[0]);
	search(method, REFERENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/s2/A.java [s2.pack.age.S.out]\n" +
		"src/s2/B.java void s2.B.foo() [out()]\n" +
		"src/s2/C.java [s2.pack.age.S.out]\n" +
		"src/s2/C.java void s2.C.foo() [out()]"
	);
}
public void testStaticImportMethod03() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "s2.pack.age", "S.java").getType("S");
	IType member = type.getType("M");
	search(member, REFERENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/s2/A.java [s2.pack.age.S.M]\n" +
		"src/s2/B.java [s2.pack.age.S.M]\n" +
		"src/s2/C.java [s2.pack.age.S.M]\n" +
		"src/s2/D.java [s2.pack.age.S.M]\n" +
		"src/s2/D.java void s2.D.foo() [M]\n" +
		"src/s2/D.java void s2.D.foo() [M]"
	);
}
public void testStaticImportMethod04() throws CoreException {
	IType type = getCompilationUnit("JavaSearch15", "src", "s2.pack.age", "S.java").getType("S");
	IType member = type.getType("M");
	IMethod method = member.getMethod("in", new String[0]);
	search(method, REFERENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/s2/A.java [s2.pack.age.S.M.in]\n" +
		"src/s2/B.java void s2.B.foo() [in()]\n" +
		"src/s2/C.java [s2.pack.age.S.M.in]\n" +
		"src/s2/C.java void s2.C.foo() [in()]\n" +
		"src/s2/D.java void s2.D.foo() [in()]"
	);
}
// for packages
public void testStaticImportPackage01() throws CoreException {
	IPackageFragment pkg = getPackageFragment("JavaSearch15", "src", "s1.pack.age");
	search(pkg, REFERENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/s1/A.java [s1.pack.age]\n" +
		"src/s1/A.java [s1.pack.age]\n" +
		"src/s1/A.java [s1.pack.age]\n" +
		"src/s1/B.java [s1.pack.age]\n" +
		"src/s1/B.java [s1.pack.age]\n" +
		"src/s1/C.java [s1.pack.age]\n" +
		"src/s1/C.java [s1.pack.age]\n" +
		"src/s1/D.java [s1.pack.age]"
	);
}
public void testStaticImportPackage02() throws CoreException {
	IPackageFragment pkg = getPackageFragment("JavaSearch15", "src", "s2.pack.age");
	search(pkg, REFERENCES, getJavaSearchScope15(), this.resultCollector);
	assertSearchResults(
		"src/s2/A.java [s2.pack.age]\n" +
		"src/s2/A.java [s2.pack.age]\n" +
		"src/s2/A.java [s2.pack.age]\n" +
		"src/s2/B.java [s2.pack.age]\n" +
		"src/s2/B.java [s2.pack.age]\n" +
		"src/s2/C.java [s2.pack.age]\n" +
		"src/s2/C.java [s2.pack.age]\n" +
		"src/s2/D.java [s2.pack.age]"
	);
}

/**
 * @test Bug 110060: [plan][search] Add support for Camel Case search pattern
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=110060"
 *
 * These tests are not really duplicates of {@link JavaSearchBugsTests} ones
 * as they also test camel case in indexes...
 */
public void testCamelCaseTypePattern01_CamelCase() throws CoreException {
	search("RE", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH);
	assertSearchResults(
		"src/a3/References.java a3.References [References]\n" +
		""+ getExternalJCLPathString() + " java.lang.RuntimeException"
	);
}
public void testCamelCaseTypePattern02_CamelCase() throws CoreException {
	search("RException", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH);
	assertSearchResults(
		""+ getExternalJCLPathString() + " java.lang.RuntimeException"
	);
}
public void testCamelCaseTypePattern03_CamelCase() throws CoreException {
	search("RuntimeException", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH);
	assertSearchResults(
		""+ getExternalJCLPathString() + " java.lang.RuntimeException"
	);
}
public void testCamelCaseTypePattern04_CamelCase() throws CoreException {
	search("RUNTIMEEXCEPTION", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH);
	assertSearchResults(
		""+ getExternalJCLPathString() + " java.lang.RuntimeException"
	);
}
public void testCamelCaseTypePattern05_CamelCase() throws CoreException {
	search("R*E*", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH);
	assertSearchResults(
		"src/a3/References.java a3.References [References]\n" +
		""+ getExternalJCLPathString() + " java.lang.RuntimeException"
	);
}
public void testCamelCaseTypePattern06_CamelCase() throws CoreException {
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
	searchAllTypeNames("CNS", SearchPattern.R_CAMELCASE_MATCH, requestor);
	assertSearchResults(
		"Unexpected all type names",
		"java.lang.CloneNotSupportedException",
		requestor);
}
public void testCamelCaseTypePattern07_CamelCase() throws CoreException {
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
	searchAllTypeNames("AA", SearchPattern.R_CAMELCASE_MATCH, requestor);
	assertSearchResults(
		"Unexpected all type names",
		"AA\n" +
		"c9.AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyz\n" +
		"d8.AA\n" +
		"p6.AA\n" +
		"q1.AA",
		requestor);
}
public void testCamelCaseTypePattern08_CamelCase() throws CoreException {
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
	searchAllTypeNames("aa", SearchPattern.R_CAMELCASE_MATCH, requestor);
	assertSearchResults(
		"Unexpected all type names",
		"AA\n" +
		"d8.AA\n" +
		"p6.AA\n" +
		"q1.AA",
		requestor);
}
public void testCamelCaseTypePattern09_CamelCase() throws CoreException {
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
	searchAllTypeNames("aa", SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_PREFIX_MATCH, requestor);
	assertSearchResults(
		"Unexpected all type names",
		"AA\n" +
		"d8.AA\n" +
		"p6.AA\n" +
		"q1.AA",
		requestor);
}
public void testCamelCaseTypePattern10_CamelCase() throws CoreException {
	this.workingCopies = new ICompilationUnit[1];
	this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/Test.java",
		"class Null {}\n" +
		"class NULL {}\n" +
		"class NullPointerException {}\n" +
		"class Nullpointerexception {}\n" +
		"class NULLPointerException {}\n" +
		"class NULLPOINTERException {}\n" +
		"class NULLPOINTEREXCEPTION {}\n"
	);
	search("Null", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH);
	assertSearchResults(
		"src/Test.java Null [Null]\n" +
		"src/Test.java NULL [NULL]\n" +
		"src/Test.java NullPointerException [NullPointerException]\n" +
		"src/Test.java Nullpointerexception [Nullpointerexception]\n" +
		"src/Test.java NULLPointerException [NULLPointerException]\n" +
		"src/Test.java NULLPOINTERException [NULLPOINTERException]\n" +
		"src/Test.java NULLPOINTEREXCEPTION [NULLPOINTEREXCEPTION]"
	);
}
public void testCamelCaseTypePattern11_CamelCase() throws CoreException {
	this.workingCopies = new ICompilationUnit[1];
	this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/Test.java",
		"class Null {}\n" +
		"class NULL {}\n" +
		"class NullPointerException {}\n" +
		"class Nullpointerexception {}\n" +
		"class NULLPointerException {}\n" +
		"class NULLPOINTERException {}\n" +
		"class NULLPOINTEREXCEPTION {}\n"
	);
	search("Null", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_PREFIX_MATCH);
	assertSearchResults(
		"src/Test.java Null [Null]\n" +
		"src/Test.java NULL [NULL]\n" +
		"src/Test.java NullPointerException [NullPointerException]\n" +
		"src/Test.java Nullpointerexception [Nullpointerexception]\n" +
		"src/Test.java NULLPointerException [NULLPointerException]\n" +
		"src/Test.java NULLPOINTERException [NULLPOINTERException]\n" +
		"src/Test.java NULLPOINTEREXCEPTION [NULLPOINTEREXCEPTION]"
	);
}
public void testCamelCaseTypePattern12_CamelCase() throws CoreException {
	this.workingCopies = new ICompilationUnit[1];
	this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/Test.java",
		"class Null {}\n" +
		"class NULL {}\n" +
		"class NullPointerException {}\n" +
		"class Nullpointerexception {}\n" +
		"class NULLPointerException {}\n" +
		"class NULLPOINTERException {}\n" +
		"class NULLPOINTEREXCEPTION {}\n"
	);
	search("Null", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CASE_SENSITIVE);
	assertSearchResults(
		"src/Test.java Null [Null]\n" +
		"src/Test.java NullPointerException [NullPointerException]\n" +
		"src/Test.java Nullpointerexception [Nullpointerexception]"
	);
}
public void testCamelCaseTypePattern13_CamelCase() throws CoreException {
	this.workingCopies = new ICompilationUnit[1];
	this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/Test.java",
		"class Null {}\n" +
		"class NULL {}\n" +
		"class NullPointerException {}\n" +
		"class Nullpointerexception {}\n" +
		"class NULLPointerException {}\n" +
		"class NULLPOINTERException {}\n" +
		"class NULLPOINTEREXCEPTION {}\n"
	);
	search("Null", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE);
	assertSearchResults(
		"src/Test.java Null [Null]\n" +
		"src/Test.java NullPointerException [NullPointerException]\n" +
		"src/Test.java Nullpointerexception [Nullpointerexception]"
	);
}
// Same tests using SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH instead
public void testCamelCaseTypePattern01_CamelCaseSamePartCount() throws CoreException {
	search("RE", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH);
	assertSearchResults(
		""+ getExternalJCLPathString() + " java.lang.RuntimeException"
	);
}
public void testCamelCaseTypePattern02_CamelCaseSamePartCount() throws CoreException {
	search("RException", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH);
	assertSearchResults(
		""+ getExternalJCLPathString() + " java.lang.RuntimeException"
	);
}
public void testCamelCaseTypePattern03_CamelCaseSamePartCount() throws CoreException {
	search("RuntimeException", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH);
	assertSearchResults(
		""+ getExternalJCLPathString() + " java.lang.RuntimeException"
	);
}
public void testCamelCaseTypePattern04_CamelCaseSamePartCount() throws CoreException {
	search("RUNTIMEEXCEPTION", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH);
	assertSearchResults("");
}
public void testCamelCaseTypePattern05_CamelCaseSamePartCount() throws CoreException {
	search("R*E*", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH);
	assertSearchResults(
		"src/a3/References.java a3.References [References]\n" +
		""+ getExternalJCLPathString() + " java.lang.RuntimeException"
	);
}
public void testCamelCaseTypePattern06_CamelCaseSamePartCount() throws CoreException {
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
	searchAllTypeNames("CNS", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH, requestor);
	assertSearchResults(
		"Unexpected all type names",
		"",
		requestor);
}
public void testCamelCaseTypePattern07_CamelCaseSamePartCount() throws CoreException {
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
	searchAllTypeNames("AA", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH, requestor);
	assertSearchResults(
		"Unexpected all type names",
		"AA\n" +
		"d8.AA\n" +
		"p6.AA\n" +
		"q1.AA",
		requestor);
}
public void testCamelCaseTypePattern08_CamelCaseSamePartCount() throws CoreException {
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
	searchAllTypeNames("aa", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH, requestor);
	assertSearchResults(
		"Unexpected all type names",
		"AA\n" +
		"d8.AA\n" +
		"p6.AA\n" +
		"q1.AA",
		requestor);
}
public void testCamelCaseTypePattern09_CamelCaseSamePartCount() throws CoreException {
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
	searchAllTypeNames("aa", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern.R_PREFIX_MATCH, requestor);
	assertSearchResults(
		"Unexpected all type names",
		"AA\n" +
		"d8.AA\n" +
		"p6.AA\n" +
		"q1.AA",
		requestor);
}
public void testCamelCaseTypePattern10_CamelCaseSamePartCount() throws CoreException {
	this.workingCopies = new ICompilationUnit[1];
	this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/Test.java",
		"class Null {}\n" +
		"class NULL {}\n" +
		"class NullPointerException {}\n" +
		"class Nullpointerexception {}\n" +
		"class NULLPointerException {}\n" +
		"class NULLPOINTERException {}\n" +
		"class NULLPOINTEREXCEPTION {}\n"
	);
	search("Null", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH);
	assertSearchResults(
		"src/Test.java Null [Null]\n" +
		"src/Test.java NULL [NULL]"
	);
}
public void testCamelCaseTypePattern11_CamelCaseSamePartCount() throws CoreException {
	this.workingCopies = new ICompilationUnit[1];
	this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/Test.java",
		"class Null {}\n" +
		"class NULL {}\n" +
		"class NullPointerException {}\n" +
		"class Nullpointerexception {}\n" +
		"class NULLPointerException {}\n" +
		"class NULLPOINTERException {}\n" +
		"class NULLPOINTEREXCEPTION {}\n"
	);
	search("Null", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern.R_PREFIX_MATCH);
	assertSearchResults(
		"src/Test.java Null [Null]\n" +
		"src/Test.java NULL [NULL]"
	);
}
public void testCamelCaseTypePattern12_CamelCaseSamePartCount() throws CoreException {
	this.workingCopies = new ICompilationUnit[1];
	this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/Test.java",
		"class Null {}\n" +
		"class NULL {}\n" +
		"class NullPointerException {}\n" +
		"class Nullpointerexception {}\n" +
		"class NULLPointerException {}\n" +
		"class NULLPOINTERException {}\n" +
		"class NULLPOINTEREXCEPTION {}\n"
	);
	search("Null", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern.R_CASE_SENSITIVE);
	assertSearchResults(
		"src/Test.java Null [Null]"
	);
}
public void testCamelCaseTypePattern13_CamelCaseSamePartCount() throws CoreException {
	this.workingCopies = new ICompilationUnit[1];
	this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/Test.java",
		"class Null {}\n" +
		"class NULL {}\n" +
		"class NullPointerException {}\n" +
		"class Nullpointerexception {}\n" +
		"class NULLPointerException {}\n" +
		"class NULLPOINTERException {}\n" +
		"class NULLPOINTEREXCEPTION {}\n"
	);
	search("Null", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE);
	assertSearchResults(
		"src/Test.java Null [Null]"
	);
}

/**
 * @bug 160323: [search] TypeNameMatch: support hashCode/equals
 * @test Ensure that match equals and hashCode methods return same values than those of stored {@link IType}.
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=160323"
 */
public void testBug160323() throws CoreException {
	// Search all type names with TypeNameMatchRequestor
	TypeNameMatchCollector collector = new TypeNameMatchCollector() {
		public String toString(){
			return toFullyQualifiedNamesString();
		}
	};
	new SearchEngine().searchAllTypeNames(
		null,
		SearchPattern.R_EXACT_MATCH,
		null,
		SearchPattern.R_PREFIX_MATCH,
		IJavaSearchConstants.TYPE,
		getJavaSearchScope(),
		collector,
		IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
		null);
	// Search all type names with TypeNameRequestor
	SearchTests.SearchTypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor();
	new SearchEngine().searchAllTypeNames(
		null,
		SearchPattern.R_EXACT_MATCH,
		null,
		SearchPattern.R_PREFIX_MATCH,
		IJavaSearchConstants.TYPE,
		getJavaSearchScope(),
		requestor,
		IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
		null);
	// Should have same types with these 2 searches
	assertEquals("Found types sounds not to be correct", requestor.toString(), collector.toString());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383908
public void testBug383908() throws CoreException {
	try {
		String fileContent = "package p;\n" +
								"public class X {\n" +
								"  public void foobar(X this, String str) {\n" +
								"  }\n" +
								"}";
		createJavaProject("P", new String[] {"src"}, new String[0], "bin");
		createFolder("/P/src/p");
		createFile("/P/src/p/X.java", fileContent);

		IType type = getCompilationUnit("P", "src", "p", "X.java").getType("X");
		IMethod[] methods = type.getMethods();
		search(
				methods[0],
				DECLARATIONS,
				SearchEngine.createJavaSearchScope(new IJavaElement[] {type}),
				this.resultCollector);

		assertSearchResults(
				"src/p/X.java void p.X.foobar(String) [foobar]",
				this.resultCollector);

	} finally {
		deleteProject("P");
	}
}

}

Back to the top