ASTNode (ASTNode left, ASTNode right) { Language l = PsiUtilCore.getNotAnyLanguage(left); Language rightLang = PsiUtilCore.getNotAnyLanguage(right); if (rightLang.isKindOf(l)) { l = rightLang; // get more precise lexer } final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l); if (parserDefinition != null) { PsiManager manager = right.getTreeParent().getPsi().getManager(); ASTNode generatedWhitespace; switch (parserDefinition.spaceExistenceTypeBetweenTokens(left, right)) { case MUST: generatedWhitespace = Factory.createSingleLeafElement(TokenType.WHITE_SPACE, " ", 0, 1, null, manager); break; case MUST_LINE_BREAK: generatedWhitespace = Factory.createSingleLeafElement(TokenType.WHITE_SPACE, "\n", 0, 1, null, manager); break; default: generatedWhitespace = null; } return generatedWhitespace; } return null; }