diff options
author | unknown <Roels@.tis.local> | 2009-10-18 15:12:41 +0200 |
---|---|---|
committer | unknown <Roels@.tis.local> | 2009-10-18 15:12:41 +0200 |
commit | 1b0d0ff5ad539f34fc27a8a27621b3f8d6d982b7 (patch) | |
tree | 41c3f687db56c92610f0687d3466ab573a02d573 /src | |
parent | 4bf8ee3f67f7c076421b6c6a396c85e7bd794749 (diff) | |
download | lombok-1b0d0ff5ad539f34fc27a8a27621b3f8d6d982b7.tar.gz lombok-1b0d0ff5ad539f34fc27a8a27621b3f8d6d982b7.tar.bz2 lombok-1b0d0ff5ad539f34fc27a8a27621b3f8d6d982b7.zip |
Configured warnings and solved some.
Diffstat (limited to 'src')
-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 |
10 files changed, 50 insertions, 49 deletions
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); } } |