@Override public String apply(VariableTree variableTree) { for (Compound c : ASTHelpers.getSymbol(variableTree).getAnnotationMirrors()) { if (((TypeElement) c.getAnnotationType().asElement()) .getQualifiedName() .contentEquals(ASSISTED_ANNOTATION)) { // Assisted only has 'value', and value can only contain 1 element. Collection<Attribute> valueEntries = c.getElementValues().values(); if (!valueEntries.isEmpty()) { return Iterables.getOnlyElement(valueEntries).getValue().toString(); } } } return ""; } };
/** * Works for method parameters defined either in source or in class files * * @param symbol the method symbol * @param paramInd index of the parameter * @return all declaration and type-use annotations for the parameter */ public static Stream<? extends AnnotationMirror> getAllAnnotationsForParameter( Symbol.MethodSymbol symbol, int paramInd) { Symbol.VarSymbol varSymbol = symbol.getParameters().get(paramInd); return Stream.concat( varSymbol.getAnnotationMirrors().stream(), symbol .getRawTypeAttributes() .stream() .filter( t -> t.position.type.equals(TargetType.METHOD_FORMAL_PARAMETER) && t.position.parameter_index == paramInd)); }
@Override public String apply(VariableTree variableTree) { for (Compound c : ASTHelpers.getSymbol(variableTree).getAnnotationMirrors()) { if (((TypeElement) c.getAnnotationType().asElement()) .getQualifiedName() .contentEquals(ASSISTED_ANNOTATION)) { // Assisted only has 'value', and value can only contain 1 element. Collection<Attribute> valueEntries = c.getElementValues().values(); if (!valueEntries.isEmpty()) { return Iterables.getOnlyElement(valueEntries).getValue().toString(); } } } return ""; } };
boolean hasInvisible = false; if (m.params != null) for (VarSymbol s : m.params) { for (Attribute.Compound a : s.getAnnotationMirrors()) { switch (getRetention(a.type.tsym)) { case SOURCE: break; for (VarSymbol s : m.params) { ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>(); for (Attribute.Compound a : s.getAnnotationMirrors()) if (getRetention(a.type.tsym) == RetentionPolicy.RUNTIME) buf.append(a); for (VarSymbol s : m.params) { ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>(); for (Attribute.Compound a : s.getAnnotationMirrors()) if (getRetention(a.type.tsym) == RetentionPolicy.CLASS) buf.append(a);
boolean hasInvisible = false; if (m.params != null) for (VarSymbol s : m.params) { for (Attribute.Compound a : s.getAnnotationMirrors()) { switch (getRetention(a.type.tsym)) { case SOURCE: break; for (VarSymbol s : m.params) { ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>(); for (Attribute.Compound a : s.getAnnotationMirrors()) if (getRetention(a.type.tsym) == RetentionPolicy.RUNTIME) buf.append(a); for (VarSymbol s : m.params) { ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>(); for (Attribute.Compound a : s.getAnnotationMirrors()) if (getRetention(a.type.tsym) == RetentionPolicy.CLASS) buf.append(a);
for (Attribute.Compound compound : parameterSymbol.getAnnotationMirrors())
/** Create a variable definition from a variable symbol and an initializer * expression. */ public JCVariableDecl VarDef(VarSymbol v, JCExpression init) { return (JCVariableDecl) new JCVariableDecl( Modifiers(v.flags(), Annotations(v.getAnnotationMirrors())), v.name, Type(v.type), init, v).setPos(pos).setType(v.type); }
/** Create a variable definition from a variable symbol and an initializer * expression. */ public JCVariableDecl VarDef(VarSymbol v, JCExpression init) { return (JCVariableDecl) new JCVariableDecl( Modifiers(v.flags(), Annotations(v.getAnnotationMirrors())), v.name, Type(v.type), init, v).setPos(pos).setType(v.type); }