void (MasqueradingLexer lexer) { lexer.start(getDelegate().getOriginalText()); myShrunkSequence = new ArrayList<>(); StringBuilder charSequenceBuilder = new StringBuilder(); int realPos = 0; int shrunkPos = 0; while (lexer.getTokenType() != null) { final IElementType masqueTokenType = lexer.getMasqueTokenType(); final String masqueTokenText = lexer.getMasqueTokenText(); final int realLength = lexer.getTokenEnd() - lexer.getTokenStart(); if (masqueTokenType != null) { assert masqueTokenText != null; final int masqueLength = masqueTokenText.length(); myShrunkSequence.add(new MyShiftedToken(masqueTokenType, realPos, realPos + realLength, shrunkPos, shrunkPos + masqueLength)); charSequenceBuilder.append(masqueTokenText); shrunkPos += masqueLength; } realPos += realLength; lexer.advance(); } myShrunkCharSequence = charSequenceBuilder.toString(); }