Java 类com.intellij.psi.tree.ILeafElementType 实例源码

项目:consulo    文件:DefaultASTLeafFactory.java   
@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);
}
项目:intellij-ce-playground    文件:ASTFactory.java   
@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);
}