private boolean shouldWorkaroundBug() { Boolean result = HAS_BUG.get(); if (result != null) { return result; } Context ctx = ((JavacProcessingEnvironment) processingEnv).getContext(); TreeMaker make = TreeMaker.instance(ctx); final JCLiteral val = make.Literal(""); JCMethodDecl method = make.MethodDef(null, null, null, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), null, val); final boolean[] noBug = new boolean[] {false}; new TreeScanner() { @Override public void scan(JCTree tree) { noBug[0] |= (tree == val); super.scan(tree); } }.scan(method); HAS_BUG.compareAndSet(null, Boolean.valueOf(!noBug[0])); return HAS_BUG.get(); }
@Override public JCMethodDecl inline(Inliner inliner) throws CouldNotResolveImportException { return inliner .maker() .MethodDef( getModifiers().inline(inliner), getName().inline(inliner), getReturnType().inline(inliner), List.<JCTypeParameter>nil(), List.convert(JCVariableDecl.class, inliner.inlineList(getParameters())), inliner.<JCExpression>inlineList(getThrows()), getBody().inline(inliner), null); }
/** Create a method definition from a method symbol and a method body. */ public JCMethodDecl MethodDef(MethodSymbol m, JCBlock body) { return MethodDef(m, m.type, body); }
/** Create a method definition from a method symbol and a method body. */ public JCMethodDecl MethodDef(MethodSymbol m, JCBlock body) { return MethodDef(m, m.type, body); }
/** Create a method definition from a method symbol and a method body. */ public JCMethodDecl MethodDef(MethodSymbol m, JCBlock body) { return MethodDef(m, m.type, body); }
/** Create a method definition from a method symbol and a method body. */ public JCMethodDecl MethodDef(MethodSymbol m, JCBlock body) { return MethodDef(m, m.type, body); }
public MethodTree Method(ExecutableElement element, BlockTree body) { return make.at(NOPOS).MethodDef((Symbol.MethodSymbol)element, (JCBlock)body); }
public JCTree visitMethod(MethodTree node, P p) { JCMethodDecl t = (JCMethodDecl) node; JCModifiers mods = copy(t.mods, p); JCExpression restype = copy(t.restype, p); List<JCTypeParameter> typarams = copy(t.typarams, p); List<JCVariableDecl> params = copy(t.params, p); List<JCExpression> thrown = copy(t.thrown, p); JCBlock body = copy(t.body, p); JCExpression defaultValue = copy(t.defaultValue, p); return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, params, thrown, body, defaultValue); }
private MethodSymbol addEnumFieldNameMethod(JCClassDecl cdef, VarSymbol nameSymbol) { // Add the accessor methods for name Symbol nameSym = lookupMethod(cdef.pos(), names._name, cdef.type, List.<Type>nil()); assert(nameSym != null); assert(nameSym instanceof MethodSymbol); JCStatement ret = make.Return(make.Ident(nameSymbol)); cdef.defs = cdef.defs.append(make.MethodDef((MethodSymbol)nameSym, make.Block(0L, List.of(ret)))); return (MethodSymbol)nameSym; }
public JCTree visitMethod(MethodTree node, P p) { JCMethodDecl t = (JCMethodDecl) node; JCModifiers mods = copy(t.mods, p); JCExpression restype = copy(t.restype, p); List<JCTypeParameter> typarams = copy(t.typarams, p); List<JCVariableDecl> params = copy(t.params, p); List<JCExpression> thrown = copy(t.thrown, p); JCBlock body = copy(t.body, p); JCExpression defaultValue = copy(t.defaultValue, p); return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, params, thrown, body, defaultValue); }
private MethodSymbol addEnumFieldOrdinalMethod(JCClassDecl cdef, VarSymbol ordinalSymbol) { // Add the accessor methods for ordinal Symbol ordinalSym = lookupMethod(cdef.pos(), names.ordinal, cdef.type, List.<Type>nil()); assert(ordinalSym != null); assert(ordinalSym instanceof MethodSymbol); JCStatement ret = make.Return(make.Ident(ordinalSymbol)); cdef.defs = cdef.defs.append(make.MethodDef((MethodSymbol)ordinalSym, make.Block(0L, List.of(ret)))); return (MethodSymbol)ordinalSym; }
private MethodSymbol addEnumFieldOrdinalMethod(JCClassDecl cdef, VarSymbol ordinalSymbol) { // Add the accessor methods for ordinal Symbol ordinalSym = lookupMethod(cdef.pos(), names.ordinal, cdef.type, List.<Type>nil()); assert(ordinalSym != null); assert(ordinalSym instanceof MethodSymbol); JCStatement ret = make.Return(make.Ident(ordinalSymbol)); cdef.defs = cdef.defs.append(make.MethodDef((MethodSymbol)ordinalSym, make.Block(0L, List.of(ret)))); return (MethodSymbol)ordinalSym; }
private MethodSymbol addEnumFieldNameMethod(JCClassDecl cdef, VarSymbol nameSymbol) { // Add the accessor methods for name Symbol nameSym = lookupMethod(cdef.pos(), names._name, cdef.type, List.<Type>nil()); assert(nameSym != null); assert(nameSym instanceof MethodSymbol); JCStatement ret = make.Return(make.Ident(nameSymbol)); cdef.defs = cdef.defs.append(make.MethodDef((MethodSymbol)nameSym, make.Block(0L, List.of(ret)))); return (MethodSymbol)nameSym; }
public JCTree visitMethod(MethodTree node, P p) { JCMethodDecl t = (JCMethodDecl) node; JCModifiers mods = copy(t.mods, p); JCExpression restype = copy(t.restype, p); List<JCTypeParameter> typarams = copy(t.typarams, p); List<JCVariableDecl> params = copy(t.params, p); JCVariableDecl recvparam = copy(t.recvparam, p); List<JCExpression> thrown = copy(t.thrown, p); JCBlock body = copy(t.body, p); JCExpression defaultValue = copy(t.defaultValue, p); return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, recvparam, params, thrown, body, defaultValue); }
public JCTree visitMethod(MethodTree node, P p) { JCMethodDecl t = (JCMethodDecl) node; JCModifiers mods = copy(t.mods, p); JCExpression restype = copy(t.restype, p); List<JCTypeParameter> typarams = copy(t.typarams, p); List<JCVariableDecl> params = copy(t.params, p); JCVariableDecl recvparam = copy(t.recvparam, p); List<JCExpression> thrown = copy(t.thrown, p); JCBlock body = copy(t.body, p); JCExpression defaultValue = copy(t.defaultValue, p); return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, recvparam, params, thrown, body, defaultValue); }
@Override public boolean visitConstructorDeclaration(ConstructorDeclaration node) { JCMethodDecl constrDef = treeMaker.MethodDef( (JCModifiers)toTree(node.astModifiers()), table.init, null, toList(JCTypeParameter.class, node.astTypeVariables()), toList(JCVariableDecl.class, node.astParameters()), toList(JCExpression.class, node.astThrownTypeReferences()), (JCBlock)toTree(node.astBody()), null ); for (JCVariableDecl decl : constrDef.params) { decl.mods.flags |= Flags.PARAMETER; } int start = node.astTypeName().getPosition().getStart(); int end = node.getPosition().getEnd(); return set(node, setPos(start, end, constrDef)); }
@Override public boolean visitAnnotationMethodDeclaration(AnnotationMethodDeclaration node) { JCMethodDecl methodDef = treeMaker.MethodDef( (JCModifiers)toTree(node.astModifiers()), toName(node.astMethodName()), toExpression(node.astReturnTypeReference()), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), null, toExpression(node.astDefaultValue()) ); int start = node.astMethodName().getPosition().getStart(); int end = node.getPosition().getEnd(); return set(node, setPos(start, end, methodDef)); }
@Override public boolean visitAnnotationMethodDeclaration(AnnotationMethodDeclaration node) { JCMethodDecl methodDef = treeMaker.MethodDef( (JCModifiers)toTree(node.astModifiers()), toName(node.astMethodName()), toExpression(node.astReturnTypeReference()), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), null, toExpression(node.astDefaultValue()) ); int start = node.astMethodName().getPosition().getStart(); int end = node.getPosition().getEnd(); return set(node, setPos(start, end, methodDef)); }
@Override public boolean visitAnnotationMethodDeclaration(AnnotationMethodDeclaration node) { JCMethodDecl methodDef = treeMaker.MethodDef( (JCModifiers)toTree(node.astModifiers()), toName(node.astMethodName()), toExpression(node.astReturnTypeReference()), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), null, toExpression(node.astDefaultValue()) ); int start = node.astMethodName().getPosition().getStart(); int end = node.getPosition().getEnd(); return set(node, setPos(start, end, methodDef)); }
@Override public JCMethodDecl inline(Inliner inliner) throws CouldNotResolveImportException { return inliner .maker() .MethodDef( getModifiers().inline(inliner), getName().inline(inliner), getReturnType().inline(inliner), List.<JCTypeParameter>nil(), List.convert(JCVariableDecl.class, inliner.inlineList(getParameters())), inliner.<JCExpression>inlineList(getThrows()), getBody().inline(inliner), null); }