Search for Overridden Methods and Fields
Hi,
Is it possible to find overridden methods and fields at scope public, protected, private levels thorough Intellij structural search
the private level meaning I could have the same field say x in both parent and child. then it could be taken as x is hidden in the child.
Structural search is very power full.. but lacks proper documentation.. any pointers would help.
Regards,
Nagendra
Please sign in to leave a comment.
I am in heavy need of finding out Overridden methods..
Was able to figure out how to get private methods and fields but not overridden methods.
Regards,
Nagendra
Is Jetbrains listening.. pl. support as there should be some simple way to get this though structural search..
Sorry for late answer:
Take this pattern (slightly modified predefined pattern "fields of class")
class $Class$ extends $SuperClass$ {
$FieldType$ $FieldName$ = $Init$;
}
and set complete match script constraint like
SuperClass.parent.parent.findFieldByName(FieldName.text, false) != null
On 09.03.2010 20:19, Nagendra wrote:
>
--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
Actually, set complete match script constraint should be like
SuperClass.resolve().findFieldByName(FieldName.text, false) != null
On 09.03.2010 21:41, Maxim Mossienko (JetBrains) wrote:
>
>
>
>
>
>> Is Jetbrains listening.. pl. support as there should be some simple
>> way to get this though structural search..
>>
>> ---
>> Original message URL:
>> http://www.jetbrains.net/devnet/message/5258204#5258204
>
>
--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
Thank You Maxim for responding. I appricate your time on this.
I have tried what you suggested, but it does not seem to work.. I tried with a simple case with
both parent and child delcaring a variable
int k = 10;
and with complete match script value to check for SuperClass.resolve().findFieldByName(FieldName.text, false) != null
This is not able to show this field overide.
Could you also help on
1. How to get overriden methods
2. Also a good documentation related to structural search and api related to script e.g what are the supported methods in SuperClass etc.
I understand Structural Search is very powerfull but lacks any serious documentation (May be I am unable to find one). Pl. respond.
Regards,
Nagendra
Argh, it worked for just for single example:
class Foo {
int x;
}
class Bar extends Foo {
int x;
}
class Foo2 {
}
class Bar2 extends Foo2 {
int x;
}
Actually, if you see psi structure for the pattern you will exact class names for the variables and available methods (e.g. SuperClass.parent.parent is just PsiClass and have all methods from it)
Could you try adding a new variable k
class Bar2 extends Foo2{
int x;
int k;
}
some thing like this and try it..
not sure why it does not work with new variable addition.
Regards,
Nagendra
If I add another set of fields $FieldType2$ $FieldName2$ = $Init2$;
with constraints 0 .. unlimited for FieldName2 and 0 .. 1 for Init2
SSR correctly finds needed fields for me
Hi Maxim,
Nope this does not seem to work for me..
> SSR correctly finds needed fields for me
In your case are u seeing only x of Bar2 class.
In my case it always says no match found.
Also, I was thinking the first pattern and complete match should still find the x value when k is added.
Any case I did try your suggestions with 2nd pattern and constraints.. but no luck.
Any case your inputs are very valuable and hope in few other days of effort at my end, I may get it right.
Could you pl. help me on the method overrides too pl.
Regards,
Nagendra
I mean following complete pattern works for me (with additional constraints specified in previous post):
class $Class$ extends $SuperClass$ {
$FieldType$ $FieldName$ = $Init$;
$FieldType2$ $FieldName2$ = $Init2$;
}
Please use http://www.jetbrains.com/idea/documentation/ssr.html for starting point