TextFieldWithAutoCompletion with only Interfaces

Hi

I'm using TextFieldWithAutoCompletion in my plugin. It works fine but I want to have only Interfaces (without java class etc.) in it. Is it possible to display only interfaces or make it work as in editor with implements (everything that isn't interface have red font)?

TextFieldWithAutoCompletion(PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext()), TextFieldWithAutoCompletion.EMPTY_COMPLETION, true, null);
0
1 comment
Official comment

TextFieldWithAutoCompletion is for simple cases where you can enumerate the suggestions. If you want to show all interfaces, that's not so simple a case. I'd try suggest to

  • create JavaCodeFragmentFactory#createReferenceCodeFragment
  • bind it to an EditorTextField: setDocument(PsiDocumentManager.getInstance(myProject).getDocument(fragment)))
  • put some special user data to the document
  • create a CompletionContributor (please read javadoc there for details), register it with order="first", and filter out non-interface suggestions generated by standard Java completion, but only if original position file's document contains your user data from above

Please sign in to leave a comment.