aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/javac
AgeCommit message (Collapse)Author
2009-07-28Changed the way toString is generated to reduce the number of superfluous ↵Reinier Zwitserloot
'plus' nodes (e.g. concatenating the infix ", " and a field name literal such as "width=" into ", width=". Also removed the [] brackets from the supercall, as, if you're chaining to another lombok-generated toString, those are superfluous - lombok's toString includes parentheses already.
2009-07-27on javac: Warnings associated with specific values in annotation parameters ↵Reinier Zwitserloot
now 'point at' the right position, instead of at the entire annotation. (it already did so for errors). Fixes issue #11
2009-07-27Split off generation of equals() and hashCode() methods form @Data into a ↵Reinier Zwitserloot
new annotation, @EqualsAndHashCode. Addresses issue #8
2009-07-27[TRIVIAL]Reinier Zwitserloot
2009-07-27[TRIVIAL]Reinier Zwitserloot
2009-07-27Added support for @ToString annotation. The code for generating toStrings ↵Reinier Zwitserloot
has now moved from HandleData to the new HandleToString.
2009-07-26Addresses issue #5:Reinier Zwitserloot
hitting 'find callers' on a @Data annotation should find callers of the (static) constructor. Right now it'll find callers to the *static* constructor ONLY. Letting it find callers of the public constructor if there is no static constructor just doesn't work.
2009-07-26[TRIVIAL]Reinier Zwitserloot
2009-07-26Addresses issue #4:Reinier Zwitserloot
If boolean fields already start with a typical getter prefix (is, has, or get), lombok's @Getter will no longer generate its own prefix as well, so a field named 'hasFoo' will result in a getter named 'hasFoo()', not 'isHasFoo()'. Also, if any likely getter name already exists for a boolean, a getter will not be generated. Thus, if your field is called 'hasFoo', and you already have a method named 'isFoo', then @Getter will not generate anything (and warn, unless the getter is being generated due to @Data). This last mechanism works by taking the field name *AND* any other likely base names (defined by the field name being named as prefix+baseName, with prefix being is/has/get), and then prefixing all the likely fieldnames with is/has/get, and checking if any method with that name exists. Of course, this means weird things are going to happen if you have 2 fields named 'isFoo' and 'hasFoo', but then, you'd be a real idiot if you did that.
2009-07-18No constructor entry should be made for assigned final fieldsRoel Spilker
2009-07-18Refactored the name of the cleanup method arg to 'value'.Reinier Zwitserloot
2009-07-12More fixes to avoid erroneous "getter/setter is already there, not ↵Reinier Zwitserloot
generating it" warnings when the getter/setter already there was in fact generated by lombok, and fixed a bug in eclipse where a boolean array's getter method would be called isFoo() instead of getFoo().
2009-07-11'fixed' data up a bit by including only the final fields for the constructor.Reinier Zwitserloot
Also fixed a bug in javac's toString() generation for the @Data constructor. It did not include the transient fields.
2009-07-11The setter/getter handlers now mark themselves as not wanted to be called ↵Reinier Zwitserloot
upon anymore when reporting errors. They were logging 4 or more identical warnings per problem before this change.
2009-07-11Made 'printContent=true' work for types as well as method bodies/initializers.Reinier Zwitserloot
2009-07-06Fixed javadoc problems, and added a javadoc target to the build script.Reinier Zwitserloot
2009-07-06Last massive documentation dump. All basic javadoc is now done, though ↵Reinier Zwitserloot
especially the docs on the lombok annotations in the lombok package need far more massaging. Also added a feature to HandleSynchronized to not auto-generate the locker fields if a specific name is provided (because, imagine you typoed those. You'd never find it!)
2009-07-05More documentation.Reinier Zwitserloot
2009-07-03Fine-tuning eclipse's error reporting found some minor issues and even 1 bug ↵Reinier Zwitserloot
that would show up rarely or not at all.
2009-07-01Added @SneakyThrows support for javac. W00t.Reinier Zwitserloot
2009-07-01Added ability to @Synchronized to explicitly name the lock object.Reinier Zwitserloot
Spruced up @Cleanup's position settings and also forced initialization, because the error appears in a screwed up place if you don't, and we can't seem to move it.
2009-07-01Added @Synchronized support to javac. Seems to work well.Reinier Zwitserloot
2009-07-01Added a bonus feature to @Cleanup: Assigning a @Cleanup marked variable to ↵Reinier Zwitserloot
anything else generates a warning.
2009-07-01Pretty big fix for reparse() - now uses rebuild(), which also received a ↵Reinier Zwitserloot
pretty big fix in making the loop detection algorithm far more robust. Still not sure what was the problem, but the robustificationization helped.
2009-07-01Added HandleCleanup support for javac, and fixed a bug in AST.java which ↵Reinier Zwitserloot
caused nested @Cleanup annotations to simply be ignored (rebuild was broken). HandleCleanup seems to work swimmingly now on both targets. yay!
2009-06-30After a great many iterations, Cleanup has now been reduced in functionality ↵Reinier Zwitserloot
(exceptions from the cleanup call WILL mask exceptions from the body - this isn't intended, but it's just not possible to fix this without java 7 features or requiring a rewrite of the class file data. Tried tactics, and why they won't work: - Replace every 'return', 'break', and 'continue' statement (for the latter 2, only if they break/continue out of the try block) with a block that first sets a uniquely named flag before doing the operation. Then, check that flag in the finally block to see if the cleanup call should be guarded by a try/catchThrowable. This doesn't work, because its not possible to instrument the 4th way out of a try block without throwing an exception: Just letting it run its course. Tossing a "#flag = true;" at the end may cause a compile time error if the code is not reachable, but figuring that out requires resolution and quite a bit of analysis. - Put catch blocks in for all relevant exceptions (RuntimeException, Error, all exceptions declared as thrown by the method, and all types of exceptions of the catch blocks of encapsulating try blocks. This doesn't work, partly because it'll fail for sneakily thrown exceptions, but mostly because you can't just catch an exception listed in the 'throws' clause of the method body; catching an exception that no statement in the try block can throw is a compile time error, but it is perfectly allright to declare these as 'thrown'. - Put in a blanket catch Throwable to set the flag. Two problems with this: First, sneaky throw can't be done. Thread.stop invokes a security manager and triggers a warning, Calling a sneakyThrow method creates a runtime dependency on lombok, constructing a sneakyThrow in-class creates visible methods or at least visible class files, and creating a new class via Class.loadClass would be very slow without caching - which gets you the same issues. Secondly, this would mean that any statements in the try body that throw an exception aren't flagged to the user as needing to be handled. The Cleanup annotation now also calls the cleanup method for you, and will call it at the END of the current scope. The following plans have been tried and abandoned: - Cleanup right after the final mention. This doesn't work, because the final mention may not be the final use-place. Example: @Cleanup InputStream in = new FileInputStream(someFile); InputStreamReader reader = new InputStreamReader(in); reader.read(); //oops - in is already closed by now. - Require an explicit var.cleanup() call and consider that the cue to close off the try block. This doesn't work either, because now variables set in between the @Cleanup declaration and the var.cleanup() call become invisible to following statements. Example: @Cleanup InputStream in = new FileInputStream(someFile); int i = in.read(); in.close(); System.out.println(i); //fail - i is inside the generated try block but this isn't, so 'i' is not visible from here. By running to the end of visible scope, all these problems are avoided. This does remove the flexibility of declaring where you want a close call to be executed, but there are two mitigating factors available: 1) Create an explicit scope block. You can just stick { code } in any place where you can legally write a statement, in java. This is relatively unknown, so I expect most users will go for: 2) Just call close explicitly. I've yet to see a cleanup method which isn't idempotent anyway (calling it multiple times is no different than calling it once). During the course of investigating these options, the AST code has been extended to support live replacement of any child node, including updating the actual underlying system AST as well as our own. Unfortunately, this code has NOT been tested. It was rather a lot of work so I'm leaving it in, and at least for eclipse it even seemed to work.
2009-06-28Preparating for java 1.5-ification. All stuff that isn't specific to javac ↵Reinier Zwitserloot
should run in java 1.5, so that an eclipse started on a 1.5 JVM will still run lombok.
2009-06-27[IMPROVEMENT]Reinier Zwitserloot
Eclipse will now also hold off on running @PrintAST handlers until the very end. Simple generators such as @Getter didn't need this, because PrintAST's handler will hold off until eclipse does a full parse, but when changing the innards of methods, you would likely not see what you did. Fixed that. Also, PrintAST has an option to, instead of diving into the ASTNodes of bodies (methods, initializers, etc), to just render the java code, to see if the AST creation/rewriting you've been doing looks like the java code you intended.
2009-06-27[BUGFIX] For some reason, JCLiteral objects contain '1' or '0' (integers) ↵Reinier Zwitserloot
for booleans, not actual booleans. You can tell the difference via the getKind() method. hence, boolean fields in annotations were throwing unexpected type errors (Integer instead of Boolean). Fixed this.
2009-06-25Added support for generating toString to javac's HandleData. Now javac's ↵Reinier Zwitserloot
HandleData is COMPLETE! w00t!
2009-06-25Added generating hashCode() to javac's HandleData.Reinier Zwitserloot
2009-06-25javac's HandleData now makes equals methods.Reinier Zwitserloot
2009-06-25Heh, on errors you'd never actually see any message, just the exception ↵Reinier Zwitserloot
type. Whoops.
2009-06-24javac's HandleData now generates the constructor only if it doesn't already ↵Reinier Zwitserloot
exist, and the staticConstructor is now also completed. Left: toString, hashCode, equals.
2009-06-24Work on HandleData, as well as generalizing features in the the PKG class ↵Reinier Zwitserloot
and updating HandleGetter/Setter to call into it.
2009-06-24Added printing for a constructor if it is the default (generated) ↵Reinier Zwitserloot
constructor or not.
2009-06-24Added proper support for changing the AST as its being visited, both removal ↵Reinier Zwitserloot
and addition. The rule is now: children traversal traverses through the tree mostly as it was when it started.
2009-06-21Due to a java bug, constants in enums don't work, so instead the default ↵Reinier Zwitserloot
access level for @Getter and @Setter have now just been hardcoded in GetterHandler and SetterHandler. Added ability to look up the Node object for any given AST object on Node itself, as you don't usually have the AST object. Added toString() method generating to @Data, and this required some fancy footwork in finding if we've already generated methods, and editing a generated method to fill in binding and type resolutions. HandleGetter and HandleSetter have been updated to use these features. Exceptions caused by lombok handlers show up in the eclipse error log, but now, if they are related to a CompilationUnit, also as a problem (error) on the CUD - those error log entries are easy to miss! Our ASTs can now be appended to. When you generate a new AST node, you should add it to the AST, obviously. Getter/Setter have been updated to use this.
2009-06-19Added initial support for the @Data annotation. Currently produces getters ↵Reinier Zwitserloot
and setters only, not yet a constructor, toString, hashCode, or equals. HandleGetter and HandleSetter have been updated to handle static (theoretic; you can't put annotations on static fields normally). You can now make AnnotationValue objects using just an annotationNode and a target type, as well as check if a given annotationNode is likely to represent a target annotation type. This is in Javac and Eclipse classes. HandleGetter and HandleSetter can now be asked to make a getter/setter, and will grab access level off of a Getter/Setter annotation, if present.
2009-06-18Created a fully working HandleSetter for eclipse, and refactored ↵Reinier Zwitserloot
HandleGetter a little mostly to stuff common code into PKG.
2009-06-18Expanded the AST printers to support a target PrintStream, and expanded the ↵Reinier Zwitserloot
@PrintAST annotation to let you supply an optional filename. Useful particularly for IDEs, which don't usually have a viewable console. Also renamed the printers to just 'Printer', as they are already inner classes of a specifically named type (JavacASTVisitor & co).
2009-06-17AnnotationHandlers can now return a boolean to set if they actually handled ↵Reinier Zwitserloot
the annotation or not (previously, the presumption was they always handled the annotation). This is very useful for PrintAST on eclipse, because before this change, you'd never see method contents (as the initial dietParse would come first). Now Eclipse PrintASTHandler will skip any non-full runs, and only print non-diet. It then returns true only if it printed.
2009-06-17Added 'does setX/getX already exist' check to javac's HandleGetter/Setter. ↵Reinier Zwitserloot
If they exist (with any returntype/paramlist), no getter/setter is generated, and instead a warning is added on the annotation.
2009-06-17Added the SetterHandler for javac. Also added a way to get the SymbolTable ↵Reinier Zwitserloot
on a JavacAST.Node, because you need it to e.g. access constant types like 'void'.
2009-06-17Made the printing of Statements for @PrintAST slightly more useful (if a lot ↵Reinier Zwitserloot
more verbose), and bumped the version number in honour of quite a bit of redesign these past few commits.
2009-06-17A useful annotation that prints the AST of any annotated element via the ↵Reinier Zwitserloot
XASTPrinters in each ASTVisitor interface.
2009-06-17Just renamed some parameters to more sensical names.Reinier Zwitserloot
2009-06-17A bugfix to the visitMethodArgument method, and printing improved by ↵Reinier Zwitserloot
printing the raw (instead of resolved) types for fields etc, because usually they aren't resolved yet.
2009-06-17Moved the traverse() from Eclipse/JavacAST to Eclipse/JavacAST.Node, so that ↵Reinier Zwitserloot
you can start your traversal at any point, not just from the top. Also a bugfix for endVisitStatement which passed the wrong node, and method arguments in Javac are no longer misfiled as local declarations.
2009-06-17Renamed the Handler implementations.Reinier Zwitserloot