当前位置: 首页>>代码示例>>Java>>正文


Java PsiBuilderFactory类代码示例

本文整理汇总了Java中com.intellij.lang.PsiBuilderFactory的典型用法代码示例。如果您正苦于以下问题:Java PsiBuilderFactory类的具体用法?Java PsiBuilderFactory怎么用?Java PsiBuilderFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PsiBuilderFactory类属于com.intellij.lang包,在下文中一共展示了PsiBuilderFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DtdParsing

import com.intellij.lang.PsiBuilderFactory; //导入依赖的package包/类
public DtdParsing(CharSequence chars,
                  final IElementType type,
                  final XmlEntityDecl.EntityContextType contextType,
                  PsiFile contextFile
) {
  this(
    type,
    contextType,
    PsiBuilderFactory.getInstance().createBuilder(
      LanguageParserDefinitions.INSTANCE.forLanguage(DTDLanguage.INSTANCE),
      new DtdLexer(false) {
        final int myInitialState = getLexerInitialState(type, contextType);
        @Override
        public void start(@NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) {
          super.start(buffer, startOffset, endOffset, myInitialState);
        }
      }, chars
    )
  );
  if (contextFile != null) myBuilder.putUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY, contextFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:DtdParsing.java

示例2: parseImpl

import com.intellij.lang.PsiBuilderFactory; //导入依赖的package包/类
private ASTNode parseImpl(ASTNode chameleon) {
  final PsiElement parentElement = chameleon.getTreeParent().getPsi();
  final Project project = parentElement.getProject();
  final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, new GroovyLexer(), getLanguage(), chameleon.getText());

  PsiBuilder.Marker rootMarker = builder.mark();
  if (BUILT_IN_TYPES.contains(chameleon.getText())) {
    builder.advanceLexer();
  } else {
    ReferenceElement.parse(builder, false, false, false, false, false);
    while (!builder.eof()) {
      builder.advanceLexer();
    }
  }
  rootMarker.done(this);
  return builder.getTreeBuilt().getFirstChildNode();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GroovyDocTagValueTokenType.java

示例3: doParseContents

import com.intellij.lang.PsiBuilderFactory; //导入依赖的package包/类
@Override protected ASTNode doParseContents(final ASTNode chameleon, final PsiElement psi) {
    final Project project = psi.getProject();

    final MetaborgIdeaLanguage language = getMetaborgIdeaLanguage();
    final PsiBuilder builder =
        PsiBuilderFactory.getInstance().createBuilder(project, chameleon, null, language, chameleon.getChars());


    @Nullable final FileObject resource = getResource(psi, builder);
    final ILanguageImpl languageImpl = getLanguageImpl(resource, psi, this);

    final String text = builder.getOriginalText().toString();
    final ISpoofaxInputUnit input = unitService.inputUnit(resource, text, languageImpl, null);
    final ISpoofaxParseUnit parseResult = parseAll(input);

    final AstBuilder astBuilder =
        new AstBuilder(languageImpl, this.elementTypeProviderFactory, this.tokenTypesManager);
    final ASTNode tree = astBuilder.build(parseResult, this, builder);

    final ASTNode rootNode = tree.getFirstChildNode();

    final MetaborgFile file = (MetaborgFile) psi;
    file.putUserData(MetaborgFile.PARSE_RESULT_KEY, parseResult);

    return rootNode;
}
 
开发者ID:metaborg,项目名称:spoofax-intellij,代码行数:27,代码来源:MetaborgFileElementType.java

示例4: DtdParsing

import com.intellij.lang.PsiBuilderFactory; //导入依赖的package包/类
public DtdParsing(CharSequence chars,
                  final IElementType type,
                  final XmlEntityDecl.EntityContextType contextType,
                  PsiFile contextFile
) {
  this(
    type,
    contextType,
    PsiBuilderFactory.getInstance().createBuilder(
      LanguageParserDefinitions.INSTANCE.forLanguage(DTDLanguage.INSTANCE),
      new DtdLexer(false) {
        final int myInitialState = getLexerInitialState(type, contextType);
        @Override
        public void start(CharSequence buffer, int startOffset, int endOffset, int initialState) {
          super.start(buffer, startOffset, endOffset, myInitialState);
        }
      }, chars
    )
  );
  if (contextFile != null) myBuilder.putUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY, contextFile);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:DtdParsing.java

示例5: createElementType

import com.intellij.lang.PsiBuilderFactory; //导入依赖的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

示例6: doParseContents

import com.intellij.lang.PsiBuilderFactory; //导入依赖的package包/类
@Override
protected ASTNode doParseContents(@NotNull ASTNode chameleon, @NotNull PsiElement psi)
{
	final PsiBuilderFactory factory = PsiBuilderFactory.getInstance();
	final PsiBuilder psiBuilder = factory.createBuilder(getProject(), chameleon, LanguageVersionUtil.findDefaultVersion(getLanguage()));
	final PsiBuilder builder = adapt_builder_(HaxeTokenTypes.EXPRESSION, psiBuilder, new HaxeParser());

	final PsiBuilder.Marker marker = builder.mark();
	enter_section_(builder, 0, _NONE_, "<code fragment>");
	HaxeParser.expression(builder, 1);
	while(builder.getTokenType() != null)
	{
		builder.advanceLexer();
	}
	marker.done(HaxeTokenTypes.EXPRESSION);
	return builder.getTreeBuilt();
}
 
开发者ID:consulo,项目名称:consulo-haxe,代码行数:18,代码来源:HaxeExpressionCodeFragmentImpl.java

示例7: parseContents

import com.intellij.lang.PsiBuilderFactory; //导入依赖的package包/类
@Override
public ASTNode parseContents(ASTNode chameleon)
{
	Project project = chameleon.getTreeParent().getPsi().getProject();
	PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, new GroovyLexer(), GroovyFileType.GROOVY_LANGUAGE,
			LanguageVersionUtil.findDefaultVersion(GroovyFileType.GROOVY_LANGUAGE), chameleon.getText());

	PsiBuilder.Marker mark = builder.mark();
	GroovyParser.parseExpression(builder);
	if(!builder.eof())
	{
		builder.error("expression expected");

		while(!builder.eof())
		{
			builder.advanceLexer();
		}
	}
	mark.done(GroovyParserDefinition.GROOVY_FILE);

	return builder.getTreeBuilt().getFirstChildNode();
}
 
开发者ID:consulo,项目名称:consulo-play,代码行数:23,代码来源:PlayBaseTemplateGroovyExpressionElementType.java

示例8: PsiManagerImpl

import com.intellij.lang.PsiBuilderFactory; //导入依赖的package包/类
public PsiManagerImpl(Project project,
                      FileDocumentManager fileDocumentManager,
                      PsiBuilderFactory psiBuilderFactory,
                      FileIndexFacade fileIndex,
                      MessageBus messageBus,
                      PsiModificationTracker modificationTracker) {
  myProject = project;
  myFileIndex = fileIndex;
  myMessageBus = messageBus;
  myModificationTracker = modificationTracker;

  //We need to initialize PsiBuilderFactory service so it won't initialize under PsiLock from ChameleonTransform
  @SuppressWarnings({"UnusedDeclaration", "UnnecessaryLocalVariable"}) Object used = psiBuilderFactory;

  myFileManager = new FileManagerImpl(this, fileDocumentManager, fileIndex);

  myTreeChangePreprocessors.add((PsiTreeChangePreprocessor)modificationTracker);

  Disposer.register(project, () -> myIsDisposed = true);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:PsiManagerImpl.java

示例9: DtdParsing

import com.intellij.lang.PsiBuilderFactory; //导入依赖的package包/类
public DtdParsing(CharSequence chars,
                  final IElementType type,
                  final XmlEntityDecl.EntityContextType contextType,
                  PsiFile contextFile
) {
  this(
    type,
    contextType,
    PsiBuilderFactory.getInstance().createBuilder(
      LanguageParserDefinitions.INSTANCE.forLanguage(DTDLanguage.INSTANCE),
      new DtdLexer(false) {
        final int myInitialState = getLexerInitialState(type, contextType);
        @Override
        public void start(CharSequence buffer, int startOffset, int endOffset, int initialState) {
          super.start(buffer, startOffset, endOffset, myInitialState);
        }
      }, LanguageVersionUtil.findDefaultVersion(DTDLanguage.INSTANCE), chars
    )
  );
  if (contextFile != null) myBuilder.putUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY, contextFile);
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:22,代码来源:DtdParsing.java

示例10: PsiManagerImpl

import com.intellij.lang.PsiBuilderFactory; //导入依赖的package包/类
public PsiManagerImpl(Project project,
                      FileDocumentManager fileDocumentManager,
                      PsiBuilderFactory psiBuilderFactory,
                      FileIndexFacade fileIndex,
                      MessageBus messageBus,
                      PsiModificationTracker modificationTracker) {
  myProject = project;
  myFileIndex = fileIndex;
  myMessageBus = messageBus;
  myModificationTracker = modificationTracker;

  //We need to initialize PsiBuilderFactory service so it won't initialize under PsiLock from ChameleonTransform
  @SuppressWarnings({"UnusedDeclaration", "UnnecessaryLocalVariable"}) Object used = psiBuilderFactory;

  boolean isProjectDefault = project.isDefault();

  myFileManager = isProjectDefault ? new EmptyFileManager(this) : new FileManagerImpl(this, fileDocumentManager, fileIndex);

  myTreeChangePreprocessors.add((PsiTreeChangePreprocessor)modificationTracker);
  Collections.addAll(myTreeChangePreprocessors, Extensions.getExtensions(PsiTreeChangePreprocessor.EP_NAME, myProject));

  Disposer.register(project, new Disposable() {
    @Override
    public void dispose() {
      myIsDisposed = true;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:PsiManagerImpl.java

示例11: parseContents

import com.intellij.lang.PsiBuilderFactory; //导入依赖的package包/类
@Override
public ASTNode parseContents(final ASTNode chameleon) {
    final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(chameleon.getTreeParent().getPsi().getProject(),
            chameleon,
            new SquirrelDocLexer(),
            getLanguage(),
            chameleon.getChars());
    doParse(builder);
    return builder.getTreeBuilt().getFirstChildNode();
}
 
开发者ID:shvetsgroup,项目名称:squirrel-lang-idea-plugin,代码行数:11,代码来源:SquirrelTokenTypesSets.java

示例12: PsiManagerImpl

import com.intellij.lang.PsiBuilderFactory; //导入依赖的package包/类
public PsiManagerImpl(Project project,
                      FileDocumentManager fileDocumentManager,
                      PsiBuilderFactory psiBuilderFactory,
                      FileIndexFacade excludedFileIndex,
                      MessageBus messageBus,
                      PsiModificationTracker modificationTracker) {
  myProject = project;
  myExcludedFileIndex = excludedFileIndex;
  myMessageBus = messageBus;
  myModificationTracker = modificationTracker;

  //We need to initialize PsiBuilderFactory service so it won't initialize under PsiLock from ChameleonTransform
  @SuppressWarnings({"UnusedDeclaration", "UnnecessaryLocalVariable"}) Object used = psiBuilderFactory;

  boolean isProjectDefault = project.isDefault();

  myFileManager = isProjectDefault ? new EmptyFileManager(this) : new FileManagerImpl(this, fileDocumentManager, excludedFileIndex);

  myTreeChangePreprocessors.add((PsiTreeChangePreprocessor)modificationTracker);
  Collections.addAll(myTreeChangePreprocessors, Extensions.getExtensions(PsiTreeChangePreprocessor.EP_NAME, myProject));

  Disposer.register(project, new Disposable() {
    @Override
    public void dispose() {
      myIsDisposed = true;
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:PsiManagerImpl.java

示例13: doParseContents

import com.intellij.lang.PsiBuilderFactory; //导入依赖的package包/类
@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, new _CSharpMacroLexer(), languageForParser, languageVersion, chameleon.getChars());
	final PsiParser parser = LanguageParserDefinitions.INSTANCE.forLanguage(languageForParser).createParser(languageVersion);
	return parser.parse(this, builder, languageVersion).getFirstChildNode();
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:12,代码来源:CSharpPreprocessorElements.java

示例14: doParseContents

import com.intellij.lang.PsiBuilderFactory; //导入依赖的package包/类
@Override
protected ASTNode doParseContents(@NotNull final ASTNode chameleon, @NotNull final 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());

	return ourExpressionParser.parse(this, builder, languageVersion).getFirstChildNode();
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:13,代码来源:CSharpFragmentFactory.java

示例15: doParseContents

import com.intellij.lang.PsiBuilderFactory; //导入依赖的package包/类
@Override
protected ASTNode doParseContents(@NotNull final ASTNode chameleon, @NotNull final PsiElement psi)
{
	final Project project = psi.getProject();
	final Language languageForParser = getLanguageForParser(psi);
	CSharpReferenceLexer lexer = new CSharpReferenceLexer();
	PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, lexer, languageForParser, languageForParser.getVersions()[0], chameleon.getChars());
	return ourParser.parse(this, builder, languageForParser.getVersions()[0]).getFirstChildNode();
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:10,代码来源:CSharpInjectExpressionElementType.java


注:本文中的com.intellij.lang.PsiBuilderFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。