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


Java PsiParser类代码示例

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


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

示例1: createParser

import com.intellij.lang.PsiParser; //导入依赖的package包/类
@Override
public PsiParser createParser(Project project) {
  return new PsiParser() {
    @NotNull
    @Override
    public ASTNode parse(IElementType root, PsiBuilder builder) {
      final PsiBuilder.Marker rootMarker = builder.mark();
      final PsiBuilder.Marker propertiesList = builder.mark();
      while (!builder.eof()) {
        parseProvider(builder);
      }
      propertiesList.done(SPIElementTypes.PROVIDERS_LIST);
      rootMarker.done(root);
      return builder.getTreeBuilt();
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SPIParserDefinition.java

示例2: createAST

import com.intellij.lang.PsiParser; //导入依赖的package包/类
private ASTNode createAST(String text) {
  ParserDefinition definition = new BuildParserDefinition();
  PsiParser parser = definition.createParser(getProject());
  Lexer lexer = definition.createLexer(getProject());
  PsiBuilderImpl psiBuilder =
      new PsiBuilderImpl(
          getProject(), null, definition, lexer, new CharTableImpl(), text, null, null);
  PsiBuilderAdapter adapter =
      new PsiBuilderAdapter(psiBuilder) {
        @Override
        public void error(String messageText) {
          super.error(messageText);
          errors.add(messageText);
        }
      };
  return parser.parse(definition.getFileNodeType(), adapter);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:18,代码来源:BuildParserTest.java

示例3: createParser

import com.intellij.lang.PsiParser; //导入依赖的package包/类
@NotNull
@Override
public PsiParser createParser(Project project) {
  return new PsiParser() {
    @NotNull
    @Override
    public ASTNode parse(IElementType root, PsiBuilder builder) {
      return new DtdParsing(root, XmlEntityDecl.EntityContextType.GENERIC_XML, builder).parse();
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:DTDParserDefinition.java

示例4: createParser

import com.intellij.lang.PsiParser; //导入依赖的package包/类
@Override
public PsiParser createParser(Project project) {
  return (root, builder) -> {
    PsiBuilder.Marker rootMarker = builder.mark();
    new ProjectViewPsiParser(builder).parseFile();
    rootMarker.done(root);
    return builder.getTreeBuilt();
  };
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:10,代码来源:ProjectViewParserDefinition.java

示例5: parseText

import com.intellij.lang.PsiParser; //导入依赖的package包/类
public static @NotNull <T extends PsiElement> T parseText(
    @NotNull String text,
    @NotNull IElementType rootElementType,
    @NotNull Class<T> rootElementClass,
    @NotNull ParserDefinition parserDefinition,
    @Nullable ErrorProcessor errorProcessor) {

  LanguageParserDefinitions.INSTANCE.addExplicitExtension(
      parserDefinition.getFileNodeType().getLanguage(),
      parserDefinition
  );

  PsiParser parser = parserDefinition.createParser(model.first);
  Lexer lexer = parserDefinition.createLexer(model.first);
  PsiBuilderImpl psiBuilder = new PsiBuilderImpl(
      model.first,
      null,
      parserDefinition,
      lexer,
      new CharTableImpl(),
      text,
      null,
      null
  );

  ASTNode astNode = parser.parse(rootElementType, psiBuilder);
  T res = astNode.getPsi(rootElementClass);
  collectErrors(res, errorProcessor);

  return res;
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:32,代码来源:EpigraphPsiUtil.java

示例6: createParser

import com.intellij.lang.PsiParser; //导入依赖的package包/类
@NotNull
public PsiParser createParser(final Project project) {
    if(project != null) {
        project.putUserData(JSGRAPHQL_ACTIVATED, true);
    }
    return new JSGraphQLParser();
}
 
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:8,代码来源:JSGraphQLParserDefinition.java

示例7: createParser

import com.intellij.lang.PsiParser; //导入依赖的package包/类
@NotNull
public PsiParser createParser(final Project project) {
    //return new MultiMarkdownParser();
    return MultiMarkdownGlobalSettings.getInstance().lightParserFailedBuild.runBuild(new FailedBuildRunnable<PsiParser>() {
        @Nullable @Override public PsiParser runCanFail() throws Throwable {
            return new MultiMarkdownLightParser();
        }

        @Nullable @Override public PsiParser run() {
            return new MultiMarkdownParser();
        }
    });
}
 
开发者ID:vsch,项目名称:idea-multimarkdown,代码行数:14,代码来源:MultiMarkdownParserDefinition.java

示例8: stateHackMess

import com.intellij.lang.PsiParser; //导入依赖的package包/类
/**
 * Called when the parser gets confused from layout rules.
 *
 * Increases the debt of rbraces in the token remapper in
 * HaskellParserWrapper. When the remapper is in debt it will swallow
 * (=remap them to TokenType.WHITE_SPACE) synthetic rbraces until no debt
 * remains.
 */
public static boolean stateHackMess(@NotNull PsiBuilder builder,  int level) {
    if (!(builder instanceof Builder)) return false;
    PsiParser wrapper = ((Builder) builder).parser;
    if (!(wrapper instanceof HaskellParserWrapper)) return false;

    // IElementType tok = builder.getTokenType();
    int offs = builder.getCurrentOffset();
    int line = StringUtil.offsetToLineNumber(builder.getOriginalText(), offs);
    int lineStart = StringUtil.lineColToOffset(builder.getOriginalText(), line, 1);
    Pair<Integer, Integer> p = ((HaskellParserWrapper) wrapper).debtPoints.get(offs);
    if (p != null && p.getSecond() == 0 && !((HaskellParserWrapper) wrapper).regressed) {
        ((HaskellParserWrapper) wrapper).maxRbraceDebt = ((HaskellParserWrapper) wrapper).debtPoints.get(offs).getFirst();
        ((HaskellParserWrapper) wrapper).rbraceDebt = ((HaskellParserWrapper) wrapper).rbraceDebt - ((HaskellParserWrapper) wrapper).maxRbraceDebt;
        ((HaskellParserWrapper) wrapper).debtPoints.put(offs, Pair.create(((HaskellParserWrapper) wrapper).maxRbraceDebt, ((HaskellParserWrapper) wrapper).maxRbraceDebt));
    } else if (((HaskellParserWrapper) wrapper).maxRbraceDebt == -1) {
        int numOpen = findBraces(((HaskellParserWrapper) wrapper).lexer.openBraces, offs, line, lineStart);
        ((HaskellParserWrapper) wrapper).maxRbraceDebt = numOpen;
    }
    // System.out.println("Confused at: " + offs + " line " + line + " on token " + tok
    //        + " regressed: " + ((HaskellParserWrapper) wrapper).regressed + " max: "
    //        + ((HaskellParserWrapper) wrapper).maxRbraceDebt);

    boolean ret = ((HaskellParserWrapper) wrapper).increaseRbraceDebt(builder.getCurrentOffset());
    if (((HaskellParserWrapper) wrapper).maxRbraceDebt == 0) ((HaskellParserWrapper) wrapper).maxRbraceDebt = -1;
    return ret;
}
 
开发者ID:carymrobbins,项目名称:intellij-haskforce,代码行数:35,代码来源:HaskellParserUtilBase.java

示例9: indented

import com.intellij.lang.PsiParser; //导入依赖的package包/类
public static boolean indented(@NotNull PsiBuilder builder, int level, Parser geq) {
    if (!(builder instanceof Builder)) return false;
    PsiParser wrapper = ((Builder) builder).parser;
    if (!(wrapper instanceof HaskellParserWrapper)) return false;
    if (builder.eof()) return false;

    // IElementType currtok = builder.getTokenType();
    Pair<Integer, IElementType> prevtok = previousElem(builder);
    if (prevtok == null) return true;

    int offs = builder.getCurrentOffset();
    int line = StringUtil.offsetToLineNumber(builder.getOriginalText(), offs);
    int prevline = StringUtil.offsetToLineNumber(builder.getOriginalText(), offs + prevtok.getFirst());
    if (prevline == line) return true;

    int thisLineStart = StringUtil.lineColToOffset(builder.getOriginalText(), line, 0);
    int prevLineStart = StringUtil.lineColToOffset(builder.getOriginalText(), prevline, 0);
    // CharSequence lineStuff = builder.getOriginalText().subSequence(thisLineStart, offs);
    CharSequence prevLineStuff = builder.getOriginalText().subSequence(prevLineStart, thisLineStart - 1);
    int indentation = indentationLevel(prevLineStuff);
    int myindentation = offs - thisLineStart;
    // String tokName = builder.getTokenText();

    boolean geqVal = geq.parse(builder, level);
    if (geqVal && myindentation >= indentation ||
            !geqVal && myindentation > indentation) return true;
    return false;
}
 
开发者ID:carymrobbins,项目名称:intellij-haskforce,代码行数:29,代码来源:HaskellParserUtilBase.java

示例10: doParseContents

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

示例11: doParseContents

import com.intellij.lang.PsiParser; //导入依赖的package包/类
@Override
@RequiredReadAction
protected ASTNode doParseContents(@NotNull final ASTNode chameleon, @NotNull final PsiElement psi)
{
	final Project project = psi.getProject();
	CSharpDocLanguage docLanguage = CSharpDocLanguage.INSTANCE;
	final LanguageVersion languageVersion = LanguageVersionUtil.findDefaultVersion(docLanguage);
	DeprecatedCSharpDocLexer docLexer = new DeprecatedCSharpDocLexer();
	final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, docLexer, docLanguage, languageVersion, chameleon.getChars());
	final PsiParser parser = LanguageParserDefinitions.INSTANCE.forLanguage(docLanguage).createParser(languageVersion);
	return parser.parse(this, builder, languageVersion).getFirstChildNode();
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:13,代码来源:CSharpDocElements.java

示例12: doParse

import com.intellij.lang.PsiParser; //导入依赖的package包/类
@NotNull
private PsiBuilder doParse(@NotNull ASTNode chameleon, Project project, LanguageVersion languageVersion)
{
	LanguageLevel languageLevel = LanguageLevel.HIGHEST;
	PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, new JspJavaLexer(languageLevel), JavaLanguage.INSTANCE, languageVersion, chameleon.getChars());
	JavaParserUtil.setLanguageLevel(builder, languageLevel);
	PsiParser parser = new JavaInJspParser();
	parser.parse(this, builder, languageVersion);
	return builder;
}
 
开发者ID:consulo,项目名称:consulo-javaee,代码行数:11,代码来源:JspJavaFileElementType.java

示例13: createParser

import com.intellij.lang.PsiParser; //导入依赖的package包/类
@NotNull
@Override
public PsiParser createParser()
{
	if(myExpressionElementType == null)
	{
		myExpressionElementType = createExpressionElementType();
	}
	return new CfsParser(myExpressionElementType);
}
 
开发者ID:consulo,项目名称:consulo-dotnet,代码行数:11,代码来源:BaseExpressionCfsLanguageVersion.java

示例14: createParser

import com.intellij.lang.PsiParser; //导入依赖的package包/类
@Nonnull
@Override
public PsiParser createParser(@Nonnull LanguageVersion languageVersion) {
  if(languageVersion instanceof LanguageVersionWithParsing) {
    return ((LanguageVersionWithParsing)languageVersion).createParser();
  }
  throw new IllegalArgumentException("'createParser' need override for language version '" + languageVersion + "'");
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:LanguageVersionableParserDefinition.java

示例15: createParser

import com.intellij.lang.PsiParser; //导入依赖的package包/类
@Override
public PsiParser createParser(Project project) {
    return new TSParser();
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:5,代码来源:TSParserDefinition.java


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