Injecting language into method parameter of only extending class

Hello!

I want to add support for injecting my language into a method that is overriden from an interface the class extends. How can I achieve this?

The class in question:

The class it extends

And I want to inject into deserialize family of methods in ComponentSerializer. MiniMessage sets the generic to String.

You probably need LanguageInjectionContributor extension to decide on the injection point programmatically

I see, so essentially I would find any method call expression and check if the class the method is being called is an instance of MiniMessage?

EDIT: I’ve been searching for a while now and can’t find a way to get the instance of class in in method call, I can get the super class (ComponentSerializer).

Update, I found a solution using PsiReferenceExpression.getQualifierExpression().getType() which returns PsiType containing all data you need, e.g. PsiType.getCanonicalText() which returns in my case net.kyori.adventure.text.minimessage.MiniMessage.

I combined this with PsiMethodCallExpression.resolveMethod().getName() to match the name with methods I wish to inject into.