MergeFunction () { MergeFunction origMergeFunction = super.getMergeFunction(); return (type, originalLexer) -> { if (type == BAD_CHARACTER && getElementType(getBaseTokenText()) == PyConsoleTokenTypes.PLING) { collectFullLine(originalLexer); return SHELL_COMMAND; } if (type == PERC) { if (additionMagicLineCheck(originalLexer)){ collectFullLine(originalLexer); return MAGIC_COMMAND_LINE; } } return origMergeFunction.merge(type, originalLexer); }; }