AutoComplete in xml editor

hi everybody
i am working on a plugin for some xml based config file and wanna enable auto complete so i begin searching and realised that i must override the PsiElement.getVariants and provide some variation in PsiReference to those elements BUT i have some questions
1- if i subclassed the XmlTag and XmlAttribute and provide them with my custom PsiReference, HOW TO REGISTER THESE CLASSES TO MAKE IDEA USE THEM NOT THE ORIGINAL IMPLEMENTATION, how to make my custom class with the overridden getReference used

2- while browsing this forum i notice that u r using some classes which i cannot find in the whole classpath of the plugin project such as
CompletionData,CompletionUtil,ReferenceProvidersRegistry
so where r these classes and where to find anyting about them

by joseph

4 comments

Hello joe,

j> i am working on a plugin for some xml based config file and wanna
j> enable auto complete so i begin searching and realised that i must
j> override the PsiElement.getVariants and provide some variation in
j> PsiReference to those elements BUT i have some questions
j>
j> 1- if i subclassed the XmlTag and XmlAttribute and provide them with
j> my custom PsiReference, HOW TO REGISTER THESE CLASSES TO MAKE IDEA
j> USE THEM NOT THE ORIGINAL IMPLEMENTATION, how to make my custom class
j> with the overridden getReference used

This is not possible. Subclassing XmlTag is not the way to achieve the behavior
you need.

j> 2- while browsing this forum i notice that u r using some classes
j> which i cannot find in the whole classpath of the plugin project such
j> as
j>
j> CompletionData,CompletionUtil,ReferenceProvidersRegistry
j>
j> so where r these classes and where to find anyting about them

These are internal undocumented classes which are in idea.jar. Using these
classes (ReferenceProviderRegistry in particular), is in fact the correct
way to implement this functionality, but as they are not (yet) part of OpenAPI,
we don't provide any official support for them. You can find advice and examples
of using these classes if you search this forum.

--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"


0

ok , i browsed a lot of posts here and i am confused a bit between 2 ways of doing it
is the right way is:
implement PsiReference and PsiReferenceProvider (especially getVarient which i read that get called upon CTRL-SPACE and the entries it return will be available in the popup) and register with the ReferenceProvidersRegistry

OR
subclass CompletionData,override completeReference,add the entries to the set and then register it with CompletionUtil

please someone explain which method to use and when to use the other
thanx in advance
joe

0

Hello joe,

j> ok , i browsed a lot of posts here and i am confused a bit between 2
j> ways of doing it
j> is the right way is:
j> implement PsiReference and PsiReferenceProvider (especially
j> getVarient which i read that get called upon CTRL-SPACE and the
j> entries it return will be available in the popup) and register with
j> the ReferenceProvidersRegistry
j> OR
j> subclass CompletionData,override completeReference,add the entries to
j> the set and then register it with CompletionUtil
j> please someone explain which method to use and when to use the other

Tinkering with CompletionData will only let you extend the completion. On
the other hand, providing references through PsiReferenceProvider will let
you implement navigation, find usages, handle renaming of the class referenced
from your XML file, and other nice things.

--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"


0

really thank you for the advice, certainly your support is superior than all other communities
joe

Message was edited by:
joe

0

Please sign in to leave a comment.