SemanticEditorPosition () { return createEditorPosition(myEditor, isAtEnd() ? -1 : myIterator.getStart(), (editor, offset) -> !isAtEnd() ? myCreateHighlighterIteratorAtOffset.apply(editor, offset) : new HighlighterIteratorWrapper(myIterator) { // A wrapper around current iterator to make it immutable. @Override public void advance() { // do nothing } @Override public void retreat() { // do nothing } }, myTypeMapper); }