void (@NotNull Runnable action) { if (myFreezedHighlighters != null) { action.run(); return; } myFreezedHighlighters = new HashSet<>(); try { action.run(); } finally { myFreezedHighlighters.forEach(highlighter -> { try { highlighter.finishUpdate(); } catch (IllegalStateException e) { LOG.error(e.getMessage() + "\nLayer highlighter: " + highlighter.getSyntaxHighlighter() + "\nTop level highlighter: " + LayeredLexerEditorHighlighter.this.getSyntaxHighlighter(), e, new Attachment("layerTextAfterChange.txt", highlighter.myText.toString()), new Attachment("editorTextAfterChange.txt", myText.toString())); } }); myFreezedHighlighters = null; } }