IntelliJ DSL plugin provide completion of Java classes and methods


I'm attempting to write an IntelliJ plugin for a DSL which references Java classes and methods. The DSL is exposed in `*.conf` files within a Java project. A typical snippet of the DSL looks like this:

TASK taskClass=com.example.Foo taskMethod=someMethod;

I've been working through the IJ 'Simple' plugin tutorial to learn about plugins and am able to implement a fair bit of my own plugin. Currently, however, I'm stuck on trying to understand how I can provide auto-completion for the taskClass and taskMethod keywords. Having worked through the Simple tutorial all my completion shows is 'Hello'. Now I want to be able to extend my CompletionContributor to show java classes and methods that exist in the project. This doesn't seem to be addressed in the tutorial, but perhaps I'm just missing it.

Since first writing this and looking around some more I see reference to using JavaPsiFacade, but to use that I also need a reference to a Project. How would I get that from my CompletionContributor? Thanks for any help.

1 comment
Comment actions Permalink

You probably want to use PsiReferences instead, which provide additional functionality e.g. resolving to the actual declaration, find usages etc.


For resolving to class, see com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReference as starting point. Resolving to method can re-use resolve PsiClass from taskClass to then iterate available methods (and apply custom filtering as needed).


Please sign in to leave a comment.