@Override public com.sun.tools.javac.util.List<JCStatement> inlineStatements(Inliner inliner) { ListBuffer<JCStatement> buffer = new ListBuffer<>(); for (StatementTree stmt : inliner.getOptionalBinding(key()).or(ImmutableList.<StatementTree>of())) { buffer.add((JCStatement) stmt); } return buffer.toList(); } }
static com.sun.tools.javac.util.List<JCStatement> inlineStatementList( Iterable<? extends UStatement> statements, Inliner inliner) throws CouldNotResolveImportException { ListBuffer<JCStatement> buffer = new ListBuffer<>(); for (UStatement statement : statements) { buffer.appendList(statement.inlineStatements(inliner)); } return buffer.toList(); }
private JCTree.JCBlock addReturnBlock(JavacTreeMaker singletonClassTreeMaker, JavacNode holderInnerClass) { JCTree.JCClassDecl holderInnerClassDecl = (JCTree.JCClassDecl) holderInnerClass.get(); JavacTreeMaker holderInnerClassTreeMaker = holderInnerClass.getTreeMaker(); JCTree.JCIdent holderInnerClassType = holderInnerClassTreeMaker.Ident(holderInnerClassDecl.name); JCTree.JCFieldAccess instanceVarAccess = holderInnerClassTreeMaker.Select(holderInnerClassType, holderInnerClass.toName("INSTANCE")); JCTree.JCReturn returnValue = singletonClassTreeMaker.Return(instanceVarAccess); ListBuffer<JCTree.JCStatement> statements = new ListBuffer<>(); statements.append(returnValue); return singletonClassTreeMaker.Block(0L, statements.toList()); }
public <R> com.sun.tools.javac.util.List<R> inlineList( Iterable<? extends Inlineable<? extends R>> elements) throws CouldNotResolveImportException { ListBuffer<R> result = new ListBuffer<>(); for (Inlineable<? extends R> e : elements) { if (e instanceof URepeated) { // URepeated is bound to a list of expressions. URepeated repeated = (URepeated) e; for (JCExpression expr : getBinding(repeated.key())) { @SuppressWarnings("unchecked") // URepeated is an Inlineable<JCExpression>, so if e is also an Inlineable<? extends R>, // then R must be ? super JCExpression. R r = (R) expr; result.append(r); } } else { result.append(e.inline(this)); } } return result.toList(); }
public List<JCVariableDecl> inlineParams(Inliner inliner) throws CouldNotResolveImportException { if (parameterKind() == ParameterKind.EXPLICIT) { return List.convert(JCVariableDecl.class, inliner.inlineList(getParameters())); } ListBuffer<JCVariableDecl> params = new ListBuffer<>(); for (UVariableDecl param : getParameters()) { params.add(param.inlineImplicitType(inliner)); } return params.toList(); }
private boolean checkBounds(Unifier unifier, Inliner inliner, Warner warner) throws CouldNotResolveImportException { Types types = unifier.types(); ListBuffer<Type> varsBuffer = new ListBuffer<>(); ListBuffer<Type> bindingsBuffer = new ListBuffer<>(); for (UTypeVar typeVar : typeVariables(unifier.getContext())) { varsBuffer.add(inliner.inlineAsVar(typeVar)); bindingsBuffer.add(unifier.getBinding(typeVar.key()).type()); } List<Type> vars = varsBuffer.toList(); List<Type> bindings = bindingsBuffer.toList(); for (UTypeVar typeVar : typeVariables(unifier.getContext())) { List<Type> bounds = types.getBounds(inliner.inlineAsVar(typeVar)); bounds = types.subst(bounds, vars, bindings); if (!types.isSubtypeUnchecked(unifier.getBinding(typeVar.key()).type(), bounds, warner)) { logger.log( FINE, String.format("%s is not a subtype of %s", inliner.getBinding(typeVar.key()), bounds)); return false; } } return true; }
@Override public Void visitClass(ClassTree node, Context context) { Symbol sym = ASTHelpers.getSymbol(node); if (sym == null || !sym.getQualifiedName().contentEquals(rule().qualifiedTemplateClass())) { ListBuffer<JCStatement> statements = new ListBuffer<>(); for (Tree tree : node.getMembers()) { if (tree instanceof JCStatement) { statements.append((JCStatement) tree); } else { tree.accept(this, context); } } scan(TreeMaker.instance(context).Block(0, statements.toList()), context); } return null; }
public com.sun.tools.javac.util.List<JCExpression> Types(List<Type> ts) { ListBuffer<JCExpression> types = new ListBuffer<JCExpression>(); for (Type t : ts) types.append((JCExpression) Type(t)); return types.toList(); }
public MemberReferenceTree MemberReference(ReferenceMode refMode, CharSequence name, ExpressionTree expression, List<? extends ExpressionTree> typeArguments) { ListBuffer<JCExpression> targs; if (typeArguments != null) { targs = new ListBuffer<JCExpression>(); for (ExpressionTree t : typeArguments) targs.append((JCExpression)t); } else { targs = null; } return make.at(NOPOS).Reference(refMode, names.fromString(name.toString()), (JCExpression) expression, targs != null ? targs.toList() : null); }
public AttributeTree Attribute(CharSequence name, AttributeTree.ValueKind vkind, List<? extends DocTree> value) { ListBuffer<DCTree> lb = null; if(value != null) { lb = new ListBuffer<DCTree>(); for (DocTree t : value) { lb.append((DCTree) t); } } return docMake.at(NOPOS).Attribute((Name) names.fromString(name.toString()), vkind, lb != null ? lb.toList() : null); }
public UnknownInlineTagTree UnknownInlineTag(CharSequence name, List<? extends DocTree> content) { ListBuffer<DCTree> cont = new ListBuffer<DCTree>(); for (DocTree t : content) { cont.append((DCTree) t); } return docMake.at(NOPOS).UnknownInlineTag(names.fromString(name.toString()), cont.toList()); }
public CaseTree Case(ExpressionTree expression, List<? extends StatementTree> statements) { ListBuffer<JCStatement> lb = new ListBuffer<JCStatement>(); for (StatementTree t : statements) lb.append((JCStatement)t); return make.at(NOPOS).Case((JCExpression)expression, lb.toList()); }
public ParameterizedTypeTree ParameterizedType(Tree type, List<? extends Tree> typeArguments) { ListBuffer<JCExpression> typeargs = new ListBuffer<JCExpression>(); for (Tree t : typeArguments) typeargs.append((JCExpression)t); return make.at(NOPOS).TypeApply((JCExpression)type, typeargs.toList()); }
public SwitchTree Switch(ExpressionTree expression, List<? extends CaseTree> caseList) { ListBuffer<JCCase> cases = new ListBuffer<JCCase>(); for (CaseTree t : caseList) cases.append((JCCase)t); return make.at(NOPOS).Switch((JCExpression)expression, cases.toList()); }
public DeprecatedTree Deprecated(List<? extends DocTree> text) { ListBuffer<DCTree> txt = new ListBuffer<DCTree>(); for (DocTree t : text) { txt.append((DCTree) t); } return docMake.at(NOPOS).Deprecated(txt.toList()); }
public LinkTree Link(ReferenceTree ref, List<? extends DocTree> label) { ListBuffer<DCTree> lbl = new ListBuffer<DCTree>(); for (DocTree t : label) { lbl.append((DCTree) t); } return docMake.at(NOPOS).Link((DCTree.DCReference)ref, lbl.toList()); }
public SerialFieldTree SerialField(com.sun.source.doctree.IdentifierTree name, ReferenceTree type, List<? extends DocTree> description) { ListBuffer<DCTree> desc = new ListBuffer<DCTree>(); for (DocTree t : description) { desc.append((DCTree) t); } return docMake.at(NOPOS).SerialField((DCIdentifier)name, (DCReference)type, desc.toList()); }
public AnnotationTree Annotation(Tree type, List<? extends ExpressionTree> arguments) { ListBuffer<JCExpression> lb = new ListBuffer<JCExpression>(); for (ExpressionTree t : arguments) lb.append((JCExpression)t); return make.at(NOPOS).Annotation((JCTree)type, lb.toList()); }
public UnionTypeTree UnionType(List<? extends Tree> typeComponents) { ListBuffer<JCExpression> components = new ListBuffer<JCExpression>(); for (Tree t : typeComponents) components.append((JCExpression)t); return make.at(NOPOS).TypeUnion(components.toList()); }
public ThrowsTree Exception(ReferenceTree name, List<? extends DocTree> description) { ListBuffer<DCTree> desc = new ListBuffer<DCTree>(); for (DocTree t : description) { desc.append((DCTree) t); } return docMake.at(NOPOS).Exception((DCReference)name, desc.toList()); }