public static boolean eof(PsiBuilder builder, int level) { return builder.eof(); }
@Override public boolean parse(PsiBuilder builder, int level) { if (builder.eof()) return false; builder.advanceLexer(); return true; } };
private static void addCompletionVariant(@NotNull PsiBuilder builder, @NotNull CompletionState completionState, Object o) { int offset = builder.getCurrentOffset(); if (!builder.eof() && offset == builder.rawTokenTypeStart(1)) return; // suppress for zero-length tokens String text = completionState.convertItem(o); int length = text == null? 0 : text.length(); boolean add = length != 0 && completionState.prefixMatches(builder, text); add = add && length > 1 && !(text.charAt(0) == '<' && text.charAt(length - 1) == '>') && !(text.charAt(0) == '\'' && text.charAt(length - 1) == '\'' && length < 5); if (add) { completionState.addItem(builder, text); } }
private static boolean addVariantSmart(PsiBuilder builder, Object token, boolean force) { ErrorState state = ErrorState.get(builder); // skip FIRST check in completion mode if (state.completionState != null && !force) return false; builder.eof(); if (!state.suppressErrors && state.predicateCount < 2) { addVariant(builder, state, token); } return true; }
private static void addVariant(PsiBuilder builder, ErrorState state, Object o) { builder.eof(); // skip whitespaces addVariantInner(state, builder.rawTokenIndex(), o); CompletionState completionState = state.completionState; if (completionState != null && state.predicateSign) { addCompletionVariant(builder, completionState, o); } }
public static boolean consumeBlock(PsiBuilder builder_, @SuppressWarnings("UnusedParameters") int level) { PsiFile file = builder_.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY); VirtualFile data = file != null ? file.getUserData(IndexingDataKeys.VIRTUAL_FILE) : null; if (data == null) return false; int i = 0; PsiBuilder.Marker m = builder_.mark(); do { IElementType type = builder_.getTokenType(); if (type == GoTypes.TYPE_ && nextIdentifier(builder_)) { // don't count a.(type), only type <ident> m.rollbackTo(); return false; } i += type == GoTypes.LBRACE ? 1 : type == GoTypes.RBRACE ? -1 : 0; builder_.advanceLexer(); } while (i > 0 && !builder_.eof()); boolean result = i == 0; if (result) { m.drop(); } else { m.rollbackTo(); } return result; }
String message = expectedText + (builder.eof() ? "unexpected end of file" : notEmpty ? "got " + actual : actual + " unexpected"); if (advance) { PsiBuilder.Marker mark = builder.mark(); builder.error(message); builder.eof(); // skip whitespaces frame.errorReportedAt = builder.rawTokenIndex(); return true;
if (!state.suppressErrors && eatMore != null) { state.suppressErrors = true; final boolean eatMoreFlagOnce = !builder.eof() && eatMore.parse(builder, frame.level + 1); boolean eatMoreFlag = eatMoreFlagOnce || !result && frame.position == initialPos && lastErrorPos > frame.position;
if (frame.level == 0) builder.eof(); // skip whitespaces marker.done(elementType);
private static void addCompletionVariant(@NotNull PsiBuilder builder, @NotNull CompletionState completionState, Object o) { int offset = builder.getCurrentOffset(); if (!builder.eof() && offset == builder.rawTokenTypeStart(1)) return; // suppress for zero-length tokens String text = completionState.convertItem(o); int length = text == null ? 0 : text.length(); boolean add = length != 0 && completionState.prefixMatches(builder, text); add = add && length > 1 && !(text.charAt(0) == '<' && text.charAt(length - 1) == '>') && !(text.charAt(0) == '\'' && text.charAt(length - 1) == '\'' && length < 5); if (add) { completionState.addItem(builder, text); } }
private static boolean addVariantSmart(PsiBuilder builder, Object token, boolean force) { ErrorState state = ErrorState.get(builder); // skip FIRST check in completion mode if (state.completionState != null && !force) return false; builder.eof(); if (!state.suppressErrors && state.predicateCount < 2) { addVariant(builder, state, token); } return true; }
@Override public void advance() { if (!builder.eof()) { previousToken = token(); } builder.advanceLexer(); symbolIndex++; }
public static boolean is_new_line(PsiBuilder builder, int level) { if (builder.eof()) return true; for (int i=-1; ; i--) { IElementType type = builder.rawLookup(i); if (type == TokenType.WHITE_SPACE) continue; if (type == JFlexTypes.FLEX_LINE_COMMENT || type == JFlexTypes.FLEX_BLOCK_COMMENT) continue; if (type == JFlexParserDefinition.FLEX_NEWLINE || type == null) return true; if (builder.getOriginalText().charAt(builder.rawTokenTypeStart(i+1)-1) == '\n') return true; addVariant(builder, "<new-line>"); return false; } }
private static void addVariant(PsiBuilder builder, ErrorState state, Object o) { builder.eof(); // skip whitespaces addVariantInner(state, state.currentFrame, builder.rawTokenIndex(), o); CompletionState completionState = state.completionState; if (completionState != null && state.predicateSign) { addCompletionVariant(builder, completionState, o); } }
public void advanceLexer() throws CriticalParserError { if (myBuilder.eof()) { myBuilder.error("More input expected"); throw new CriticalParserError("Unexpected end of input."); } myImportantLinebreakHandler.reset(); myBuilder.advanceLexer(); }
/** Convert ANTLR parse tree to PSI tree. */ protected void walkParseTree(ParseTree parseTree, AstBuilderListener listener, IElementType root, PsiBuilder builder) { PsiBuilder.Marker rootMarker = builder.mark(); ParseTreeWalker.DEFAULT.walk(listener, parseTree); while (!builder.eof()) { builder.advanceLexer(); } rootMarker.done(root); } }
public static boolean parsePerlBlock(PsiBuilder b, int l, IElementType closeToken, IElementType blockToken) { PsiBuilder.Marker abstractBlockMarker = b.mark(); b.advanceLexer(); while (!b.eof() && b.getTokenType() != closeToken) { if (!PerlParserProxy.file_item(b, l)) { break; } } boolean r = endOrRecover(b, closeToken); abstractBlockMarker.done(blockToken); return r; }
public static boolean parseTags(PsiBuilder b, int l) { PsiBuilder.Marker m = null; while (!b.eof() && !isEndMarker(b)) { if (m == null) { m = b.mark(); } b.advanceLexer(); } if (m != null) { m.collapse(TT2_STRING_CONTENT); m.precede().done(SQ_STRING_EXPR); } return true; }
public static boolean collapseNonSpaceTo(PsiBuilder b, int l, IElementType targetElement) { IElementType tokenType = b.getTokenType(); if (tokenType == POD_IDENTIFIER) { PsiBuilder.Marker m = b.mark(); while (!b.eof() && !PodParserDefinition.ALL_WHITE_SPACES.contains(b.rawLookup(1))) { b.advanceLexer(); } b.advanceLexer(); m.collapse(targetElement); return true; } return false; }