DOM Model - Collisions between multiple models

Hi, I'm working on plugin to add some (our company) specific features for StrutsAssistant and I have problem with DOM model for config file of formdef (it's Struts plugin for defining forms and validation).

In this XML file is used element ]]>. I created appropriate DOM interface, used correct annotations, etc. but I always get NullPointerException in NameUtil.
I tried to do some workarounds and found out, that the problem is probably caused by collision of Field interface in StrutsAssistant's Validator DOM Model and interface in my Formdef DOM model. Is there any way, how to separate these two models? I tried renamimg my Field interface (FormdefField) and mapping it to XML via annotations but it doesn't work either.

Or did I miss some instruction? I will be thankful for any advice.

Here's the stack:

java.lang.NullPointerException
at com.intellij.psi.codeStyle.NameUtil.nameToWords(NameUtil.java:30)
at com.intellij.util.xml.HyphenNameStrategy.convertName(HyphenNameStrategy.java:17)
at com.intellij.util.xml.impl.GenericInfoImpl.b(GenericInfoImpl.java:296)
at com.intellij.util.xml.impl.GenericInfoImpl.c(GenericInfoImpl.java:238)
at com.intellij.util.xml.impl.GenericInfoImpl.a(GenericInfoImpl.java:97)
at com.intellij.util.xml.impl.GenericInfoImpl.buildMethodMaps(GenericInfoImpl.java:48)
at com.intellij.util.xml.impl.GenericInfoImpl.getAttributeChildrenDescriptions(GenericInfoImpl.java:174)
at com.intellij.util.xml.impl.GenericInfoImpl.getChildrenDescriptions(GenericInfoImpl.java:189)
at com.intellij.util.xml.impl.GenericInfoImpl.a(GenericInfoImpl.java:70)
at com.intellij.util.xml.impl.GenericInfoImpl.a(GenericInfoImpl.java:58)
at com.intellij.util.xml.impl.GenericInfoImpl.a(GenericInfoImpl.java:58)
at com.intellij.util.xml.impl.GenericInfoImpl.a(GenericInfoImpl.java:58)
at com.intellij.util.xml.impl.GenericInfoImpl.getReferenceAttributeNames(GenericInfoImpl.java:266)
at com.intellij.util.xml.impl.DomManagerImpl$13.getReferenceElementNames(DomManagerImpl.java:3)
at com.intellij.util.xml.impl.DomLazyReferenceProvider.a(DomLazyReferenceProvider.java:14)
at com.intellij.util.xml.impl.DomLazyReferenceProvider.getReferencesByElement(DomLazyReferenceProvider.java:12)
at com.intellij.psi.impl.source.resolve.ResolveUtil.getReferencesFromProviders(ResolveUtil.java:109)
at com.intellij.psi.impl.source.xml.XmlAttributeValueImpl.getReferences(XmlAttributeValueImpl.java:35)
at com.intellij.psi.impl.SharedPsiElementImplUtil.a(SharedPsiElementImplUtil.java:20)
at com.intellij.psi.impl.SharedPsiElementImplUtil.findReferenceAt(SharedPsiElementImplUtil.java:10)
at com.intellij.psi.CompositeLanguageFileViewProvider.findReferenceAt(CompositeLanguageFileViewProvider.java:117)
at com.intellij.psi.impl.source.PsiFileImpl.findReferenceAt(PsiFileImpl.java:129)
at com.intellij.codeInsight.TargetElementUtil.findReference(TargetElementUtil.java:82)
at com.intellij.codeInsight.navigation.CtrlMouseHandler.a(CtrlMouseHandler.java:52)
at com.intellij.codeInsight.navigation.CtrlMouseHandler.access$700(CtrlMouseHandler.java:98)
at com.intellij.codeInsight.navigation.CtrlMouseHandler$TooltipProvider.execute(CtrlMouseHandler.java:31)
at com.intellij.codeInsight.navigation.CtrlMouseHandler$5.mouseMoved(CtrlMouseHandler.java:16)
at sun.reflect.GeneratedMethodAccessor116.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.util.EventDispatcher.dispatch(EventDispatcher.java:73)
at com.intellij.util.EventDispatcher.access$100(EventDispatcher.java:21)
at com.intellij.util.EventDispatcher$1.invoke(EventDispatcher.java:52)
at $Proxy17.mouseMoved(Unknown Source)
at com.intellij.openapi.editor.impl.EditorImpl$MyMouseMotionListener.mouseMoved(EditorImpl.java:15)
at java.awt.Component.processMouseMotionEvent(Component.java:5546)
at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:3153)
at java.awt.Component.processEvent(Component.java:5270)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3968)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3905)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1778)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:38)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:108)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:79)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

5 comments
Comment actions Permalink

Seems that this isn't connected to collisions. Could you provide the
code of interface that defines DOM model for the parent tag of the
attribute you're ctrl+mouse-moving on?

0
Comment actions Permalink

Here it is. For tags I am using HyphenNameStrategy aand for attributes JavaNameStrategy.

Thank you, Josef.

public interface Field extends FormdefRootElement {

@NotNull
@NameValue
@Required
public GenericAttributeValue getProperty(); @Nullable public GenericAttributeValue getGetter(); @Nullable public GenericAttributeValue getSetter(); @Nullable public GenericAttributeValue getInitial(); @Nullable @Convert(BooleanConverter.class) public GenericAttributeValue getReset(); @Nullable public GenericAttributeValue getSize(); @Nullable @Convert(FormPropertyTypeConverter.class) public GenericAttributeValue getType(); @Nullable public GenericAttributeValue getFormName(); @Nullable @Convert(BooleanConverter.class) public GenericAttributeValue getExclude(); @Nullable @ExtendClass("org.apache.struts.config.FormPropertyConfig") public GenericAttributeValue getConfigType(); @Nullable @Convert(BooleanConverter.class) public GenericAttributeValue getValidate(); @Nullable public GenericAttributeValue getDepends(); @Nullable @Convert(FormPropertyTypeConverter.class) public GenericAttributeValue getPage(); @Nullable public GenericAttributeValue getIndexedListProperty(); @Nullable public Converter getConverter(); @Nullable public List getSetProperties(); public SetProperty addSetProperty(); @Nullable public List getMsg(); public Msg addMsg(); @Nullable public List getArg(); public Arg addArg(); @Nullable public List]]> getVar();

public Var addVar();
}

0
Comment actions Permalink

A note: everything is actually @NotNull here.

How do you manage to use the same converter for PsiType (getType()) and
Long (getPage())?

What is Converter? Is it your DomElement? Please make sure that this
reference doesn't resolve to anywhere else.

And finally, rename your collection getters to getMsgs(), getArgs(),
getVars(). This should fix the problem. And thank you, I'll add an
assertion.

0
Comment actions Permalink

- FormPropertyConverter - my plugin has dependency on StrutsAssistant, from which I am using FormPropertyTypeConverter, just like interface "com.intellij.struts.dom.FormBean".

"Converter getConverter()" is part of my DOM model and I didn't notice any errors caused by this interface.

I knew, it would be something such stupid just like wrong names of getters.

Thank you for your help, I really appreciate it.

Josef Pavlas

0
Comment actions Permalink

Everything works fine now. At last I had to rename Converter interface in my DOM model, because it produced again NullPointerException in NameUtil, when I tried to access it's child tags (but it worked well, when I accessed only the ]]> element).

Thank you, Josef Pavlas.

0

Please sign in to leave a comment.