/** ClassDeclaration = CLASS Ident TypeParametersOpt [EXTENDS Type] * [IMPLEMENTS TypeList] ClassBody * @param mods The modifiers starting the class declaration * @param dc The documentation comment for the class, or null. */ JCClassDecl classDeclaration(JCModifiers mods, String dc) { int pos = S.pos(); accept(CLASS); Name name = ident(); List<JCTypeParameter> typarams = typeParametersOpt(); JCTree extending = null; if (S.token() == EXTENDS) { S.nextToken(); extending = type(); } List<JCExpression> implementing = List.nil(); if (S.token() == IMPLEMENTS) { S.nextToken(); implementing = typeList(); } List<JCTree> defs = classOrInterfaceBody(name, false); JCClassDecl result = toP(F.at(pos).ClassDef( mods, name, typarams, extending, implementing, defs)); attach(result, dc); return result; }
S.nextToken(); } else { type = type();
/** ClassDeclaration = CLASS Ident TypeParametersOpt [EXTENDS Type] * [IMPLEMENTS TypeList] ClassBody * @param mods The modifiers starting the class declaration * @param dc The documentation comment for the class, or null. */ JCClassDecl classDeclaration(JCModifiers mods, String dc) { int pos = S.pos(); accept(CLASS); Name name = ident(); List<JCTypeParameter> typarams = typeParametersOpt(); JCTree extending = null; if (S.token() == EXTENDS) { S.nextToken(); extending = type(); } List<JCExpression> implementing = List.nil(); if (S.token() == IMPLEMENTS) { S.nextToken(); implementing = typeList(); } List<JCTree> defs = classOrInterfaceBody(name, false); JCClassDecl result = toP(F.at(pos).ClassDef( mods, name, typarams, extending, implementing, defs)); attach(result, dc); return result; }
S.nextToken(); } else { type = type();
/** * For internal use by Sun Microsystems only. This method will be * removed without warning. */ public Type parseType(String expr, TypeElement scope) { if (expr == null || expr.equals("")) throw new IllegalArgumentException(); compiler = JavaCompiler.instance(context); JavaFileObject prev = compiler.log.useSource(null); Scanner.Factory scannerFactory = Scanner.Factory.instance(context); Parser.Factory parserFactory = Parser.Factory.instance(context); Attr attr = Attr.instance(context); try { Scanner scanner = scannerFactory.newScanner((expr+"\u0000").toCharArray(), expr.length()); Parser parser = parserFactory.newParser(scanner, false, false); JCTree tree = parser.type(); return attr.attribType(tree, (Symbol.TypeSymbol)scope); } finally { compiler.log.useSource(prev); } }
/** * For internal use only. This method will be * removed without warning. */ public Type parseType(String expr, TypeElement scope) { if (expr == null || expr.equals("")) throw new IllegalArgumentException(); compiler = JavaCompiler.instance(context); JavaFileObject prev = compiler.log.useSource(null); Scanner.Factory scannerFactory = Scanner.Factory.instance(context); Parser.Factory parserFactory = Parser.Factory.instance(context); Attr attr = Attr.instance(context); try { Scanner scanner = scannerFactory.newScanner((expr+"\u0000").toCharArray(), expr.length()); Parser parser = parserFactory.newParser(scanner, false, false); JCTree tree = parser.type(); return attr.attribType(tree, (Symbol.TypeSymbol)scope); } finally { compiler.log.useSource(prev); } }
/** TypeParameter = TypeVariable [TypeParameterBound] * TypeParameterBound = EXTENDS Type {"&" Type} * TypeVariable = Ident */ JCTypeParameter typeParameter() { int pos = S.pos(); Name name = ident(); ListBuffer<JCExpression> bounds = new ListBuffer<JCExpression>(); if (S.token() == EXTENDS) { S.nextToken(); bounds.append(type()); while (S.token() == AMP) { S.nextToken(); bounds.append(type()); } } return toP(F.at(pos).TypeParameter(name, bounds.toList())); }
/** TypeParameter = TypeVariable [TypeParameterBound] * TypeParameterBound = EXTENDS Type {"&" Type} * TypeVariable = Ident */ JCTypeParameter typeParameter() { int pos = S.pos(); Name name = ident(); ListBuffer<JCExpression> bounds = new ListBuffer<JCExpression>(); if (S.token() == EXTENDS) { S.nextToken(); bounds.append(type()); while (S.token() == AMP) { S.nextToken(); bounds.append(type()); } } return toP(F.at(pos).TypeParameter(name, bounds.toList())); }
/** FormalParameter = { FINAL | '@' Annotation } Type VariableDeclaratorId * LastFormalParameter = { FINAL | '@' Annotation } Type '...' Ident | FormalParameter */ JCVariableDecl formalParameter() { JCModifiers mods = optFinal(Flags.PARAMETER); JCExpression type = type(); if (S.token() == ELLIPSIS) { checkVarargs(); mods.flags |= Flags.VARARGS; type = to(F.at(S.pos()).TypeArray(type)); S.nextToken(); } return variableDeclaratorId(mods, type); }
/** FormalParameter = { FINAL | '@' Annotation } Type VariableDeclaratorId * LastFormalParameter = { FINAL | '@' Annotation } Type '...' Ident | FormalParameter */ JCVariableDecl formalParameter() { JCModifiers mods = optFinal(Flags.PARAMETER); JCExpression type = type(); if (S.token() == ELLIPSIS) { checkVarargs(); mods.flags |= Flags.VARARGS; type = to(F.at(S.pos()).TypeArray(type)); S.nextToken(); } return variableDeclaratorId(mods, type); }
int pos = S.pos(); S.nextToken(); odStack[top] = topOp == INSTANCEOF ? type() : term3(); while (top > 0 && prec(topOp) >= prec(S.token())) { odStack[top-1] = makeOp(pos, topOp, odStack[top-1],
/** ForInit = StatementExpression MoreStatementExpressions * | { FINAL | '@' Annotation } Type VariableDeclarators */ List<JCStatement> forInit() { ListBuffer<JCStatement> stats = lb(); int pos = S.pos(); if (S.token() == FINAL || S.token() == MONKEYS_AT) { return variableDeclarators(optFinal(0), type(), stats).toList(); } else { JCExpression t = term(EXPR | TYPE); if ((lastmode & TYPE) != 0 && (S.token() == IDENTIFIER || S.token() == ASSERT || S.token() == ENUM)) return variableDeclarators(modifiersOpt(), t, stats).toList(); else return moreStatementExpressions(pos, t, stats).toList(); } }
/** ForInit = StatementExpression MoreStatementExpressions * | { FINAL | '@' Annotation } Type VariableDeclarators */ List<JCStatement> forInit() { ListBuffer<JCStatement> stats = lb(); int pos = S.pos(); if (S.token() == FINAL || S.token() == MONKEYS_AT) { return variableDeclarators(optFinal(0), type(), stats).toList(); } else { JCExpression t = term(EXPR | TYPE); if ((lastmode & TYPE) != 0 && (S.token() == IDENTIFIER || S.token() == ASSERT || S.token() == ENUM)) return variableDeclarators(modifiersOpt(), t, stats).toList(); else return moreStatementExpressions(pos, t, stats).toList(); } }
int pos = S.pos(); S.nextToken(); odStack[top] = topOp == INSTANCEOF ? type() : term3(); while (top > 0 && prec(topOp) >= prec(S.token())) { odStack[top-1] = makeOp(pos, topOp, odStack[top-1],
if (S.token() != QUES) return type(); int pos = S.pos(); S.nextToken(); TypeBoundKind t = to(F.at(S.pos()).TypeBoundKind(BoundKind.EXTENDS)); S.nextToken(); return F.at(pos).Wildcard(t, type()); } else if (S.token() == SUPER) { TypeBoundKind t = to(F.at(S.pos()).TypeBoundKind(BoundKind.SUPER)); S.nextToken(); return F.at(pos).Wildcard(t, type()); } else if (S.token() == IDENTIFIER) {
if (S.token() != QUES) return type(); int pos = S.pos(); S.nextToken(); TypeBoundKind t = to(F.at(S.pos()).TypeBoundKind(BoundKind.EXTENDS)); S.nextToken(); return F.at(pos).Wildcard(t, type()); } else if (S.token() == SUPER) { TypeBoundKind t = to(F.at(S.pos()).TypeBoundKind(BoundKind.SUPER)); S.nextToken(); return F.at(pos).Wildcard(t, type()); } else if (S.token() == IDENTIFIER) {