Lines 10-17
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.core.tests.model; |
11 |
package org.eclipse.jdt.core.tests.model; |
12 |
|
12 |
|
13 |
import org.eclipse.jdt.core.*; |
13 |
import java.io.File; |
|
|
14 |
import java.util.HashMap; |
14 |
|
15 |
|
|
|
16 |
import org.eclipse.jdt.core.*; |
17 |
import org.eclipse.jdt.core.tests.util.Util; |
15 |
import junit.framework.*; |
18 |
import junit.framework.*; |
16 |
|
19 |
|
17 |
public class ResolveTests2 extends ModifyingResourceTests { |
20 |
public class ResolveTests2 extends ModifyingResourceTests { |
Lines 68-74
Link Here
|
68 |
|
71 |
|
69 |
assertElementsEqual( |
72 |
assertElementsEqual( |
70 |
"Unexpected elements", |
73 |
"Unexpected elements", |
71 |
"", |
74 |
"Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + "]]]", // Object is found in another project with Object on his classpath |
72 |
elements |
75 |
elements |
73 |
); |
76 |
); |
74 |
} finally { |
77 |
} finally { |
Lines 192-195
Link Here
|
192 |
this.deleteProject("P1"); |
195 |
this.deleteProject("P1"); |
193 |
} |
196 |
} |
194 |
} |
197 |
} |
|
|
198 |
|
199 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=232880 |
200 |
public void testBug232880a() throws Exception { |
201 |
String outputDirectory = Util.getOutputDirectory(); |
202 |
String externalJar1 = outputDirectory + File.separator + "bug232880a.jar"; //$NON-NLS-1$ |
203 |
String externalJar2 = outputDirectory + File.separator + "bug232880b.jar"; //$NON-NLS-1$ |
204 |
try { |
205 |
|
206 |
// create external jar 1 |
207 |
Util.createJar( |
208 |
new String[] { |
209 |
"test1/IResource.java", //$NON-NLS-1$ |
210 |
"package test1;\n" + //$NON-NLS-1$ |
211 |
"public class IResource {\n" + //$NON-NLS-1$ |
212 |
"}" //$NON-NLS-1$ |
213 |
}, |
214 |
new HashMap(), |
215 |
externalJar1); |
216 |
|
217 |
// create external jar 2 |
218 |
String source2 = |
219 |
"package test2;\n" + //$NON-NLS-1$ |
220 |
"import test1.IResource;\n" + //$NON-NLS-1$ |
221 |
"public class IJavaElement {\n" + //$NON-NLS-1$ |
222 |
" IResource foo() {return null;}\n" + //$NON-NLS-1$ |
223 |
"}"; //$NON-NLS-1$ |
224 |
|
225 |
Util.createJar( |
226 |
new String[] { |
227 |
"test2/IJavaElement.java", //$NON-NLS-1$ |
228 |
source2 |
229 |
}, |
230 |
null, |
231 |
new HashMap(), |
232 |
new String[]{externalJar1}, |
233 |
externalJar2); |
234 |
|
235 |
// create P1 |
236 |
IJavaProject project1 = this.createJavaProject( |
237 |
"PS1", |
238 |
new String[]{"src"}, |
239 |
new String[]{"JCL_LIB", externalJar1, externalJar2}, |
240 |
"bin"); |
241 |
|
242 |
this.createFolder("/PS1/attachment/test2"); |
243 |
this.createFile( |
244 |
"/PS1/attachment/test2/IJavaElement.java", |
245 |
source2); |
246 |
|
247 |
IPackageFragmentRoot root = project1.getPackageFragmentRoot(externalJar2); |
248 |
attachSource(root, "/PS1/attachment/", ""); |
249 |
|
250 |
waitUntilIndexesReady(); |
251 |
|
252 |
// do code select |
253 |
IClassFile cf = getClassFile("PS1", externalJar2, "test2", "IJavaElement.class"); |
254 |
|
255 |
IJavaElement[] elements = codeSelect(cf, "IResource foo", "IResource"); |
256 |
|
257 |
assertElementsEqual( |
258 |
"Unexpected elements", |
259 |
"IResource [in IResource.class [in test1 [in "+outputDirectory + File.separator+"bug232880a.jar]]]", |
260 |
elements |
261 |
); |
262 |
} finally { |
263 |
this.deleteExternalFile(externalJar1); |
264 |
this.deleteExternalFile(externalJar2); |
265 |
refreshExternalArchives(getJavaProject("PS1")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
266 |
this.deleteProject("PS1"); |
267 |
} |
268 |
} |
269 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=232880 |
270 |
public void testBug232880b() throws Exception { |
271 |
String outputDirectory = Util.getOutputDirectory(); |
272 |
String externalJar1 = outputDirectory + File.separator + "bug232880a.jar"; //$NON-NLS-1$ |
273 |
String externalJar2 = outputDirectory + File.separator + "bug232880b.jar"; //$NON-NLS-1$ |
274 |
try { |
275 |
|
276 |
// create external jar 1 |
277 |
Util.createJar( |
278 |
new String[] { |
279 |
"test1/IResource.java", //$NON-NLS-1$ |
280 |
"package test1;\n" + //$NON-NLS-1$ |
281 |
"public class IResource {\n" + //$NON-NLS-1$ |
282 |
"}" //$NON-NLS-1$ |
283 |
}, |
284 |
new HashMap(), |
285 |
externalJar1); |
286 |
|
287 |
// create external jar 2 |
288 |
String source2 = |
289 |
"package test2;\n" + //$NON-NLS-1$ |
290 |
"import test1.IResource;\n" + //$NON-NLS-1$ |
291 |
"public class IJavaElement {\n" + //$NON-NLS-1$ |
292 |
" IResource foo() {return null;}\n" + //$NON-NLS-1$ |
293 |
"}"; //$NON-NLS-1$ |
294 |
|
295 |
Util.createJar( |
296 |
new String[] { |
297 |
"test2/IJavaElement.java", //$NON-NLS-1$ |
298 |
source2 |
299 |
}, |
300 |
null, |
301 |
new HashMap(), |
302 |
new String[]{externalJar1}, |
303 |
externalJar2); |
304 |
|
305 |
// create P1 |
306 |
IJavaProject project1 = this.createJavaProject( |
307 |
"PS1", |
308 |
new String[]{"src"}, |
309 |
new String[]{"JCL_LIB", externalJar2}, |
310 |
"bin"); |
311 |
|
312 |
this.createFolder("/PS1/attachment/test2"); |
313 |
this.createFile( |
314 |
"/PS1/attachment/test2/IJavaElement.java", |
315 |
source2); |
316 |
|
317 |
IPackageFragmentRoot root = project1.getPackageFragmentRoot(externalJar2); |
318 |
attachSource(root, "/PS1/attachment/", ""); |
319 |
|
320 |
waitUntilIndexesReady(); |
321 |
|
322 |
// do code select |
323 |
IClassFile cf = getClassFile("PS1", externalJar2, "test2", "IJavaElement.class"); |
324 |
|
325 |
IJavaElement[] elements = codeSelect(cf, "IResource foo", "IResource"); |
326 |
|
327 |
assertElementsEqual( |
328 |
"Unexpected elements", |
329 |
"", |
330 |
elements |
331 |
); |
332 |
} finally { |
333 |
this.deleteExternalFile(externalJar1); |
334 |
this.deleteExternalFile(externalJar2); |
335 |
refreshExternalArchives(getJavaProject("PS1")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
336 |
this.deleteProject("PS1"); |
337 |
} |
338 |
} |
339 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=232880 |
340 |
public void testBug232880c() throws Exception { |
341 |
String outputDirectory = Util.getOutputDirectory(); |
342 |
String externalJar1 = outputDirectory + File.separator + "bug232880a.jar"; //$NON-NLS-1$ |
343 |
String externalJar2 = outputDirectory + File.separator + "bug232880b.jar"; //$NON-NLS-1$ |
344 |
try { |
345 |
|
346 |
// create external jar 1 |
347 |
Util.createJar( |
348 |
new String[] { |
349 |
"test1/IResource.java", //$NON-NLS-1$ |
350 |
"package test1;\n" + //$NON-NLS-1$ |
351 |
"public class IResource {\n" + //$NON-NLS-1$ |
352 |
"}" //$NON-NLS-1$ |
353 |
}, |
354 |
new HashMap(), |
355 |
externalJar1); |
356 |
|
357 |
// create external jar 2 |
358 |
String source2 = |
359 |
"package test2;\n" + //$NON-NLS-1$ |
360 |
"import test1.IResource;\n" + //$NON-NLS-1$ |
361 |
"public class IJavaElement {\n" + //$NON-NLS-1$ |
362 |
" IResource foo() {return null;}\n" + //$NON-NLS-1$ |
363 |
"}"; //$NON-NLS-1$ |
364 |
|
365 |
Util.createJar( |
366 |
new String[] { |
367 |
"test2/IJavaElement.java", //$NON-NLS-1$ |
368 |
source2 |
369 |
}, |
370 |
null, |
371 |
new HashMap(), |
372 |
new String[]{externalJar1}, |
373 |
externalJar2); |
374 |
|
375 |
// create P1 |
376 |
IJavaProject project1 = this.createJavaProject( |
377 |
"PS1", |
378 |
new String[]{"src"}, |
379 |
new String[]{"JCL_LIB", externalJar2}, |
380 |
"bin"); |
381 |
|
382 |
this.createFolder("/PS1/attachment/test2"); |
383 |
this.createFile( |
384 |
"/PS1/attachment/test2/IJavaElement.java", |
385 |
source2); |
386 |
|
387 |
IPackageFragmentRoot root = project1.getPackageFragmentRoot(externalJar2); |
388 |
attachSource(root, "/PS1/attachment/", ""); |
389 |
|
390 |
// create P2 |
391 |
this.createJavaProject( |
392 |
"PS2", |
393 |
new String[]{"src"}, |
394 |
new String[]{"JCL_LIB", externalJar1}, |
395 |
"bin"); |
396 |
|
397 |
waitUntilIndexesReady(); |
398 |
|
399 |
// do code select |
400 |
IClassFile cf = getClassFile("PS1", externalJar2, "test2", "IJavaElement.class"); |
401 |
|
402 |
IJavaElement[] elements = codeSelect(cf, "IResource foo", "IResource"); |
403 |
|
404 |
assertElementsEqual( |
405 |
"Unexpected elements", |
406 |
"IResource [in IResource.class [in test1 [in "+outputDirectory+File.separator+"bug232880a.jar]]]", |
407 |
elements |
408 |
); |
409 |
} finally { |
410 |
this.deleteExternalFile(externalJar1); |
411 |
this.deleteExternalFile(externalJar2); |
412 |
refreshExternalArchives(getJavaProject("PS1")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
413 |
refreshExternalArchives(getJavaProject("PS2")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
414 |
this.deleteProject("PS1"); |
415 |
this.deleteProject("PS2"); |
416 |
} |
417 |
} |
418 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=232880 |
419 |
public void testBug232880d() throws Exception { |
420 |
String outputDirectory = Util.getOutputDirectory(); |
421 |
String externalJar1 = outputDirectory + File.separator + "bug232880a.jar"; //$NON-NLS-1$ |
422 |
String externalJar2 = outputDirectory + File.separator + "bug232880b.jar"; //$NON-NLS-1$ |
423 |
try { |
424 |
|
425 |
// create external jar 1 |
426 |
String source1 = |
427 |
"package test1;\n" + //$NON-NLS-1$ |
428 |
"public class IResource {\n" + //$NON-NLS-1$ |
429 |
"}"; //$NON-NLS-1$ |
430 |
|
431 |
Util.createJar( |
432 |
new String[] { |
433 |
"test1/IResource.java", //$NON-NLS-1$ |
434 |
source1 |
435 |
}, |
436 |
new HashMap(), |
437 |
externalJar1); |
438 |
|
439 |
// create external jar 2 |
440 |
String source2 = |
441 |
"package test2;\n" + //$NON-NLS-1$ |
442 |
"import test1.IResource;\n" + //$NON-NLS-1$ |
443 |
"public class IJavaElement {\n" + //$NON-NLS-1$ |
444 |
" IResource foo() {return null;}\n" + //$NON-NLS-1$ |
445 |
"}"; //$NON-NLS-1$ |
446 |
|
447 |
Util.createJar( |
448 |
new String[] { |
449 |
"test2/IJavaElement.java", //$NON-NLS-1$ |
450 |
source2 |
451 |
}, |
452 |
null, |
453 |
new HashMap(), |
454 |
new String[]{externalJar1}, |
455 |
externalJar2); |
456 |
|
457 |
// create P1 |
458 |
IJavaProject project1 = this.createJavaProject( |
459 |
"PS1", |
460 |
new String[]{"src"}, |
461 |
new String[]{"JCL_LIB", externalJar2}, |
462 |
"bin"); |
463 |
|
464 |
this.createFolder("/PS1/attachment/test2"); |
465 |
this.createFile( |
466 |
"/PS1/attachment/test2/IJavaElement.java", |
467 |
source2); |
468 |
|
469 |
IPackageFragmentRoot root = project1.getPackageFragmentRoot(externalJar2); |
470 |
attachSource(root, "/PS1/attachment/", ""); |
471 |
|
472 |
// create P2 |
473 |
this.createJavaProject( |
474 |
"PS2", |
475 |
new String[]{"src"}, |
476 |
new String[]{"JCL_LIB"}, |
477 |
"bin"); |
478 |
|
479 |
this.createFolder("/PS2/src/test1"); |
480 |
this.createFile( |
481 |
"/PS2/src/test1/IResource.java", |
482 |
source1); |
483 |
|
484 |
waitUntilIndexesReady(); |
485 |
|
486 |
// do code select |
487 |
IClassFile cf = getClassFile("PS1", externalJar2, "test2", "IJavaElement.class"); |
488 |
|
489 |
IJavaElement[] elements = codeSelect(cf, "IResource foo", "IResource"); |
490 |
|
491 |
assertElementsEqual( |
492 |
"Unexpected elements", |
493 |
"IResource [in IResource.java [in test1 [in src [in PS2]]]]", |
494 |
elements |
495 |
); |
496 |
} finally { |
497 |
this.deleteExternalFile(externalJar1); |
498 |
this.deleteExternalFile(externalJar2); |
499 |
refreshExternalArchives(getJavaProject("PS1")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
500 |
refreshExternalArchives(getJavaProject("PS2")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
501 |
this.deleteProject("PS1"); |
502 |
this.deleteProject("PS2"); |
503 |
} |
504 |
} |
505 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=232880 |
506 |
public void testBug232880e() throws Exception { |
507 |
String outputDirectory = Util.getOutputDirectory(); |
508 |
String externalJar1 = outputDirectory + File.separator + "bug232880a.jar"; //$NON-NLS-1$ |
509 |
String externalJar2 = outputDirectory + File.separator + "bug232880b.jar"; //$NON-NLS-1$ |
510 |
try { |
511 |
|
512 |
// create external jar 1 |
513 |
String source1_1 = |
514 |
"package test1;\n" + //$NON-NLS-1$ |
515 |
"public class CoreException extends Exception {\n" + //$NON-NLS-1$ |
516 |
"}"; //$NON-NLS-1$ |
517 |
|
518 |
String source1_2 = |
519 |
"package test1;\n" + //$NON-NLS-1$ |
520 |
"public class IResource {\n" + //$NON-NLS-1$ |
521 |
"}"; //$NON-NLS-1$ |
522 |
|
523 |
Util.createJar( |
524 |
new String[] { |
525 |
"test1/CoreException.java", //$NON-NLS-1$ |
526 |
source1_1, |
527 |
"test1/IResource.java", //$NON-NLS-1$ |
528 |
source1_2 |
529 |
}, |
530 |
new HashMap(), |
531 |
externalJar1); |
532 |
|
533 |
// create external jar 2 |
534 |
String source2_1 = |
535 |
"package test2;\n" + //$NON-NLS-1$ |
536 |
"import test1.CoreException;\n" + //$NON-NLS-1$ |
537 |
"public class JavaModelException extends CoreException {\n" + //$NON-NLS-1$ |
538 |
"}"; //$NON-NLS-1$ |
539 |
|
540 |
String source2_2 = |
541 |
"package test2;\n" + //$NON-NLS-1$ |
542 |
"import test1.IResource;\n" + //$NON-NLS-1$ |
543 |
"public class IJavaElement {\n" + //$NON-NLS-1$ |
544 |
" void foo1() throws JavaModelException {}\n" + //$NON-NLS-1$ |
545 |
" IResource foo2() {return null;}\n" + //$NON-NLS-1$ |
546 |
"}"; //$NON-NLS-1$ |
547 |
|
548 |
Util.createJar( |
549 |
new String[] { |
550 |
"test2/JavaModelException.java", //$NON-NLS-1$ |
551 |
source2_1, |
552 |
"test2/IJavaElement.java", //$NON-NLS-1$ |
553 |
source2_2 |
554 |
}, |
555 |
null, |
556 |
new HashMap(), |
557 |
new String[]{externalJar1}, |
558 |
externalJar2); |
559 |
|
560 |
// create P1 |
561 |
IJavaProject project1 = this.createJavaProject( |
562 |
"PS1", |
563 |
new String[]{"src"}, |
564 |
new String[]{"JCL_LIB", externalJar2}, |
565 |
"bin"); |
566 |
|
567 |
this.createFolder("/PS1/attachment/test2"); |
568 |
this.createFile( |
569 |
"/PS1/attachment/test2/IJavaElement.java", |
570 |
source2_2); |
571 |
|
572 |
IPackageFragmentRoot root = project1.getPackageFragmentRoot(externalJar2); |
573 |
attachSource(root, "/PS1/attachment/", ""); |
574 |
|
575 |
// create P2 |
576 |
this.createJavaProject( |
577 |
"PS2", |
578 |
new String[]{"src"}, |
579 |
new String[]{"JCL_LIB"}, |
580 |
"bin"); |
581 |
|
582 |
this.createFolder("/PS2/src/test1"); |
583 |
this.createFile( |
584 |
"/PS2/src/test1/IResource.java", |
585 |
source1_2); |
586 |
|
587 |
waitUntilIndexesReady(); |
588 |
|
589 |
// do code select |
590 |
IClassFile cf = getClassFile("PS1", externalJar2, "test2", "IJavaElement.class"); |
591 |
|
592 |
IJavaElement[] elements = codeSelect(cf, "IResource foo", "IResource"); |
593 |
|
594 |
assertElementsEqual( |
595 |
"Unexpected elements", |
596 |
"IResource [in IResource.java [in test1 [in src [in PS2]]]]", |
597 |
elements |
598 |
); |
599 |
} finally { |
600 |
this.deleteExternalFile(externalJar1); |
601 |
this.deleteExternalFile(externalJar2); |
602 |
refreshExternalArchives(getJavaProject("PS1")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
603 |
refreshExternalArchives(getJavaProject("PS2")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
604 |
this.deleteProject("PS1"); |
605 |
this.deleteProject("PS2"); |
606 |
} |
607 |
} |
608 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=232880 |
609 |
public void testBug232880f() throws Exception { |
610 |
String outputDirectory = Util.getOutputDirectory(); |
611 |
String externalJar1 = outputDirectory + File.separator + "bug232880a.jar"; //$NON-NLS-1$ |
612 |
String externalJar2 = outputDirectory + File.separator + "bug232880b.jar"; //$NON-NLS-1$ |
613 |
try { |
614 |
|
615 |
// create external jar 1 |
616 |
Util.createJar( |
617 |
new String[] { |
618 |
"test1/IResource.java", //$NON-NLS-1$ |
619 |
"package test1;\n" + //$NON-NLS-1$ |
620 |
"public class IResource {\n" + //$NON-NLS-1$ |
621 |
"}", //$NON-NLS-1$ |
622 |
"test2/IResource.java", //$NON-NLS-1$ |
623 |
"package test2;\n" + //$NON-NLS-1$ |
624 |
"public class IResource {\n" + //$NON-NLS-1$ |
625 |
"}" //$NON-NLS-1$ |
626 |
}, |
627 |
new HashMap(), |
628 |
externalJar1); |
629 |
|
630 |
// create external jar 2 |
631 |
String source2 = |
632 |
"package test3;\n" + //$NON-NLS-1$ |
633 |
"import test2.IResource;\n" + //$NON-NLS-1$ |
634 |
"public class IJavaElement {\n" + //$NON-NLS-1$ |
635 |
" IResource foo() {return null;}\n" + //$NON-NLS-1$ |
636 |
"}"; //$NON-NLS-1$ |
637 |
|
638 |
Util.createJar( |
639 |
new String[] { |
640 |
"test3/IJavaElement.java", //$NON-NLS-1$ |
641 |
source2 |
642 |
}, |
643 |
null, |
644 |
new HashMap(), |
645 |
new String[]{externalJar1}, |
646 |
externalJar2); |
647 |
|
648 |
// create P1 |
649 |
IJavaProject project1 = this.createJavaProject( |
650 |
"PS1", |
651 |
new String[]{"src"}, |
652 |
new String[]{"JCL_LIB", externalJar2}, |
653 |
"bin"); |
654 |
|
655 |
this.createFolder("/PS1/attachment/test3"); |
656 |
this.createFile( |
657 |
"/PS1/attachment/test3/IJavaElement.java", |
658 |
source2); |
659 |
|
660 |
IPackageFragmentRoot root = project1.getPackageFragmentRoot(externalJar2); |
661 |
attachSource(root, "/PS1/attachment/", ""); |
662 |
|
663 |
// create P2 |
664 |
this.createJavaProject( |
665 |
"PS2", |
666 |
new String[]{"src"}, |
667 |
new String[]{"JCL_LIB", externalJar1}, |
668 |
"bin"); |
669 |
|
670 |
waitUntilIndexesReady(); |
671 |
|
672 |
// do code select |
673 |
IClassFile cf = getClassFile("PS1", externalJar2, "test3", "IJavaElement.class"); |
674 |
|
675 |
IJavaElement[] elements = codeSelect(cf, "IResource foo", "IResource"); |
676 |
|
677 |
assertElementsEqual( |
678 |
"Unexpected elements", |
679 |
"IResource [in IResource.class [in test2 [in "+outputDirectory+File.separator+"bug232880a.jar]]]", |
680 |
elements |
681 |
); |
682 |
} finally { |
683 |
this.deleteExternalFile(externalJar1); |
684 |
this.deleteExternalFile(externalJar2); |
685 |
refreshExternalArchives(getJavaProject("PS1")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
686 |
refreshExternalArchives(getJavaProject("PS2")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
687 |
this.deleteProject("PS1"); |
688 |
this.deleteProject("PS2"); |
689 |
} |
690 |
} |
691 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=232880 |
692 |
public void testBug232880g() throws Exception { |
693 |
String outputDirectory = Util.getOutputDirectory(); |
694 |
String externalJar1 = outputDirectory + File.separator + "bug232880a.jar"; //$NON-NLS-1$ |
695 |
String externalJar2 = outputDirectory + File.separator + "bug232880b.jar"; //$NON-NLS-1$ |
696 |
try { |
697 |
|
698 |
// create external jar 1 |
699 |
Util.createJar( |
700 |
new String[] { |
701 |
"test1/IResource.java", //$NON-NLS-1$ |
702 |
"package test1;\n" + //$NON-NLS-1$ |
703 |
"public class IResource {\n" + //$NON-NLS-1$ |
704 |
"}", //$NON-NLS-1$ |
705 |
"test2/IResource.java", //$NON-NLS-1$ |
706 |
"package test2;\n" + //$NON-NLS-1$ |
707 |
"public class IResource {\n" + //$NON-NLS-1$ |
708 |
"}" //$NON-NLS-1$ |
709 |
}, |
710 |
new HashMap(), |
711 |
externalJar1); |
712 |
|
713 |
// create external jar 2 |
714 |
String source2 = |
715 |
"package test3;\n" + //$NON-NLS-1$ |
716 |
"import test2.*;\n" + //$NON-NLS-1$ |
717 |
"public class IJavaElement {\n" + //$NON-NLS-1$ |
718 |
" IResource foo() {return null;}\n" + //$NON-NLS-1$ |
719 |
"}"; //$NON-NLS-1$ |
720 |
|
721 |
Util.createJar( |
722 |
new String[] { |
723 |
"test3/IJavaElement.java", //$NON-NLS-1$ |
724 |
source2 |
725 |
}, |
726 |
null, |
727 |
new HashMap(), |
728 |
new String[]{externalJar1}, |
729 |
externalJar2); |
730 |
|
731 |
// create P1 |
732 |
IJavaProject project1 = this.createJavaProject( |
733 |
"PS1", |
734 |
new String[]{"src"}, |
735 |
new String[]{"JCL_LIB", externalJar2}, |
736 |
"bin"); |
737 |
|
738 |
this.createFolder("/PS1/attachment/test3"); |
739 |
this.createFile( |
740 |
"/PS1/attachment/test3/IJavaElement.java", |
741 |
source2); |
742 |
|
743 |
IPackageFragmentRoot root = project1.getPackageFragmentRoot(externalJar2); |
744 |
attachSource(root, "/PS1/attachment/", ""); |
745 |
|
746 |
// create P2 |
747 |
this.createJavaProject( |
748 |
"PS2", |
749 |
new String[]{"src"}, |
750 |
new String[]{"JCL_LIB", externalJar1}, |
751 |
"bin"); |
752 |
|
753 |
waitUntilIndexesReady(); |
754 |
|
755 |
// do code select |
756 |
IClassFile cf = getClassFile("PS1", externalJar2, "test3", "IJavaElement.class"); |
757 |
|
758 |
IJavaElement[] elements = codeSelect(cf, "IResource foo", "IResource"); |
759 |
|
760 |
assertElementsEqual( |
761 |
"Unexpected elements", |
762 |
"IResource [in IResource.class [in test2 [in "+outputDirectory+File.separator+"bug232880a.jar]]]", |
763 |
elements |
764 |
); |
765 |
} finally { |
766 |
this.deleteExternalFile(externalJar1); |
767 |
this.deleteExternalFile(externalJar2); |
768 |
refreshExternalArchives(getJavaProject("PS1")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
769 |
refreshExternalArchives(getJavaProject("PS2")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
770 |
this.deleteProject("PS1"); |
771 |
this.deleteProject("PS2"); |
772 |
} |
773 |
}//https://bugs.eclipse.org/bugs/show_bug.cgi?id=232880 |
774 |
public void testBug232880h() throws Exception { |
775 |
String outputDirectory = Util.getOutputDirectory(); |
776 |
String externalJar1 = outputDirectory + File.separator + "bug232880a.jar"; //$NON-NLS-1$ |
777 |
String externalJar2 = outputDirectory + File.separator + "bug232880b.jar"; //$NON-NLS-1$ |
778 |
try { |
779 |
|
780 |
// create external jar 1 |
781 |
Util.createJar( |
782 |
new String[] { |
783 |
"test1/IResource.java", //$NON-NLS-1$ |
784 |
"package test1;\n" + //$NON-NLS-1$ |
785 |
"public class IResource {\n" + //$NON-NLS-1$ |
786 |
"}", //$NON-NLS-1$ |
787 |
"test2/IResource.java", //$NON-NLS-1$ |
788 |
"package test2;\n" + //$NON-NLS-1$ |
789 |
"public class IResource {\n" + //$NON-NLS-1$ |
790 |
"}" //$NON-NLS-1$ |
791 |
}, |
792 |
new HashMap(), |
793 |
externalJar1); |
794 |
|
795 |
// create external jar 2 |
796 |
String source2 = |
797 |
"package test3;\n" + //$NON-NLS-1$ |
798 |
"import test1.*;\n" + //$NON-NLS-1$ |
799 |
"import test2.IResource;\n" + //$NON-NLS-1$ |
800 |
"public class IJavaElement {\n" + //$NON-NLS-1$ |
801 |
" IResource foo() {return null;}\n" + //$NON-NLS-1$ |
802 |
"}"; //$NON-NLS-1$ |
803 |
|
804 |
Util.createJar( |
805 |
new String[] { |
806 |
"test3/IJavaElement.java", //$NON-NLS-1$ |
807 |
source2 |
808 |
}, |
809 |
null, |
810 |
new HashMap(), |
811 |
new String[]{externalJar1}, |
812 |
externalJar2); |
813 |
|
814 |
// create P1 |
815 |
IJavaProject project1 = this.createJavaProject( |
816 |
"PS1", |
817 |
new String[]{"src"}, |
818 |
new String[]{"JCL_LIB", externalJar2}, |
819 |
"bin"); |
820 |
|
821 |
this.createFolder("/PS1/attachment/test3"); |
822 |
this.createFile( |
823 |
"/PS1/attachment/test3/IJavaElement.java", |
824 |
source2); |
825 |
|
826 |
IPackageFragmentRoot root = project1.getPackageFragmentRoot(externalJar2); |
827 |
attachSource(root, "/PS1/attachment/", ""); |
828 |
|
829 |
// create P2 |
830 |
this.createJavaProject( |
831 |
"PS2", |
832 |
new String[]{"src"}, |
833 |
new String[]{"JCL_LIB", externalJar1}, |
834 |
"bin"); |
835 |
|
836 |
waitUntilIndexesReady(); |
837 |
|
838 |
// do code select |
839 |
IClassFile cf = getClassFile("PS1", externalJar2, "test3", "IJavaElement.class"); |
840 |
|
841 |
IJavaElement[] elements = codeSelect(cf, "IResource foo", "IResource"); |
842 |
|
843 |
assertElementsEqual( |
844 |
"Unexpected elements", |
845 |
"IResource [in IResource.class [in test2 [in "+outputDirectory+File.separator+"bug232880a.jar]]]", |
846 |
elements |
847 |
); |
848 |
} finally { |
849 |
this.deleteExternalFile(externalJar1); |
850 |
this.deleteExternalFile(externalJar2); |
851 |
refreshExternalArchives(getJavaProject("PS1")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
852 |
refreshExternalArchives(getJavaProject("PS2")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
853 |
this.deleteProject("PS1"); |
854 |
this.deleteProject("PS2"); |
855 |
} |
856 |
} |
857 |
public void testBug232880i() throws Exception { |
858 |
String outputDirectory = Util.getOutputDirectory(); |
859 |
String externalJar1 = outputDirectory + File.separator + "bug232880a.jar"; //$NON-NLS-1$ |
860 |
String externalJar2 = outputDirectory + File.separator + "bug232880b.jar"; //$NON-NLS-1$ |
861 |
try { |
862 |
|
863 |
// create external jar 1 |
864 |
Util.createJar( |
865 |
new String[] { |
866 |
"test1/IResource.java", //$NON-NLS-1$ |
867 |
"package test1;\n" + //$NON-NLS-1$ |
868 |
"public class IResource {\n" + //$NON-NLS-1$ |
869 |
"}", //$NON-NLS-1$ |
870 |
"test2/IResource.java", //$NON-NLS-1$ |
871 |
"package test2;\n" + //$NON-NLS-1$ |
872 |
"public class IResource {\n" + //$NON-NLS-1$ |
873 |
"}" //$NON-NLS-1$ |
874 |
}, |
875 |
new HashMap(), |
876 |
externalJar1); |
877 |
|
878 |
// create external jar 2 |
879 |
String source2 = |
880 |
"package test3;\n" + //$NON-NLS-1$ |
881 |
"public class IJavaElement {\n" + //$NON-NLS-1$ |
882 |
" test2.IResource foo() {return null;}\n" + //$NON-NLS-1$ |
883 |
"}"; //$NON-NLS-1$ |
884 |
|
885 |
Util.createJar( |
886 |
new String[] { |
887 |
"test3/IJavaElement.java", //$NON-NLS-1$ |
888 |
source2 |
889 |
}, |
890 |
null, |
891 |
new HashMap(), |
892 |
new String[]{externalJar1}, |
893 |
externalJar2); |
894 |
|
895 |
// create P1 |
896 |
IJavaProject project1 = this.createJavaProject( |
897 |
"PS1", |
898 |
new String[]{"src"}, |
899 |
new String[]{"JCL_LIB", externalJar2}, |
900 |
"bin"); |
901 |
|
902 |
this.createFolder("/PS1/attachment/test3"); |
903 |
this.createFile( |
904 |
"/PS1/attachment/test3/IJavaElement.java", |
905 |
source2); |
906 |
|
907 |
IPackageFragmentRoot root = project1.getPackageFragmentRoot(externalJar2); |
908 |
attachSource(root, "/PS1/attachment/", ""); |
909 |
|
910 |
// create P2 |
911 |
this.createJavaProject( |
912 |
"PS2", |
913 |
new String[]{"src"}, |
914 |
new String[]{"JCL_LIB", externalJar1}, |
915 |
"bin"); |
916 |
|
917 |
waitUntilIndexesReady(); |
918 |
|
919 |
// do code select |
920 |
IClassFile cf = getClassFile("PS1", externalJar2, "test3", "IJavaElement.class"); |
921 |
|
922 |
IJavaElement[] elements = codeSelect(cf, "IResource foo", "IResource"); |
923 |
|
924 |
assertElementsEqual( |
925 |
"Unexpected elements", |
926 |
"IResource [in IResource.class [in test1 [in "+outputDirectory+File.separator+"bug232880a.jar]]]\n" + |
927 |
"IResource [in IResource.class [in test2 [in "+outputDirectory+File.separator+"bug232880a.jar]]]", |
928 |
elements |
929 |
); |
930 |
} finally { |
931 |
this.deleteExternalFile(externalJar1); |
932 |
this.deleteExternalFile(externalJar2); |
933 |
refreshExternalArchives(getJavaProject("PS1")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
934 |
refreshExternalArchives(getJavaProject("PS2")); // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 |
935 |
this.deleteProject("PS1"); |
936 |
this.deleteProject("PS2"); |
937 |
} |
938 |
} |
195 |
} |
939 |
} |