void (ChangeInfo changeInfo) { ArrayList<TextRange> deleteRanges = new ArrayList<>(); ArrayList<TextRange> newRanges = new ArrayList<>(); String methodSignature = myDetector.getMethodSignaturePreview(changeInfo, deleteRanges, newRanges); myPreview.getMarkupModel().removeAllHighlighters(); WriteCommandAction.writeCommandAction(null).run(() -> myPreview.getDocument().replaceString(0, myPreview.getDocument().getTextLength(), methodSignature)); for (TextRange range : deleteRanges) { myPreview.getMarkupModel().addRangeHighlighter(CodeInsightColors.DEPRECATED_ATTRIBUTES, range.getStartOffset(), range.getEndOffset(), HighlighterLayer.ADDITIONAL_SYNTAX, HighlighterTargetArea.EXACT_RANGE); } for (TextRange range : newRanges) { myPreview.getMarkupModel().addRangeHighlighter(CodeInsightColors.TODO_DEFAULT_ATTRIBUTES, range.getStartOffset(), range.getEndOffset(), HighlighterLayer.ADDITIONAL_SYNTAX, HighlighterTargetArea.EXACT_RANGE); } }