|
15 | 15 | */
|
16 | 16 | package org.eclipse.jdt.core.groovy.tests.search;
|
17 | 17 |
|
| 18 | +import static org.eclipse.jdt.groovy.core.tests.GroovyBundle.isAtLeastGroovy; |
| 19 | +import static org.eclipse.jdt.groovy.core.tests.GroovyBundle.isParrotParser; |
18 | 20 | import static org.junit.Assert.assertEquals;
|
19 | 21 | import static org.junit.Assert.assertNotNull;
|
20 | 22 | import static org.junit.Assert.assertTrue;
|
| 23 | +import static org.junit.Assume.assumeTrue; |
21 | 24 |
|
22 | 25 | import java.util.List;
|
23 | 26 |
|
@@ -502,6 +505,32 @@ public void testInnerTypes5() throws Exception {
|
502 | 505 | assertEquals(secondContents.lastIndexOf("p.First"), match.getOffset());
|
503 | 506 | }
|
504 | 507 |
|
| 508 | + @Test // GROOVY-11178 |
| 509 | + public void testTypeAnnotations() throws Exception { |
| 510 | + assumeTrue(isParrotParser()); |
| 511 | + |
| 512 | + String firstContents = |
| 513 | + "package p\n" + |
| 514 | + "import java.lang.annotation.*\n" + |
| 515 | + "@Target(ElementType.TYPE_USE)\n" + |
| 516 | + "public @interface First {\n" + |
| 517 | + "}\n"; |
| 518 | + String secondContents = |
| 519 | + "package q\n" + |
| 520 | + "import p.*\n" + |
| 521 | + "Object o = new @First Object()\n"; |
| 522 | + |
| 523 | + List<SearchMatch> matches = searchForFirst(firstContents, secondContents, "p", "q"); |
| 524 | + if (!isAtLeastGroovy(50)) { |
| 525 | + assertTrue(matches.isEmpty()); |
| 526 | + } else { |
| 527 | + assertEquals(1, matches.size()); |
| 528 | + SearchMatch match = matches.get(0); |
| 529 | + assertEquals("First".length(), match.getLength()); |
| 530 | + assertEquals(secondContents.indexOf("First"), match.getOffset()); |
| 531 | + } |
| 532 | + } |
| 533 | + |
505 | 534 | @Test
|
506 | 535 | public void testConstructorWithDefaultArgsInCompileStatic() throws Exception {
|
507 | 536 | String firstContents =
|
|
0 commit comments