PsiAugmentProvider to augment that class implements some interface


I'm trying to use PsiAugmentProvider to make Idea think my class implements some interface.
What would be the correct PsiElement type to work with and return from getAugments?

I have tried to do something like this:

    LightReferenceListBuilder referenceList = new LightReferenceListBuilder(psiClass.getManager(), JavaLanguage.INSTANCE, PsiReferenceList.Role.IMPLEMENTS_LIST);

but there is no way to set the scope / containing class for this object, so it looks like this can only be used when defining class using AbstractLightClass and getImplementsList.

Thanks for any hints.



It's not (yet) possible; current implementation only allows adding members to classes and annotations to modifier lists.


Hey Roman. Thanks for the answer. Do you know if such a feature is planned in a matter of next few months?


Rather yes - as it is needed for IDEA-59138. You may watch the issue to get notified when it's done.


Hi Roman.

Is there a technical hurdle obstructing the implementation of this feature?  This is a critical blocker for me right now and I'd be happy to contribute my time toward this with your help, if possible.  Please advise.  Thanks!


I'm terribly sorry, but there is little I can do at the moment. The plugin isn't in open source, and I don't have time for it right now :(


Thanks, Roman, for the quick response.  I was hoping there would be some way to contribute to PsiAugmentProvider to implement interface support.  This feature is critical for my use-case.  Can you recommend an alternative approach?  Essentially I need to hook into ClsClassImpl classes to add additional interfaces, exactly in the manner of PsiAugmentProvider.  At this point any kind of workaround is ok if you have ideas.  Thanks.


PsiAugmentProvider won't work here, but implementing "com.intellij.directClassInheritorsSearch" extension point may do.


Will this trick IntelliJ into allowing an assignment like the following?  Thanks again for your help!

IFoo foo = new FooImpl();

interface IFoo {}

class FooImpl { // does not implement IFoo, need to trick IJ into thinking it does though

Actually, the example is more about existing Java classes, so to be clearer I need something like this to work:

IFoo foo = "hello"; // need to trick IJ into thinking java.lang.String implements IFoo 

interface IFoo {}

Apologies for all the comments, but one more thought.  If there isn't yet a way to augment classes with interfaces, perhaps there is a way to remove the "incompatible types" errors that will result. I have the compiler side of this working, so now it's really about making IJ behave.  Thanks.


It turned out IDEA doesn't use inheritor searchers when checking assignability, so no luck here :/

Suppression is possible, via "com.intellij.daemon.highlightInfoFilter" EP (please use with great care).


Excellent.  Error suppression will be enough.  Thanks for your help, Roman.


Please sign in to leave a comment.