diff options
-rw-r--r-- | .settings/org.eclipse.jdt.core.prefs | 64 | ||||
-rw-r--r-- | experimental/src/lombok/javac/disableCheckedExceptions/DisableCheckedExceptionsAgent.java | 12 | ||||
-rw-r--r-- | src/lombok/core/AST.java | 3 | ||||
-rw-r--r-- | src/lombok/core/AnnotationValues.java | 21 | ||||
-rw-r--r-- | src/lombok/core/LombokNode.java | 8 | ||||
-rw-r--r-- | src/lombok/core/SpiLoadUtil.java | 2 | ||||
-rw-r--r-- | src/lombok/eclipse/EclipseASTVisitor.java | 2 | ||||
-rw-r--r-- | src/lombok/eclipse/handlers/PKG.java | 4 | ||||
-rw-r--r-- | src/lombok/installer/Installer.java | 16 | ||||
-rw-r--r-- | src/lombok/javac/JavacAST.java | 19 | ||||
-rw-r--r-- | src/lombok/javac/JavacNode.java | 10 | ||||
-rw-r--r-- | src/lombok/javac/apt/Processor.java | 14 | ||||
-rw-r--r-- | src_eclipseagent/lombok/eclipse/agent/EclipsePatcher.java | 4 |
13 files changed, 121 insertions, 58 deletions
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 87342633..807a9a51 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,4 @@ -#Fri Jun 12 03:57:29 CEST 2009 +#Sun Oct 18 14:45:17 CEST 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 @@ -7,7 +7,69 @@ org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.processAnnotations=enabled org.eclipse.jdt.core.compiler.source=1.6 diff --git a/experimental/src/lombok/javac/disableCheckedExceptions/DisableCheckedExceptionsAgent.java b/experimental/src/lombok/javac/disableCheckedExceptions/DisableCheckedExceptionsAgent.java index 8dc084ce..7c020a65 100644 --- a/experimental/src/lombok/javac/disableCheckedExceptions/DisableCheckedExceptionsAgent.java +++ b/experimental/src/lombok/javac/disableCheckedExceptions/DisableCheckedExceptionsAgent.java @@ -45,10 +45,10 @@ import com.sun.tools.javac.processing.JavacProcessingEnvironment; @SupportedSourceVersion(SourceVersion.RELEASE_6) public class DisableCheckedExceptionsAgent extends AbstractProcessor { /** Inject an agent if we're on a sun-esque JVM. */ - @Override public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - if (!(processingEnv instanceof JavacProcessingEnvironment)) { - processingEnv.getMessager().printMessage(Kind.WARNING, "You aren't using a compiler based around javac v1.6, so lombok will not work properly."); + @Override public void init(ProcessingEnvironment procEnv) { + super.init(procEnv); + if (!(procEnv instanceof JavacProcessingEnvironment)) { + procEnv.getMessager().printMessage(Kind.WARNING, "You aren't using a compiler based around javac v1.6, so lombok will not work properly."); this.processingEnv = null; } @@ -60,11 +60,11 @@ public class DisableCheckedExceptionsAgent extends AbstractProcessor { return false; } - public static void agentmain(String agentArgs, Instrumentation instrumentation) throws Exception { + public static void agentmain(@SuppressWarnings("unused") String agentArgs, Instrumentation instrumentation) throws Exception { registerPatchScripts(instrumentation, true); } - public static void premain(String agentArgs, Instrumentation instrumentation) throws Exception { + public static void premain(@SuppressWarnings("unused") String agentArgs, Instrumentation instrumentation) throws Exception { registerPatchScripts(instrumentation, false); } diff --git a/src/lombok/core/AST.java b/src/lombok/core/AST.java index 31b8f0fd..b1b5f3be 100644 --- a/src/lombok/core/AST.java +++ b/src/lombok/core/AST.java @@ -210,9 +210,8 @@ public abstract class AST<A extends AST<A, L, N>, L extends LombokNode<A, L, N>, if (type instanceof ParameterizedType) { Type component = ((ParameterizedType)type).getActualTypeArguments()[0]; return component instanceof Class<?> ? (Class<?>)component : Object.class; - } else { - return Object.class; } + return Object.class; } /** diff --git a/src/lombok/core/AnnotationValues.java b/src/lombok/core/AnnotationValues.java index 8912ccd8..0408de85 100644 --- a/src/lombok/core/AnnotationValues.java +++ b/src/lombok/core/AnnotationValues.java @@ -202,18 +202,19 @@ public class AnnotationValues<A extends Annotation> { Object defaultValue = method.getDefaultValue(); if (defaultValue == null) throw makeNoDefaultFail(v, method); return defaultValue; - } else return result; - } else { - if (result == null) { - if (v.valueGuesses.size() == 1) { - Object defaultValue = method.getDefaultValue(); - if (defaultValue == null) throw makeNoDefaultFail(v, method); - return defaultValue; - } else throw new AnnotationValueDecodeFail(v, - "I can't make sense of this annotation value. Try using a fully qualified literal.", idx); } - Array.set(array, idx++, result); + return result; + } + if (result == null) { + if (v.valueGuesses.size() == 1) { + Object defaultValue = method.getDefaultValue(); + if (defaultValue == null) throw makeNoDefaultFail(v, method); + return defaultValue; + } + throw new AnnotationValueDecodeFail(v, + "I can't make sense of this annotation value. Try using a fully qualified literal.", idx); } + Array.set(array, idx++, result); } return array; diff --git a/src/lombok/core/LombokNode.java b/src/lombok/core/LombokNode.java index e4712313..c8ee4c00 100644 --- a/src/lombok/core/LombokNode.java +++ b/src/lombok/core/LombokNode.java @@ -125,8 +125,8 @@ public abstract class LombokNode<A extends AST<A, L, N>, L extends LombokNode<A, * Also affects the underlying (Eclipse/javac) AST. */ @SuppressWarnings("unchecked") - public L replaceWith(N newN, Kind kind) { - L newNode = ast.buildTree(newN, kind); + public L replaceWith(N newN, Kind newNodeKind) { + L newNode = ast.buildTree(newN, newNodeKind); newNode.parent = parent; for (int i = 0; i < parent.children.size(); i++) { if (parent.children.get(i) == this) ((List)parent.children).set(i, newNode); @@ -227,8 +227,8 @@ public abstract class LombokNode<A extends AST<A, L, N>, L extends LombokNode<A, * Does not change the underlying (javac/Eclipse) AST, only the wrapped view. */ @SuppressWarnings("unchecked") - public L add(N newChild, Kind kind) { - L n = ast.buildTree(newChild, kind); + public L add(N newChild, Kind newChildKind) { + L n = ast.buildTree(newChild, newChildKind); if (n == null) return null; n.parent = (L) this; ((List)children).add(n); diff --git a/src/lombok/core/SpiLoadUtil.java b/src/lombok/core/SpiLoadUtil.java index 3031576a..0a97af7e 100644 --- a/src/lombok/core/SpiLoadUtil.java +++ b/src/lombok/core/SpiLoadUtil.java @@ -123,7 +123,7 @@ public class SpiLoadUtil { } } finally { try { - in.close(); + if (in != null) in.close(); } catch (Throwable ignore) {} } } diff --git a/src/lombok/eclipse/EclipseASTVisitor.java b/src/lombok/eclipse/EclipseASTVisitor.java index 3397e1cc..793166d7 100644 --- a/src/lombok/eclipse/EclipseASTVisitor.java +++ b/src/lombok/eclipse/EclipseASTVisitor.java @@ -144,7 +144,7 @@ public interface EclipseASTVisitor { private String str(char[] c) { if (c == null) return "(NULL)"; - else return new String(c); + return new String(c); } private String str(TypeReference type) { diff --git a/src/lombok/eclipse/handlers/PKG.java b/src/lombok/eclipse/handlers/PKG.java index 65145262..1d5c6ae1 100644 --- a/src/lombok/eclipse/handlers/PKG.java +++ b/src/lombok/eclipse/handlers/PKG.java @@ -162,6 +162,8 @@ class PKG { node = node.up(); } + if (node == null) return null; + if (node.get() instanceof TypeDeclaration) { for (AbstractMethodDeclaration def : ((TypeDeclaration)node.get()).methods) { if (def instanceof ConstructorDeclaration) { @@ -180,6 +182,8 @@ class PKG { node = node.up(); } + if (node == null) return null; + if (node.get() instanceof TypeDeclaration) { for (AbstractMethodDeclaration def : ((TypeDeclaration)node.get()).methods) { char[] mName = def.selector; diff --git a/src/lombok/installer/Installer.java b/src/lombok/installer/Installer.java index 07830964..b19649a7 100644 --- a/src/lombok/installer/Installer.java +++ b/src/lombok/installer/Installer.java @@ -40,7 +40,6 @@ import java.awt.event.ActionListener; import java.awt.font.TextAttribute; import java.io.File; import java.io.FilenameFilter; -import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.Collections; @@ -276,7 +275,7 @@ public class Installer { return container; } - private Component buildEclipseArea() throws IOException { + private Component buildEclipseArea() { JPanel container = new JPanel(); container.setLayout(new GridBagLayout()); @@ -357,17 +356,16 @@ public class Installer { buttonBar.add(specifyEclipseLocationButton); specifyEclipseLocationButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { - final String name = EclipseFinder.getEclipseExecutableName(); + final String exeName = EclipseFinder.getEclipseExecutableName(); String file = null; if (EclipseFinder.getOS() == OS.MAC_OS_X) { FileDialog chooser = new FileDialog(appWindow); chooser.setMode(FileDialog.LOAD); chooser.setFilenameFilter(new FilenameFilter() { - @Override public boolean accept(File dir, String name) { - if (name.equalsIgnoreCase(name)) return true; - if (new File(dir, name).isDirectory()) return true; - + @Override public boolean accept(File dir, String fileName) { + if (exeName.equalsIgnoreCase(fileName)) return true; + if (new File(dir, fileName).isDirectory()) return true; return false; } }); @@ -381,7 +379,7 @@ public class Installer { chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setFileFilter(new FileFilter() { @Override public boolean accept(File f) { - if (f.getName().equalsIgnoreCase(name)) return true; + if (f.getName().equalsIgnoreCase(exeName)) return true; if (f.isDirectory()) return true; return false; @@ -668,7 +666,7 @@ public class Installer { @Override public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { return 1; } - }; + } private void buildChrome(Container appWindowContainer) { JLabel leftGraphic = new JLabel(new ImageIcon(Installer.class.getResource("/lombok/installer/lombok.png"))); diff --git a/src/lombok/javac/JavacAST.java b/src/lombok/javac/JavacAST.java index eea1bad9..77e365ee 100644 --- a/src/lombok/javac/JavacAST.java +++ b/src/lombok/javac/JavacAST.java @@ -251,6 +251,7 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> { } /** For javac, both JCExpression and JCStatement are considered as valid children types. */ + @Override protected Collection<Class<? extends JCTree>> getStatementTypes() { Collection<Class<? extends JCTree>> collection = new ArrayList<Class<? extends JCTree>>(2); collection.add(JCStatement.class); @@ -305,11 +306,9 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> { com.sun.tools.javac.util.List<?> oldL = (com.sun.tools.javac.util.List<?>) current; com.sun.tools.javac.util.List<?> newL = replaceInConsList(oldL, oldO, newO); if (chain.isEmpty()) return newL; - else { - List<Collection<?>> reducedChain = new ArrayList<Collection<?>>(chain); - Collection<?> newCurrent = reducedChain.remove(reducedChain.size() -1); - return setElementInConsList(reducedChain, newCurrent, oldL, newL); - } + List<Collection<?>> reducedChain = new ArrayList<Collection<?>>(chain); + Collection<?> newCurrent = reducedChain.remove(reducedChain.size() -1); + return setElementInConsList(reducedChain, newCurrent, oldL, newL); } private com.sun.tools.javac.util.List<?> replaceInConsList(com.sun.tools.javac.util.List<?> oldL, Object oldO, Object newO) { @@ -323,16 +322,16 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> { } if (repl) return com.sun.tools.javac.util.List.<Object>from(a); - else return oldL; + return oldL; } - private void increaseErrorCount(Messager messager) { + private void increaseErrorCount(Messager m) { try { - Field f = messager.getClass().getDeclaredField("errorCount"); + Field f = m.getClass().getDeclaredField("errorCount"); f.setAccessible(true); if (f.getType() == int.class) { - int val = ((Number)f.get(messager)).intValue(); - f.set(messager, val +1); + int val = ((Number)f.get(m)).intValue(); + f.set(m, val +1); } } catch (Throwable t) { //Very unfortunate, but in most cases it still works fine, so we'll silently swallow it. diff --git a/src/lombok/javac/JavacNode.java b/src/lombok/javac/JavacNode.java index 004aff19..46e06579 100644 --- a/src/lombok/javac/JavacNode.java +++ b/src/lombok/javac/JavacNode.java @@ -81,10 +81,10 @@ public class JavacNode extends lombok.core.LombokNode<JavacAST, JavacNode, JCTre visitor.endVisitInitializer(this, (JCBlock)get()); break; case ARGUMENT: - JCMethodDecl parent = (JCMethodDecl) up().get(); - visitor.visitMethodArgument(this, (JCVariableDecl)get(), parent); + JCMethodDecl parentMethod = (JCMethodDecl) up().get(); + visitor.visitMethodArgument(this, (JCVariableDecl)get(), parentMethod); ast.traverseChildren(visitor, this); - visitor.endVisitMethodArgument(this, (JCVariableDecl)get(), parent); + visitor.endVisitMethodArgument(this, (JCVariableDecl)get(), parentMethod); break; case LOCAL: visitor.visitLocal(this, (JCVariableDecl)get()); @@ -175,7 +175,7 @@ public class JavacNode extends lombok.core.LombokNode<JavacAST, JavacNode, JCTre /** * Generates an compiler error focused on the AST node represented by this node object. */ - public void addError(String message) { + @Override public void addError(String message) { ast.printMessage(Diagnostic.Kind.ERROR, message, this, null); } @@ -189,7 +189,7 @@ public class JavacNode extends lombok.core.LombokNode<JavacAST, JavacNode, JCTre /** * Generates a compiler warning focused on the AST node represented by this node object. */ - public void addWarning(String message) { + @Override public void addWarning(String message) { ast.printMessage(Diagnostic.Kind.WARNING, message, this, null); } diff --git a/src/lombok/javac/apt/Processor.java b/src/lombok/javac/apt/Processor.java index 0c187f4b..9f3951bb 100644 --- a/src/lombok/javac/apt/Processor.java +++ b/src/lombok/javac/apt/Processor.java @@ -69,15 +69,15 @@ public class Processor extends AbstractProcessor { private Trees trees; /** {@inheritDoc} */ - @Override public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - if (!(processingEnv instanceof JavacProcessingEnvironment)) { - processingEnv.getMessager().printMessage(Kind.WARNING, "You aren't using a compiler based around javac v1.6, so lombok will not work properly."); + @Override public void init(ProcessingEnvironment procEnv) { + super.init(procEnv); + if (!(procEnv instanceof JavacProcessingEnvironment)) { + procEnv.getMessager().printMessage(Kind.WARNING, "You aren't using a compiler based around javac v1.6, so lombok will not work properly."); this.processingEnv = null; } else { - this.processingEnv = (JavacProcessingEnvironment) processingEnv; - handlers = HandlerLibrary.load(processingEnv.getMessager()); - trees = Trees.instance(processingEnv); + this.processingEnv = (JavacProcessingEnvironment) procEnv; + handlers = HandlerLibrary.load(procEnv.getMessager()); + trees = Trees.instance(procEnv); } } diff --git a/src_eclipseagent/lombok/eclipse/agent/EclipsePatcher.java b/src_eclipseagent/lombok/eclipse/agent/EclipsePatcher.java index d1759127..68be033d 100644 --- a/src_eclipseagent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src_eclipseagent/lombok/eclipse/agent/EclipsePatcher.java @@ -44,11 +44,11 @@ import lombok.patcher.scripts.ScriptBuilder; public class EclipsePatcher { private EclipsePatcher() {} - public static void agentmain(String agentArgs, Instrumentation instrumentation) throws Exception { + public static void agentmain(@SuppressWarnings("unused") String agentArgs, Instrumentation instrumentation) throws Exception { registerPatchScripts(instrumentation, true); } - public static void premain(String agentArgs, Instrumentation instrumentation) throws Exception { + public static void premain(@SuppressWarnings("unused") String agentArgs, Instrumentation instrumentation) throws Exception { registerPatchScripts(instrumentation, false); } |