Add and Remove errors in EditorTextField


I am using the following Custom EditorTextField inside a DialogWrapper:

class CustomTextField(project: Project, s: String) : LanguageTextField(XmlLanguage.INSTANCE, project, s) {

override fun createEditor(): EditorEx {
val editor = super.createEditor()
editor.isOneLineMode = false

val settings = editor.settings
settings.isLineNumbersShown = true
settings.isAutoCodeFoldingEnabled = true
settings.isFoldingOutlineShown = true
settings.isLineMarkerAreaShown = false
settings.isIndentGuidesShown = true
settings.isAllowSingleLogicalLineFolding = true
settings.isRightMarginShown = true

val editorMarkupModel = editor.markupModel as EditorMarkupModel
editorMarkupModel.isErrorStripeVisible = true
return editor

The language of the EditorField is XML. When I load an "XML string" in this EditorField, I am getting multiple errors in the Right Margin like "Namespace not bound". I get nearly 50 - 60 errors. But I don't care about any of these errors at all.

I just want to get rid of all these Errors (suppress them) and add my own set of Errors. How do I do this?

I tried `editorMarkupModel.removeAllHighlighters()` but this doesn't have any impact on the errors.

Any help here is greatly appreciated. Thanks.

Comment actions Permalink
Official comment

Unfortunately there is no workaround to this

Comment actions Permalink

Please add this in createEditor():


final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
if (file != null) {
DaemonCodeAnalyzer.getInstance(project).setHighlightingEnabled(file, false);
Comment actions Permalink

Thanks. This is exactly what I needed.

Comment actions Permalink

@Yann Cebron,

I did this and now I lost the Code Folding in XML. It seems that CODE_FOLDING is tied up to the `isHighlightingEnabled()`.


Please sign in to leave a comment.