void () { WriteCommandAction.runWriteCommandAction(null, () -> { final String text1 = "/** "; final String text = text1 + "*/public class B { }"; initDocument(text); HighlighterIterator iterator = myHighlighter.createIterator(text1.length() + 2); assertEquals(JavaTokenType.PUBLIC_KEYWORD, iterator.getTokenType()); myDocument.deleteString(0, text1.length() + 1); iterator = myHighlighter.createIterator(1); assertEquals(JavaTokenType.PUBLIC_KEYWORD, iterator.getTokenType()); }); }