aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/eclipse/EclipseAST.java
AgeCommit message (Collapse)Author
2009-07-08Renamed all true names of 'eclipse' to 'Eclipse' (but not the eclipse ↵Reinier Zwitserloot
package, of course), and fixed a showstopper bug in the installer that would add -javaagent:lombok.jar to eclipse.ini, which is wrong of course; it needs to be lombok.eclipse.agent.jar.
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-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-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-28AptProblem is not available when eclipse is run on java 1.5, and AptProblem ↵Reinier Zwitserloot
is not neccessarily the proper target anyway. Rolled our own DefaultProblem subclass for problem reporting.
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-21trivialReinier Zwitserloot
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-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-17Turns out using instanceof checks to figure out if a LocalDeclaration is a ↵Reinier Zwitserloot
method argument or not (by instanceof checking if it's an Argument) is faulty, as e.g. the argument to a catch block is also an Argument object. Rewritten the visitChild method to be based on a switch on the Node's getKind(), just like JavacAST. This even looks nicer.
2009-06-17Massive refactors. This list isn't complete, but should give you an idea:Reinier Zwitserloot
A) many things in lombok.eclipse moved to lombok.core to enable reuse with lombok.javac. B) lombok.javac works now similarly to eclipse's model: We first make big ASTs that are bidirectionally traversable, then we walk through that for annotations. C) Instead of getting an annotation instance, you now get an object that is more flexible and can e.g. give you class values in an enum as a string instead of a Class object, which may fail if that class isn't on the classpath of lombok. D) sources to the internal sun classes for javac added to /contrib.
2009-06-15Switched the level of the Node object you get during a visitAnnotationOnX ↵Reinier Zwitserloot
call from the Field/Type/Method/Local to the Annotation, so that you can interact with its handled flag.
2009-06-15Added annotations as definitive children of nodes in our custom AST, and ↵Reinier Zwitserloot
updated the visitor to call a separate visitAnnotationOnX method for annotated stuff. This way, 'handled' can be set per annotation. Also fixed a bug in AST generation that caused StackOverflowErrors on most source files, and did some cosmetic renaming of parameters.
2009-06-15all eclipse AST Statements objects are now part of the custom AST we build ↵Reinier Zwitserloot
for lombok. This way something like @AutoClose on a local var declaration can walk up one node, find all mentions of the variable, and add a close call right after the last mention.
2009-06-14Made lombok more robust by catching exceptions near the top level and ↵Reinier Zwitserloot
turning them into eclipse-wide errors in the worst case, but usually in an error in the problems dialog.
2009-06-14Added support to generate errors, both on specific nodes in an AST ↵Reinier Zwitserloot
(generified code in HandlerLibrary for unintelligible annotation param values), and more severe general errors for eclipse's error log. Also unrolled the foreach loop on ServiceLoader, because any given .next() call can throw a ServiceLoaderError, which we now handle somewhat more nicely.
2009-06-12Clinits should be skipped, as they are useless, and the docs even say they ↵Reinier Zwitserloot
will be skipped. Now they are skipped.
2009-06-12Removed the WeakHashMap for caching EclipseAST objects; obviously wasn't ↵Reinier Zwitserloot
working due to circular reference from the EclipseAST back to the CUD. Now, patched a field into CompilationUnitDeclaration and using that, which works much better together with the garbage collector.
2009-06-12Singularly massive code change, too hard to document. Basically, hooking now ↵Reinier Zwitserloot
occurs in the two most sane places: - After the parser is done building a first rendition of the AST. (Usually lightweight and missing method bodies etc) - After the parser is done taking such a lightweight AST and filling in the gaps. Lombok then builts its own bidirectional and somewhat saner AST out of this, and hands this saner AST off for treatment. Things in the AST can be marked as 'handled'. This seems to work swimmingly and should allow us to easily identify the annotations that are for us, and work our magic, no matter where they appear or on what, including stuff inside method bodies.