當前位置: 首頁>>代碼示例>>Java>>正文


Java IFileElementType類代碼示例

本文整理匯總了Java中com.intellij.psi.tree.IFileElementType的典型用法代碼示例。如果您正苦於以下問題:Java IFileElementType類的具體用法?Java IFileElementType怎麽用?Java IFileElementType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IFileElementType類屬於com.intellij.psi.tree包,在下文中一共展示了IFileElementType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: canHaveStub

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
@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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:CoreStubTreeLoader.java

示例2: getCumulativeVersion

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:CumulativeStubVersion.java

示例3: canHaveStub

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:StubUpdatingIndex.java

示例4: createLanguageBindings

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:metaborg,項目名稱:spoofax-intellij,代碼行數:26,代碼來源:DefaultIdeaLanguageManager.java

示例5: canHaveStub

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
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);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:24,代碼來源:StubUpdatingIndex.java

示例6: computeVersionMap

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
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;
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:21,代碼來源:StubUpdatingIndex.java

示例7: IgnoreFile

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
/** 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);
}
 
開發者ID:hsz,項目名稱:idea-gitignore,代碼行數:19,代碼來源:IgnoreFile.java

示例8: createElementType

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
@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();
		}
	};
}
 
開發者ID:consulo,項目名稱:consulo-csharp,代碼行數:23,代碼來源:CSharpFileFactory.java

示例9: parseImpl

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
@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));
	}
}
 
開發者ID:antlr,項目名稱:intellij-plugin-v4,代碼行數:27,代碼來源:ANTLRv4GrammarParser.java

示例10: canHaveStub

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
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);
}
 
開發者ID:consulo,項目名稱:consulo,代碼行數:26,代碼來源:StubUpdatingIndex.java

示例11: getVersionOwner

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
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;
}
 
開發者ID:consulo,項目名稱:consulo,代碼行數:20,代碼來源:StubVersionMap.java

示例12: buildStubTree

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
@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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:33,代碼來源:LightStubBuilder.java

示例13: createLazy

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
@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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:CoreASTFactory.java

示例14: createComposite

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
@Override
@NotNull
public CompositeElement createComposite(final IElementType type) {
  if (type instanceof IFileElementType) {
    return new FileElement(type, null);
  }

  return new CompositeElement(type);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:CoreASTFactory.java

示例15: createComposite

import com.intellij.psi.tree.IFileElementType; //導入依賴的package包/類
@Override
@Nullable
public CompositeElement createComposite(final IElementType type) {
  if (type instanceof IFileElementType) {
    return new FileElement(type, null);
  }
  return new CompositeElement(type);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:9,代碼來源:PropertiesASTFactory.java


注:本文中的com.intellij.psi.tree.IFileElementType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。