Need help creating filter for ReferenceProvider

Hello
I got following situation
There's 2 annotations: @Inner and @Outer. @Inner can be used inside @Outer and on it's own. @Inner has attribute "field".
class MyClass {

@Inner(field = "fld")
public void method1() {
}
@Outer({
@Inner(field = "fld")
})
public void method2() {
}
}
The goal is to get text element corresponding to value of attribute field that INSIDE @Outer annotation.
There's obvius solution to filter all @Inner annotaitons and then search for parent, but it bringing some overheads and ugliness in code :)

So is there any way to do this using only filters ?

To filter all annotations i did following
registry.registerReferenceProvider(
new AnnotationParameterFilter(PsiLiteralExpression.class, "org.Outer", "field"),
PsiLiteralExpression.class,
new MyReferenceProvider()
);

Edited by: evgeny on Apr 3, 2008 6:47 AM

2 comments
Comment actions Permalink

evgeny wrote:

Hello
I got following situation
There's 2 annotations: @Inner and @Outer. @Inner can be used inside @Outer and on it's own. @Inner has attribute "field".

class MyClass {

@Inner(field = "fld")
public void method1() {
}
@Outer{
@Inner(field = "fld")
}
public void method2() {
}
}

The goal is to get text element corresponding to value of attribute field that INSIDE @Outer annotation.
There's obvius solution to filter all @Inner annotaitons and then search for parent, but it bringing some overheads and ugliness in code :)

So is there any way to do this using only filters ?

To filter all annotations i did following
registry.registerReferenceProvider(
new AnnotationParameterFilter(PsiLiteralExpression.class, "org.Outer", "field"),
PsiLiteralExpression.class,
new MyReferenceProvider()
);


something like
new AndFilter(new AnnotationParameterFilter(PsiLiteralExpression.class,
"org.Inner", "field"), new SuperParentFilter(new AndFilter(new
ClassFilter(PsiAnnotation.class, new TextFilter("org.Outer")))))
?

0
Comment actions Permalink

Hi! Thnx !!!
Not exactly the same but appreciate for the idea how to implement this :)

0

Please sign in to leave a comment.