Esempio n. 1
0
 /** Get the annotations of this parameter. Return an empty array if there are none. */
 public AnnotationDesc[] annotations() {
   AnnotationDesc res[] = new AnnotationDesc[sym.getRawAttributes().length()];
   int i = 0;
   for (Attribute.Compound a : sym.getRawAttributes()) {
     res[i++] = new AnnotationDescImpl(env, a);
   }
   return res;
 }
Esempio n. 2
0
 /** @return all values of the given enum type, in declaration order. */
 public static LinkedHashSet<String> enumValues(TypeSymbol enumType) {
   if (enumType.getKind() != ElementKind.ENUM) {
     throw new IllegalStateException();
   }
   Scope scope = enumType.members();
   Deque<String> values = new ArrayDeque<>();
   for (Symbol sym : scope.getSymbols()) {
     if (sym instanceof VarSymbol) {
       VarSymbol var = (VarSymbol) sym;
       if ((var.flags() & Flags.ENUM) != 0) {
         /**
          * Javac gives us the members backwards, apparently. It's worth making an effort to
          * preserve declaration order because it's useful for diagnostics (e.g. in {@link
          * MissingCasesInEnumSwitch}).
          */
         values.push(sym.name.toString());
       }
     }
   }
   return new LinkedHashSet<>(values);
 }
Esempio n. 3
0
 private static boolean isParameter(VarSymbol var) {
   return (var.flags() & Flags.PARAMETER) != 0;
 }
Esempio n. 4
0
 /**
  * Get local name of this parameter. For example if parameter is the short 'index', returns
  * "index".
  */
 public String name() {
   return sym.toString();
 }
Esempio n. 5
0
 /**
  * Make an item representing a local variable.
  *
  * @param v The represented variable.
  */
 LocalItem makeLocalItem(VarSymbol v) {
   return new LocalItem(v.erasure(types), v.adr);
 }