mirror of
https://github.com/tiennm99/lombok.git
synced 2026-09-04 04:17:59 +00:00
Made lombok more stable in netbeans based on some smart observations by Jan Lahoda of team Netbeans.
This commit is contained in:
committed by
Reinier Zwitserloot
parent
0befce2072
commit
6bf2b9299d
@@ -1,8 +1,9 @@
|
||||
Lombok Changelog
|
||||
----------------
|
||||
|
||||
### v0.11.3 Edge
|
||||
### v0.11.3 (Edgy Guinea Pig)
|
||||
* BUGFIX: Eclipse would throw an OOME. [Issue #390](http://code.google.com/p/projectlombok/issues/detail?id=390)
|
||||
* BUGFIX: [Netbeans] `@Cleanup` and `@Synchronized` cause far fewer issues in the netbeans editor. [Issue #393](http://code.google.com/p/projectlombok/issues/detail?id=393)
|
||||
|
||||
|
||||
### v0.11.2 "Dashing Kakapo" (July 3rd, 2012)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2011 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2012 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,8 +23,8 @@ package lombok.javac.handlers;
|
||||
|
||||
import static lombok.javac.handlers.JavacHandlerUtil.*;
|
||||
import lombok.Cleanup;
|
||||
import lombok.core.AnnotationValues;
|
||||
import lombok.core.AST.Kind;
|
||||
import lombok.core.AnnotationValues;
|
||||
import lombok.javac.Javac;
|
||||
import lombok.javac.JavacAnnotationHandler;
|
||||
import lombok.javac.JavacNode;
|
||||
@@ -33,7 +33,6 @@ import org.mangosdk.spi.ProviderFor;
|
||||
|
||||
import com.sun.tools.javac.code.TypeTags;
|
||||
import com.sun.tools.javac.tree.JCTree;
|
||||
import com.sun.tools.javac.tree.TreeMaker;
|
||||
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
|
||||
import com.sun.tools.javac.tree.JCTree.JCAssign;
|
||||
import com.sun.tools.javac.tree.JCTree.JCBinary;
|
||||
@@ -50,6 +49,7 @@ import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
|
||||
import com.sun.tools.javac.tree.JCTree.JCStatement;
|
||||
import com.sun.tools.javac.tree.JCTree.JCTypeCast;
|
||||
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
|
||||
import com.sun.tools.javac.tree.TreeMaker;
|
||||
import com.sun.tools.javac.util.List;
|
||||
import com.sun.tools.javac.util.ListBuffer;
|
||||
import com.sun.tools.javac.util.Name;
|
||||
@@ -60,6 +60,8 @@ import com.sun.tools.javac.util.Name;
|
||||
@ProviderFor(JavacAnnotationHandler.class)
|
||||
public class HandleCleanup extends JavacAnnotationHandler<Cleanup> {
|
||||
@Override public void handle(AnnotationValues<Cleanup> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
if (inNetbeansEditor(annotationNode)) return;
|
||||
|
||||
deleteAnnotationIfNeccessary(annotationNode, Cleanup.class);
|
||||
String cleanupName = annotation.getInstance().value();
|
||||
if (cleanupName.length() == 0) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2011 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2012 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -52,6 +52,8 @@ public class HandleSynchronized extends JavacAnnotationHandler<Synchronized> {
|
||||
private static final String STATIC_LOCK_NAME = "$LOCK";
|
||||
|
||||
@Override public void handle(AnnotationValues<Synchronized> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
if (inNetbeansEditor(annotationNode)) return;
|
||||
|
||||
deleteAnnotationIfNeccessary(annotationNode, Synchronized.class);
|
||||
JavacNode methodNode = annotationNode.up();
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
|
||||
import com.sun.tools.javac.util.List;
|
||||
import com.sun.tools.javac.util.ListBuffer;
|
||||
import com.sun.tools.javac.util.Name;
|
||||
import com.sun.tools.javac.util.Options;
|
||||
|
||||
/**
|
||||
* Container for static utility methods useful to handlers written for javac.
|
||||
@@ -92,6 +93,16 @@ public class JavacHandlerUtil {
|
||||
|
||||
private static Map<JCTree, WeakReference<JCTree>> generatedNodes = new WeakHashMap<JCTree, WeakReference<JCTree>>();
|
||||
|
||||
/**
|
||||
* Contributed by Jan Lahoda; many lombok transformations should not be run (or a lite version should be run) when the netbeans editor
|
||||
* is running javac on the open source file to find inline errors and such. As class files are compiled separately this does not affect
|
||||
* actual runtime behaviour or file output of the netbeans IDE.
|
||||
*/
|
||||
public static boolean inNetbeansEditor(JavacNode node) {
|
||||
Options options = Options.instance(node.getContext());
|
||||
return (options.keySet().contains("ide") && !options.keySet().contains("backgroundCompilation"));
|
||||
}
|
||||
|
||||
public static JCTree getGeneratedBy(JCTree node) {
|
||||
synchronized (generatedNodes) {
|
||||
WeakReference<JCTree> ref = generatedNodes.get(node);
|
||||
|
||||
Reference in New Issue
Block a user