XML Api: Help needed with Dom resolve/convert

The basic mechanism supplied with @NameValue is almost what I need, but not quite:

My elements represent states which can be nested. Each state has a name that is relative to the super state's name. Each state also contains a list of transition where the "to" attribute references another state using relative names.
For example this would be a valid transition:

      
    
]]>


The documentation is a little terse on how to achieve this.
My understanding is that I should extend DomResolveConverter, but which methods should I override?
All in all I am in a confused state right now with all those converters, resolvers and meta-annotations whirling around.

10 comments

There are 2 basic methods in converters: fromString() and toString(). You
should anyway override them, and get working XML references. If you extend
ResolvingConverter and override getVariants() method, you'll have
completion. I don't think you should deal with DomResolveConverter, it just
won't help you.

"Stephen Friedrich" <no_mail@jetbrains.com> wrote in message
news:27430469.1159535668436.JavaMail.itn@is.intellij.net...

The basic mechanism supplied with @NameValue is almost what I need, but
not quite:

>

My elements represent states which can be nested. Each state has a name
that is relative to the super state's name. Each state also contains a
list of transition where the "to" attribute references another state
using relative names.
For example this would be a valid transition:

    
>      
>    
> ]]>

>

The documentation is a little terse on how to achieve this.
My understanding is that I should extend DomResolveConverter, but which
methods should I override?
All in all I am in a confused state right now with all those converters,
resolvers and meta-annotations whirling around.



0

A closely related question/problem:
It seems that "multi-interface-inheritance" is not supported.
Not all my state elements can be the target of a transition.
Those that can have a name attribute that is required.
To be more specific in the declaration of my transition element, I introduced another interface "DomToNode" which is used as the type value of the "to" attribute of transition:

 getName();
}
]]>

All nodes that can be the target of a transition additionally extend this interface, e.g.

 getAsync();

    List getScripts();
    ....
]]></pre><p>After I implemented this change resolving did no longer work.</p>
0

Status update:
I pushed down the getName() method to each individual node class and it did not help.
Then I changed the reference in Transition back from DomToNode to a single specific node class (task nodes):

 getTo();
]]>

Now resolving works again - but only for that single class...

0

If "multi-interface-inheritance" were not supported, all our Java EE
wouldn't work, since it heavily uses lots of interfaces. So at least in some
way it works. Of course, there can be bugs there.

Resolving from where to where? How does your reference declaration and
resolving work? Maybe, you have in fact several @NameValue-methods in your
DomFork?

"Stephen Friedrich" <no_mail@jetbrains.com> wrote in message
news:4882298.1159537669954.JavaMail.itn@is.intellij.net...
>A closely related question/problem:

It seems that "multi-interface-inheritance" is not supported.
Not all my state elements can be the target of a transition.
Those that can have a name attribute that is required.
To be more specific in the declaration of my transition element, I
introduced another interface "DomToNode" which is used as the type value
of the "to" attribute of transition:

 public interface DomToNode extends DomElement {
>    @NameValue
>    @NotNull
>    @Required
>    GenericAttributeValue getName();
> }
> ]]>

All nodes that can be the target of a transition additionally extend this
interface, e.g.

 public interface DomFork extends DomJpdlBaseElement, DomToNode {
>    @NotNull
>    GenericAttributeValue getAsync();
>
>    List getScripts();
>    ....
> ]]></pre><p>After I implemented this change resolving did no longer work. </p></blockquote><p><br/><br/></p>
0

Does your task have parents that are also DomToNode's? If yes, then,
unfortunately, currently DOM resolving works so that as soon as it founds
something belonging to the needed class, it doesn't go to its children for
performance reasons. You can file a JIRA request, I'll try to fix this.

"Stephen Friedrich" <no_mail@jetbrains.com> wrote in message
news:14537283.1159538799579.JavaMail.itn@is.intellij.net...

Status update:
I pushed down the getName() method to each individual node class and it
did not help.
Then I changed the reference in Transition back from DomToNode to a single
specific node class (task nodes):

 public interface DomTransition extends DomJpdlBaseElement {
>    @Required
>    @NotNull
>    GenericAttributeValue getTo();
> ]]>

Now resolving works again - but only for that single class...



0

Ah, I see. That will be the problem. A super state can also have incoming transitions. In fact resolving indeed works for the outermost node (which is a process-definition).

Hm, I have to do my own resolving anyway to handle relative names. If I do that I will be able to go down from super states to nested states myself, right?

So actually there seems to be no real problem with "multi-interface-inheritance" by itself and I can continue, write my own resolver and introduce yet another interface "DomFromNode" for all Nodes that have a "List]]> getTransactions()" method/children tags.

Thanks a lot for being so responsive.

0

Hm, I have to do my own resolving anyway to handle relative names. If I do
that I will be able to go down from super states to nested states myself,
right?

Sure.


0

Thanks. That seems to be working now. So far I have only implemented a Converter rather than a ResolvingConverter (difference should only be in missing code completion, right?)
However I do not get working error highlighting. When I return null from fromString() my getErrorMessage() method occasionally gets called, but I never actually see any errors in the editor.

There are a lot of exceptions though, whenever I edit. Can it be that the following exceptions prevents highlighting. Do you have any idea where I should go and look for the cause of this?
The stacktrace is not that helpful to me, because it does not contain any references to my own code (though my own code is responsible for it without doubt).

)
	at com.intellij.util.xml.impl.GenericValueReferenceProvider.getReferencesByElement(GenericValueReferenceProvider.java:61)
	at com.intellij.psi.impl.source.resolve.ResolveUtil.getReferencesFromProviders(ResolveUtil.java:99)
	at com.intellij.psi.impl.source.xml.XmlAttributeValueImpl.getReferences(XmlAttributeValueImpl.java:5)
	at com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor.a(XmlHighlightVisitor.java:74)
	at com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor.visitXmlAttributeValue(XmlHighlightVisitor.java:225)
	at com.intellij.psi.impl.source.xml.XmlAttributeValueImpl.accept(XmlAttributeValueImpl.java:6)
	at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visitXmlElement(HighlightVisitorImpl.java:535)
	at com.intellij.psi.XmlElementVisitor.visitXmlAttributeValue(XmlElementVisitor.java:62)
	at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visitXmlAttributeValue(HighlightVisitorImpl.java:354)
	at com.intellij.psi.impl.source.xml.XmlAttributeValueImpl.accept(XmlAttributeValueImpl.java:6)
	at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visit(HighlightVisitorImpl.java:42)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(GeneralHighlightingPass.java:60)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.doCollectInformation(GeneralHighlightingPass.java:120)
	at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:59)
	at com.intellij.codeInsight.daemon.impl.UpdateThread$2.run(UpdateThread.java:7)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:42)
	at com.intellij.codeInsight.daemon.impl.UpdateThread.a(UpdateThread.java:45)
	at com.intellij.codeInsight.daemon.impl.UpdateThread.access$100(UpdateThread.java:42)
	at com.intellij.codeInsight.daemon.impl.UpdateThread$1.run(UpdateThread.java:2)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:40)
	at com.intellij.codeInsight.daemon.impl.UpdateThread.run(UpdateThread.java:40)
Caused by: java.lang.IllegalStateException: @NotNull method com/intellij/util/xml/impl/DomInvocationHandler.getScalarConverter must not return null
	at com.intellij.util.xml.impl.DomInvocationHandler.getScalarConverter(DomInvocationHandler.java)
	at com.intellij.util.xml.impl.InvocationCache$3.invoke(InvocationCache.java:4)
	... 24 more
]]>

0

Thanks. That seems to be working now. So far I have only implemented a
Converter rather than a ResolvingConverter (difference should only be in
missing code completion, right?)

ResolvingConverter has more methods that are delegated from the reference,
but basically - yes.

However I do not get working error highlighting. When I return null from
fromString() my getErrorMessage() method occasionally gets called, but I
never actually see any errors in the editor.

Very strange. The references should be created anyway, they should be
resolved, completed, and highlighted in case they cannot be resolved. Are
the first two points present? Could you provide more details?

There are a lot of exceptions though, whenever I edit. Can it be that the
following exceptions prevents highlighting. Do you have any idea where I
should go and look for the cause of this?
The stacktrace is not that helpful to me, because it does not contain any
references to my own code (though my own code is responsible for it
without doubt).


Maybe, you have disabled assertions? This is the only way I can figure out
about this. If yes, please, enable them, and you'll see some other
exception, which, maybe, will help.


0

Maybe, you have disabled assertions? This is the only way I can figure out
about this. If yes, please, enable them, and you'll see some other
exception, which, maybe, will help.

Thanks again for the hint. I checked my idea.exe.vmoptions and assertions are enabled there.
Then I remembered that those options aren't important because I started the Idea instance as a run configuration from my plugin project. Idea does not add "-ea" in the run configuration automatically and I had not added it there either.

I try to make heads and tails of the exception I am getting now tomorrow when I got a little sleep:

)
	at com.intellij.util.xml.impl.GenericValueReferenceProvider.getReferencesByElement(GenericValueReferenceProvider.java:8)
	at com.intellij.psi.impl.source.resolve.ResolveUtil.getReferencesFromProviders(ResolveUtil.java:58)
	at com.intellij.psi.impl.source.xml.XmlAttributeValueImpl.getReferences(XmlAttributeValueImpl.java:10)
	at com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor.a(XmlHighlightVisitor.java:339)
	at com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor.visitXmlAttributeValue(XmlHighlightVisitor.java:447)
	at com.intellij.psi.impl.source.xml.XmlAttributeValueImpl.accept(XmlAttributeValueImpl.java:18)
	at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visitXmlElement(HighlightVisitorImpl.java:139)
	at com.intellij.psi.XmlElementVisitor.visitXmlAttributeValue(XmlElementVisitor.java:62)
	at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visitXmlAttributeValue(HighlightVisitorImpl.java:596)
	at com.intellij.psi.impl.source.xml.XmlAttributeValueImpl.accept(XmlAttributeValueImpl.java:18)
	at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visit(HighlightVisitorImpl.java:552)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(GeneralHighlightingPass.java:67)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.doCollectInformation(GeneralHighlightingPass.java:130)
	at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:59)
	at com.intellij.codeInsight.daemon.impl.UpdateThread$2.run(UpdateThread.java:4)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:328)
	at com.intellij.codeInsight.daemon.impl.UpdateThread.a(UpdateThread.java:28)
	at com.intellij.codeInsight.daemon.impl.UpdateThread.access$100(UpdateThread.java:35)
	at com.intellij.codeInsight.daemon.impl.UpdateThread$1.run(UpdateThread.java:0)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:82)
	at com.intellij.codeInsight.daemon.impl.UpdateThread.run(UpdateThread.java:20)
Caused by: java.lang.AssertionError: T interface com.intellij.util.xml.GenericAttributeValue
	at com.intellij.util.xml.impl.DomInvocationHandler$2.create(DomInvocationHandler.java:8)
	at com.intellij.util.xml.impl.DomInvocationHandler$2.create(DomInvocationHandler.java:6)
	at com.intellij.util.containers.FactoryMap.get(FactoryMap.java:35)
	at com.intellij.util.xml.impl.DomInvocationHandler.getScalarConverter(DomInvocationHandler.java:30)
	at com.intellij.util.xml.impl.InvocationCache$3.invoke(InvocationCache.java)
	... 24 more]]>

0

Please sign in to leave a comment.