|
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 |
public void testBug431357_007() throws CoreException { |
| 13755 |
this.workingCopies = new ICompilationUnit[1]; |
| 13756 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13757 |
"// --\n" + |
| 13758 |
"interface I { \n" + |
| 13759 |
" public void query(Foo.Key key);// Search result of method query(Foo.Key) returns the method query(Bar.Key) too \n" + |
| 13760 |
" public void query/*here*/(Key key);\n" + |
| 13761 |
" public void query(Bar.Key key);\n" + |
| 13762 |
"}\n" + |
| 13763 |
"\n" + |
| 13764 |
"class Foo { \n" + |
| 13765 |
" static class Key { \n" + |
| 13766 |
" }\n" + |
| 13767 |
" public static void foo(I i, Key key) {\n" + |
| 13768 |
" i.query(key);\n" + |
| 13769 |
" }\n" + |
| 13770 |
" \n" + |
| 13771 |
"}\n" + |
| 13772 |
"\n" + |
| 13773 |
"class Key {\n" + |
| 13774 |
" \n" + |
| 13775 |
"}\n" + |
| 13776 |
"class Bar {\n" + |
| 13777 |
" static class Key {\n" + |
| 13778 |
" \n" + |
| 13779 |
" } \n" + |
| 13780 |
" public static void bar(I i, Key key) {\n" + |
| 13781 |
" i.query(key);\n" + |
| 13782 |
" }\n" + |
| 13783 |
"}\n" + |
| 13784 |
"\n" + |
| 13785 |
"public class X {\n" + |
| 13786 |
" public static I getInstance() {\n" + |
| 13787 |
" return null;\n" + |
| 13788 |
" }\n" + |
| 13789 |
" public static void bar(I i, Key key) {\n" + |
| 13790 |
" i.query(key);\n" + |
| 13791 |
" }\n" + |
| 13792 |
"}\n" |
| 13793 |
); |
| 13794 |
|
| 13795 |
String str = this.workingCopies[0].getSource(); |
| 13796 |
String selection = "query/*here*/"; |
| 13797 |
int start = str.indexOf(selection); |
| 13798 |
int length = "query".length(); |
| 13799 |
|
| 13800 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 13801 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], ALL_OCCURRENCES, EXACT_RULE | ERASURE_RULE); |
| 13802 |
|
| 13803 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13804 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13805 |
getJavaSearchWorkingCopiesScope(), |
| 13806 |
this.resultCollector, |
| 13807 |
null); |
| 13808 |
assertSearchResults( |
| 13809 |
"src/X.java void I.query(Key) [query] EXACT_MATCH\n" + |
| 13810 |
"src/X.java void X.bar(I, Key) [query(key)] EXACT_MATCH" |
| 13811 |
); |
| 13812 |
} |
| 13813 |
public void testBug431357_008() throws CoreException { |
| 13814 |
this.workingCopies = new ICompilationUnit[1]; |
| 13815 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13816 |
"// --\n" + |
| 13817 |
"interface I { \n" + |
| 13818 |
" public void query(Foo.Key key);// Search result of method query(Foo.Key) returns the method query(Bar.Key) too \n" + |
| 13819 |
" public void query(Key key);\n" + |
| 13820 |
" public void query/*here*/(Bar.Key key);\n" + |
| 13821 |
"}\n" + |
| 13822 |
"\n" + |
| 13823 |
"class Foo { \n" + |
| 13824 |
" static class Key { \n" + |
| 13825 |
" }\n" + |
| 13826 |
" public static void foo(I i, Key key) {\n" + |
| 13827 |
" i.query(key);\n" + |
| 13828 |
" }\n" + |
| 13829 |
" \n" + |
| 13830 |
"}\n" + |
| 13831 |
"\n" + |
| 13832 |
"class Key {\n" + |
| 13833 |
" \n" + |
| 13834 |
"}\n" + |
| 13835 |
"class Bar {\n" + |
| 13836 |
" static class Key {\n" + |
| 13837 |
" \n" + |
| 13838 |
" } \n" + |
| 13839 |
" public static void bar(I i, Key key) {\n" + |
| 13840 |
" i.query(key);\n" + |
| 13841 |
" }\n" + |
| 13842 |
"}\n" + |
| 13843 |
"\n" + |
| 13844 |
"public class X {\n" + |
| 13845 |
" public static I getInstance() {\n" + |
| 13846 |
" return null;\n" + |
| 13847 |
" }\n" + |
| 13848 |
" public static void bar(I i, Key key) {\n" + |
| 13849 |
" i.query(key);\n" + |
| 13850 |
" }\n" + |
| 13851 |
"}\n" |
| 13852 |
); |
| 13853 |
|
| 13854 |
String str = this.workingCopies[0].getSource(); |
| 13855 |
String selection = "query/*here*/"; |
| 13856 |
int start = str.indexOf(selection); |
| 13857 |
int length = "query".length(); |
| 13858 |
|
| 13859 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 13860 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], ALL_OCCURRENCES, EXACT_RULE | ERASURE_RULE); |
| 13861 |
|
| 13862 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13863 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13864 |
getJavaSearchWorkingCopiesScope(), |
| 13865 |
this.resultCollector, |
| 13866 |
null); |
| 13867 |
assertSearchResults( |
| 13868 |
"src/X.java void I.query(Bar.Key) [query] EXACT_MATCH\n" + |
| 13869 |
"src/X.java void Bar.bar(I, Key) [query(key)] EXACT_MATCH" |
| 13870 |
); |
| 13871 |
} |
| 13872 |
public void testBug431357_009() throws CoreException { |
| 13873 |
this.workingCopies = new ICompilationUnit[1]; |
| 13874 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13875 |
"interface MyIF { \n" + |
| 13876 |
" public void query(Foo.InnerKey fk, Bar.InnerKey bk, String s); \n" + |
| 13877 |
" public void query/*here*/(Bar.InnerKey fk, Bar.InnerKey bk, String s);\n" + |
| 13878 |
"}\n" + |
| 13879 |
"\n" + |
| 13880 |
"class Foo { \n" + |
| 13881 |
" static class InnerKey { \n" + |
| 13882 |
" }\n" + |
| 13883 |
"\n" + |
| 13884 |
"}\n" + |
| 13885 |
"\n" + |
| 13886 |
"class Bar {\n" + |
| 13887 |
" static class InnerKey {\n" + |
| 13888 |
" }\n" + |
| 13889 |
" public static void bar(MyIF i, Foo.InnerKey fk, Bar.InnerKey bk) {\n" + |
| 13890 |
" i.query(fk, bk, \"\");\n" + |
| 13891 |
" }\n" + |
| 13892 |
"}\n" + |
| 13893 |
"public class X {}\n" |
| 13894 |
); |
| 13895 |
|
| 13896 |
String str = this.workingCopies[0].getSource(); |
| 13897 |
String selection = "query/*here*/"; |
| 13898 |
int start = str.indexOf(selection); |
| 13899 |
int length = "query".length(); |
| 13900 |
|
| 13901 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 13902 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], REFERENCES, EXACT_RULE | ERASURE_RULE); |
| 13903 |
|
| 13904 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13905 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13906 |
getJavaSearchWorkingCopiesScope(), |
| 13907 |
this.resultCollector, |
| 13908 |
null); |
| 13909 |
assertSearchResults("" |
| 13910 |
); |
| 13911 |
} |
| 13912 |
public void testBug431357_010() throws CoreException { |
| 13913 |
this.workingCopies = new ICompilationUnit[1]; |
| 13914 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13915 |
"interface MyIF { \n" + |
| 13916 |
" public void query(Foo.InnerKey fk, String s); \n" + |
| 13917 |
" public void query/*here*/(Bar.InnerKey fk, String s);\n" + |
| 13918 |
"}\n" + |
| 13919 |
"\n" + |
| 13920 |
"class Foo { \n" + |
| 13921 |
" static class InnerKey {}\n" + |
| 13922 |
"}\n" + |
| 13923 |
"\n" + |
| 13924 |
"class Bar {\n" + |
| 13925 |
" static class InnerKey {}\n" + |
| 13926 |
" public static void bar(MyIF i, Foo.InnerKey fk) {\n" + |
| 13927 |
" i.query(fk, \"\");\n" + |
| 13928 |
" }\n" + |
| 13929 |
"}\n" + |
| 13930 |
"public class X {}\n" |
| 13931 |
); |
| 13932 |
|
| 13933 |
String str = this.workingCopies[0].getSource(); |
| 13934 |
String selection = "query/*here*/"; |
| 13935 |
int start = str.indexOf(selection); |
| 13936 |
int length = "query".length(); |
| 13937 |
|
| 13938 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 13939 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], REFERENCES, EXACT_RULE | ERASURE_RULE); |
| 13940 |
|
| 13941 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13942 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13943 |
getJavaSearchWorkingCopiesScope(), |
| 13944 |
this.resultCollector, |
| 13945 |
null); |
| 13946 |
assertSearchResults("" |
| 13947 |
); |
| 13948 |
} |
| 13949 |
public void testBug431357_011() throws CoreException { |
| 13950 |
this.workingCopies = new ICompilationUnit[1]; |
| 13951 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13952 |
"interface MyIF { \n" + |
| 13953 |
" public void query(String s, Foo.InnerKey fk); \n" + |
| 13954 |
"}\n" + |
| 13955 |
"\n" + |
| 13956 |
"class Foo { \n" + |
| 13957 |
" static class InnerKey {}\n" + |
| 13958 |
"}\n" + |
| 13959 |
"\n" + |
| 13960 |
"class Bar {\n" + |
| 13961 |
" static class InnerKey {}\n" + |
| 13962 |
" public static void bar(MyIF i, Foo.InnerKey fk) {\n" + |
| 13963 |
" i.query(\"\", fk);\n" + |
| 13964 |
" }\n" + |
| 13965 |
"}\n" + |
| 13966 |
"public class X {}\n" |
| 13967 |
); |
| 13968 |
|
| 13969 |
String nonExistentPattern = "MyIF.query(String, Bar.InnerKey)"; |
| 13970 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(nonExistentPattern, IJavaSearchConstants.METHOD, REFERENCES, EXACT_RULE | ERASURE_RULE); |
| 13971 |
|
| 13972 |
new SearchEngine(this.workingCopies).search(pattern, |
| 13973 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 13974 |
getJavaSearchWorkingCopiesScope(), |
| 13975 |
this.resultCollector, |
| 13976 |
null); |
| 13977 |
assertSearchResults("" |
| 13978 |
);// Add new tests in JavaSearchBugsTests2 |
| 13979 |
} |
| 13980 |
public void testBug431357_012() throws CoreException { |
| 13981 |
this.workingCopies = new ICompilationUnit[1]; |
| 13982 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", |
| 13983 |
"interface MyIF { \n" + |
| 13984 |
" public void query/*here*/(Foo.InnerKey fk, Bar.InnerKey bk, String s); \n" + |
| 13985 |
" public void query(Bar.InnerKey fk, Bar.InnerKey bk, String s);\n" + |
| 13986 |
"}\n" + |
| 13987 |
"\n" + |
| 13988 |
"class Foo { \n" + |
| 13989 |
" static class InnerKey { \n" + |
| 13990 |
" }\n" + |
| 13991 |
" \n" + |
| 13992 |
"}\n" + |
| 13993 |
"\n" + |
| 13994 |
"class Bar {\n" + |
| 13995 |
" static class InnerKey extends Foo.InnerKey {\n" + |
| 13996 |
" }\n" + |
| 13997 |
" public static void bar(MyIF i, Foo.InnerKey fk, Bar.InnerKey bk) {\n" + |
| 13998 |
" i.query(fk, bk, \"\");\n" + |
| 13999 |
" }\n" + |
| 14000 |
"}\n" + |
| 14001 |
"public class X {}\n" |
| 14002 |
); |
| 14003 |
|
| 14004 |
String str = this.workingCopies[0].getSource(); |
| 14005 |
String selection = "query/*here*/"; |
| 14006 |
int start = str.indexOf(selection); |
| 14007 |
int length = "query".length(); |
| 14008 |
|
| 14009 |
IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length); |
| 14010 |
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(elements[0], ALL_OCCURRENCES, EXACT_RULE | ERASURE_RULE); |
| 14011 |
|
| 14012 |
new SearchEngine(this.workingCopies).search(pattern, |
| 14013 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
| 14014 |
getJavaSearchWorkingCopiesScope(), |
| 14015 |
this.resultCollector, |
| 14016 |
null); |
| 14017 |
assertSearchResults("src/X.java void MyIF.query(Foo.InnerKey, Bar.InnerKey, String) [query] EXACT_MATCH\n" + |
| 14018 |
"src/X.java void Bar.bar(MyIF, Foo.InnerKey, Bar.InnerKey) [query(fk, bk, \"\")] EXACT_MATCH" |
| 14019 |
); |
| 14020 |
} |
| 13430 |
} |
14021 |
} |