Пример #1
0
  /**
   * Given a list of field names and a node referring to a type, finds each name in the list that
   * does not match a field within the type.
   */
  public static List<Integer> createListOfNonExistentFields(
      List<String> list, JavacNode type, boolean excludeStandard, boolean excludeTransient) {
    boolean[] matched = new boolean[list.size()];

    for (JavacNode child : type.down()) {
      if (list.isEmpty()) break;
      if (child.getKind() != Kind.FIELD) continue;
      JCVariableDecl field = (JCVariableDecl) child.get();
      if (excludeStandard) {
        if ((field.mods.flags & Flags.STATIC) != 0) continue;
        if (field.name.toString().startsWith("$")) continue;
      }
      if (excludeTransient && (field.mods.flags & Flags.TRANSIENT) != 0) continue;

      int idx = list.indexOf(child.getName());
      if (idx > -1) matched[idx] = true;
    }

    ListBuffer<Integer> problematic = ListBuffer.lb();
    for (int i = 0; i < list.size(); i++) {
      if (!matched[i]) problematic.append(i);
    }

    return problematic.toList();
  }
 @Override
 protected String capturedVarId(CapturedType t, Locale locale) {
   return "" + (allCaptured.indexOf(t) + 1);
 }