void () { WriteCommandAction.runWriteCommandAction(null, () -> { final String text1 = "/**\n * <co"; final String text2 = text1 + " \n * @param someParam\n */"; final String text3 = text2 + "class"; initDocument(text3); HighlighterIterator iterator = myHighlighter.createIterator(text2.length()); assertEquals(JavaTokenType.CLASS_KEYWORD, iterator.getTokenType()); myDocument.insertString(text1.length(), "d"); iterator = myHighlighter.createIterator(text2.length() + 1); assertEquals(JavaTokenType.CLASS_KEYWORD, iterator.getTokenType()); myDocument.deleteString(text1.length(), text1.length() + 1); iterator = myHighlighter.createIterator(text2.length() + 1); assertEquals(JavaTokenType.CLASS_KEYWORD, iterator.getTokenType()); }); }