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

项目:intellij-ce-playground    文件:CoreStubTreeLoader.java   
@Override
public boolean canHaveStub(VirtualFile file) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof LanguageFileType) {
    Language l = ((LanguageFileType)fileType).getLanguage();
    ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
    if (parserDefinition == null) return false;
    final IFileElementType elementType = parserDefinition.getFileNodeType();
    return elementType instanceof IStubFileElementType && ((IStubFileElementType)elementType).shouldBuildStubFor(file);
  }
  else if (fileType.isBinary()) {
    final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
    return builder != null && builder.acceptsFile(file);
  }
  return false;
}
项目:intellij-ce-playground    文件:CumulativeStubVersion.java   
public static int getCumulativeVersion() {
  int version = VERSION;
  for (final FileType fileType : FileTypeRegistry.getInstance().getRegisteredFileTypes()) {
    if (fileType instanceof LanguageFileType) {
      Language l = ((LanguageFileType)fileType).getLanguage();
      ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
      if (parserDefinition != null) {
        final IFileElementType type = parserDefinition.getFileNodeType();
        if (type instanceof IStubFileElementType) {
          version += ((IStubFileElementType)type).getStubVersion();
        }
      }
    }

    BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
    if (builder != null) {
      version += builder.getStubVersion();
    }
  }
  return version;
}
项目:intellij-ce-playground    文件:StubUpdatingIndex.java   
public static boolean canHaveStub(@NotNull VirtualFile file) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof LanguageFileType) {
    final Language l = ((LanguageFileType)fileType).getLanguage();
    final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
    if (parserDefinition == null) {
      return false;
    }

    final IFileElementType elementType = parserDefinition.getFileNodeType();
    if (elementType instanceof IStubFileElementType) {
      if (((IStubFileElementType)elementType).shouldBuildStubFor(file)) {
        return true;
      }
      if (IndexingStamp.isFileIndexedStateCurrent(file, INDEX_ID)) {
        return true;
      }
    }
  }
  final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
  return builder != null && builder.acceptsFile(file);
}
项目:spoofax-intellij    文件:DefaultIdeaLanguageManager.java   
/**
 * Creates the IDEA language object associated with the specified language.
 *
 * @param language
 *            The language.
 * @return The created IDEA language.
 */
private LanguageBindings createLanguageBindings(final ILanguage language) {
    final MetaborgIdeaLanguage ideaLanguage = createIdeaLanguage(language);
    final MetaborgLanguageFileType fileType = createFileType(ideaLanguage);
    final SpoofaxTokenTypeManager tokenTypeManager = createTokenTypeManager(ideaLanguage);
    final IFileElementType fileElementType = createFileElementType(ideaLanguage, tokenTypeManager);
    final ParserDefinition parserDefinition = createParserDefinition(fileType, fileElementType);
    final SpoofaxSyntaxHighlighterFactory syntaxHighlighterFactory = createSyntaxHighlighterFactory();

    final InstanceLanguageExtensionPoint<?> parserDefinitionExtension =
        new InstanceLanguageExtensionPoint<>(ExtensionIds.ParserDefinition, ideaLanguage, parserDefinition);
    final InstanceSyntaxHighlighterFactoryExtensionPoint syntaxHighlighterFactoryExtension =
        new InstanceSyntaxHighlighterFactoryExtensionPoint(ideaLanguage, syntaxHighlighterFactory);
    final InstanceLanguageExtensionPoint<?> externalAnnotatorExtension = new InstanceLanguageExtensionPoint<>(
        ExtensionIds.ExternalAnnotator, ideaLanguage, this.metaborgSourceAnnotator);

    return new LanguageBindings(tokenTypeManager, fileType, parserDefinitionExtension,
        syntaxHighlighterFactoryExtension, externalAnnotatorExtension);
}
项目:tools-idea    文件:CoreStubTreeLoader.java   
@Override
public boolean canHaveStub(VirtualFile file) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof LanguageFileType) {
    Language l = ((LanguageFileType)fileType).getLanguage();
    ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
    if (parserDefinition == null) return false;
    final IFileElementType elementType = parserDefinition.getFileNodeType();
    return elementType instanceof IStubFileElementType && ((IStubFileElementType)elementType).shouldBuildStubFor(file);
  }
  else if (fileType.isBinary()) {
    final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
    return builder != null && builder.acceptsFile(file);
  }
  return false;
}
项目:tools-idea    文件:StubUpdatingIndex.java   
public static boolean canHaveStub(@NotNull VirtualFile file) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof LanguageFileType) {
    final Language l = ((LanguageFileType)fileType).getLanguage();
    final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
    if (parserDefinition == null) {
      return false;
    }

    final IFileElementType elementType = parserDefinition.getFileNodeType();
    if (elementType instanceof IStubFileElementType) {
      if (((IStubFileElementType)elementType).shouldBuildStubFor(file)) {
        return true;
      }
      final ID indexId = IndexInfrastructure.getStubId(INDEX_ID, file.getFileType());
      if (IndexingStamp.isFileIndexed(file, indexId, IndexInfrastructure.getIndexCreationStamp(indexId))) {
        return true;
      }
    }
  }
  final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
  return builder != null && builder.acceptsFile(file);
}
项目:tools-idea    文件:StubUpdatingIndex.java   
private static Map<FileType, Integer> computeVersionMap() {
  Map<FileType, Integer> map = new HashMap<FileType, Integer>();
  for (final FileType fileType : FileTypeManager.getInstance().getRegisteredFileTypes()) {
    if (fileType instanceof LanguageFileType) {
      Language l = ((LanguageFileType)fileType).getLanguage();
      ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
      if (parserDefinition != null) {
        final IFileElementType type = parserDefinition.getFileNodeType();
        if (type instanceof IStubFileElementType) {
          map.put(fileType, ((IStubFileElementType)type).getStubVersion());
        }
      }
    }
    final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
    if (builder != null) {
      map.put(fileType, builder.getStubVersion());
    }
  }
  return map;
}
项目:idea-gitignore    文件:IgnoreFile.java   
/** Builds a new instance of {@link IgnoreFile}. */
public IgnoreFile(@NotNull FileViewProvider viewProvider, @NotNull IgnoreFileType fileType) {
    super(viewProvider);

    this.fileType = fileType;
    this.language = findLanguage(fileType.getLanguage(), viewProvider);

    final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(this.language);
    if (parserDefinition == null) {
        throw new RuntimeException(
                "PsiFileBase: language.getParserDefinition() returned null for: " + this.language
        );
    }
    this.parserDefinition = parserDefinition;

    final IFileElementType nodeType = parserDefinition.getFileNodeType();
    init(nodeType, nodeType);
}
项目:consulo-csharp    文件:CSharpFileFactory.java   
@NotNull
private static IElementType createElementType(String id, BiConsumer<PsiBuilder, LanguageVersion> consumer)
{
    return new IFileElementType(id, CSharpLanguage.INSTANCE)
    {
        @Override
        protected ASTNode doParseContents(@NotNull ASTNode chameleon, @NotNull PsiElement psi)
        {
            final Project project = psi.getProject();
            final Language languageForParser = getLanguageForParser(psi);
            final LanguageVersion tempLanguageVersion = chameleon.getUserData(LanguageVersion.KEY);
            final LanguageVersion languageVersion = tempLanguageVersion == null ? psi.getLanguageVersion() : tempLanguageVersion;
            final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, null, languageForParser, languageVersion, chameleon.getChars());
            consumer.accept(builder, languageVersion);
            while(!builder.eof())
            {
                builder.advanceLexer();
            }
            return builder.getTreeBuilt();
        }
    };
}
项目:intellij-plugin-v4    文件:ANTLRv4GrammarParser.java   
@Override
protected ParseTree parseImpl(ANTLRv4Parser parser, IElementType root, PsiBuilder builder) {
    int startRule;
    if (root instanceof IFileElementType) {
        startRule = ANTLRv4Parser.RULE_grammarSpec;
    }
    else if (root == ANTLRv4TokenTypes.TOKEN_ELEMENT_TYPES.get(ANTLRv4Lexer.TOKEN_REF)
        || root == ANTLRv4TokenTypes.TOKEN_ELEMENT_TYPES.get(ANTLRv4Lexer.RULE_REF)) {
        startRule = ANTLRv4Parser.RULE_atom;
    }
    else {
        startRule = Token.INVALID_TYPE;
    }

    switch (startRule) {
    case ANTLRv4Parser.RULE_grammarSpec:
        return parser.grammarSpec();

    case ANTLRv4Parser.RULE_atom:
        return parser.atom();

    default:
        String ruleName = ANTLRv4Parser.ruleNames[startRule];
        throw new UnsupportedOperationException(String.format("cannot start parsing using root element %s", root));
    }
}
项目:consulo    文件:CoreStubTreeLoader.java   
@Override
public boolean canHaveStub(VirtualFile file) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof LanguageFileType) {
    Language l = ((LanguageFileType)fileType).getLanguage();
    ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
    if (parserDefinition == null) return false;
    final IFileElementType elementType = parserDefinition.getFileNodeType();
    return elementType instanceof IStubFileElementType && ((IStubFileElementType)elementType).shouldBuildStubFor(file);
  }
  else if (fileType.isBinary()) {
    final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
    return builder != null && builder.acceptsFile(file);
  }
  return false;
}
项目:consulo    文件:StubUpdatingIndex.java   
public static boolean canHaveStub(@Nonnull VirtualFile file) {
  final FileType fileType = file.getFileType();
  if (fileType instanceof LanguageFileType) {
    final Language l = ((LanguageFileType)fileType).getLanguage();
    final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
    if (parserDefinition == null) {
      return false;
    }

    final IFileElementType elementType = parserDefinition.getFileNodeType();
    if (elementType instanceof IStubFileElementType) {
      if (((IStubFileElementType)elementType).shouldBuildStubFor(file)) {
        return true;
      }
      FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
      if (file instanceof NewVirtualFile &&
          fileBasedIndex instanceof FileBasedIndexImpl &&
          ((FileBasedIndexImpl)fileBasedIndex).getIndex(INDEX_ID).isIndexedStateForFile(((NewVirtualFile)file).getId(), file)) {
        return true;
      }
    }
  }
  final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
  return builder != null && builder.acceptsFile(file);
}
项目:consulo    文件:StubVersionMap.java   
private static Object getVersionOwner(FileType fileType) {
  Object owner = null;
  if (fileType instanceof LanguageFileType) {
    Language l = ((LanguageFileType)fileType).getLanguage();
    ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
    if (parserDefinition != null) {
      final IFileElementType type = parserDefinition.getFileNodeType();
      if (type instanceof IStubFileElementType) {
        owner = type;
      }
    }
  }

  BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
  if (builder != null) {
    owner = builder;
  }
  return owner;
}
项目:intellij-ce-playground    文件:LightStubBuilder.java   
@Override
public StubElement buildStubTree(@NotNull PsiFile file) {
  LighterAST tree = FORCED_AST.get();
  if (tree == null) {
    FileType fileType = file.getFileType();
    if (!(fileType instanceof LanguageFileType)) {
      LOG.error("File is not of LanguageFileType: " + fileType + ", " + file);
      return null;
    }
    Language language = ((LanguageFileType)fileType).getLanguage();
    final IFileElementType contentType = LanguageParserDefinitions.INSTANCE.forLanguage(language).getFileNodeType();
    if (!(contentType instanceof IStubFileElementType)) {
      LOG.error("File is not of IStubFileElementType: " + contentType + ", " + file);
      return null;
    }

    final FileASTNode node = file.getNode();
    if (contentType instanceof ILightStubFileElementType) {
      tree = node.getLighterAST();
    }
    else {
      tree = new TreeBackedLighterAST(node);
    }
  } else {
    FORCED_AST.set(null);
  }
  if (tree == null) return null;

  final StubElement rootStub = createStubForFile(file, tree);
  buildStubTree(tree, tree.getRoot(), rootStub);
  return rootStub;
}
项目:intellij-ce-playground    文件:CoreASTFactory.java   
@Override
@NotNull
public LazyParseableElement createLazy(final ILazyParseableElementType type, final CharSequence text) {
  if (type instanceof IFileElementType) {
    return new FileElement(type, text);
  }

  return new LazyParseableElement(type, text);
}
项目:intellij-ce-playground    文件:CoreASTFactory.java   
@Override
@NotNull
public CompositeElement createComposite(final IElementType type) {
  if (type instanceof IFileElementType) {
    return new FileElement(type, null);
  }

  return new CompositeElement(type);
}
项目:intellij-ce-playground    文件:PropertiesASTFactory.java   
@Override
@Nullable
public CompositeElement createComposite(final IElementType type) {
  if (type instanceof IFileElementType) {
    return new FileElement(type, null);
  }
  return new CompositeElement(type);
}
项目:spoofax-intellij    文件:IdeaSpoofaxMetaModule.java   
/**
 * Binds token and PSI elements and related classes.
 */
protected void bindElements() {
    bind(IMetaborgPsiElementFactory.class).to(DefaultMetaborgPsiElementFactory.class).in(Singleton.class);
    install(new FactoryModuleBuilder()
            .implement(IFileElementType.class, MetaborgFileElementType.class)
            .build(IFileElementTypeFactory.class));
    install(new FactoryModuleBuilder()
            .implement(ATermAstElementTypeProvider.class, ATermAstElementTypeProvider.class)
            .build(IATermAstElementTypeProviderFactory.class));
}
项目:spoofax-intellij    文件:MetaborgParserDefinition.java   
@Inject
/* package private */ MetaborgParserDefinition(
        @Assisted final MetaborgLanguageFileType fileType,
        @Assisted final IFileElementType fileElementType,
        final IMetaborgPsiElementFactory psiElementFactory,
        final ICharacterLexerFactory characterLexerFactory,
        final ILanguageBindingManager bindingManager) {
    this.fileType = fileType;
    this.fileElement = fileElementType;
    this.psiElementFactory = psiElementFactory;
    this.characterLexerFactory = characterLexerFactory;
    this.bindingManager = bindingManager;
}
项目:tools-idea    文件:CoreASTFactory.java   
@Override
@NotNull
public LazyParseableElement createLazy(final ILazyParseableElementType type, final CharSequence text) {
  if (type instanceof IFileElementType) {
    return new FileElement(type, text);
  }

  return new LazyParseableElement(type, text);
}
项目:tools-idea    文件:CoreASTFactory.java   
@Override
@NotNull
public CompositeElement createComposite(final IElementType type) {
  if (type instanceof IFileElementType) {
    return new FileElement(type, null);
  }

  return new CompositeElement(type);
}
项目:tools-idea    文件:PropertiesASTFactory.java   
@Nullable
public CompositeElement createComposite(final IElementType type) {
  if (type instanceof IFileElementType) {
    return new FileElement(type, null);
  }
  return new CompositeElement(type);
}
项目:intellij-plugin-v4    文件:ANTLRv4ASTFactory.java   
/** Create a FileElement for root or a parse tree CompositeElement (not
*  PSI) for the token. This impl is more or less the default.
*/
  @Override
  public CompositeElement createComposite(IElementType type) {
      if (type instanceof IFileElementType) {
          return new FileElement(type, null);
}
      return new CompositeElement(type);
  }
项目:consulo    文件:DefaultASTCompositeFactory.java   
@Nonnull
@Override
public CompositeElement createComposite(IElementType type) {
  if (type instanceof IFileElementType) {
    return new FileElement(type, null);
  }
  if (type instanceof ICompositeElementType) {
    return (CompositeElement)((ICompositeElementType)type).createCompositeNode();
  }
  return new CompositeElement(type);
}
项目:TS-IJ    文件:TSParserDefinition.java   
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
项目:AppleScript-IDEA    文件:AppleScriptParserDefinition.java   
@Override
public IFileElementType getFileNodeType() {
  return FILE;
}
项目:reasonml-idea-plugin    文件:RmlParserDefinition.java   
@Override
public IFileElementType getFileNodeType() {
    return RmlFileStubElementType.INSTANCE;
}
项目:reasonml-idea-plugin    文件:OclP4ParserDefinition.java   
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
项目:reasonml-idea-plugin    文件:OclParserDefinition.java   
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
项目:greycat-idea-plugin    文件:GCMParserDefinition.java   
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
项目:EmojiPrefix    文件:EmojiResourceParserDefinition.java   
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchParserDefinition.java   
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
项目:hybris-integration-intellij-idea-plugin    文件:ImpexParserDefinition.java   
@NotNull
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
项目:intellij-plugin    文件:CoffigYamlParserDefinition.java   
public IFileElementType getFileNodeType() {
    return FILE;
}
项目:idea-onescript    文件:OneScriptParserDefinition.java   
@NotNull
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
项目:intellij-csv-validator    文件:CsvParserDefinition.java   
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
项目:Goal-Intellij-Plugin    文件:ActionSpecParserDefinition.java   
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
项目:Goal-Intellij-Plugin    文件:PrologParserDefinition.java   
@Override
public IFileElementType getFileNodeType() {
    return File;
}
项目:Goal-Intellij-Plugin    文件:ModuleParserDefinition.java   
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
项目:Goal-Intellij-Plugin    文件:MasParserDefinition.java   
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}