Beispiel #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.");
   }
 }
Beispiel #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);
  }
Beispiel #3
0
 static void changeTypeContext(ResolutionContext old, ResolutionContext new_, FieldDeclaration f) {
   f.setType(changeTypeContext(old, new_, f.getType()));
 }
Beispiel #4
0
 @Override
 public List<Annotation> getAnnotations() {
   return SourceInfo.this.getAnnotationsInternal(declaration.getAnnotations());
 }
Beispiel #5
0
 @Override
 public void setType(Type type) {
   declaration.setType(SourceInfo.this.setType(type, declaration.getType()));
 }
Beispiel #6
0
 @Override
 public Type getType() {
   return getContext().resolve(declaration.getType());
 }
Beispiel #7
0
 @Override
 public void setAccessFlags(AccessFlags accessFlags) {
   declaration.setModifiers(accessFlags.access);
 }
Beispiel #8
0
 @Override
 public AccessFlags getAccessFlags() {
   return new AccessFlags(declaration.getModifiers());
 }
Beispiel #9
0
 @Override
 public void setName(String name) {
   declaration.getVariables().get(0).getId().setName(name);
 }
Beispiel #10
0
 @Override
 public String getName() {
   return declaration.getVariables().get(0).getId().getName();
 }