Error highlighting in Editors
Is it possible to have an Editor that shows on-the-fly error highlighting without putting
it into a Dialog(Wrapper), i.e. in a ToolWindow? I can successfully embed one into a
dialog, but inside a ToolWindow it just doesn't do any highlighting except for basic syntax.
The editor is an EditorTextField with a document that refers to a PsiCodeFragment instance
obtained by PsiElementFactory.createCodeBlockCodeFragment("java code", context, true);
Is there a reason and maybe a workaround for the missing error highlighting in tool windows?
Sascha
Please sign in to leave a comment.
Anybody got an idea why this doesn't work?
Sascha
Hello Sascha,
SW> Is it possible to have an Editor that shows on-the-fly error
SW> highlighting without putting it into a Dialog(Wrapper), i.e. in a
SW> ToolWindow? I can successfully embed one into a dialog, but inside a
SW> ToolWindow it just doesn't do any highlighting except for basic
SW> syntax.
SW>
SW> The editor is an EditorTextField with a document that refers to a
SW> PsiCodeFragment instance
SW> obtained by PsiElementFactory.createCodeBlockCodeFragment("java
SW> code", context, true);
SW> Is there a reason and maybe a workaround for the missing error
SW> highlighting in tool windows?
No, there is no workaround for this. The background error highlighting thread
updates the editors in a modal dialog if one is active, or the editors in
the main tabbed pane if no modal dialog is active.
Please file a JIRA request to enable highlighting for editors in tool windows.
--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"
Dmitry Jemerov (JetBrains) wrote:
Hmm, the debugger's evaluation dialog isn't modal and it does work there. You probably
mean any dialog if it has the focus? Could I do these updates myself?
Sascha
Hello Sascha,
>> No, there is no workaround for this. The background error
>> highlighting thread updates the editors in a modal dialog if one is
>> active, or the editors in the main tabbed pane if no modal dialog is
>> active.
>>
SW> Hmm, the debugger's evaluation dialog isn't modal and it does work
SW> there. You probably mean any dialog if it has the focus? Could I do
SW> these updates myself?
Well, you can try to. Create a TextEditorBackgroundHighlighter passing EditorTextField.getEditor()
to its constructor (this class is not OpenAPI, but I guess you're used to
it. :) ). Call its createPassesForEditor() method to get an array of HighlightingPass
objects. For every HighlightingPass, call collectInformation() and then applyInformationToEditor().
Add asynchronous-ness to taste (I guess the text in the editor box is small
enough to perform all highlighting synchronously without adverse performance
effects).
I haven't tried implementing this myself, but that's basically what IDEA
does to update the editors, so that should work for you as well.
--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"
Dmitry Jemerov (JetBrains) wrote:
Sweet, I'll try that. Thanks a lot for the gory (non-OpenAPI) details ;)
Sascha