Java 类com.intellij.lang.impl.PsiBuilderAdapter 实例源码

项目: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);
}
项目:consulo-java    文件:JavaParserUtil.java   
public static PsiBuilder stoppingBuilder(final PsiBuilder builder, final int stopAt)
{
    return new PsiBuilderAdapter(builder)
    {
        @Override
        public IElementType getTokenType()
        {
            return getCurrentOffset() < stopAt ? super.getTokenType() : null;
        }

        @Override
        public boolean eof()
        {
            return getCurrentOffset() >= stopAt || super.eof();
        }
    };
}
项目:intellij-ce-playground    文件:JavaParserUtil.java   
public static PsiBuilder stoppingBuilder(final PsiBuilder builder, final int stopAt) {
  return new PsiBuilderAdapter(builder) {
    @Override
    public IElementType getTokenType() {
      return getCurrentOffset() < stopAt ? super.getTokenType() : null;
    }

    @Override
    public boolean eof() {
      return getCurrentOffset() >= stopAt || super.eof();
    }
  };
}
项目:tools-idea    文件:JavaParserUtil.java   
public static PsiBuilder stoppingBuilder(final PsiBuilder builder, final int stopAt) {
  return new PsiBuilderAdapter(builder) {
    @Override
    public IElementType getTokenType() {
      return getCurrentOffset() < stopAt ? super.getTokenType() : null;
    }

    @Override
    public boolean eof() {
      return getCurrentOffset() >= stopAt || super.eof();
    }
  };
}