com.intellij.psi.tree.IFileElementType源码实例Demo

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

下面列出了com.intellij.psi.tree.IFileElementType 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: consulo-csharp   文件: CSharpFileFactory.java
@Nonnull
private static IElementType createElementType(String id, BiConsumer<PsiBuilder, LanguageVersion> consumer)
{
	return new IFileElementType(id, CSharpLanguage.INSTANCE)
	{
		@Override
		protected ASTNode doParseContents(@Nonnull ASTNode chameleon, @Nonnull 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();
		}
	};
}
 
源代码2 项目: 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);
}
 
源代码3 项目: intellij-plugin-v4   文件: ANTLRv4GrammarParser.java
@Override
protected ParseTree parse(Parser parser, IElementType root) {
	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 ((ANTLRv4Parser) parser).grammarSpec();

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

	default:
		String ruleName = ANTLRv4Parser.ruleNames[startRule];
		throw new UnsupportedOperationException(String.format("cannot start parsing using root element %s", root));
	}
}
 
源代码4 项目: 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;
}
 
源代码5 项目: consulo   文件: StubUpdatingIndex.java
public static boolean canHaveStub(@Nonnull ProjectLocator projectLocator, @Nullable Project project, @Nonnull VirtualFile file) {
  FileType fileType = SubstitutedFileType.substituteFileType(file, file.getFileType(), project == null ? projectLocator.guessProjectForFile(file) : project);
  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);
}
 
源代码6 项目: 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;
}
 
public void parseLight(IElementType t, PsiBuilder b) {
  boolean r;
  b = adapt_builder_(t, b, this, null);
  Marker m = enter_section_(b, 0, _COLLAPSE_, null);
  if (t instanceof IFileElementType) {
    r = parse_root_(t, b, 0);
  }
  else {
    r = false;
  }
  exit_section_(b, 0, m, t, r, true, TRUE_CONDITION);
}
 
源代码8 项目: 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);
  }
 
源代码9 项目: consulo   文件: DefaultASTCompositeFactory.java
@Nonnull
@Override
public CompositeElement createComposite(@Nonnull IElementType type) {
  if (type instanceof IFileElementType) {
    return new FileElement(type, null);
  }
  if (type instanceof ICompositeElementType) {
    return (CompositeElement)((ICompositeElementType)type).createCompositeNode();
  }
  return new CompositeElement(type);
}
 
源代码10 项目: intellij-jsonnet   文件: JsonnetParserDefinition.java
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
 
源代码11 项目: reasonml-idea-plugin   文件: RmlParserDefinition.java
@NotNull
@Override
public IFileElementType getFileNodeType() {
    return RmlFileStubElementType.INSTANCE;
}
 
@NotNull
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
 
@NotNull
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
 
@NotNull
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
 
@NotNull
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
 
源代码16 项目: reasonml-idea-plugin   文件: OclParserDefinition.java
@NotNull
@Override
public IFileElementType getFileNodeType() {
    return OclFileStubElementType.INSTANCE;
}
 
@NotNull
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
 
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
 
@Override
public IFileElementType getFileNodeType() {
  return FILE;
}
 
@Override
public IFileElementType getFileNodeType() {
    return TSV_FILE;
}
 
@Override
public IFileElementType getFileNodeType() {
    return PSV_FILE;
}
 
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
 
public IFileElementType getFileNodeType()
{
    return FILE;
}
 
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
 
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
 
源代码26 项目: nix-idea   文件: NixParserDefinition.java
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
 
源代码27 项目: intellij-neos   文件: FusionParserDefinition.java
@Override
public IFileElementType getFileNodeType() {
    return FusionFileStub.TYPE;
}
 
源代码28 项目: arma-intellij-plugin   文件: SQFParserDefinition.java
@Override
public IFileElementType getFileNodeType() {
	return FILE;
}
 
@Override
public IFileElementType getFileNodeType() {
	return FILE;
}
 
源代码30 项目: elm-plugin   文件: ElmParserDefinition.java
@Override
public IFileElementType getFileNodeType() {
    return FILE;
}
 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法