Autocomplete and highlighting for classes not in a project

Hi,

I'm writing a tool window for trying out requests in a Java-based DSL. In actual code such requests are often passed as just strings, so I'd like to support using my tool window without depending on DSL JARs in user's projects.

So currently I have a tool window with an EditorTextField implemented as shown below. DslClass is a class that is not defined in any opened project or their dependencies. Instead, it is defined in my plugin code and also it's available in a separate JAR.

How to implement autocomplete and syntax highlighting for methods of this DslClass in that EditorTextField? Or may be there is an open-source plugin that does something like this?

fun createUIComponents() {
val importsCode = JavaCodeFragmentFactory.getInstance(project).createCodeBlockCodeFragment(
"import com.foobar.DslClass;",
null, true
)
val importsDocument = PsiDocumentManager.getInstance(project).getDocument(importsCode)!!
val importsContext = PsiDocumentManager.getInstance(project).getPsiFile(importsDocument)!!

val editorCode = JavaCodeFragmentFactory.getInstance(project).createCodeBlockCodeFragment(
"new DslClass()", // default code in the tool window
importsContext,
true)
val editorDocument = PsiDocumentManager.getInstance(project).getDocument(editorCode)!!
toolWindowField = EditorTextField(editorDocument, project, JavaFileType.INSTANCE)
}
0

Please sign in to leave a comment.