protected <T extends JCTree> T toP(T t) { storeEnd(t, parser.S.prevToken().endPos); return t; }
protected <T extends JCTree> T toP(T t) { storeEnd(t, parser.S.prevToken().endPos); return t; }
/** If next input token matches given token, skip it, otherwise report * an error. */ public void accept(TokenKind tk) { if (token.kind == tk) { nextToken(); } else { setErrorEndPos(token.pos); reportSyntaxError(S.prevToken().endPos, "expected", tk); } }
/** If next input token matches given token, skip it, otherwise report * an error. */ public void accept(TokenKind tk) { if (token.kind == tk) { nextToken(); } else { setErrorEndPos(token.pos); reportSyntaxError(S.prevToken().endPos, "expected", tk); } }
JCModifiers mods(int pos, long flags, List<JCAnnotation> annotations) { /* A modifiers tree with no modifier tokens or annotations * has no text position. */ if ((flags & (Flags.ModifierFlags | Flags.ANNOTATION)) == 0 && annotations.isEmpty()) pos = Position.NOPOS; JCModifiers mods = F.at(pos).Modifiers(flags, annotations); if (pos != Position.NOPOS) storeEnd(mods, S.prevToken().endPos); return mods; }
/** Annotation = "@" Qualident [ "(" AnnotationFieldValues ")" ] * * @param pos position of "@" token * @param kind Whether to parse an ANNOTATION or TYPE_ANNOTATION */ JCAnnotation annotation(int pos, Tag kind) { // accept(AT); // AT consumed by caller checkAnnotations(); if (kind == Tag.TYPE_ANNOTATION) { checkTypeAnnotations(); } JCTree ident = qualident(false); List<JCExpression> fieldValues = annotationFieldValuesOpt(); JCAnnotation ann; if (kind == Tag.ANNOTATION) { ann = F.at(pos).Annotation(ident, fieldValues); } else if (kind == Tag.TYPE_ANNOTATION) { ann = F.at(pos).TypeAnnotation(ident, fieldValues); } else { throw new AssertionError("Unhandled annotation kind: " + kind); } storeEnd(ann, S.prevToken().endPos); return ann; }
protected JCCase switchBlockStatementGroup() { int pos = token.pos; List<JCStatement> stats; JCCase c; switch (token.kind) { case CASE: nextToken(); JCExpression pat = parseExpression(); accept(COLON); stats = blockStatements(); c = F.at(pos).Case(pat, stats); if (stats.isEmpty()) storeEnd(c, S.prevToken().endPos); return c; case DEFAULT: nextToken(); accept(COLON); stats = blockStatements(); c = F.at(pos).Case(null, stats); if (stats.isEmpty()) storeEnd(c, S.prevToken().endPos); return c; } throw new AssertionError("should not reach here"); }
protected JCCase switchBlockStatementGroup() { int pos = token.pos; List<JCStatement> stats; JCCase c; switch (token.kind) { case CASE: nextToken(); JCExpression pat = parseExpression(); accept(COLON); stats = blockStatements(); c = F.at(pos).Case(pat, stats); if (stats.isEmpty()) storeEnd(c, S.prevToken().endPos); return c; case DEFAULT: nextToken(); accept(COLON); stats = blockStatements(); c = F.at(pos).Case(null, stats); if (stats.isEmpty()) storeEnd(c, S.prevToken().endPos); return c; } throw new AssertionError("should not reach here"); }
/** Annotation = "@" Qualident [ "(" AnnotationFieldValues ")" ] * * @param pos position of "@" token * @param kind Whether to parse an ANNOTATION or TYPE_ANNOTATION */ JCAnnotation annotation(int pos, Tag kind) { // accept(AT); // AT consumed by caller checkAnnotations(); if (kind == Tag.TYPE_ANNOTATION) { checkTypeAnnotations(); } JCTree ident = qualident(false); List<JCExpression> fieldValues = annotationFieldValuesOpt(); JCAnnotation ann; if (kind == Tag.ANNOTATION) { ann = F.at(pos).Annotation(ident, fieldValues); } else if (kind == Tag.TYPE_ANNOTATION) { ann = F.at(pos).TypeAnnotation(ident, fieldValues); } else { throw new AssertionError("Unhandled annotation kind: " + kind); } storeEnd(ann, S.prevToken().endPos); return ann; }
storeEnd(mods, S.prevToken().endPos); return mods;
attach(toplevel, firstToken.comment(CommentStyle.JAVADOC)); if (defs.isEmpty()) storeEnd(toplevel, S.prevToken().endPos); if (keepDocComments) toplevel.docComments = docComments;
attach(toplevel, firstToken.comment(CommentStyle.JAVADOC)); if (defs.isEmpty()) storeEnd(toplevel, S.prevToken().endPos); if (keepDocComments) toplevel.docComments = docComments;
JCNewClass create = F.at(createPos).NewClass(null, typeArgs, ident, args, body); if (createPos != identPos) storeEnd(create, S.prevToken().endPos); ident = F.at(identPos).Ident(enumName); JCTree result = toP(F.at(pos).VarDef(mods, name, ident, create));
JCNewClass create = F.at(createPos).NewClass(null, typeArgs, ident, args, body); if (createPos != identPos) storeEnd(create, S.prevToken().endPos); ident = F.at(identPos).Ident(enumName); JCTree result = toP(F.at(pos).VarDef(mods, name, ident, create));
setErrorEndPos(S.prevToken().endPos); JCErroneous err = F.at(pos).Erroneous(typeArgs.prepend(e)); reportSyntaxError(err, "cannot.create.array.with.type.arguments");
setErrorEndPos(S.prevToken().endPos); JCErroneous err = F.at(pos).Erroneous(typeArgs.prepend(e)); reportSyntaxError(err, "cannot.create.array.with.type.arguments");