OuterLanguageElementImpl (@NotNull CharSequence internedTokenText, @NotNull IElementType outerElementType) { var factoryCreatedElement = ASTFactory.leaf(outerElementType, internedTokenText); if (factoryCreatedElement instanceof OuterLanguageElementImpl) { return (OuterLanguageElementImpl)factoryCreatedElement; } LOG.error( "Wrong element created by ASTFactory. See method documentation for details. Here is what we have:" + " elementType: " + outerElementType + "; language: " + outerElementType.getLanguage() + "; element from factory: " + factoryCreatedElement); return new OuterLanguageElementImpl(outerElementType, internedTokenText); }