Field field = root.getRecords().get(0).getFields().get(0);
//I expected that I could get a instance of Form.class or Tree.class like this:
field.getForm()
field.getTree()
// but my registered "Tree" and "Form" not not available from the field.
Unless you want to have your DOM-extensions mapped to accessor with com.intellij.util.xml.CustomChildren, you probably want to use com.intellij.util.xml.reflect.DomExtensionsRegistrar#registerFixedNumberChildExtension com.intellij.util.xml.reflect.DomExtensionsRegistrar#registerCollectionChildrenExtension for sub-tag(s) instead.
Currently, the class "Field" not have accessors to "Form" and "Tree", because "Field" may be of another type, which does not need a reference to "Form" or "Tree". I expected that the accessor will be created automatically in implementation of my "Field" interface. Are there ways to access elements of a registered child without a accessor in parent interface?
Accessors cannot be generated dynamically. You could provide @CustomChildren accessor in parent DOM to gather all "dynamic" sub-elements (and use registerCustomChildrenExtension() again).
In this case, I do not understand how to implement Android plugin. AndroidDomExtender registers the child elements of the function registerSubtags(), but there is no interface accessors. For example org.jetbrains.android.dom.manifest.ManifestElement is empty, but AndroidDomExtender.registerExtensionsForManifest() add subTags for it. How does it work?
I assume Android plugin does not need to access DOM programmatically at runtime, but adding custom DOM like this still provides completion, highlighting, navigation etc.
Unfortunately I'm not aware of examples in Community Edition besides test (com.intellij.util.xml.DomChildrenTest#testGetDomElementCustomChild and com.intellij.util.xml.DomExtensionsTest#testCustomChildrenAccessFromExtender)
What do you mean with "from the code"? What usecase are you trying to solve?
Yann, thank you for having responded.
I will try to describe the problem in more detail.
I have xml like this:
and extender class:
Unless you want to have your DOM-extensions mapped to accessor with com.intellij.util.xml.CustomChildren, you probably want to use com.intellij.util.xml.reflect.DomExtensionsRegistrar#registerFixedNumberChildExtension com.intellij.util.xml.reflect.DomExtensionsRegistrar#registerCollectionChildrenExtension for sub-tag(s) instead.
Currently, the class "Field" not have accessors to "Form" and "Tree", because "Field" may be of another type, which does not need a reference to "Form" or "Tree".
I expected that the accessor will be created automatically in implementation of my "Field" interface.
Are there ways to access elements of a registered child without a accessor in parent interface?
Accessors cannot be generated dynamically. You could provide @CustomChildren accessor in parent DOM to gather all "dynamic" sub-elements (and use registerCustomChildrenExtension() again).
In this case, I do not understand how to implement Android plugin.
AndroidDomExtender registers the child elements of the function registerSubtags(), but there is no interface accessors. For example org.jetbrains.android.dom.manifest.ManifestElement is empty, but AndroidDomExtender.registerExtensionsForManifest() add subTags for it.
How does it work?
I assume Android plugin does not need to access DOM programmatically at runtime, but adding custom DOM like this still provides completion, highlighting, navigation etc.
Thank you very much for your answers.
Could you give me a link to example that uses dynamically added child elements at runtime?
Unfortunately I'm not aware of examples in Community Edition besides test (com.intellij.util.xml.DomChildrenTest#testGetDomElementCustomChild and com.intellij.util.xml.DomExtensionsTest#testCustomChildrenAccessFromExtender)
This is just what I was looking for.
Thank you.