| Summary: | Is SearchPattern.createPattern(...) works with vararg methods? | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | satya kalali <edigasatya> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | Manoj N Palat <manoj.palat> |
| Severity: | normal | ||
| Priority: | P3 | CC: | jarthana, manoj.palat |
| Version: | 4.5.1 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | stalebug | ||
(In reply to satya kalali from comment #0) Please try the following: MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(method, IJavaSearchConstants.METHOD,IJavaSearchConstants.REFERENCES, R_EXACT_MATCH); pattern.varargs = true;//use this pattern to search. new SearchEngine().search(pattern, new SearchParticipant[] { getDefaultSearchParticipant() }, scope, requestor, null); Many Thanks Manoj,Now I can see all references.
could you also please help me with below question?
below is the method:
de.allianz.abs.adag.vertrag.leben.navi.gen.vertrag.navigationservice.VertragNavigationService.hspEigen(de.allianz.abs.adag.vertrag.leben.navi.base.ComparableAttributeFilter.CompareType, java.lang.String[])
here CompareType is ENUM.
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(method, IJavaSearchConstants.METHOD,IJavaSearchConstants.REFERENCES, R_EXACT_MATCH);
pattern.varargs = true;
new SearchEngine().search(pattern, new SearchParticipant[] {getDefaultSearchParticipant() }, scope, requestor, null);
1) Above code working fine in eclipse Kepler
Version: Kepler Service Release 1
Build id: 20130911-2042
2) but same code not working in eclipse Mars
Version: Mars.1 Release (4.5.1)
Build id: 20150924-1200
I have tried below method signature in Mars Eclipse. Nothing is working fine.
de.allianz.abs.adag.vertrag.leben.navi.gen.vertrag.navigationservice.VertragNavigationService.hspEigen(de.allianz.abs.adag.vertrag.leben.navi.base.ComparableAttributeFilter.CompareType, java.lang.String[])
de.allianz.abs.adag.vertrag.leben.navi.gen.vertrag.navigationservice.VertragNavigationService.hspEigen(de.allianz.abs.adag.vertrag.leben.navi.base.ComparableAttributeFilter.CompareType, String[])
de.allianz.abs.adag.vertrag.leben.navi.gen.vertrag.navigationservice.VertragNavigationService.hspEigen(CompareType, String[])
de.allianz.abs.adag.vertrag.leben.navi.gen.vertrag.navigationservice.VertragNavigationService.hspEigen(CompareType, String...)
de.allianz.abs.adag.vertrag.leben.navi.gen.vertrag.navigationservice.VertragNavigationService.hspEigen(CompareType, java.lang.String...)
could please let me know what I missed in this case. please see below enum class also.
public class ComparableAttributeFilter {
public enum CompareType {
EQUAL,NOT}
}
Extracting a test case from your comment 2, the search for references yield correct results - the test case which I used is given below: enum CompareType { EQUAL,NOT} class X { public void foo(CompareType ct, String s) {} public void foo(CompareType ct, String ... s) {} public static void main(String[] args) { X x = new X(); CompareType ct = CompareType.EQUAL; String s = null; x.foo(ct, s); x.foo(ct, s, s); x.foo(ct, s, s, s); } } I've tested with the Neon release. If you find a problem with Neon release, I would request you to post a self-contained test case that reproduces the issue. Hi Manoj,
Please find the below test cas, here enum is inside the class.
public class BOSample{
public enum ComapreType {
NOT,EQUAL;
}
}
public class SampleTest {
public static void comapreTest(ComapreType comapre,String...criteria){
//
}
}
public class SampleToolTest {
public void test(){
SampleTest.comapreTest(ComapreType.EQUAL, "satya");
SampleTest.comapreTest(ComapreType.EQUAL, "satya","kalali");
}
}
IJavaSearchScope scope = createJavaSearchScope(packages.toArray(new IPackageFragment[packages.size()]));
MethodPattern pattern = (MethodPattern) SearchPattern.createPattern(method, IJavaSearchConstants.METHOD,IJavaSearchConstants.REFERENCES, R_EXACT_MATCH);
pattern.varargs = true;
new SearchEngine().search(pattern, new SearchParticipant[] { getDefaultSearchParticipant() }, scope, requestor, null);
Here method is: sampletest.SampleTest.comapreTest(SampleTest.BOSample.ComapreType, java.lang.String[])
No search references I have found.
I have to use Mars Eclipse IDE because my development IDE is Eclipse Mars. could you please check search references for above test case?
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
SearchPattern pattern = SearchPattern.createPattern(method, IJavaSearchConstants.METHOD,IJavaSearchConstants.REFERENCES, R_EXACT_MATCH); new SearchEngine().search(pattern, new SearchParticipant[] { getDefaultSearchParticipant() }, scope, requestor, null); here method: de.test.aktivstrg.TestSparteEigen.test(java.land.String[]) My method is vararg method ,need to find all method references in the workspace, but in the result I can see only references with one argument. could you help me with this? For Exaple: Var arg method:public static void test(String...criteria){ // } It has two references in workspace: public void testwithsingleparameter(){ TestSparteEigen.test("satya"); } public void testwithmutipleparameter(){ TestSparteEigen.test("satya","kalali"); } I got the below result: public void testwithsingleparameter(){ TestSparteEigen.test("satya"); }