How do I add custom references to AutoCompletion?

I'm developing cakephp framework plugin.
so, I want to do is things like this image.

Should I use "CompletionProvider#addCompletions" or "ReferencesProvider#registerReferenceProviders" or others?



I use reference converters registered with @Converter on DOM interfaces.  They return specific PSI Reference contributors,
which hprovide lists of candidates. This was enough for code completion and display of error on broken links


Thank you for response!

I did not find the information that would be helpful.

Can you show details such as sample code?


Your reference provider  creates reference class for given PSI element (say, attribute value), and this reference class shall implement com.intellij.psi.PsiReference
( Usually you sholr extend PsiReferenceBase )  Usually you have to implement:

    public PsiElement resolve();

    public Object[] getVariants();

Where resolve() delievers PsiElement in question ( or null, in case no missing element is found - in this case error will be shown )
and getVariants()  delievers array of candidates for autocompletion ( either  plain strings, or LookupElementBuilder -  in case you like to have fancy icons etc )

Reference providers are registered by reference contributor, declared in your plugin.xml:

                implementation="ClaassContributingReferece extends PsiReferenceContributor"/>

where you can bind reference providers to certain psi elements.   Loook into  struts plugin for inspiration.