Java 类com.intellij.lang.PsiParser 实例源码

项目:intellij-ce-playground    文件:SPIParserDefinition.java   
@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();
    }
  };
}
项目:intellij    文件:BuildParserTest.java   
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);
}
项目:tools-idea    文件:SPIParserDefinition.java   
@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();
    }
  };
}
项目:intellij-ce-playground    文件:DTDParserDefinition.java   
@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();
    }
  };
}
项目:intellij    文件:ProjectViewParserDefinition.java   
@Override
public PsiParser createParser(Project project) {
  return (root, builder) -> {
    PsiBuilder.Marker rootMarker = builder.mark();
    new ProjectViewPsiParser(builder).parseFile();
    rootMarker.done(root);
    return builder.getTreeBuilt();
  };
}
项目:epigraph    文件:EpigraphPsiUtil.java   
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;
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLParserDefinition.java   
@NotNull
public PsiParser createParser(final Project project) {
    if(project != null) {
        project.putUserData(JSGRAPHQL_ACTIVATED, true);
    }
    return new JSGraphQLParser();
}
项目:idea-multimarkdown    文件:MultiMarkdownParserDefinition.java   
@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();
        }
    });
}
项目:intellij-haskforce    文件:HaskellParserUtilBase.java   
/**
 * 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;
}
项目:intellij-haskforce    文件:HaskellParserUtilBase.java   
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;
}
项目:tools-idea    文件:DTDParserDefinition.java   
@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();
    }
  };
}
项目:consulo-csharp    文件:CSharpPreprocessorElements.java   
@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();
}
项目:consulo-csharp    文件:CSharpDocElements.java   
@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();
}
项目:consulo-javaee    文件:JspJavaFileElementType.java   
@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;
}
项目:consulo-dotnet    文件:BaseExpressionCfsLanguageVersion.java   
@NotNull
@Override
public PsiParser createParser()
{
    if(myExpressionElementType == null)
    {
        myExpressionElementType = createExpressionElementType();
    }
    return new CfsParser(myExpressionElementType);
}
项目:consulo    文件:LanguageVersionableParserDefinition.java   
@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 + "'");
}
项目:TS-IJ    文件:TSParserDefinition.java   
@Override
public PsiParser createParser(Project project) {
    return new TSParser();
}
项目:AppleScript-IDEA    文件:AppleScriptParserDefinition.java   
@NotNull
public PsiParser createParser(final Project project) {
  return new AppleScriptParser();
}
项目:reasonml-idea-plugin    文件:RmlParserDefinition.java   
@NotNull
public PsiParser createParser(final Project project) {
    return new RmlParser();
}
项目:reasonml-idea-plugin    文件:OclP4ParserDefinition.java   
@NotNull
public PsiParser createParser(final Project project) {
    return new OclParser();
}
项目:reasonml-idea-plugin    文件:OclParserDefinition.java   
@NotNull
public PsiParser createParser(final Project project) {
    return new OclParser();
}
项目:greycat-idea-plugin    文件:GCMParserDefinition.java   
@NotNull
public PsiParser createParser(final Project project) {
    return new GCMParser();
}
项目:bamboo-soy    文件:SoyParserDefinition.java   
@NotNull
public PsiParser createParser(final Project project) {
  return new SoyParser();
}
项目:EmojiPrefix    文件:EmojiResourceParserDefinition.java   
@Override
public PsiParser createParser(Project project) {
    return new EmojiResourceParser();
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchParserDefinition.java   
@NotNull
public PsiParser createParser(final Project project) {
    return new FlexibleSearchParser();
}
项目:hybris-integration-intellij-idea-plugin    文件:ImpexParserDefinition.java   
@NotNull
@Override
public PsiParser createParser(final Project project) {
    return new ImpexParser();
}
项目:idea-onescript    文件:OneScriptParserDefinition.java   
@Override
public PsiParser createParser(Project project) {
    return new OneScriptParser();
}
项目:intellij-csv-validator    文件:CsvParserDefinition.java   
@Override
@NotNull
public PsiParser createParser(final Project project) {
    return new CsvParser();
}
项目:Goal-Intellij-Plugin    文件:ActionSpecParserDefinition.java   
@Override
public PsiParser createParser(Project project) {
    return new ActionSpecParser();
}
项目:Goal-Intellij-Plugin    文件:PrologParserDefinition.java   
@Override
public PsiParser createParser(Project project) {
    return new PrologParser();
}
项目:Goal-Intellij-Plugin    文件:ModuleParserDefinition.java   
@Override
public PsiParser createParser(Project project) {
    return new ModuleParser();
}
项目:Goal-Intellij-Plugin    文件:MasParserDefinition.java   
@Override
public PsiParser createParser(Project project) {
    return new MasParser();
}
项目:Goal-Intellij-Plugin    文件:TestParserDefinition.java   
@Override
public PsiParser createParser(Project project) {
    return new TestParser();
}
项目:mule-intellij-plugins    文件:RamlParserDefinition.java   
@Nullable
public PsiParser createParser(final Project project)
{
    return new YAMLParser();
}
项目:mule-intellij-plugins    文件:MelParserDefinition.java   
@Override
public PsiParser createParser(Project project) {
    return new MelParser();
}
项目:mule-intellij-plugins    文件:WeaveParserDefinition.java   
@Override
public PsiParser createParser(Project project) {
    return new WeaveParser();
}
项目:nix-idea    文件:NixParserDefinition.java   
@NotNull
public PsiParser createParser(final Project project) {
    return new NixParser();
}
项目:sutr-io    文件:SutrParserDefinition.java   
@Override
public PsiParser createParser(final Project project) {
    return new SutrParser();
}
项目:sutr-io    文件:UtrParserDefinition.java   
@Override
public PsiParser createParser(final Project project) {
    return new UtrParser();
}
项目:smcplugin    文件:SmcParserDefinition.java   
@NotNull
public PsiParser createParser(final Project project) {
    return new SmcParser();
}