/** VariableDeclarator = Ident VariableDeclaratorRest * ConstantDeclarator = Ident ConstantDeclaratorRest */ JCVariableDecl variableDeclarator(JCModifiers mods, JCExpression type, boolean reqInit, String dc) { return variableDeclaratorRest(S.pos(), mods, type, ident(), reqInit, dc); }
/** VariableDeclarators = VariableDeclarator { "," VariableDeclarator } */ public <T extends ListBuffer<? super JCVariableDecl>> T variableDeclarators(JCModifiers mods, JCExpression type, T vdefs) { return variableDeclaratorsRest(S.pos(), mods, type, ident(), false, null, vdefs); }
/** VariableDeclarators = VariableDeclarator { "," VariableDeclarator } */ public <T extends ListBuffer<? super JCVariableDecl>> T variableDeclarators(JCModifiers mods, JCExpression type, T vdefs) { return variableDeclaratorsRest(S.pos(), mods, type, ident(), false, null, vdefs); }
/** VariableDeclarator = Ident VariableDeclaratorRest * ConstantDeclarator = Ident ConstantDeclaratorRest */ JCVariableDecl variableDeclarator(JCModifiers mods, JCExpression type, boolean reqInit, String dc) { return variableDeclaratorRest(S.pos(), mods, type, ident(), reqInit, dc); }
/** VariableDeclaratorId = Ident BracketsOpt */ JCVariableDecl variableDeclaratorId(JCModifiers mods, JCExpression type) { int pos = S.pos(); Name name = ident(); if ((mods.flags & Flags.VARARGS) == 0) type = bracketsOpt(type); return toP(F.at(pos).VarDef(mods, name, type, null)); }
/** VariableDeclaratorId = Ident BracketsOpt */ JCVariableDecl variableDeclaratorId(JCModifiers mods, JCExpression type) { int pos = S.pos(); Name name = ident(); if ((mods.flags & Flags.VARARGS) == 0) type = bracketsOpt(type); return toP(F.at(pos).VarDef(mods, name, type, null)); }
/** InnerCreator = Ident [TypeArguments] ClassCreatorRest */ JCExpression innerCreator(int newpos, List<JCExpression> typeArgs, JCExpression encl) { JCExpression t = toP(F.at(S.pos()).Ident(ident())); if (S.token() == LT) { checkGenerics(); t = typeArguments(t); } return classCreatorRest(newpos, encl, typeArgs, t); }
/** InnerCreator = Ident [TypeArguments] ClassCreatorRest */ JCExpression innerCreator(int newpos, List<JCExpression> typeArgs, JCExpression encl) { JCExpression t = toP(F.at(S.pos()).Ident(ident())); if (S.token() == LT) { checkGenerics(); t = typeArguments(t); } return classCreatorRest(newpos, encl, typeArgs, t); }
/** SuperSuffix = Arguments | "." [TypeArguments] Ident [Arguments] */ JCExpression superSuffix(List<JCExpression> typeArgs, JCExpression t) { S.nextToken(); if (S.token() == LPAREN || typeArgs != null) { t = arguments(typeArgs, t); } else { int pos = S.pos(); accept(DOT); typeArgs = (S.token() == LT) ? typeArguments() : null; t = toP(F.at(pos).Select(t, ident())); t = argumentsOpt(typeArgs, t); } return t; }
/** SuperSuffix = Arguments | "." [TypeArguments] Ident [Arguments] */ JCExpression superSuffix(List<JCExpression> typeArgs, JCExpression t) { S.nextToken(); if (S.token() == LPAREN || typeArgs != null) { t = arguments(typeArgs, t); } else { int pos = S.pos(); accept(DOT); typeArgs = (S.token() == LT) ? typeArguments() : null; t = toP(F.at(pos).Select(t, ident())); t = argumentsOpt(typeArgs, t); } return t; }
/** InterfaceDeclaration = INTERFACE Ident TypeParametersOpt * [EXTENDS TypeList] InterfaceBody * @param mods The modifiers starting the interface declaration * @param dc The documentation comment for the interface, or null. */ JCClassDecl interfaceDeclaration(JCModifiers mods, String dc) { int pos = S.pos(); accept(INTERFACE); Name name = ident(); List<JCTypeParameter> typarams = typeParametersOpt(); List<JCExpression> extending = List.nil(); if (S.token() == EXTENDS) { S.nextToken(); extending = typeList(); } List<JCTree> defs = classOrInterfaceBody(name, true); JCClassDecl result = toP(F.at(pos).ClassDef( mods, name, typarams, null, extending, defs)); attach(result, dc); return result; }
/** 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())); }
/** InterfaceDeclaration = INTERFACE Ident TypeParametersOpt * [EXTENDS TypeList] InterfaceBody * @param mods The modifiers starting the interface declaration * @param dc The documentation comment for the interface, or null. */ JCClassDecl interfaceDeclaration(JCModifiers mods, String dc) { int pos = S.pos(); accept(INTERFACE); Name name = ident(); List<JCTypeParameter> typarams = typeParametersOpt(); List<JCExpression> extending = List.nil(); if (S.token() == EXTENDS) { S.nextToken(); extending = typeList(); } List<JCTree> defs = classOrInterfaceBody(name, true); JCClassDecl result = toP(F.at(pos).ClassDef( mods, name, typarams, null, extending, defs)); attach(result, dc); return result; }
/** ImportDeclaration = IMPORT [ STATIC ] Ident { "." Ident } [ "." "*" ] ";" */ JCTree importDeclaration() { int pos = S.pos(); S.nextToken(); boolean importStatic = false; if (S.token() == STATIC) { checkStaticImports(); importStatic = true; S.nextToken(); } JCExpression pid = toP(F.at(S.pos()).Ident(ident())); do { int pos1 = S.pos(); accept(DOT); if (S.token() == STAR) { pid = to(F.at(pos1).Select(pid, names.asterisk)); S.nextToken(); break; } else { pid = toP(F.at(pos1).Select(pid, ident())); } } while (S.token() == DOT); accept(SEMI); return toP(F.at(pos).Import(pid, importStatic)); }
/** 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())); }
/** EnumDeclaration = ENUM Ident [IMPLEMENTS TypeList] EnumBody * @param mods The modifiers starting the enum declaration * @param dc The documentation comment for the enum, or null. */ JCClassDecl enumDeclaration(JCModifiers mods, String dc) { int pos = S.pos(); accept(ENUM); Name name = ident(); List<JCExpression> implementing = List.nil(); if (S.token() == IMPLEMENTS) { S.nextToken(); implementing = typeList(); } List<JCTree> defs = enumBody(name); JCModifiers newMods = F.at(mods.pos).Modifiers(mods.flags|Flags.ENUM, mods.annotations); JCClassDecl result = toP(F.at(pos). ClassDef(newMods, name, List.<JCTypeParameter>nil(), null, implementing, defs)); attach(result, dc); return result; }
/** EnumDeclaration = ENUM Ident [IMPLEMENTS TypeList] EnumBody * @param mods The modifiers starting the enum declaration * @param dc The documentation comment for the enum, or null. */ JCClassDecl enumDeclaration(JCModifiers mods, String dc) { int pos = S.pos(); accept(ENUM); Name name = ident(); List<JCExpression> implementing = List.nil(); if (S.token() == IMPLEMENTS) { S.nextToken(); implementing = typeList(); } List<JCTree> defs = enumBody(name); JCModifiers newMods = F.at(mods.pos).Modifiers(mods.flags|Flags.ENUM, mods.annotations); JCClassDecl result = toP(F.at(pos). ClassDef(newMods, name, List.<JCTypeParameter>nil(), null, implementing, defs)); attach(result, dc); return result; }
/** 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; }