Disabling buillt-in completions for specific Java string literals


My plugin provides references from specific String literals in Java code
to other Psi elements.
Completion works fine, with one nuisance:
There are three built-in Idea components that contribute quite a few suggestions
to the completion menu for String literals:
a) a reference provider that contributes resource keys
b) a reference provider that contributes file path elements
c) some other component that provides (CompletionData?) suggestions from
words in the current compilation unit

The result of all this is (in nontrivial projects): the completion menu gets
clutterd with a huge amount of items quickly, making it less effective.

Now, for some very specific String literals, my plugin knows best what to
suggest, and I'd like to lock others out.
I have collected a number of approaches to implement this (thanks Sascha),
and am seeking some feedback (I'm new with openapi & plugins):

1) Provide a custom language that is injected into Java String literals

Will this disable all the three completions listed above (a,b and c)?
When editing a Javascript file I don't see a, b or c. Is this indeed by design,
and not by accident?
This solution would be Demetra-only, correct?

2) Registering completion using CompletionUtil.registerXXX for Java filetype.

If I understand correctly, this is IDEA-global, and therefore a bad idea.
Correct?

3) Somehow hooking the completion action and filtering there. It seems the
cons of (2) apply here as well.

4) Something else I should look at?

Thanks


Please sign in to leave a comment.