conditions to match reference provider
Hi all,
I'm stich at condition for mathcing reference provider.
I managed to match content of xml attribute by name:
xmlAttributeValue().withLocalName("receiver")
and now I'm trying to constrain this condition to certain tag defined as dom elemement:
xmlAttributeValue().withLocalName("receiver").and(domElement().withParent(FooBar.class))
and (surprize!) this does not work as intendet. Is there some desrcription abot condition mathing?
( sources are bare of comments )
Please sign in to leave a comment.
Something like this should work:
xmlAttributeValue()
.withLocalName("receiver")
.withSuperParent(2, DomPatterns.withDom(domElement(FooBar.class)
Hi Pribluda,
Could you post your sample XML, what you're trying to match, and what your DomElement interfaces look like? :)
Could it also be that your parent DomElement is actually a SuperParent for instance?
For example, here is an example of matching the XmlAttributeValue "value" if it has a super domElement parent of a BlueprintBean
Example of matched XML :
<property name="quux" value="${hello.world}" />
</bean>
Example of the pattern used
My XML:
And automagically generated interface:
So I like to reference to attribute value of this tag defined by interface. And while we are at it, I'd like to navigate to some other corresponding
tag ( so I shall return proper PSI element from my reference provicder? right? ) and provide error if no such tag is found. Is PsiReferenceContributor proper tool for this?
PS: My first name is Konstantin %)
Solved.
Proper condition was:
Depending on your DOM and @Namespace definitions there, this might differ in the future when you change one place. I'd use DomPatterns if possible to make sure any changes in DOM are reflected here.
It did not worked with DomPatterns , despite declared namespace on generated interface.
Did you call com.intellij.util.xml.DomFileDescription#registerNamespacePolicy in your DomFileDescription?
Namespace policy is registered. Shall I put key of namespace policy into @Namespace annotation or uri on interface?
@Namespace takes the key which is then registered in com.intellij.util.xml.DomFileDescription#registerNamespacePolicy with the corresponding URI(s).
See com.intellij.struts2.dom.struts.Struts2DomFileDescription and com.intellij.struts2.dom.struts.StrutsRoot as example.
OK, not I'm slowly groking my problem. You have to assure reachability of all the elements from root elelemt
with proper @Subag annotations - otherwise DOM does not work properlyand does not know subtag classes.
Also, need to check generated dom classes and adjust manually