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

项目:TS-IJ    文件:TSParserUtil.java   
private static boolean assign_ref_expr(PsiBuilder b, int l) {
    //So this is rather wonky. What we do here is try to parse the incoming nodes as an expression,
    // as assign_ref_expr (and the below rules) need an expression as the first argument, but
    // you can chain them together. And calling expr will eat the assign_ref_expr when it parses.
    //So to get to the point here:
    // We run expr() and then see what it comes up with. If the last node (basically the expression
    // that it parsed from the call) is of our type, then we successfully parsed it.
    boolean r;
    PsiBuilder.Marker m = enter_section_(b);
    //Group -1 so we parse whatever expression is next
    r = expr(b, l + 1, -1);
    if (r) {
        //If we parsed an expression, check if we parsed the type we'ere looking for
        PsiBuilderImpl.ProductionMarker last = (PsiBuilderImpl.ProductionMarker) b.getLatestDoneMarker();
        r = last != null && last.getTokenType().equals(ASSIGN_REF_EXPR);
    }
    exit_section_(b, m, null, r);
    return r;
}
项目:intellij-ce-playground    文件:PsiBuilderQuickTest.java   
private static PsiBuilderImpl createBuilder(CharSequence text) {
  ParserDefinition parserDefinition = new PlainTextParserDefinition() {
    @NotNull
    @Override
    public Lexer createLexer(Project project) {
      return new MyTestLexer();
    }

    @NotNull
    @Override
    public TokenSet getWhitespaceTokens() {
      return WHITESPACE_SET;
    }

    @NotNull
    @Override
    public TokenSet getCommentTokens() {
      return COMMENT_SET;
    }
  };
  return new PsiBuilderImpl(getProject(), null, parserDefinition, parserDefinition.createLexer(getProject()), null, text, null, null);
}
项目:intellij-ce-playground    文件:GeneratedParserUtilBase.java   
private static void close_marker_impl_(Frame frame, PsiBuilder.Marker marker, IElementType elementType, boolean result) {
  if (marker == null) return;
  if (result) {
    if (elementType != null) {
      marker.done(elementType);
    }
    else {
      marker.drop();
    }
  }
  else {
    if (frame != null) {
      int position = ((PsiBuilderImpl.ProductionMarker)marker).getStartIndex();
      if (frame.errorReportedAt > position && frame.parentFrame != null) {
        frame.errorReportedAt = frame.parentFrame.errorReportedAt;
      }
    }
    marker.rollbackTo();
  }
}
项目: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);
}
项目:firstspiritlanguagesupport    文件:GeneratedParserUtilBase.java   
private static void close_marker_impl_(Frame frame, PsiBuilder.Marker marker, IElementType elementType, boolean result) {
    if (marker == null) return;
    if (result) {
        if (elementType != null) {
            marker.done(elementType);
        }
        else {
            marker.drop();
        }
    }
    else {
        if (frame != null) {
            int position = ((PsiBuilderImpl.ProductionMarker)marker).getStartOffset();
            if (frame.errorReportedAt > position) {
                frame.errorReportedAt = frame.errorReportedAtPrev;
            }
        }
        marker.rollbackTo();
    }
}
项目:intellij-latte    文件:GeneratedParserUtilBase.java   
private static void close_marker_impl_(Frame frame, PsiBuilder.Marker marker, IElementType elementType, boolean result) {
    if (marker == null) return;
    if (result) {
        if (elementType != null) {
            marker.done(elementType);
        }
        else {
            marker.drop();
        }
    }
    else {
        if (frame != null) {
            int position = ((PsiBuilderImpl.ProductionMarker)marker).getStartIndex();
            if (frame.errorReportedAt > position && frame.parentFrame != null) {
                frame.errorReportedAt = frame.parentFrame.errorReportedAt;
            }
        }
        marker.rollbackTo();
    }
}
项目:intellij-xquery    文件:GeneratedParserUtilBase.java   
private static void close_marker_impl_(Frame frame, PsiBuilder.Marker marker, IElementType elementType, boolean result) {
    if (marker == null) return;
    if (result) {
        if (elementType != null) {
            marker.done(elementType);
        }
        else {
            marker.drop();
        }
    }
    else {
        if (frame != null) {
            int position = ((PsiBuilderImpl.ProductionMarker)marker).getStartIndex();
            if (frame.errorReportedAt > position && frame.parentFrame != null) {
                frame.errorReportedAt = frame.parentFrame.errorReportedAt;
            }
        }
        marker.rollbackTo();
    }
}
项目:consulo    文件:GeneratedParserUtilBase.java   
private static void close_marker_impl_(Frame frame, PsiBuilder.Marker marker, IElementType elementType, boolean result) {
  if (marker == null) return;
  if (result) {
    if (elementType != null) {
      marker.done(elementType);
    }
    else {
      marker.drop();
    }
  }
  else {
    if (frame != null) {
      int position = ((PsiBuilderImpl.ProductionMarker)marker).getStartIndex();
      if (frame.errorReportedAt > position && frame.parentFrame != null) {
        frame.errorReportedAt = frame.parentFrame.errorReportedAt;
      }
    }
    marker.rollbackTo();
  }
}
项目:TS-IJ    文件:TSParserUtil.java   
private static boolean assign_ref_index_expr(PsiBuilder b, int l) {
    //See assign_ref_expr for explanation
    boolean r;
    PsiBuilder.Marker m = enter_section_(b);
    r = expr(b, l + 1, -1);
    if (r) {
        PsiBuilderImpl.ProductionMarker last = (PsiBuilderImpl.ProductionMarker)b.getLatestDoneMarker();
        r = last != null && last.getTokenType().equals(ASSIGN_REF_INDEX_EXPR);
    }
    exit_section_(b, m, null, r);
    return r;
}
项目:TS-IJ    文件:TSParserUtil.java   
private static boolean call_method_expr(PsiBuilder b, int l) {
    //See assign_ref_expr for explanation
    boolean r;
    PsiBuilder.Marker m = enter_section_(b);
    r = expr(b, l + 1, -1);
    if (r) {
        PsiBuilderImpl.ProductionMarker last = (PsiBuilderImpl.ProductionMarker)b.getLatestDoneMarker();
        r = last != null && last.getTokenType().equals(CALL_METHOD_EXPR);
    }
    exit_section_(b, m, null, r);
    return r;
}
项目:RtplPlugin    文件:RtplParser.java   
@Override
@NotNull
public ASTNode parse(final IElementType root, final PsiBuilder builder) {
  builder.enforceCommentTokens(TokenSet.EMPTY);
  builder.putUserDataUnprotected(PsiBuilderImpl.CUSTOM_COMPARATOR, REPARSE_XML_TAG_BY_NAME);
  final PsiBuilder.Marker file = builder.mark();
  new XmlParsing(builder).parseDocument();
  file.done(root);
  return builder.getTreeBuilt();
}
项目:intellij-ce-playground    文件:PsiBuilderTest.java   
private static PsiBuilderImpl createBuilder(final String text, ASTNode originalTree) {
  final Language lang = StdFileTypes.JAVA.getLanguage();
  final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
  assertNotNull(parserDefinition);
  PsiFile psiFile = createFile("x.java", text);
  return new PsiBuilderImpl(getProject(), psiFile, parserDefinition, JavaParserDefinition.createLexer(LanguageLevel.JDK_1_5),
                            SharedImplUtil.findCharTableByTree(psiFile.getNode()), text, originalTree, null);
}
项目:intellij-ce-playground    文件:GeneratedParserUtilBase.java   
private static boolean reportError(PsiBuilder builder,
                                   ErrorState state,
                                   Frame frame,
                                   IElementType elementType,
                                   boolean force,
                                   boolean advance) {
  String expectedText = state.getExpectedText(builder);
  boolean notEmpty = StringUtil.isNotEmpty(expectedText);
  if (!(force || notEmpty || advance)) return false;

  String gotText = builder.eof() ? "unexpected end of file" :
                         notEmpty? "got '" + builder.getTokenText() +"'" :
                         "'" + builder.getTokenText() +"' unexpected";
  String message = expectedText + gotText;
  if (advance) {
    PsiBuilder.Marker mark = builder.mark();
    builder.advanceLexer();
    mark.error(message);
  }
  else if (!force) {
    PsiBuilder.Marker extensionMarker = null;
    IElementType extensionTokenType = null;
    PsiBuilderImpl.ProductionMarker latestDoneMarker = elementType == null ? null : (PsiBuilderImpl.ProductionMarker)builder.getLatestDoneMarker();
    if (latestDoneMarker != null &&
        frame.position >= latestDoneMarker.getStartIndex() &&
        frame.position <= latestDoneMarker.getEndIndex()) {
      extensionMarker = ((PsiBuilder.Marker)latestDoneMarker).precede();
      extensionTokenType = latestDoneMarker.getTokenType();
      ((PsiBuilder.Marker)latestDoneMarker).drop();
    }
    builder.error(message);
    if (extensionMarker != null) extensionMarker.done(extensionTokenType);
  }
  else {
    builder.error(message);
  }
  builder.eof(); // skip whitespaces
  frame.errorReportedAt = builder.rawTokenIndex();
  return true;
}
项目:intellij-ce-playground    文件:MasqueradingPsiBuilderAdapter.java   
public MasqueradingPsiBuilderAdapter(@NotNull final Project project,
                      @NotNull final ParserDefinition parserDefinition,
                      @NotNull final MasqueradingLexer lexer,
                      @NotNull final ASTNode chameleon,
                      @NotNull final CharSequence text) {
  this(new PsiBuilderImpl(project, parserDefinition, lexer, chameleon, text));
}
项目:intellij-ce-playground    文件:MasqueradingPsiBuilderAdapter.java   
public MasqueradingPsiBuilderAdapter(@NotNull final Project project,
                      @NotNull final ParserDefinition parserDefinition,
                      @NotNull final MasqueradingLexer lexer,
                      @NotNull final LighterLazyParseableNode chameleon,
                      @NotNull final CharSequence text) {
  this(new PsiBuilderImpl(project, parserDefinition, lexer, chameleon, text));
}
项目:intellij-ce-playground    文件:MasqueradingPsiBuilderAdapter.java   
private MasqueradingPsiBuilderAdapter(PsiBuilderImpl builder) {
  super(builder);

  LOG.assertTrue(myDelegate instanceof PsiBuilderImpl);
  myBuilderDelegate = ((PsiBuilderImpl)myDelegate);

  LOG.assertTrue(myBuilderDelegate.getLexer() instanceof MasqueradingLexer);
  myLexer = ((MasqueradingLexer)myBuilderDelegate.getLexer());

  initShrunkSequence();
}
项目:intellij-ce-playground    文件:XmlParser.java   
@Override
@NotNull
public ASTNode parse(final IElementType root, final PsiBuilder builder) {
  builder.enforceCommentTokens(TokenSet.EMPTY);
  builder.putUserDataUnprotected(PsiBuilderImpl.CUSTOM_COMPARATOR, REPARSE_XML_TAG_BY_NAME);
  final PsiBuilder.Marker file = builder.mark();
  new XmlParsing(builder).parseDocument();
  file.done(root);
  return builder.getTreeBuilt();
}
项目:intellij-ce-playground    文件:PropertiesParser.java   
public void doParse(IElementType root, PsiBuilder builder) {
  builder.putUserDataUnprotected(PsiBuilderImpl.CUSTOM_COMPARATOR, MATCH_BY_KEY);
  final PsiBuilder.Marker rootMarker = builder.mark();
  final PsiBuilder.Marker propertiesList = builder.mark();
  while (!builder.eof()) {
    Parsing.parseProperty(builder);
  }
  propertiesList.done(PropertiesElementTypes.PROPERTIES_LIST);
  rootMarker.done(root);
}
项目: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;
}
项目:intellij-ocaml    文件:OCamlPsiUtil.java   
@NotNull
public static PsiElement parse(@NotNull final CharSequence text, @NotNull final ParserDefinition parserDefinition, @NotNull final Project project, final boolean isTestMode) {
    final Lexer lexer = parserDefinition.createLexer(project);
    final PsiParser parser = parserDefinition.createParser(project);
    final PsiBuilderImpl builder = new PsiBuilderImpl(lexer, parserDefinition.getWhitespaceTokens(), parserDefinition.getCommentTokens(), text);
    builder.setDebugMode(isTestMode);
    return parserDefinition.createElement(parser.parse(parserDefinition.getFileNodeType(), builder));
}
项目:intellij-haskforce    文件:HaskellParserWrapper.java   
@NotNull
@Override
public ASTNode parse(IElementType root_, PsiBuilder builder_) {
    maxRbraceDebt = -1;
    lastCountedTok = -1;
    regressed = false;
    debtPoints.clear();
    builder_.setTokenTypeRemapper(myRemapper);
    lexer =  (_HaskellParsingLexer) ((FlexAdapter) ((PsiBuilderImpl) builder_).getLexer()).getFlex();
    ASTNode node = super.parse(root_, builder_);
    return node;
}
项目:tools-idea    文件:PsiBuilderTest.java   
private static PsiBuilderImpl createBuilder(final String text, ASTNode originalTree) {
  final Language lang = StdFileTypes.JAVA.getLanguage();
  final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
  assertNotNull(parserDefinition);
  PsiFile psiFile = createFile("x.java", text);
  return new PsiBuilderImpl(getProject(), psiFile, parserDefinition, JavaParserDefinition.createLexer(LanguageLevel.JDK_1_5),
                            SharedImplUtil.findCharTableByTree(psiFile.getNode()), text, originalTree, null);
}
项目:tools-idea    文件:XmlParser.java   
@NotNull
public ASTNode parse(final IElementType root, final PsiBuilder builder) {
  builder.enforceCommentTokens(TokenSet.EMPTY);
  builder.putUserDataUnprotected(PsiBuilderImpl.CUSTOM_COMPARATOR, REPARSE_XML_TAG_BY_NAME);
  final PsiBuilder.Marker file = builder.mark();
  new XmlParsing(builder).parseDocument();
  file.done(root);
  return builder.getTreeBuilt();
}
项目:intellij-latte    文件:GeneratedParserUtilBase.java   
private static boolean reportError(PsiBuilder builder,
                                   ErrorState state,
                                   Frame frame,
                                   IElementType elementType,
                                   boolean force,
                                   boolean advance) {
    String expectedText = state.getExpectedText(builder);
    boolean notEmpty = StringUtil.isNotEmpty(expectedText);
    if (!(force || notEmpty || advance)) return false;

    String gotText = builder.eof() ? "unexpected end of file" :
        notEmpty? "got '" + builder.getTokenText() +"'" :
            "'" + builder.getTokenText() +"' unexpected";
    String message = expectedText + gotText;
    if (advance) {
        PsiBuilder.Marker mark = builder.mark();
        builder.advanceLexer();
        mark.error(message);
    }
    else if (!force) {
        PsiBuilder.Marker extensionMarker = null;
        IElementType extensionTokenType = null;
        PsiBuilderImpl.ProductionMarker latestDoneMarker = elementType == null ? null : (PsiBuilderImpl.ProductionMarker)builder.getLatestDoneMarker();
        if (latestDoneMarker != null &&
            frame.position >= latestDoneMarker.getStartIndex() &&
            frame.position <= latestDoneMarker.getEndIndex()) {
            extensionMarker = ((PsiBuilder.Marker)latestDoneMarker).precede();
            extensionTokenType = latestDoneMarker.getTokenType();
            ((PsiBuilder.Marker)latestDoneMarker).drop();
        }
        builder.error(message);
        if (extensionMarker != null) extensionMarker.done(extensionTokenType);
    }
    else {
        builder.error(message);
    }
    builder.eof(); // skip whitespaces
    frame.errorReportedAt = builder.rawTokenIndex();
    return true;
}
项目:intellij-xquery    文件:GeneratedParserUtilBase.java   
private static boolean reportError(PsiBuilder builder,
                                   ErrorState state,
                                   Frame frame,
                                   IElementType elementType,
                                   boolean force,
                                   boolean advance) {
    String expectedText = state.getExpectedText(builder);
    boolean notEmpty = isNotEmpty(expectedText);
    if (!(force || notEmpty || advance)) return false;

    String actual = "'" + first(notNullize(builder.getTokenText(), "null"), MAX_ERROR_TOKEN_TEXT, true) + "'";
    String message = expectedText + (builder.eof() ? "unexpected end of file" : notEmpty ? "got " + actual : actual + " unexpected");
    if (advance) {
        PsiBuilder.Marker mark = builder.mark();
        builder.advanceLexer();
        mark.error(message);
    }
    else if (!force) {
        PsiBuilder.Marker extensionMarker = null;
        IElementType extensionTokenType = null;
        PsiBuilderImpl.ProductionMarker latestDoneMarker = elementType == null ? null : (PsiBuilderImpl.ProductionMarker)builder.getLatestDoneMarker();
        if (latestDoneMarker != null &&
                frame.position >= latestDoneMarker.getStartIndex() &&
                frame.position <= latestDoneMarker.getEndIndex()) {
            extensionMarker = ((PsiBuilder.Marker)latestDoneMarker).precede();
            extensionTokenType = latestDoneMarker.getTokenType();
            ((PsiBuilder.Marker)latestDoneMarker).drop();
        }
        builder.error(message);
        if (extensionMarker != null) extensionMarker.done(extensionTokenType);
    }
    else {
        builder.error(message);
    }
    builder.eof(); // skip whitespaces
    frame.errorReportedAt = builder.rawTokenIndex();
    return true;
}
项目:consulo    文件:GeneratedParserUtilBase.java   
@Override
public PsiBuilder.Marker run(PsiBuilder builder, PsiBuilder.Marker marker, String param) {
  PsiBuilderImpl.ProductionMarker m = (PsiBuilderImpl.ProductionMarker)marker;
  int start = m == null ? builder.getCurrentOffset() : m.getStartOffset();
  int end = m == null ? start : m.getEndOffset();
  String prefix = "[" + start + ", " + end + "]" + (m == null ? "" : " " + m.getTokenType());
  builder.mark().error(prefix + ": " + param);
  return marker;
}
项目:consulo    文件:GeneratedParserUtilBase.java   
private static boolean reportError(PsiBuilder builder,
                                   ErrorState state,
                                   Frame frame,
                                   IElementType elementType,
                                   boolean force,
                                   boolean advance) {
  String expectedText = state.getExpectedText(builder);
  boolean notEmpty = isNotEmpty(expectedText);
  if (!(force || notEmpty || advance)) return false;

  String actual = "'" + first(notNullize(builder.getTokenText(), "null"), MAX_ERROR_TOKEN_TEXT, true) + "'";
  String message = expectedText + (builder.eof() ? "unexpected end of file" : notEmpty ? "got " + actual : actual + " unexpected");
  if (advance) {
    PsiBuilder.Marker mark = builder.mark();
    builder.advanceLexer();
    mark.error(message);
  }
  else if (!force) {
    PsiBuilder.Marker extensionMarker = null;
    IElementType extensionTokenType = null;
    PsiBuilderImpl.ProductionMarker latestDoneMarker = elementType == null ? null : (PsiBuilderImpl.ProductionMarker)builder.getLatestDoneMarker();
    if (latestDoneMarker != null &&
        frame.position >= latestDoneMarker.getStartIndex() &&
        frame.position <= latestDoneMarker.getEndIndex()) {
      extensionMarker = ((PsiBuilder.Marker)latestDoneMarker).precede();
      extensionTokenType = latestDoneMarker.getTokenType();
      ((PsiBuilder.Marker)latestDoneMarker).drop();
    }
    builder.error(message);
    if (extensionMarker != null) extensionMarker.done(extensionTokenType);
  }
  else {
    builder.error(message);
  }
  builder.eof(); // skip whitespaces
  frame.errorReportedAt = builder.rawTokenIndex();
  return true;
}
项目:consulo-xml    文件:XmlParser.java   
@NotNull
public ASTNode parse(@NotNull final IElementType root, @NotNull final PsiBuilder builder, @NotNull LanguageVersion languageVersion) {
  builder.enforceCommentTokens(TokenSet.EMPTY);
  builder.putUserDataUnprotected(PsiBuilderImpl.CUSTOM_COMPARATOR, REPARSE_XML_TAG_BY_NAME);
  final PsiBuilder.Marker file = builder.mark();
  new XmlParsing(builder).parseDocument();
  file.done(root);
  return builder.getTreeBuilt();
}
项目:intellij-ce-playground    文件:PsiBuilderTest.java   
private static PsiBuilderImpl createBuilder(final String text) {
  return createBuilder(text,null);
}
项目:intellij-ce-playground    文件:DebugUtil.java   
public static void lightTreeToBuffer(@NotNull final FlyweightCapableTreeStructure<LighterASTNode> tree,
                                     @NotNull final LighterASTNode node,
                                     @NotNull final Appendable buffer,
                                     final int indent,
                                     final boolean skipWhiteSpaces) {
  final IElementType tokenType = node.getTokenType();
  if (skipWhiteSpaces && tokenType == TokenType.WHITE_SPACE) return;

  final boolean isLeaf = (node instanceof LighterASTTokenNode);

  StringUtil.repeatSymbol(buffer, ' ', indent);
  try {
    if (tokenType == TokenType.ERROR_ELEMENT) {
      buffer.append("PsiErrorElement:").append(PsiBuilderImpl.getErrorMessage(node));
    }
    else if (tokenType == TokenType.WHITE_SPACE) {
      buffer.append("PsiWhiteSpace");
    }
    else {
      buffer.append(isLeaf ? "PsiElement" : "Element").append('(').append(tokenType.toString()).append(')');
    }

    if (isLeaf) {
      final String text = ((LighterASTTokenNode)node).getText().toString();
      buffer.append("('").append(fixWhiteSpaces(text)).append("')");
    }
    buffer.append('\n');

    if (!isLeaf) {
      final Ref<LighterASTNode[]> kids = new Ref<LighterASTNode[]>();
      final int numKids = tree.getChildren(tree.prepareForGetChildren(node), kids);
      if (numKids == 0) {
        StringUtil.repeatSymbol(buffer, ' ', indent + 2);
        buffer.append("<empty list>\n");
      }
      else {
        for (int i = 0; i < numKids; i++) {
          lightTreeToBuffer(tree, kids.get()[i], buffer, indent + 2, skipWhiteSpaces);
        }
      }
    }
  }
  catch (IOException e) {
    LOG.error(e);
  }
}
项目:intellij-ce-playground    文件:GeneratedParserUtilBase.java   
public static boolean isWhitespaceOrComment(@NotNull PsiBuilder builder, @Nullable IElementType type) {
  return ((PsiBuilderImpl)((Builder)builder).getDelegate()).whitespaceOrComment(type);
}
项目:intellij-ce-playground    文件:GeneratedParserUtilBase.java   
private static void close_frame_impl_(ErrorState state,
                                      Frame frame,
                                      PsiBuilder builder,
                                      PsiBuilder.Marker marker,
                                      IElementType elementType,
                                      boolean result,
                                      boolean pinned) {
  if (elementType != null && marker != null) {
    if ((frame.modifiers & _COLLAPSE_) != 0) {
      PsiBuilderImpl.ProductionMarker last = result || pinned? (PsiBuilderImpl.ProductionMarker)builder.getLatestDoneMarker() : null;
      if (last != null && last.getStartIndex() == frame.position &&
          state.typeExtends(last.getTokenType(), elementType)) {
        IElementType resultType = last.getTokenType();
        ((PsiBuilder.Marker)last).drop();
        marker.done(resultType);
        return;
      }
    }
    if (result || pinned) {
      if ((frame.modifiers & _UPPER_) != 0) {
        marker.drop();
        for (Frame f = frame.parentFrame; f != null; f = f.parentFrame) {
          if (f.elementType == null) continue;
          f.elementType = elementType;
          break;
        }
      }
      else if ((frame.modifiers & _LEFT_INNER_) != 0 && frame.leftMarker != null) {
        marker.done(elementType);
        frame.leftMarker.precede().done(((LighterASTNode)frame.leftMarker).getTokenType());
        frame.leftMarker.drop();
      }
      else if ((frame.modifiers & _LEFT_) != 0 && frame.leftMarker != null) {
        marker.drop();
        frame.leftMarker.precede().done(elementType);
      }
      else {
        if (frame.level == 0) builder.eof(); // skip whitespaces
        marker.done(elementType);
      }
    }
    else {
      close_marker_impl_(frame, marker, null, false);
    }
  }
  else if (result || pinned) {
    if (marker != null) marker.drop();
    if ((frame.modifiers & _LEFT_INNER_) != 0 && frame.leftMarker != null) {
      frame.leftMarker.precede().done(((LighterASTNode)frame.leftMarker).getTokenType());
      frame.leftMarker.drop();
    }
  }
  else {
    close_marker_impl_(frame, marker, null, false);
  }
}
项目:intellij-ce-playground    文件:GeneratedParserUtilBase.java   
public Lexer getLexer() {
  return ((PsiBuilderImpl)myDelegate).getLexer();
}
项目:intellij-ce-playground    文件:PrattBuilderImpl.java   
@Override
public Lexer getLexer() {
  return ((PsiBuilderImpl) myBuilder).getLexer();
}
项目:coocoo-idea-plugin    文件:GeneratedParserUtilBase.java   
public Lexer getLexer() {
  return ((PsiBuilderImpl)myDelegate).getLexer();
}
项目:firstspiritlanguagesupport    文件:GeneratedParserUtilBase.java   
private static void exit_section_impl_(ErrorState state,
                                       Frame frame,
                                       PsiBuilder builder_,
                                       PsiBuilder.Marker marker,
                                       IElementType elementType,
                                       boolean result,
                                       boolean pinned) {
    if (elementType != null && marker != null) {
        if ((frame.modifiers & _COLLAPSE_) != 0) {
            PsiBuilderImpl.ProductionMarker last = result || pinned? (PsiBuilderImpl.ProductionMarker)builder_.getLatestDoneMarker() : null;
            if (last != null && last.getStartOffset() == frame.position &&
                    state.typeExtends(last.getTokenType(), elementType)) {
                IElementType resultType = last.getTokenType();
                ((PsiBuilder.Marker)last).drop();
                marker.done(resultType);
                return;
            }
        }
        if (result || pinned) {
            if ((frame.modifiers & _LEFT_INNER_) != 0 && frame.leftMarker != null) {
                marker.done(elementType);
                frame.leftMarker.precede().done(((LighterASTNode)frame.leftMarker).getTokenType());
                frame.leftMarker.drop();
            }
            else if ((frame.modifiers & _LEFT_) != 0 && frame.leftMarker != null) {
                marker.drop();
                frame.leftMarker.precede().done(elementType);
            }
            else {
                if (frame.level == 0) builder_.eof(); // skip whitespaces
                marker.done(elementType);
            }
        }
        else {
            close_marker_impl_(frame, marker, null, false);
        }
    }
    else if (result || pinned) {
        if (marker != null) marker.drop();
        if ((frame.modifiers & _LEFT_INNER_) != 0 && frame.leftMarker != null) {
            frame.leftMarker.precede().done(((LighterASTNode)frame.leftMarker).getTokenType());
            frame.leftMarker.drop();
        }
    }
    else {
        close_marker_impl_(frame, marker, null, false);
    }
}
项目:firstspiritlanguagesupport    文件:GeneratedParserUtilBase.java   
public Lexer getLexer() {
    return ((PsiBuilderImpl)myDelegate).getLexer();
}
项目:tools-idea    文件:PsiBuilderTest.java   
private static PsiBuilderImpl createBuilder(final String text) {
  return createBuilder(text,null);
}
项目:tools-idea    文件:DebugUtil.java   
public static void lightTreeToBuffer(@NotNull final FlyweightCapableTreeStructure<LighterASTNode> tree,
                                     @NotNull final LighterASTNode node,
                                     @NotNull final Appendable buffer,
                                     final int indent,
                                     final boolean skipWhiteSpaces) {
  final IElementType tokenType = node.getTokenType();
  if (skipWhiteSpaces && tokenType == TokenType.WHITE_SPACE) return;

  final boolean isLeaf = (node instanceof LighterASTTokenNode);

  StringUtil.repeatSymbol(buffer, ' ', indent);
  try {
    if (tokenType == TokenType.ERROR_ELEMENT) {
      buffer.append("PsiErrorElement:").append(PsiBuilderImpl.getErrorMessage(node));
    }
    else if (tokenType == TokenType.WHITE_SPACE) {
      buffer.append("PsiWhiteSpace");
    }
    else {
      buffer.append(isLeaf ? "PsiElement" : "Element").append('(').append(tokenType.toString()).append(')');
    }

    if (isLeaf) {
      final String text = ((LighterASTTokenNode)node).getText().toString();
      buffer.append("('").append(fixWhiteSpaces(text)).append("')");
    }
    buffer.append('\n');

    if (!isLeaf) {
      final Ref<LighterASTNode[]> kids = new Ref<LighterASTNode[]>();
      final int numKids = tree.getChildren(tree.prepareForGetChildren(node), kids);
      if (numKids == 0) {
        StringUtil.repeatSymbol(buffer, ' ', indent + 2);
        buffer.append("<empty list>\n");
      }
      else {
        for (int i = 0; i < numKids; i++) {
          lightTreeToBuffer(tree, kids.get()[i], buffer, indent + 2, skipWhiteSpaces);
        }
      }
    }
  }
  catch (IOException e) {
    LOG.error(e);
  }
}
项目:tools-idea    文件:GeneratedParserUtilBase.java   
public Lexer getLexer() {
  return ((PsiBuilderImpl)myDelegate).getLexer();
}