DOM error checking


I'm trying to get IDEA to highlight errors in my XML document.

According to the "Accessing XML through Intellij IDEA" document, adding @NameValue should be enough for IDEA to highlight duplicates on those attributes marked. Also, adding a @Required annotation should make that attribute to be marked as required as well. None of this is happening on my plugin at the moment for some reason. I override getIdentityScope() on my DomFileDescription and I see that is never been called, so I don't understand why.

Also, I want the following to be marked as an error (IDEA is already resolving 'reference' to 'element' for me)

<element id="myElement"/>
<myTag reference="myElement"/>
<myTag reference="unknownReference"/>     <!-- This should be an error, 'unknownReference' doesn't exist -->

Thanks in advance!


I'm working on similar problem.    To mark some attribute  as error  I did:
      - generated DOM model from XSD and adjusted it manually with namespaces etc.
      - (via DomFileDescription ) registered  file description with  proper Schema URI , I use URI for both key and namespace value.
      - created reference contributor and linked  PsiReferenceProvider ( implemented it ) to attribute value in question
      - reference provider creates PsiReference for just attribute value, and to mark attribute as error  just return null as reference

PROFIT:  your attribute value is now highlighted red  and there is even error messsage if you implemented one


You must provide an instance of com.intellij.util.xml.highlighting.BasicDomElementsInspection with your root DOM to provide error-highlighting.

See as sample (you don't need to override shouldCheckResolveProblems() if highlighting should be applied to all elements).


Hey Yann,

It would be nice if your information could be added to
There's currently a TODO posted at the top for exactly this question :)

I wonder if these wiki pages are publically editable? Perhaps users could contribute to the documentation to help improve things over time;



I'm going to add this bit later today. We welcome any contributions, please post anything you think should be added and we'll review and add it.

Page has been updated/clarified w/r to BasicDomElementsInspection


While yo are at it,  can you add some bits on automatic generation of DOM elements from XSD ( and that result must be processed heaviliy  )  and maybe better error messaging
when DOM  can not be created.  This one is not really helpful:

[  25891]  ERROR - currency.PrioritizedFutureTask - Original exception:  
java.lang.IllegalArgumentException: Argument 0 for @NotNull parameter of com/intellij/util/ObjectUtils._assertNotNull must not be null
     at com.intellij.util.ObjectUtils._assertNotNull(
     at com.intellij.util.ObjectUtils.assertNotNull(
     at com.intellij.util.xml.impl.StaticGenericInfo$
     at com.intellij.util.xml.impl.StaticGenericInfo$
     at com.intellij.util.containers.ContainerUtilRt.map2Set(
     at com.intellij.util.containers.ContainerUtilRt.map2Set(
     at com.intellij.util.containers.ContainerUtil.map2Set(
     at com.intellij.util.xml.impl.StaticGenericInfo.buildMethodMaps(
     at com.intellij.util.xml.impl.DynamicGenericInfo.checkInitialized(
     at com.intellij.util.xml.impl.DynamicGenericInfo.getCustomNameChildrenDescription(
     at com.intellij.util.xml.impl.DomSemContributor$
     at com.intellij.util.xml.impl.DomSemContributor$
     at com.intellij.semantic.SemServiceImpl$7$
     at com.intellij.semantic.SemServiceImpl$7$
     at com.intellij.semantic.SemServiceImpl.a(
     at com.intellij.semantic.SemServiceImpl.getSemElements(
     at com.intellij.semantic.SemService.getSemElement(
     at com.intellij.util.xml.impl.DomManagerImpl.getDomHandler(
     at com.intellij.util.xml.impl.DomManagerImpl.getDomElement(
     at com.intellij.patterns.DomPatterns$1.accepts(
     at com.intellij.patterns.DomPatterns$1.accepts(
     at com.intellij.patterns.ElementPatternCondition.accepts(
     at com.intellij.patterns.ObjectPattern.accepts(
     at com.intellij.patterns.PatternConditionPlus.process(
     at com.intellij.patterns.PatternConditionPlus.process(
     at com.intellij.patterns.TreeElementPattern$4.processValues(
     at com.intellij.patterns.PatternConditionPlus.accepts(
     at com.intellij.patterns.ElementPatternCondition.accepts(
     at com.intellij.patterns.ObjectPattern.accepts(
     at com.intellij.psi.impl.source.resolve.reference.NamedObjectProviderBinding.a(
     at com.intellij.psi.impl.source.resolve.reference.NamedObjectProviderBinding.addAcceptableReferenceProviders(
     at com.intellij.psi.impl.source.resolve.reference.PsiReferenceRegistrarImpl.getPairsByElement(
     at com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistryImpl.doGetReferencesFromProviders(
     at com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry.getReferencesFromProviders(
     at com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry.getReferencesFromProviders(
     at com.intellij.psi.impl.source.xml.XmlAttributeValueImpl.getReferences(
     at com.intellij.psi.impl.SharedPsiElementImplUtil.a(
     at com.intellij.psi.impl.SharedPsiElementImplUtil.findReferenceAt(
     at com.intellij.psi.impl.SharedPsiElementImplUtil.findReferenceAt(
     at com.intellij.psi.impl.source.tree.CompositePsiElement.findReferenceAt(
     at com.intellij.psi.SingleRootFileViewProvider.a(
     at com.intellij.psi.SingleRootFileViewProvider.findReferenceAt(
     at com.intellij.psi.impl.source.PsiFileImpl.findReferenceAt(
     at com.intellij.codeInsight.TargetElementUtilBase.findReference(
     at com.intellij.codeInsight.TargetElementUtilBase.getReferenceOrReferencedElement(
     at com.intellij.codeInsight.TargetElementUtil.getReferenceOrReferencedElement(
     at com.intellij.codeInsight.TargetElementUtilBase.findTargetElement(
     at com.intellij.codeInsight.TargetElementUtil.findTargetElement(
     at com.intellij.codeInsight.daemon.impl.IdentifierHighlighterPass.doCollectInformation(
     at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(
     at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1$
     at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(
     at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$
     at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(
     at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.a(
     at com.intellij.codeInsight.daemon.impl.PassExecutorService$
     at com.intellij.concurrency.JobLauncherImpl$
     at com.intellij.concurrency.JobLauncherImpl$
     at java.util.concurrent.FutureTask$Sync.innerRun(
     at com.intellij.concurrency.PrioritizedFutureTask.access$101(
     at com.intellij.concurrency.PrioritizedFutureTask$
     at java.util.concurrent.ThreadPoolExecutor.runWorker(
     at java.util.concurrent.ThreadPoolExecutor$
[  76475]  ERROR - n.impl.GeneralHighlightingPass - Argument 0 for @NotNull parameter of com/intellij/util/ObjectUtils._assertNotNull must not be null

( Helpful message would include offending class / method )


Thank you for your responses! I'll try that tomorrow.

While you are improving the docs, can you also add CustomReferenceConverter to it? In my experience, automatic referencing doesn't work unless you implement that interface in your Converter, although the document only says to implement the latter.


Could you please create an issue and attach your XSD you're using for creating DOM model (you can set visibility to idea-developers to hide it from public). Thanks.


You don't need to implement CustomReferenceConverter unless you want to create custom PSI references. Please post an example where your "plain" Converter does not work.


I have the following element:

<element property=""/>

'' is a property from a .properties file. I wanted to Cmd+Click on it to go to the .properties file.

I implemented a Converter<PropertyReference>, but before implementing CustomReferenceConverter, the converter did nothing as far as I know.


PropertyReference _is_ a PsiReference and should not be used as GenericAttributeValue type here.

Two possibilities:
1) change to GAV<IProperty> and use Converter
2) use CustomReferenceConverter and provide PropertyReference from there directly (easiest way)


Hi Yann,

I've tried your better solution (implement Converter<IProperty> without CustomReferenceConverter) and now I get proper errors on invalid properties (red wavy line instead of red text), but Cmd+Click doesn't go to the declaration unless I also implement the CustomReferenceConverter (after doing that, errors are now red text instead red wavy line). Is that the expected behavior?

Thanks again :)


I see, please try implementing ResolvingConverter instead and override ResolvingConverter#getPsiElement returning


Yes, that one worked, although when doing that, I lost the auto completion, as I'm returning an empty list on the getVariants() function. Previously, that worked automatically, so unless ResolvingConverter provides me with something Converter + CustomReferenceConverter does not, I'll continue with the latter :)

Thank you again, Yann!


Please sign in to leave a comment.