how to parse xml attribute value with dot to PsiElements

For example
    <bean com.seventh7.demo.Man" splitted by dot to PsiElement?

16 comments

Hi,

This functionality should already be offered to you out of the box.
You check out the DOM API for adding validation etc

Alan

0

hi,

   i can understand the api to manage xml, i just want to separate the attribute value part to PsiElement,

  such as:

  <bean com" part as a PsiElement, and take the "seventh7" as another PsiElement

0

Could you explain your usecase please?
This could help us give more concise advice related to your problem :)

0

Task an example,

A xml tag like: <bean demo", i can navigate to a package, and i click on the "Entity", i can navigate to the Human class. It's done by intellij as default.
But now, i want to something else when i click on the world "demo"

0

If you own your own XmlFileDescription class etc You can add add to your XmlAttribute field the `@Converter(YourConverter.class)` annotation. Then you should create the converter to be of type `List<YourReferenceType>`.
For instance `public class YourConverter extends Converter<List<YourReferenceType>>` and within the DomElement interface class change the field type to be of `GenericAttributeValue<List<YourReferenceType>>`

If this is functionality you are wishing to add to existing Spring files, a different approach will be required.

0

Thank you buddy

It's very near to my purpose. And does this way work with code completion as well?

I'm also interested in that how i have to deal with existing Spring files?  :)

Thank you very very much for your help

(Intellij is so well designed :p)

0

Yes, this is all configurable under the Converter implementation.

Unfortunately if you wish to add this to existing Spring files you will have to ask for the help of a Jetbrains team member, as the plugin is currently closed source.
Hopefully they will be able to help you with your issue :)

0

It's generous of you to give me so much of your time. Thank you

0

What functionality do you want to provide exactly? I don't understand what navigation target could be useful additionally to the package/class already provided by Spring plugin.

0

I'm writting a mybatis plugin.
I want to support the code completion and reference of property of resultMap in mapper xml files :)


Such as:


<resultMap id="example" type="com.seventh7.demo.Man">
   <result property="blog.user.name" column="username" />
</resultMap>

0

Ok, so this is not about integrating with spring.xml files then.

Btw, there's already three iBatis plugins, maybe you can join efforts?
http://plugins.jetbrains.com/search/index?pr=idea&search=batis

0

yeah. i'm the author of http://plugins.jetbrains.com/plugin/7293?pr=idea,
i just want to find the right way to deal with my requirement:)

0

If you're using DOM, you don't need to do anything special, just use

GenericAttributeValue<PsiClass> getProperty();

in DOM-class for <result>. All navigation/completion will be provided automatically.

0

ok, i will try it. thank you so much


0

And I am the author of http://plugins.jetbrains.com/plugin/6725 iBATIS/MyBatis mini-plugin that has pretty basic MyBatis support and emphasizes on iBATIS support. Now I feel like removing MyBatis support out of my plugin to avoid clashing with Lin Yang's MyBatis plugin. Lin Yang, is your plugin open-source? https://github.com/seventh7/intelliij-mybatis-plugin returns 404

0

i plan to make it open source when i rewrite it to make code clear and support more features, as i'm just a newer to intellij plugin development.
:)

0

Please sign in to leave a comment.