Skip to content

Commit eab7d44

Browse files
author
glelouet
committed
using ant to make eclipse project, compiles now. Test fails on the test class (expected)
1 parent 7571e41 commit eab7d44

File tree

3 files changed

+42
-21
lines changed

3 files changed

+42
-21
lines changed

src/core/lombok/Onstruct.java

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,42 @@
88
/**
99
* The {@link Onstruct} annotation declares variables based on getters of an
1010
* object.<br />
11-
* 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 />
11+
* The variables names are the one specified. If the annotation has parameters
12+
* for prefix and suffix, those parameters are added to the variable
13+
* names.<br />
1214
* The getter is the existing method in the object's class verifying
1315
* <ol>
14-
* <li>return non-void type</li>
15-
* <li>requires no argument</li>
16-
* <li>match the variable name specified, prefixed by get|is, and ignoring case. In the order :
17-
* <ol>
18-
* <li>getName is selected if exists</li>
19-
* <li>isName is selected if exists</li>
20-
* <li>getname (ignoring case) is selected if exists only ONE. compiling error if several found</li>
21-
* <li>isname (ignoring case) is selected if exists only ONE. compiling error if several found</li>
22-
* <li>if no matching method exists, error</li>
23-
* </ol>
24-
* </li>
16+
* <li>return non-void type</li>
17+
* <li>requires no argument</li>
18+
* <li>match the variable name specified, prefixed by get|is, and ignoring case.
19+
* In the order :
20+
* <ol>
21+
* <li>getName is selected if exists</li>
22+
* <li>isName is selected if exists</li>
23+
* <li>getname (ignoring case) is selected if exists only ONE. compiling error
24+
* if several found</li>
25+
* <li>isname (ignoring case) is selected if exists only ONE. compiling error if
26+
* several found</li>
27+
* <li>name is selected if exists</li>
28+
* <li>name (ignoring case) is selected if exists only ONE. compiling error if
29+
* several found</li>
30+
* <li>if no matching method exists, error</li>
31+
* </ol>
32+
* </li>
2533
* </ol>
2634
*
2735
* <p>
28-
* It MUST only be applied to var declarations.
36+
* It MUST only be applied to typed declarations. No garantee is present for var
37+
* declaration.
2938
* </p>
3039
*
3140
*
3241
* <p>
3342
* Before:
3443
*
3544
* <pre>
36-
* &#064;Onstruct(prefix="b_")
37-
* var author, name, editiondate, purchasable = mybook;
45+
* &#064;Onstruct(prefix = "b_")
46+
* Object author, name, editiondate, purchasable = mybook;
3847
* </pre>
3948
*
4049
* After:
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package lombok.eclipse.handlers;
22

3+
import org.eclipse.jdt.internal.compiler.ast.Annotation;
4+
35
import lombok.Onstruct;
46
import lombok.core.AnnotationValues;
57
import lombok.core.HandlerPriority;
@@ -8,13 +10,13 @@
810

911
@HandlerPriority(65536) // same as HandleValue // TODO
1012
public class HandleOnstruct extends EclipseAnnotationHandler<Onstruct> {
11-
13+
1214
public static final HandleOnstruct INSTANCE = new HandleOnstruct();
13-
14-
@Override
15-
public void handle(AnnotationValues<Onstruct> annotation, Annotation ast, EclipseNode annotationNode) {
15+
16+
@Override public void handle(AnnotationValues<Onstruct> annotation, Annotation ast, EclipseNode annotationNode) {
1617
// TODO Auto-generated method stub
1718

1819
}
19-
20+
21+
2022
}

test/transform/resource/before/OnstructBook.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,22 @@ public static class Book {
2121

2222
void test() {
2323
Book mybook = new Book("author0", "bookname0", new Date(), true);
24-
@Onstruct(prefix = "b_")
24+
@Onstruct()
2525
Object author, name, editiondate, purchasable = mybook;
2626
assert Objects.equals(mybook.getAuthor(), author);
2727
assert Objects.equals(mybook.name(), name);
2828
assert Objects.equals(mybook.getEditionDate(), editiondate);
2929
assert Objects.equals(mybook.isPurchasable(), purchasable);
3030
}
3131

32+
void testPrefix() {
33+
Book mybook = new Book("author0", "bookname0", new Date(), true);
34+
@Onstruct(prefix = "b_")
35+
Object author, name, editiondate, purchasable = mybook;
36+
assert Objects.equals(mybook.getAuthor(), b_author);
37+
assert Objects.equals(mybook.name(), b_name);
38+
assert Objects.equals(mybook.getEditionDate(), b_editiondate);
39+
assert Objects.equals(mybook.isPurchasable(), b_purchasable);
40+
}
41+
3242
}

0 commit comments

Comments
 (0)