|
Lines 80-85
Link Here
|
| 80 |
import org.eclipse.jdt.internal.core.search.indexing.IndexRequest; |
80 |
import org.eclipse.jdt.internal.core.search.indexing.IndexRequest; |
| 81 |
import org.eclipse.jdt.internal.core.search.matching.AndPattern; |
81 |
import org.eclipse.jdt.internal.core.search.matching.AndPattern; |
| 82 |
import org.eclipse.jdt.internal.core.search.matching.MatchLocator; |
82 |
import org.eclipse.jdt.internal.core.search.matching.MatchLocator; |
|
|
83 |
import org.eclipse.jdt.internal.core.search.matching.MethodPattern; |
| 83 |
import org.eclipse.jdt.internal.core.search.matching.PatternLocator; |
84 |
import org.eclipse.jdt.internal.core.search.matching.PatternLocator; |
| 84 |
import org.eclipse.jdt.internal.core.search.matching.TypeDeclarationPattern; |
85 |
import org.eclipse.jdt.internal.core.search.matching.TypeDeclarationPattern; |
| 85 |
|
86 |
|
|
Lines 13426-13430
Link Here
|
| 13426 |
"src/b400919/X.java b400919.X2 [Marker] EXACT_MATCH" |
13427 |
"src/b400919/X.java b400919.X2 [Marker] EXACT_MATCH" |
| 13427 |
); |
13428 |
); |
| 13428 |
} |
13429 |
} |
| 13429 |
// Add new tests in JavaSearchBugsTests2 |
13430 |
/** @bug 431357 |
|
|
13431 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 13432 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 13433 |
*/ |
| 13434 |
public void testBug431357_001() throws CoreException { |
| 13435 |
this.workingCopies = new ICompilationUnit[1]; |
| 13436 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13437 |
"interface I { \n" + |
| 13438 |
" public void query(Foo.InnerKey key);// Search result of method query(Foo.InnerKey) returns the method query(Bar.InnerKey) too \n" + |
| 13439 |
" public void query(Bar.InnerKey key);\n" + |
| 13440 |
"}\n" + |
| 13441 |
"\n" + |
| 13442 |
"class Foo { \n" + |
| 13443 |
" static class InnerKey {}\n" + |
| 13444 |
"}\n" + |
| 13445 |
"class Bar {\n" + |
| 13446 |
" static class InnerKey {}\n" + |
| 13447 |
"}\n" + |
| 13448 |
"\n" + |
| 13449 |
"class X {\n" + |
| 13450 |
" public static void foo(I i, Foo.InnerKey key) {\n" + |
| 13451 |
" i.query(key);\n" + |
| 13452 |
" }\n" + |
| 13453 |
" public static void bar(I i, Bar.InnerKey key) {\n" + |
| 13454 |
" i.query(key);\n" + |
| 13455 |
" }\n" + |
| 13456 |
" public static I getInstance() {\n" + |
| 13457 |
" return null;\n" + |
| 13458 |
" }\n" + |
| 13459 |
"}\n" |
| 13460 |
); |
| 13461 |
|
| 13462 |
String str = this.workingCopies[0].getSource(); |
| 13463 |
String selection = "query"; |
| 13464 |
int start = str.indexOf(selection); |
| 13465 |
int length = selection.length(); |
| 13466 |
|
| 13467 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 13468 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], REFERENCES, EXACT_RULE | ERASURE_RULE); |
| 13469 |
|
| 13470 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13471 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13472 |
getJavaSearchWorkingCopiesScope(), |
| 13473 |
this.resultCollector, |
| 13474 |
null); |
| 13475 |
assertSearchResults( |
| 13476 |
"src/X.java void X.foo(I, Foo.InnerKey) [query(key)] EXACT_MATCH" |
| 13477 |
); |
| 13478 |
} |
| 13479 |
/** @bug 431357 |
| 13480 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 13481 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 13482 |
*/ |
| 13483 |
public void testBug431357_002() throws CoreException { |
| 13484 |
this.workingCopies = new ICompilationUnit[1]; |
| 13485 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13486 |
"interface I { \n" + |
| 13487 |
" public void query(Foo.InnerKey key);// Search result of method query(Foo.InnerKey) returns the method query(Bar.InnerKey) too \n" + |
| 13488 |
" public void query(Bar.InnerKey key);\n" + |
| 13489 |
"}\n" + |
| 13490 |
"\n" + |
| 13491 |
"class Foo { \n" + |
| 13492 |
" static class InnerKey {}\n" + |
| 13493 |
"}\n" + |
| 13494 |
"class Bar {\n" + |
| 13495 |
" static class InnerKey {}\n" + |
| 13496 |
"}\n" + |
| 13497 |
"\n" + |
| 13498 |
"class X {\n" + |
| 13499 |
" public static void foo(I i, Foo.InnerKey key) {\n" + |
| 13500 |
" i.query(key);\n" + |
| 13501 |
" }\n" + |
| 13502 |
" public static void bar(I i, Bar.InnerKey key) {\n" + |
| 13503 |
" i.query(key);\n" + |
| 13504 |
" }\n" + |
| 13505 |
" public static I getInstance() {\n" + |
| 13506 |
" return null;\n" + |
| 13507 |
" }\n" + |
| 13508 |
"}\n" |
| 13509 |
); |
| 13510 |
|
| 13511 |
String str = this.workingCopies[0].getSource(); |
| 13512 |
String selection = "query"; |
| 13513 |
int start = str.indexOf(selection); |
| 13514 |
int length = selection.length(); |
| 13515 |
|
| 13516 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 13517 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], ALL_OCCURRENCES, EXACT_RULE | ERASURE_RULE); |
| 13518 |
|
| 13519 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13520 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13521 |
getJavaSearchWorkingCopiesScope(), |
| 13522 |
this.resultCollector, |
| 13523 |
null); |
| 13524 |
assertSearchResults( "src/X.java void I.query(Foo.InnerKey) [query] EXACT_MATCH\n" + |
| 13525 |
"src/X.java void X.foo(I, Foo.InnerKey) [query(key)] EXACT_MATCH" |
| 13526 |
); |
| 13527 |
} |
| 13528 |
/** @bug 431357 |
| 13529 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 13530 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 13531 |
*/ |
| 13532 |
public void testBug431357_003() throws CoreException { |
| 13533 |
this.workingCopies = new ICompilationUnit[1]; |
| 13534 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13535 |
"interface I { \n" + |
| 13536 |
" public void query(Foo.InnerKey key);// Search result of method query(Foo.InnerKey) returns the method query(Bar.InnerKey) too \n" + |
| 13537 |
" public void query/*here*/(Bar.InnerKey key);\n" + |
| 13538 |
"}\n" + |
| 13539 |
"\n" + |
| 13540 |
"class Foo { \n" + |
| 13541 |
" static class InnerKey {}\n" + |
| 13542 |
"}\n" + |
| 13543 |
"class Bar {\n" + |
| 13544 |
" static class InnerKey {}\n" + |
| 13545 |
"}\n" + |
| 13546 |
"\n" + |
| 13547 |
"class X {\n" + |
| 13548 |
" public static void foo(I i, Foo.InnerKey key) {\n" + |
| 13549 |
" i.query(key);\n" + |
| 13550 |
" }\n" + |
| 13551 |
" public static void bar(I i, Bar.InnerKey key) {\n" + |
| 13552 |
" i.query(key);\n" + |
| 13553 |
" }\n" + |
| 13554 |
" public static I getInstance() {\n" + |
| 13555 |
" return null;\n" + |
| 13556 |
" }\n" + |
| 13557 |
"}\n" |
| 13558 |
); |
| 13559 |
|
| 13560 |
String str = this.workingCopies[0].getSource(); |
| 13561 |
String selection = "query/*here*/"; |
| 13562 |
int start = str.indexOf(selection); |
| 13563 |
int length = "query".length(); |
| 13564 |
|
| 13565 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 13566 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], ALL_OCCURRENCES, EXACT_RULE | ERASURE_RULE); |
| 13567 |
|
| 13568 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13569 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13570 |
getJavaSearchWorkingCopiesScope(), |
| 13571 |
this.resultCollector, |
| 13572 |
null); |
| 13573 |
assertSearchResults("src/X.java void I.query(Bar.InnerKey) [query] EXACT_MATCH\n" + |
| 13574 |
"src/X.java void X.bar(I, Bar.InnerKey) [query(key)] EXACT_MATCH" |
| 13575 |
); |
| 13576 |
} |
| 13577 |
/** @bug 431357 |
| 13578 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 13579 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 13580 |
*/ |
| 13581 |
public void testBug431357_004() throws CoreException { |
| 13582 |
this.workingCopies = new ICompilationUnit[1]; |
| 13583 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13584 |
"// --\n" + |
| 13585 |
"interface I { \n" + |
| 13586 |
" public void query/*here*/(Foo.Key key);// Search result of method query(Foo.Key) returns the method query(Bar.Key) too \n" + |
| 13587 |
" public void query(Key key);\n" + |
| 13588 |
"}\n" + |
| 13589 |
"\n" + |
| 13590 |
"class Foo { \n" + |
| 13591 |
" static class Key { \n" + |
| 13592 |
" }\n" + |
| 13593 |
" public static void foo(I i, Key key) {\n" + |
| 13594 |
" i.query(key);\n" + |
| 13595 |
" }\n" + |
| 13596 |
" \n" + |
| 13597 |
"}\n" + |
| 13598 |
"\n" + |
| 13599 |
"class Key {\n" + |
| 13600 |
" \n" + |
| 13601 |
"}\n" + |
| 13602 |
"class Bar {\n" + |
| 13603 |
" \n" + |
| 13604 |
" public static void bar(I i, Key key) {\n" + |
| 13605 |
" i.query(key);\n" + |
| 13606 |
" }\n" + |
| 13607 |
"}\n" + |
| 13608 |
"\n" + |
| 13609 |
"public class X {\n" + |
| 13610 |
" public static I getInstance() {\n" + |
| 13611 |
" return null;\n" + |
| 13612 |
" }\n" + |
| 13613 |
"}\n" |
| 13614 |
); |
| 13615 |
|
| 13616 |
String str = this.workingCopies[0].getSource(); |
| 13617 |
String selection = "query/*here*/"; |
| 13618 |
int start = str.indexOf(selection); |
| 13619 |
int length = "query".length(); |
| 13620 |
|
| 13621 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 13622 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], ALL_OCCURRENCES, EXACT_RULE | ERASURE_RULE); |
| 13623 |
|
| 13624 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13625 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13626 |
getJavaSearchWorkingCopiesScope(), |
| 13627 |
this.resultCollector, |
| 13628 |
null); |
| 13629 |
assertSearchResults( |
| 13630 |
"src/X.java void I.query(Foo.Key) [query] EXACT_MATCH\n" + |
| 13631 |
"src/X.java void Foo.foo(I, Key) [query(key)] EXACT_MATCH" |
| 13632 |
); |
| 13633 |
} |
| 13634 |
/** @bug 431357 |
| 13635 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 13636 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 13637 |
*/ |
| 13638 |
public void testBug431357_005() throws CoreException { |
| 13639 |
this.workingCopies = new ICompilationUnit[1]; |
| 13640 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13641 |
"// --\n" + |
| 13642 |
"interface I { \n" + |
| 13643 |
" public void query(Foo.Key key);// Search result of method query(Foo.Key) returns the method query(Bar.Key) too \n" + |
| 13644 |
" public void query/*here*/(Key key);\n" + |
| 13645 |
"}\n" + |
| 13646 |
"\n" + |
| 13647 |
"class Foo { \n" + |
| 13648 |
" static class Key { \n" + |
| 13649 |
" }\n" + |
| 13650 |
" public static void foo(I i, Key key) {\n" + |
| 13651 |
" i.query(key);\n" + |
| 13652 |
" }\n" + |
| 13653 |
" \n" + |
| 13654 |
"}\n" + |
| 13655 |
"\n" + |
| 13656 |
"class Key {\n" + |
| 13657 |
" \n" + |
| 13658 |
"}\n" + |
| 13659 |
"class Bar {\n" + |
| 13660 |
" \n" + |
| 13661 |
" public static void bar(I i, Key key) {\n" + |
| 13662 |
" i.query(key);\n" + |
| 13663 |
" }\n" + |
| 13664 |
"}\n" + |
| 13665 |
"\n" + |
| 13666 |
"public class X {\n" + |
| 13667 |
" public static I getInstance() {\n" + |
| 13668 |
" return null;\n" + |
| 13669 |
" }\n" + |
| 13670 |
"}\n" |
| 13671 |
); |
| 13672 |
|
| 13673 |
String str = this.workingCopies[0].getSource(); |
| 13674 |
String selection = "query/*here*/"; |
| 13675 |
int start = str.indexOf(selection); |
| 13676 |
int length = "query".length(); |
| 13677 |
|
| 13678 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 13679 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], ALL_OCCURRENCES, EXACT_RULE | ERASURE_RULE); |
| 13680 |
|
| 13681 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13682 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13683 |
getJavaSearchWorkingCopiesScope(), |
| 13684 |
this.resultCollector, |
| 13685 |
null); |
| 13686 |
assertSearchResults( |
| 13687 |
"src/X.java void I.query(Key) [query] EXACT_MATCH\n" + |
| 13688 |
"src/X.java void Bar.bar(I, Key) [query(key)] EXACT_MATCH" |
| 13689 |
); |
| 13690 |
} |
| 13691 |
/** @bug 431357 |
| 13692 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 13693 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 13694 |
*/ |
| 13695 |
public void testBug431357_006() throws CoreException { |
| 13696 |
this.workingCopies = new ICompilationUnit[1]; |
| 13697 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13698 |
"// --\n" + |
| 13699 |
"interface I { \n" + |
| 13700 |
" public void query/*here*/(Foo.Key key);// Search result of method query(Foo.Key) returns the method query(Bar.Key) too \n" + |
| 13701 |
" public void query(Key key);\n" + |
| 13702 |
" public void query(Bar.Key key);\n" + |
| 13703 |
"}\n" + |
| 13704 |
"\n" + |
| 13705 |
"class Foo { \n" + |
| 13706 |
" static class Key { \n" + |
| 13707 |
" }\n" + |
| 13708 |
" public static void foo(I i, Key key) {\n" + |
| 13709 |
" i.query(key);\n" + |
| 13710 |
" }\n" + |
| 13711 |
" \n" + |
| 13712 |
"}\n" + |
| 13713 |
"\n" + |
| 13714 |
"class Key {\n" + |
| 13715 |
" \n" + |
| 13716 |
"}\n" + |
| 13717 |
"class Bar {\n" + |
| 13718 |
" static class Key {\n" + |
| 13719 |
" \n" + |
| 13720 |
" } \n" + |
| 13721 |
" public static void bar(I i, Key key) {\n" + |
| 13722 |
" i.query(key);\n" + |
| 13723 |
" }\n" + |
| 13724 |
"}\n" + |
| 13725 |
"\n" + |
| 13726 |
"public class X {\n" + |
| 13727 |
" public static I getInstance() {\n" + |
| 13728 |
" return null;\n" + |
| 13729 |
" }\n" + |
| 13730 |
" public static void bar(I i, Key key) {\n" + |
| 13731 |
" i.query(key);\n" + |
| 13732 |
" }\n" + |
| 13733 |
"}\n" |
| 13734 |
); |
| 13735 |
|
| 13736 |
String str = this.workingCopies[0].getSource(); |
| 13737 |
String selection = "query/*here*/"; |
| 13738 |
int start = str.indexOf(selection); |
| 13739 |
int length = "query".length(); |
| 13740 |
|
| 13741 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 13742 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], ALL_OCCURRENCES, EXACT_RULE | ERASURE_RULE); |
| 13743 |
|
| 13744 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13745 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13746 |
getJavaSearchWorkingCopiesScope(), |
| 13747 |
this.resultCollector, |
| 13748 |
null); |
| 13749 |
assertSearchResults( |
| 13750 |
"src/X.java void I.query(Foo.Key) [query] EXACT_MATCH\n" + |
| 13751 |
"src/X.java void Foo.foo(I, Key) [query(key)] EXACT_MATCH" |
| 13752 |
); |
| 13753 |
} |
| 13754 |
/** @bug 431357 |
| 13755 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 13756 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 13757 |
*/ |
| 13758 |
public void testBug431357_007() throws CoreException { |
| 13759 |
this.workingCopies = new ICompilationUnit[1]; |
| 13760 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13761 |
"// --\n" + |
| 13762 |
"interface I { \n" + |
| 13763 |
" public void query(Foo.Key key);// Search result of method query(Foo.Key) returns the method query(Bar.Key) too \n" + |
| 13764 |
" public void query/*here*/(Key key);\n" + |
| 13765 |
" public void query(Bar.Key key);\n" + |
| 13766 |
"}\n" + |
| 13767 |
"\n" + |
| 13768 |
"class Foo { \n" + |
| 13769 |
" static class Key { \n" + |
| 13770 |
" }\n" + |
| 13771 |
" public static void foo(I i, Key key) {\n" + |
| 13772 |
" i.query(key);\n" + |
| 13773 |
" }\n" + |
| 13774 |
" \n" + |
| 13775 |
"}\n" + |
| 13776 |
"\n" + |
| 13777 |
"class Key {\n" + |
| 13778 |
" \n" + |
| 13779 |
"}\n" + |
| 13780 |
"class Bar {\n" + |
| 13781 |
" static class Key {\n" + |
| 13782 |
" \n" + |
| 13783 |
" } \n" + |
| 13784 |
" public static void bar(I i, Key key) {\n" + |
| 13785 |
" i.query(key);\n" + |
| 13786 |
" }\n" + |
| 13787 |
"}\n" + |
| 13788 |
"\n" + |
| 13789 |
"public class X {\n" + |
| 13790 |
" public static I getInstance() {\n" + |
| 13791 |
" return null;\n" + |
| 13792 |
" }\n" + |
| 13793 |
" public static void bar(I i, Key key) {\n" + |
| 13794 |
" i.query(key);\n" + |
| 13795 |
" }\n" + |
| 13796 |
"}\n" |
| 13797 |
); |
| 13798 |
|
| 13799 |
String str = this.workingCopies[0].getSource(); |
| 13800 |
String selection = "query/*here*/"; |
| 13801 |
int start = str.indexOf(selection); |
| 13802 |
int length = "query".length(); |
| 13803 |
|
| 13804 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 13805 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], ALL_OCCURRENCES, EXACT_RULE | ERASURE_RULE); |
| 13806 |
|
| 13807 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13808 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13809 |
getJavaSearchWorkingCopiesScope(), |
| 13810 |
this.resultCollector, |
| 13811 |
null); |
| 13812 |
assertSearchResults( |
| 13813 |
"src/X.java void I.query(Key) [query] EXACT_MATCH\n" + |
| 13814 |
"src/X.java void X.bar(I, Key) [query(key)] EXACT_MATCH" |
| 13815 |
); |
| 13816 |
} |
| 13817 |
|
| 13818 |
/** @bug 431357 |
| 13819 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 13820 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 13821 |
*/ |
| 13822 |
public void testBug431357_008() throws CoreException { |
| 13823 |
this.workingCopies = new ICompilationUnit[1]; |
| 13824 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13825 |
"// --\n" + |
| 13826 |
"interface I { \n" + |
| 13827 |
" public void query(Foo.Key key);// Search result of method query(Foo.Key) returns the method query(Bar.Key) too \n" + |
| 13828 |
" public void query(Key key);\n" + |
| 13829 |
" public void query/*here*/(Bar.Key key);\n" + |
| 13830 |
"}\n" + |
| 13831 |
"\n" + |
| 13832 |
"class Foo { \n" + |
| 13833 |
" static class Key { \n" + |
| 13834 |
" }\n" + |
| 13835 |
" public static void foo(I i, Key key) {\n" + |
| 13836 |
" i.query(key);\n" + |
| 13837 |
" }\n" + |
| 13838 |
" \n" + |
| 13839 |
"}\n" + |
| 13840 |
"\n" + |
| 13841 |
"class Key {\n" + |
| 13842 |
" \n" + |
| 13843 |
"}\n" + |
| 13844 |
"class Bar {\n" + |
| 13845 |
" static class Key {\n" + |
| 13846 |
" \n" + |
| 13847 |
" } \n" + |
| 13848 |
" public static void bar(I i, Key key) {\n" + |
| 13849 |
" i.query(key);\n" + |
| 13850 |
" }\n" + |
| 13851 |
"}\n" + |
| 13852 |
"\n" + |
| 13853 |
"public class X {\n" + |
| 13854 |
" public static I getInstance() {\n" + |
| 13855 |
" return null;\n" + |
| 13856 |
" }\n" + |
| 13857 |
" public static void bar(I i, Key key) {\n" + |
| 13858 |
" i.query(key);\n" + |
| 13859 |
" }\n" + |
| 13860 |
"}\n" |
| 13861 |
); |
| 13862 |
|
| 13863 |
String str = this.workingCopies[0].getSource(); |
| 13864 |
String selection = "query/*here*/"; |
| 13865 |
int start = str.indexOf(selection); |
| 13866 |
int length = "query".length(); |
| 13867 |
|
| 13868 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 13869 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], ALL_OCCURRENCES, EXACT_RULE | ERASURE_RULE); |
| 13870 |
|
| 13871 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13872 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13873 |
getJavaSearchWorkingCopiesScope(), |
| 13874 |
this.resultCollector, |
| 13875 |
null); |
| 13876 |
assertSearchResults( |
| 13877 |
"src/X.java void I.query(Bar.Key) [query] EXACT_MATCH\n" + |
| 13878 |
"src/X.java void Bar.bar(I, Key) [query(key)] EXACT_MATCH" |
| 13879 |
); |
| 13880 |
} |
| 13881 |
|
| 13882 |
/** @bug 431357 |
| 13883 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 13884 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 13885 |
*/ |
| 13886 |
public void testBug431357_009() throws CoreException { |
| 13887 |
this.workingCopies = new ICompilationUnit[1]; |
| 13888 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13889 |
"interface MyIF { \n" + |
| 13890 |
" public void query(Foo.InnerKey fk, Bar.InnerKey bk, String s); \n" + |
| 13891 |
" public void query/*here*/(Bar.InnerKey fk, Bar.InnerKey bk, String s);\n" + |
| 13892 |
"}\n" + |
| 13893 |
"\n" + |
| 13894 |
"class Foo { \n" + |
| 13895 |
" static class InnerKey { \n" + |
| 13896 |
" }\n" + |
| 13897 |
"\n" + |
| 13898 |
"}\n" + |
| 13899 |
"\n" + |
| 13900 |
"class Bar {\n" + |
| 13901 |
" static class InnerKey {\n" + |
| 13902 |
" }\n" + |
| 13903 |
" public static void bar(MyIF i, Foo.InnerKey fk, Bar.InnerKey bk) {\n" + |
| 13904 |
" i.query(fk, bk, \"\");\n" + |
| 13905 |
" }\n" + |
| 13906 |
"}\n" + |
| 13907 |
"public class X {}\n" |
| 13908 |
); |
| 13909 |
|
| 13910 |
String str = this.workingCopies[0].getSource(); |
| 13911 |
String selection = "query/*here*/"; |
| 13912 |
int start = str.indexOf(selection); |
| 13913 |
int length = "query".length(); |
| 13914 |
|
| 13915 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 13916 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], REFERENCES, EXACT_RULE | ERASURE_RULE); |
| 13917 |
|
| 13918 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13919 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13920 |
getJavaSearchWorkingCopiesScope(), |
| 13921 |
this.resultCollector, |
| 13922 |
null); |
| 13923 |
assertSearchResults("" |
| 13924 |
); |
| 13925 |
} |
| 13926 |
|
| 13927 |
/** @bug 431357 |
| 13928 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 13929 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 13930 |
*/ |
| 13931 |
public void testBug431357_010() throws CoreException { |
| 13932 |
this.workingCopies = new ICompilationUnit[1]; |
| 13933 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13934 |
"interface MyIF { \n" + |
| 13935 |
" public void query(Foo.InnerKey fk, String s); \n" + |
| 13936 |
" public void query/*here*/(Bar.InnerKey fk, String s);\n" + |
| 13937 |
"}\n" + |
| 13938 |
"\n" + |
| 13939 |
"class Foo { \n" + |
| 13940 |
" static class InnerKey {}\n" + |
| 13941 |
"}\n" + |
| 13942 |
"\n" + |
| 13943 |
"class Bar {\n" + |
| 13944 |
" static class InnerKey {}\n" + |
| 13945 |
" public static void bar(MyIF i, Foo.InnerKey fk) {\n" + |
| 13946 |
" i.query(fk, \"\");\n" + |
| 13947 |
" }\n" + |
| 13948 |
"}\n" + |
| 13949 |
"public class X {}\n" |
| 13950 |
); |
| 13951 |
|
| 13952 |
String str = this.workingCopies[0].getSource(); |
| 13953 |
String selection = "query/*here*/"; |
| 13954 |
int start = str.indexOf(selection); |
| 13955 |
int length = "query".length(); |
| 13956 |
|
| 13957 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 13958 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], REFERENCES, EXACT_RULE | ERASURE_RULE); |
| 13959 |
|
| 13960 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13961 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13962 |
getJavaSearchWorkingCopiesScope(), |
| 13963 |
this.resultCollector, |
| 13964 |
null); |
| 13965 |
assertSearchResults("" |
| 13966 |
); |
| 13967 |
} |
| 13968 |
|
| 13969 |
/** @bug 431357 |
| 13970 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 13971 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 13972 |
*/ |
| 13973 |
public void testBug431357_011() throws CoreException { |
| 13974 |
this.workingCopies = new ICompilationUnit[1]; |
| 13975 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13976 |
"interface MyIF { \n" + |
| 13977 |
" public void query(String s, Foo.InnerKey fk); \n" + |
| 13978 |
"}\n" + |
| 13979 |
"\n" + |
| 13980 |
"class Foo { \n" + |
| 13981 |
" static class InnerKey {}\n" + |
| 13982 |
"}\n" + |
| 13983 |
"\n" + |
| 13984 |
"class Bar {\n" + |
| 13985 |
" static class InnerKey {}\n" + |
| 13986 |
" public static void bar(MyIF i, Foo.InnerKey fk) {\n" + |
| 13987 |
" i.query(\"\", fk);\n" + |
| 13988 |
" }\n" + |
| 13989 |
"}\n" + |
| 13990 |
"public class X {}\n" |
| 13991 |
); |
| 13992 |
|
| 13993 |
String nonExistentPattern = "MyIF.query(String, Bar.InnerKey)"; |
| 13994 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(nonExistentPattern, IJavaSearchConstants.METHOD, REFERENCES, EXACT_RULE | ERASURE_RULE); |
| 13995 |
|
| 13996 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13997 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13998 |
getJavaSearchWorkingCopiesScope(), |
| 13999 |
this.resultCollector, |
| 14000 |
null); |
| 14001 |
assertSearchResults("" |
| 14002 |
); |
| 14003 |
} |
| 14004 |
|
| 14005 |
/** @bug 431357 |
| 14006 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 14007 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 14008 |
*/ |
| 14009 |
public void testBug431357_012() throws CoreException { |
| 14010 |
this.workingCopies = new ICompilationUnit[1]; |
| 14011 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 14012 |
"interface MyIF { \n" + |
| 14013 |
" public void query/*here*/(Foo.InnerKey fk, Bar.InnerKey bk, String s); \n" + |
| 14014 |
" public void query(Bar.InnerKey fk, Bar.InnerKey bk, String s);\n" + |
| 14015 |
"}\n" + |
| 14016 |
"\n" + |
| 14017 |
"class Foo { \n" + |
| 14018 |
" static class InnerKey { \n" + |
| 14019 |
" }\n" + |
| 14020 |
" \n" + |
| 14021 |
"}\n" + |
| 14022 |
"\n" + |
| 14023 |
"class Bar {\n" + |
| 14024 |
" static class InnerKey extends Foo.InnerKey {\n" + |
| 14025 |
" }\n" + |
| 14026 |
" public static void bar(MyIF i, Foo.InnerKey fk, Bar.InnerKey bk) {\n" + |
| 14027 |
" i.query(fk, bk, \"\");\n" + |
| 14028 |
" }\n" + |
| 14029 |
"}\n" + |
| 14030 |
"public class X {}\n" |
| 14031 |
); |
| 14032 |
|
| 14033 |
String str = this.workingCopies[0].getSource(); |
| 14034 |
String selection = "query/*here*/"; |
| 14035 |
int start = str.indexOf(selection); |
| 14036 |
int length = "query".length(); |
| 14037 |
|
| 14038 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 14039 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], ALL_OCCURRENCES, EXACT_RULE | ERASURE_RULE); |
| 14040 |
|
| 14041 |
new SearchEngine(this.workingCopies).search(pattern, |
| 14042 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 14043 |
getJavaSearchWorkingCopiesScope(), |
| 14044 |
this.resultCollector, |
| 14045 |
null); |
| 14046 |
assertSearchResults("src/X.java void MyIF.query(Foo.InnerKey, Bar.InnerKey, String) [query] EXACT_MATCH\n" + |
| 14047 |
"src/X.java void Bar.bar(MyIF, Foo.InnerKey, Bar.InnerKey) [query(fk, bk, \"\")] EXACT_MATCH" |
| 14048 |
); |
| 14049 |
} |
| 14050 |
|
| 14051 |
/** @bug 431357 |
| 14052 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 14053 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 14054 |
*/ |
| 14055 |
public void testBug431357_013() throws CoreException { |
| 14056 |
this.workingCopies = new ICompilationUnit[1]; |
| 14057 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 14058 |
"interface MyIF { \n" + |
| 14059 |
" public void query/*here*/(Foo.InnerKey key); \n" + |
| 14060 |
" public void query(Bar.InnerKey key);\n" + |
| 14061 |
"}\n" + |
| 14062 |
"\n" + |
| 14063 |
"class Foo { \n" + |
| 14064 |
" static class InnerKey { \n" + |
| 14065 |
" }\n" + |
| 14066 |
" \n" + |
| 14067 |
"}\n" + |
| 14068 |
"\n" + |
| 14069 |
"class Bar {\n" + |
| 14070 |
" static class InnerKey{}\n" + |
| 14071 |
"}\n" + |
| 14072 |
"public class X {}\n" |
| 14073 |
); |
| 14074 |
|
| 14075 |
String str = this.workingCopies[0].getSource(); |
| 14076 |
String selection = "query/*here*/"; |
| 14077 |
int start = str.indexOf(selection); |
| 14078 |
int length = "query".length(); |
| 14079 |
|
| 14080 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 14081 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], ALL_OCCURRENCES, EXACT_RULE | ERASURE_RULE); |
| 14082 |
|
| 14083 |
new SearchEngine(this.workingCopies).search(pattern, |
| 14084 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 14085 |
getJavaSearchWorkingCopiesScope(), |
| 14086 |
this.resultCollector, |
| 14087 |
null); |
| 14088 |
assertSearchResults("src/X.java void MyIF.query(Foo.InnerKey) [query] EXACT_MATCH" |
| 14089 |
); |
| 14090 |
} |
| 14091 |
|
| 14092 |
/** @bug 431357 |
| 14093 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 14094 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 14095 |
*/ |
| 14096 |
public void testBug431357_014() throws CoreException { |
| 14097 |
this.workingCopies = new ICompilationUnit[1]; |
| 14098 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 14099 |
"interface MyIF { \n" + |
| 14100 |
" public void query/*here*/(Foo.InnerKey key); \n" + |
| 14101 |
" public void query(Bar.InnerKey key);\n" + |
| 14102 |
"}\n" + |
| 14103 |
"\n" + |
| 14104 |
"class Foo { \n" + |
| 14105 |
" static class InnerKey { \n" + |
| 14106 |
" }\n" + |
| 14107 |
" \n" + |
| 14108 |
"}\n" + |
| 14109 |
"\n" + |
| 14110 |
"class Bar {\n" + |
| 14111 |
" static class InnerKey{}\n" + |
| 14112 |
"}\n" + |
| 14113 |
"public class X {}\n" |
| 14114 |
); |
| 14115 |
|
| 14116 |
String str = this.workingCopies[0].getSource(); |
| 14117 |
String selection = "query/*here*/"; |
| 14118 |
int start = str.indexOf(selection); |
| 14119 |
int length = "query".length(); |
| 14120 |
|
| 14121 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 14122 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], DECLARATIONS, EXACT_RULE | ERASURE_RULE); |
| 14123 |
|
| 14124 |
new SearchEngine(this.workingCopies).search(pattern, |
| 14125 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 14126 |
getJavaSearchWorkingCopiesScope(), |
| 14127 |
this.resultCollector, |
| 14128 |
null); |
| 14129 |
assertSearchResults("src/X.java void MyIF.query(Foo.InnerKey) [query] EXACT_MATCH"); |
| 14130 |
} |
| 14131 |
|
| 14132 |
/** @bug 431357 |
| 14133 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 14134 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 14135 |
*/ |
| 14136 |
public void testBug431357_015() throws CoreException { |
| 14137 |
String folder = "/JavaSearchBugs/src/testBug431357_015"; |
| 14138 |
String filename = folder + "/" + "X.java"; |
| 14139 |
try { |
| 14140 |
String contents = |
| 14141 |
"package testBug431357_015;\n" + |
| 14142 |
"interface MyIF { \n" + |
| 14143 |
" public void query/*here*/(Foo.InnerKey key); \n" + |
| 14144 |
" public void query(Bar.InnerKey key);\n" + |
| 14145 |
"}\n" + |
| 14146 |
"\n" + |
| 14147 |
"class Foo { \n" + |
| 14148 |
" static class InnerKey { \n" + |
| 14149 |
" }\n" + |
| 14150 |
" \n" + |
| 14151 |
"}\n" + |
| 14152 |
"\n" + |
| 14153 |
"class Bar {\n" + |
| 14154 |
" static class InnerKey{}\n" + |
| 14155 |
"}\n" + |
| 14156 |
"public class X {}\n"; |
| 14157 |
// create files |
| 14158 |
createFolder(folder); |
| 14159 |
createFile(filename, contents); |
| 14160 |
waitUntilIndexesReady(); |
| 14161 |
|
| 14162 |
// search |
| 14163 |
IType[] types = getCompilationUnit(filename).getTypes(); |
| 14164 |
IMethod method = types[0].getMethods()[0]; |
| 14165 |
search(method, DECLARATIONS | IJavaSearchConstants.IGNORE_DECLARING_TYPE | IJavaSearchConstants.IGNORE_RETURN_TYPE, ERASURE_RULE); |
| 14166 |
assertSearchResults("src/testBug431357_015/X.java void testBug431357_015.MyIF.query(Foo.InnerKey) [query] EXACT_MATCH"); |
| 14167 |
} |
| 14168 |
finally { |
| 14169 |
// delete files |
| 14170 |
deleteFolder(folder); |
| 14171 |
} |
| 14172 |
} |
| 14173 |
|
| 14174 |
/** @bug 431357 |
| 14175 |
* [search] Search API got wrong result, when searching for method references, where the parameter is a member type of another type. |
| 14176 |
* enable this once 88997 is fixed |
| 14177 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=431357" |
| 14178 |
*/ |
| 14179 |
public void _testBug431357_016() throws CoreException { |
| 14180 |
String folder = "/JavaSearchBugs/src/testBug431357_016"; |
| 14181 |
String filename = folder + "/" + "X.java"; |
| 14182 |
try { |
| 14183 |
String contents = |
| 14184 |
"package testBug431357_016;\n" + |
| 14185 |
"interface I { \n " + |
| 14186 |
" public void query(Foo.Key key);\n" + |
| 14187 |
" public void query/*here*/(Key key);\n " + |
| 14188 |
"}\n " + |
| 14189 |
"\n " + |
| 14190 |
"class Foo { \n " + |
| 14191 |
" static class Key { \n " + |
| 14192 |
" }\n " + |
| 14193 |
" public static void foo(I i, Key key) {\n " + |
| 14194 |
" i.query(key);\n " + |
| 14195 |
" }\n " + |
| 14196 |
" \n " + |
| 14197 |
"}\n " + |
| 14198 |
"\n " + |
| 14199 |
"class Key {\n " + |
| 14200 |
" \n " + |
| 14201 |
"}\n " + |
| 14202 |
"class Bar {\n " + |
| 14203 |
" \n " + |
| 14204 |
" public static void bar(I i, Key key) {\n " + |
| 14205 |
" i.query(key);\n " + |
| 14206 |
" }\n " + |
| 14207 |
"}\n " + |
| 14208 |
"\n " + |
| 14209 |
"public class X {\n " + |
| 14210 |
" public static I getInstance() {\n " + |
| 14211 |
" return null;\n " + |
| 14212 |
" }\n " + |
| 14213 |
"}\n "; |
| 14214 |
// create files |
| 14215 |
createFolder(folder); |
| 14216 |
createFile(filename, contents); |
| 14217 |
waitUntilIndexesReady(); |
| 14218 |
|
| 14219 |
// search |
| 14220 |
IType[] types = getCompilationUnit(filename).getTypes(); |
| 14221 |
IMethod method = types[0].getMethods()[1]; |
| 14222 |
search(method, DECLARATIONS | IJavaSearchConstants.IGNORE_DECLARING_TYPE | IJavaSearchConstants.IGNORE_RETURN_TYPE, ERASURE_RULE); |
| 14223 |
assertSearchResults("src/testBug431357_016/X.java void testBug431357_016.I.query(Key) [query] EXACT_MATCH"); |
| 14224 |
} |
| 14225 |
finally { |
| 14226 |
// delete files |
| 14227 |
deleteFolder(folder); |
| 14228 |
} |
| 14229 |
} |
| 14230 |
|
| 13430 |
} |
14231 |
} |