Skip to content

Commit

Permalink
using ant to make eclipse project, compiles now. Test fails on the te…
Browse files Browse the repository at this point in the history
…st class (expected)
  • Loading branch information
glelouet committed Oct 10, 2023
1 parent 7571e41 commit eab7d44
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 21 deletions.
39 changes: 24 additions & 15 deletions src/core/lombok/Onstruct.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,42 @@
/**
* The {@link Onstruct} annotation declares variables based on getters of an
* object.<br />
* The variables names are the one specified. If the annotation has parameters for prefix and suffix, those parameters are added to the variable names.<br />
* The variables names are the one specified. If the annotation has parameters
* for prefix and suffix, those parameters are added to the variable
* names.<br />
* The getter is the existing method in the object's class verifying
* <ol>
* <li>return non-void type</li>
* <li>requires no argument</li>
* <li>match the variable name specified, prefixed by get|is, and ignoring case. In the order :
* <ol>
* <li>getName is selected if exists</li>
* <li>isName is selected if exists</li>
* <li>getname (ignoring case) is selected if exists only ONE. compiling error if several found</li>
* <li>isname (ignoring case) is selected if exists only ONE. compiling error if several found</li>
* <li>if no matching method exists, error</li>
* </ol>
* </li>
* <li>return non-void type</li>
* <li>requires no argument</li>
* <li>match the variable name specified, prefixed by get|is, and ignoring case.
* In the order :
* <ol>
* <li>getName is selected if exists</li>
* <li>isName is selected if exists</li>
* <li>getname (ignoring case) is selected if exists only ONE. compiling error
* if several found</li>
* <li>isname (ignoring case) is selected if exists only ONE. compiling error if
* several found</li>
* <li>name is selected if exists</li>
* <li>name (ignoring case) is selected if exists only ONE. compiling error if
* several found</li>
* <li>if no matching method exists, error</li>
* </ol>
* </li>
* </ol>
*
* <p>
* It MUST only be applied to var declarations.
* It MUST only be applied to typed declarations. No garantee is present for var
* declaration.
* </p>
*
*
* <p>
* Before:
*
* <pre>
* &#064;Onstruct(prefix="b_")
* var author, name, editiondate, purchasable = mybook;
* &#064;Onstruct(prefix = "b_")
* Object author, name, editiondate, purchasable = mybook;
* </pre>
*
* After:
Expand Down
12 changes: 7 additions & 5 deletions src/core/lombok/eclipse/handlers/HandleOnstruct.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package lombok.eclipse.handlers;

import org.eclipse.jdt.internal.compiler.ast.Annotation;

import lombok.Onstruct;
import lombok.core.AnnotationValues;
import lombok.core.HandlerPriority;
Expand All @@ -8,13 +10,13 @@

@HandlerPriority(65536) // same as HandleValue // TODO
public class HandleOnstruct extends EclipseAnnotationHandler<Onstruct> {

public static final HandleOnstruct INSTANCE = new HandleOnstruct();

@Override
public void handle(AnnotationValues<Onstruct> annotation, Annotation ast, EclipseNode annotationNode) {

@Override public void handle(AnnotationValues<Onstruct> annotation, Annotation ast, EclipseNode annotationNode) {
// TODO Auto-generated method stub

}



}
12 changes: 11 additions & 1 deletion test/transform/resource/before/OnstructBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,22 @@ public static class Book {

void test() {
Book mybook = new Book("author0", "bookname0", new Date(), true);
@Onstruct(prefix = "b_")
@Onstruct()
Object author, name, editiondate, purchasable = mybook;
assert Objects.equals(mybook.getAuthor(), author);
assert Objects.equals(mybook.name(), name);
assert Objects.equals(mybook.getEditionDate(), editiondate);
assert Objects.equals(mybook.isPurchasable(), purchasable);
}

void testPrefix() {
Book mybook = new Book("author0", "bookname0", new Date(), true);
@Onstruct(prefix = "b_")
Object author, name, editiondate, purchasable = mybook;
assert Objects.equals(mybook.getAuthor(), b_author);
assert Objects.equals(mybook.name(), b_name);
assert Objects.equals(mybook.getEditionDate(), b_editiondate);
assert Objects.equals(mybook.isPurchasable(), b_purchasable);
}

}

0 comments on commit eab7d44

Please sign in to comment.