|
|
|
[
Permlink
| « Hide
]
Sascha Weinreuter - 17 Aug 05 18:13
This is related to IDEA-624
This is unofficial API that will work after 3507+:
Consider we have xml like following example to be bound to custom descriptors: <ns:mytag xmlns:ns="myuri"> ... </ns:mytag> One needs to map the uri ( "myuri") to (e.g.) xml schema file that has "myuri" as target namespace (via external resource manager mapping), MetaRegistry.addMetadataBinding( IDEA will instantiate the MyNsDescriptor and will query the instance for XmlElementDescriptor/XmlAttributeDescriptors for original document tags/attributes IDEA uses XmlElementDescriptor / XmlAttributeDescriptor for the validation and completion in the xml. Maxim, I finally got to using this API. It looks like, when Filename.xml is opened, my ElementFilter is being called on some virtual document called Filename.xml.dtd, which contains full DTD specification PSI. It's never called on the actual elements of the XML file. Is this correct? Is there some way to figure out which file that DTD corresponds to?
IDEA defaults to dtd creation when schema descriptor could not be found
Keith, I wonder if you have successfully attached your custom XmlElementDescriptors,
Does the getName(PsiElement), getRootElementDescriptors(), getElementDescriptors called for your descriptors during completion?
Keith, I am keen to know about completion issue with your descriptors. Could you answer previous question, please?
It looks like now completion works. Some fix must have been committed since February because I haven't changed the code.
However there's big problem with the API. The files are defined like this <cool:root> There are no xmlns descriptors. IDEA highlights every cool:* tag in red as "Namespace cool is not bound." I wrote this code so long ago that I don't remember how this code works, so I can't guarantee that I'm not doing something wrong, but I'd appreciate any help. To provide your one info on used namespaces you may implement 'XmlFileNSInfoProvider' in your ProjectComponent. It will be quired for default prefixes and their namespaces for particular files.
You can register your PsiMetaData derived classes (XmlElementDescriptor/XmlNSDescriptor, etc) via MetaDataRegistrar that will be used as descriptors The enhancement is implemented in Demetra branch, if something is not working in 5.1.1 please file separate request
In my comment above (07 Apr 06 22:26) I explain the problem. This is in 5.1.1. I am correctly using metadata registry I know, because validation and completion works. However, the entire file is highlighted in red for "namespace cool not bound". Can I do something to avoid this in 5.1.1?
You may ask the Hector to not inspect the XML files
Custom XML descriptor validation should work independent from the Hector setting (or you mean ExternalAnnotator?). I believe the plugin could set HighlightingSettingsPerFile per needed file.
Keith, WHERE have you been in the EAP of 5.1?
First problem is most likely because one of your parent descriptors does not provide the descriptor for child tag As to inspections, you could run them if your descriptor implements Validator Have you solved the problems with work around above?
No, this won't work, it's too painful. I have about 30 inspections defined for this xml language and I won't convert them all to Validators. Additionally that would prevent them from being run in batch without me having to write custom batch inspection engine.
It would be great if you could make this work in 5.1 series and release EAP build. Until then most of us will not upgrade to 5.1. There is no plans about any development for IDEA 5.1, you need to discuss it with Max or Alex
5.1 branch is closed for new features and API change. Period.
We cannot upgrade to 5.1 then. Is there some channel we could use to avoid this in the future? We waited for 2 months for a response to this, and by then the EAP was closed. You guys are generally not responsive to posts on openapi forums or jira requests.
Your post (http://www.jetbrains.net/jira/browse/IDEADEV-5499#action_47324
Probably, you may "inject" your namespace ids and xmlemenentdescriptors via reflection... Keith, could you, please, check api in Demetra?
Your Loader doesn't implement 'XmlFileNSInfoProvider' interface that was added (and described in my comment)
Adding following code fix esthe unbound ns error. public static final String MY_NS = "net.kano"; @Nullable private boolean isAcceptableFile(String name) { return name != null && name.toLowerCase().endsWith(".cool"); } IDEA complains about
<cool:illegal/> that element is not allowed here when <cool:invalid/> is root tag it is red with 'element should be declared' message
Keith, the problem is with your code, check out result of isAcceptableFile call results.
Maxim, in 5.1.2 this seems to work, but there are a few things:
Am I right in assuming returning an array with { "", "http://myuri" } is how to set default namespace? nonprefixed items have "" prefix,
IDEA does not use provider that gives wrong (null) info, check '#com.intellij.xml.util.XmlUtil' debug messages |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||