예제 #1
0
 FieldDeclarationWrapper(FieldDeclaration declaration) {
   this.declaration = declaration;
   if (declaration.getVariables().size() != 1) {
     throw new UnsupportedOperationException(
         "Not yet implemented: multiple variables in one field decl.");
   }
 }
예제 #2
0
  @Override
  public void add(FieldInfo field) {
    FieldDeclaration fieldDeclaration;

    if (field instanceof FieldDeclarationWrapper) {
      val wrapper = (FieldDeclarationWrapper) field;
      fieldDeclaration = (FieldDeclaration) wrapper.declaration.clone();
      fieldDeclaration.setAnnotations(Collections.emptyList());
      changeTypeContext(wrapper.getContext(), getContext(), fieldDeclaration);
    } else {
      fieldDeclaration = new FieldDeclaration();
      val vars = new ArrayList<VariableDeclarator>();
      vars.add(new VariableDeclarator(new VariableDeclaratorId("unknown")));
      fieldDeclaration.setVariables(vars);
      new FieldDeclarationWrapper(fieldDeclaration).setAll(field);
    }

    addMember(fieldDeclaration);

    val result = new FieldDeclarationWrapper(fieldDeclaration);
    if (!field.similar(result))
      throw new TransformationException(
          "After adding to class, didn't match. added: " + field + " result: " + result);
  }
예제 #3
0
 static void changeTypeContext(ResolutionContext old, ResolutionContext new_, FieldDeclaration f) {
   f.setType(changeTypeContext(old, new_, f.getType()));
 }
예제 #4
0
 @Override
 public List<Annotation> getAnnotations() {
   return SourceInfo.this.getAnnotationsInternal(declaration.getAnnotations());
 }
예제 #5
0
 @Override
 public void setType(Type type) {
   declaration.setType(SourceInfo.this.setType(type, declaration.getType()));
 }
예제 #6
0
 @Override
 public Type getType() {
   return getContext().resolve(declaration.getType());
 }
예제 #7
0
 @Override
 public void setAccessFlags(AccessFlags accessFlags) {
   declaration.setModifiers(accessFlags.access);
 }
예제 #8
0
 @Override
 public AccessFlags getAccessFlags() {
   return new AccessFlags(declaration.getModifiers());
 }
예제 #9
0
 @Override
 public void setName(String name) {
   declaration.getVariables().get(0).getId().setName(name);
 }
예제 #10
0
 @Override
 public String getName() {
   return declaration.getVariables().get(0).getId().getName();
 }