boolean (PsiBuilder builder, ErrorState state, Frame frame, boolean inner, boolean force, boolean advance) { int position = builder.rawTokenIndex(); String expected = state.getExpected(position, true); if (!force && expected.isEmpty() && !advance) return false; String actual = trim(builder.getTokenText()); String message; if (expected.isEmpty()) { if (isEmpty(actual)) { message = AnalysisBundle.message("parsing.error.unmatched.input"); } else { message = AnalysisBundle.message("parsing.error.unexpected", first(actual, MAX_ERROR_TOKEN_TEXT, true)); } } else { if (isEmpty(actual)) { message = AnalysisBundle.message("parsing.error.expected", expected); } else { message = AnalysisBundle.message("parsing.error.expected.got", expected, first(actual, MAX_ERROR_TOKEN_TEXT, true)); } } if (advance) { PsiBuilder.Marker mark = builder.mark(); state.tokenAdvancer.parse(builder, frame.level + 1); mark.error(message); } else if (inner) { PsiBuilderImpl.ProductionMarker latestDoneMarker = getLatestExtensibleDoneMarker(builder); builder.error(message); if (latestDoneMarker != null && frame.position >= latestDoneMarker.getStartIndex() && frame.position <= latestDoneMarker.getEndIndex()) { extend_marker_impl((PsiBuilder.Marker)latestDoneMarker); } } else { builder.error(message); } builder.eof(); // skip whitespaces frame.errorReportedAt = builder.rawTokenIndex(); return true; }