@Nonnull @Override public LeafElement createLeaf(@Nonnull IElementType type, @Nonnull LanguageVersion languageVersion, @Nonnull CharSequence text) { final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(type.getLanguage()); if(parserDefinition != null) { if(parserDefinition.getCommentTokens(languageVersion).contains(type)) { return new PsiCoreCommentImpl(type, text); } } // this is special case, then type is WHITE_SPACE, but no parser definition if(type == TokenType.WHITE_SPACE) { return new PsiWhiteSpaceImpl(text); } if (type instanceof ILeafElementType) { return (LeafElement)((ILeafElementType)type).createLeafNode(text); } return new LeafPsiElement(type, text); }
@NotNull public static LeafElement leaf(@NotNull final IElementType type, @NotNull CharSequence text) { if (type == TokenType.WHITE_SPACE) { return new PsiWhiteSpaceImpl(text); } if (type instanceof ILeafElementType) { return (LeafElement)((ILeafElementType)type).createLeafNode(text); } final LeafElement customLeaf = factory(type).createLeaf(type, text); return customLeaf != null ? customLeaf : DefaultFactoryHolder.DEFAULT.createLeaf(type, text); }
@NotNull @Override public LeafElement createLeaf(@NotNull IElementType type, @NotNull LanguageVersion languageVersion, @NotNull CharSequence text) { if (type instanceof IXmlLeafElementType) { if (type == XML_REAL_WHITE_SPACE) { return new PsiWhiteSpaceImpl(text); } return new XmlTokenImpl(type, text); } return null; }
@NotNull public static LeafElement whitespace(final CharSequence text) { final PsiWhiteSpaceImpl w = new PsiWhiteSpaceImpl(WHITESPACES.intern(text)); CodeEditUtil.setNodeGenerated(w, true); return w; }
@Nonnull public static LeafElement whitespace(final CharSequence text) { final PsiWhiteSpaceImpl w = new PsiWhiteSpaceImpl(WHITESPACES.intern(text)); CodeEditUtil.setNodeGenerated(w, true); return w; }