mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 02:16:18 +00:00
Fixed merge conflict in changelog
This commit is contained in:
commit
f36deeb25f
43 files changed
+545
-77
No files matched your search
@@ -27,7 +27,7 @@ the common tasks and can be called on to run the main aspects of all the sub-scr
|
||||
|
||||
<property name="credentialsFile" value="google.properties" />
|
||||
<property name="build.compiler" value="javac1.6" />
|
||||
<property name="ivy.retrieve.pattern" value="lib/[conf]/[artifact].[ext]" />
|
||||
<property name="ivy.retrieve.pattern" value="lib/[conf]/[organisation]-[artifact].[ext]" />
|
||||
<available file="lib/ivyplusplus.jar" property="ivyplusplus.available" />
|
||||
|
||||
<path id="build.path">
|
||||
@@ -196,7 +196,7 @@ the common tasks and can be called on to run the main aspects of all the sub-scr
|
||||
<target name="dist" description="Builds THE lombok.jar file which contains everything." depends="version, compile">
|
||||
<mkdir dir="dist" />
|
||||
<copy file="doc/changelog.markdown" tofile="build/changelog.txt" />
|
||||
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="lib/build/jarjar.jar" />
|
||||
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="lib/build/com.googlecode.jarjar-jarjar.jar" />
|
||||
<jarjar destfile="dist/lombok-${lombok.version}.jar">
|
||||
<fileset dir="build/lombok">
|
||||
<exclude name="com/sun/tools/javac/**"/>
|
||||
@@ -271,21 +271,14 @@ the common tasks and can be called on to run the main aspects of all the sub-scr
|
||||
<settings>
|
||||
<url url="http://projectlombok.org/downloads/lombok.eclipse.settings" />
|
||||
</settings>
|
||||
<apt location="lib/build/spi.jar" />
|
||||
<apt location="lib/build/projectlombok.org-spi.jar" />
|
||||
</ivy:eclipsegen>
|
||||
|
||||
<condition property="startOnFirstThread" value="-XstartOnFirstThread" else="">
|
||||
<os family="mac" />
|
||||
</condition>
|
||||
|
||||
<copy
|
||||
file="buildScripts/eclipse-debug-target.template"
|
||||
tofile="LombokizedEclipse.launch"
|
||||
preservelastmodified="true"
|
||||
overwrite="true">
|
||||
<filterset>
|
||||
<filter token="START_ON_FIRST_THREAD" value="${startOnFirstThread}" />
|
||||
</filterset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
@@ -306,7 +299,7 @@ the common tasks and can be called on to run the main aspects of all the sub-scr
|
||||
</target>
|
||||
|
||||
<target name="test-ecj" depends="dist, contrib" unless="tests.skip">
|
||||
<java jar="lib/ecj/ecj.jar" fork="true" failonerror="true">
|
||||
<java jar="lib/ecj/org.eclipse.custom-ecj.jar" fork="true" failonerror="true">
|
||||
<jvmarg value="-javaagent:dist/lombok.jar=ecj" />
|
||||
<arg value="-source" />
|
||||
<arg value="1.6" />
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx512m -XX:MaxPermSize=256m @START_ON_FIRST_THREAD@ -Dorg.eclipse.swt.internal.carbon.smallFonts -javaagent:${project_loc:lombok}/dist/lombok.jar -Xbootclasspath/a:${project_loc:lombok}/dist/lombok.jar -Dlombok.patcher.patchDebugDir=${project_loc:lombok}/debug/patchedClasses"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx512m -XX:MaxPermSize=256m -Dorg.eclipse.swt.internal.carbon.smallFonts -javaagent:${project_loc:lombok}/dist/lombok.jar -Xbootclasspath/a:${project_loc:lombok}/dist/lombok.jar -Dlombok.patcher.patchDebugDir=${project_loc:lombok}/debug/patchedClasses"/>
|
||||
<stringAttribute key="pde.version" value="3.3"/>
|
||||
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
|
||||
<booleanAttribute key="show_selected_only" value="false"/>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
<dependency org="junit" name="junit" rev="4.8.2" conf="test->default; contrib->sources" />
|
||||
<dependency org="log4j" name="log4j" rev="1.2.16" conf="test->default; contrib->sources" />
|
||||
<dependency org="org.apache.logging.log4j" name="log4j-api" rev="2.0-beta4" conf="test->default; contrib->sources" />
|
||||
<dependency org="commons-logging" name="commons-logging" rev="1.1.1" conf="test->default; contrib->sources"/>
|
||||
<dependency org="org.slf4j" name="slf4j-api" rev="1.6.1" conf="test->default; contrib->sources"/>
|
||||
<dependency org="org.slf4j" name="slf4j-ext" rev="1.6.1" conf="test->default; contrib->sources"/>
|
||||
|
||||
@@ -4,6 +4,10 @@ Lombok Changelog
|
||||
### v0.11.7 (Edgy Guinea Pig)
|
||||
* CHANGE: {Experimental} The experimental `@Value` feature no longer implies the also experimental `@Wither`. If you like your `@Value` classes to make withers, add `@Wither` to the class right next to `@Value`.
|
||||
* FEATURE: {Experimental} Reintroduced `onMethod`, `onConstructor` and `onParam` to `@Getter`, `@Setter`, `@Wither`, and `@XArgsConstructor`. These parameters allow you to add annotations to the methods/constructors that lombok will generate. This is a workaround feature: The stability of the feature on future versions of javac is not guaranteed, and if a better way to implement this feature is found, this feature's current incarnation will be removed without a reasonable period of deprecation. [Documentation on the onX feature](http://projectlombok.org/features/experimental/onX.html)
|
||||
* FEATURE: Added support for Log4j v2.0 via `@Log4j2` [Issue #432](http://code.google.com/p/projectlombok/issues/detail?id=432)
|
||||
* ENHANCEMENT: The Lombok installer can now find and install lombok into [JBoss Developer Studio](http://www.redhat.com/products/jbossenterprisemiddleware/developer-studio/). The installer will now also look for eclipse and eclipse variants in your home directory. [Issue #434](http://code.google.com/p/projectlombok/issues/detail?id=432)
|
||||
* BUGFIX: `@ExtensionMethods` no longer causes `VerifyError` exceptions when running eclipse-compiled code if extension methods are called on expressions which are method calls whose return type is a type variable. For example, `someList.get(i).extensionMethod()` would fail that way. [Issue #436](http://code.google.com/p/projectlombok/issues/detail?id=436)
|
||||
* BUGFIX: java 7's try-with-resources statement did not delombok correctly. [Issue #459](http://code.google.com/p/projectlombok/issues/detail?id=459)
|
||||
|
||||
### v0.11.6 (October 30th, 2012)
|
||||
* FEATURE: Lombok can be disabled entirely for any given compile run by using JVM switch `-Dlombok.disable`. This might be useful for code style checkers and such.
|
||||
|
||||
@@ -29,7 +29,7 @@ import lombok.core.SpiLoadUtil;
|
||||
*
|
||||
* You MUST replace 'T' with a specific annotation type, such as:
|
||||
*
|
||||
* {@code public class HandleGetter implements EclipseAnnotationHandler<Getter>}
|
||||
* {@code public class HandleGetter extends EclipseAnnotationHandler<Getter>}
|
||||
*
|
||||
* Because this generics parameter is inspected to figure out which class you're interested in.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2012 The Project Lombok Authors.
|
||||
* Copyright (C) 2010-2013 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
|
||||
@@ -177,6 +177,16 @@ public class HandleLog {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the {@link lombok.extern.log4j.Log4j2} annotation for Eclipse.
|
||||
*/
|
||||
@ProviderFor(EclipseAnnotationHandler.class)
|
||||
public static class HandleLog4j2Log extends EclipseAnnotationHandler<lombok.extern.log4j.Log4j2> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j2> annotation, Annotation source, EclipseNode annotationNode) {
|
||||
processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the {@link lombok.extern.slf4j.Slf4j} annotation for Eclipse.
|
||||
*/
|
||||
@@ -224,6 +234,9 @@ public class HandleLog {
|
||||
// private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(TargetType.class);
|
||||
LOG4J("org.apache.log4j.Logger", "org.apache.log4j.Logger", "getLogger", "@Log4j"),
|
||||
|
||||
// private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(TargetType.class);
|
||||
LOG4J2("org.apache.logging.log4j.Logger", "org.apache.logging.log4j.LogManager", "getLogger", "@Log4j2"),
|
||||
|
||||
// private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TargetType.class);
|
||||
SLF4J("org.slf4j.Logger", "org.slf4j.LoggerFactory", "getLogger", "@Slf4j"),
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ import org.eclipse.jdt.internal.compiler.ast.Annotation;
|
||||
import org.eclipse.jdt.internal.compiler.ast.Argument;
|
||||
import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
|
||||
import org.eclipse.jdt.internal.compiler.ast.Block;
|
||||
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
|
||||
import org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall;
|
||||
import org.eclipse.jdt.internal.compiler.ast.Expression;
|
||||
import org.eclipse.jdt.internal.compiler.ast.MemberValuePair;
|
||||
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
|
||||
@@ -147,7 +149,21 @@ public class HandleSneakyThrows extends EclipseAnnotationHandler<SneakyThrows> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (method.statements == null) return;
|
||||
if (method.statements == null || method.statements.length == 0) {
|
||||
boolean hasConstructorCall = false;
|
||||
if (method instanceof ConstructorDeclaration) {
|
||||
ExplicitConstructorCall constructorCall = ((ConstructorDeclaration) method).constructorCall;
|
||||
hasConstructorCall = constructorCall != null && !constructorCall.isImplicitSuper() && !constructorCall.isImplicitThis();
|
||||
}
|
||||
|
||||
if (hasConstructorCall) {
|
||||
annotation.addWarning("Calls to sibling / super constructors are always excluded from @SneakyThrows; @SneakyThrows has been ignored because there is no other code in this constructor.");
|
||||
} else {
|
||||
annotation.addWarning("This method or constructor is empty; @SneakyThrows has been ignored.");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Statement[] contents = method.statements;
|
||||
|
||||
@@ -160,9 +176,9 @@ public class HandleSneakyThrows extends EclipseAnnotationHandler<SneakyThrows> {
|
||||
}
|
||||
|
||||
private Statement buildTryCatchBlock(Statement[] contents, DeclaredException exception, ASTNode source, AbstractMethodDeclaration method) {
|
||||
int methodStart = method.bodyStart;
|
||||
int methodEnd = method.bodyEnd;
|
||||
long methodPosEnd = methodEnd << 32 | (methodEnd & 0xFFFFFFFFL);
|
||||
int methodStart = method.bodyStart;
|
||||
int methodEnd = method.bodyEnd;
|
||||
long methodPosEnd = ((long) methodEnd) << 32 | (methodEnd & 0xFFFFFFFFL);
|
||||
|
||||
TryStatement tryStatement = new TryStatement();
|
||||
setGeneratedBy(tryStatement, source);
|
||||
|
||||
@@ -209,21 +209,25 @@ public class HandleToString extends EclipseAnnotationHandler<ToString> {
|
||||
}
|
||||
|
||||
for (EclipseNode field : fields) {
|
||||
TypeReference fType = getFieldType(field, fieldAccess);
|
||||
TypeReference fieldType = getFieldType(field, fieldAccess);
|
||||
Expression fieldAccessor = createFieldAccessor(field, fieldAccess, source);
|
||||
|
||||
// The distinction between primitive and object will be useful if we ever add a 'hideNulls' option.
|
||||
boolean fieldBaseTypeIsPrimitive = BUILT_IN_TYPES.contains(new String(fieldType.getLastToken()));
|
||||
boolean fieldIsPrimitive = fieldType.dimensions() == 0 && fieldBaseTypeIsPrimitive;
|
||||
boolean fieldIsPrimitiveArray = fieldType.dimensions() == 1 && fieldBaseTypeIsPrimitive;
|
||||
boolean fieldIsObjectArray = fieldType.dimensions() > 0 && !fieldIsPrimitiveArray;
|
||||
@SuppressWarnings("unused")
|
||||
boolean fieldIsObject = !fieldIsPrimitive && !fieldIsPrimitiveArray && !fieldIsObjectArray;
|
||||
|
||||
Expression ex;
|
||||
if (fType.dimensions() > 0) {
|
||||
if (fieldIsPrimitiveArray || fieldIsObjectArray) {
|
||||
MessageSend arrayToString = new MessageSend();
|
||||
arrayToString.sourceStart = pS; arrayToString.sourceEnd = pE;
|
||||
arrayToString.receiver = generateQualifiedNameRef(source, TypeConstants.JAVA, TypeConstants.UTIL, "Arrays".toCharArray());
|
||||
arrayToString.arguments = new Expression[] { fieldAccessor };
|
||||
setGeneratedBy(arrayToString.arguments[0], source);
|
||||
if (fType.dimensions() > 1 || !BUILT_IN_TYPES.contains(new String(fType.getLastToken()))) {
|
||||
arrayToString.selector = "deepToString".toCharArray();
|
||||
} else {
|
||||
arrayToString.selector = "toString".toCharArray();
|
||||
}
|
||||
arrayToString.selector = (fieldIsObjectArray ? "deepToString" : "toString").toCharArray();
|
||||
ex = arrayToString;
|
||||
} else {
|
||||
ex = fieldAccessor;
|
||||
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2012 The Project Lombok Authors.
|
||||
* Copyright (C) 2010-2013 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,7 @@ import java.lang.annotation.Target;
|
||||
* @see org.apache.commons.logging.LogFactory#getLog(java.lang.Class) org.apache.commons.logging.LogFactory.getLog(Class target)
|
||||
* @see lombok.extern.java.Log @Log
|
||||
* @see lombok.extern.log4j.Log4j @Log4j
|
||||
* @see lombok.extern.log4j.Log4j2 @Log4j2
|
||||
* @see lombok.extern.slf4j.Slf4j @Slf4j
|
||||
* @see lombok.extern.slf4j.XSlf4j @XSlf4j
|
||||
*/
|
||||
|
||||
Vendored
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2012 The Project Lombok Authors.
|
||||
* Copyright (C) 2010-2013 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
|
||||
@@ -51,6 +51,7 @@ import java.lang.annotation.Target;
|
||||
* @see java.util.logging.Logger#getLogger(java.lang.String) java.util.logging.Logger.getLogger(String name)
|
||||
* @see lombok.extern.apachecommons.CommonsLog @CommonsLog
|
||||
* @see lombok.extern.log4j.Log4j @Log4j
|
||||
* @see lombok.extern.log4j.Log4j2 @Log4j2
|
||||
* @see lombok.extern.slf4j.Slf4j @Slf4j
|
||||
* @see lombok.extern.slf4j.XSlf4j @XSlf4j
|
||||
*/
|
||||
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2012 The Project Lombok Authors.
|
||||
* Copyright (C) 2010-2013 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
|
||||
@@ -50,6 +50,7 @@ import java.lang.annotation.Target;
|
||||
*
|
||||
* @see org.apache.log4j.Logger org.apache.log4j.Logger
|
||||
* @see org.apache.log4j.Logger#getLogger(java.lang.Class) org.apache.log4j.Logger.getLogger(Class target)
|
||||
* @see lombok.extern.log4j.Log4j2 @Log4j2
|
||||
* @see lombok.extern.apachecommons.CommonsLog @CommonsLog
|
||||
* @see lombok.extern.java.Log @Log
|
||||
* @see lombok.extern.slf4j.Slf4j @Slf4j
|
||||
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2013 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
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.extern.log4j;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Causes lombok to generate a logger field.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/Log.html">the project lombok features page for lombok log annotations</a>.
|
||||
* <p>
|
||||
* Example:
|
||||
* <pre>
|
||||
* @Log4j2
|
||||
* public class LogExample {
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* will generate:
|
||||
*
|
||||
* <pre>
|
||||
* public class LogExample {
|
||||
* private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.Logger.getLogger(LogExample.class);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* This annotation is valid for classes and enumerations.<br />
|
||||
*
|
||||
* @see org.apache.logging.log4j.Logger org.apache.logging.log4j.Logger
|
||||
* @see org.apache.logging.log4j.LogManager#getLogger(java.lang.Class) org.apache.logging.log4j.LogManager.getLogger(Class target)
|
||||
* @see lombok.extern.log4j.Log4j @Log4j
|
||||
* @see lombok.extern.apachecommons.CommonsLog @CommonsLog
|
||||
* @see lombok.extern.java.Log @Log
|
||||
* @see lombok.extern.slf4j.Slf4j @Slf4j
|
||||
* @see lombok.extern.slf4j.XSlf4j @XSlf4j
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface Log4j2 {
|
||||
}
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2012 The Project Lombok Authors.
|
||||
* Copyright (C) 2010-2013 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
|
||||
@@ -51,6 +51,7 @@ import java.lang.annotation.Target;
|
||||
* @see lombok.extern.apachecommons.CommonsLog @CommonsLog
|
||||
* @see lombok.extern.java.Log @Log
|
||||
* @see lombok.extern.log4j.Log4j @Log4j
|
||||
* @see lombok.extern.log4j.Log4j2 @Log4j2
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(ElementType.TYPE)
|
||||
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2012 The Project Lombok Authors.
|
||||
* Copyright (C) 2012-2013 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
|
||||
@@ -51,6 +51,7 @@ import java.lang.annotation.Target;
|
||||
* @see lombok.extern.apachecommons.CommonsLog @CommonsLog
|
||||
* @see lombok.extern.java.Log @Log
|
||||
* @see lombok.extern.log4j.Log4j @Log4j
|
||||
* @see lombok.extern.log4j.Log4j2 @Log4j2
|
||||
* @see lombok.extern.slf4j.Slf4j @Slf4j
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
||||
@@ -33,7 +33,7 @@ import com.sun.tools.javac.tree.JCTree.JCAnnotation;
|
||||
*
|
||||
* You MUST replace 'T' with a specific annotation type, such as:
|
||||
*
|
||||
* {@code public class HandleGetter implements JavacAnnotationHandler<Getter>}
|
||||
* {@code public class HandleGetter extends JavacAnnotationHandler<Getter>}
|
||||
*
|
||||
* Because this generics parameter is inspected to figure out which class you're interested in.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2012 The Project Lombok Authors.
|
||||
* Copyright (C) 2010-2013 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
|
||||
@@ -82,7 +82,7 @@ public class HandleLog {
|
||||
private static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source) {
|
||||
TreeMaker maker = typeNode.getTreeMaker();
|
||||
|
||||
// private static final <loggerType> log = <factoryMethod>(<parameter>);
|
||||
// private static final <loggerType> log = <factoryMethod>(<parameter>);
|
||||
JCExpression loggerType = chainDotsString(typeNode, framework.getLoggerTypeName());
|
||||
JCExpression factoryMethod = chainDotsString(typeNode, framework.getLoggerFactoryMethodName());
|
||||
|
||||
@@ -127,6 +127,16 @@ public class HandleLog {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the {@link lombok.extern.log4j.Log4j2} annotation for javac.
|
||||
*/
|
||||
@ProviderFor(JavacAnnotationHandler.class)
|
||||
public static class HandleLog4j2Log extends JavacAnnotationHandler<lombok.extern.log4j.Log4j2> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j2> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the {@link lombok.extern.slf4j.Slf4j} annotation for javac.
|
||||
*/
|
||||
@@ -163,6 +173,9 @@ public class HandleLog {
|
||||
// private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(TargetType.class);
|
||||
LOG4J(lombok.extern.log4j.Log4j.class, "org.apache.log4j.Logger", "org.apache.log4j.Logger.getLogger"),
|
||||
|
||||
// private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(TargetType.class);
|
||||
LOG4J2(lombok.extern.log4j.Log4j2.class, "org.apache.logging.log4j.Logger", "org.apache.logging.log4j.LogManager.getLogger"),
|
||||
|
||||
// private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TargetType.class);
|
||||
SLF4J(lombok.extern.slf4j.Slf4j.class, "org.slf4j.Logger", "org.slf4j.LoggerFactory.getLogger"),
|
||||
|
||||
|
||||
@@ -84,13 +84,20 @@ public class HandleSneakyThrows extends JavacAnnotationHandler<SneakyThrows> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (method.body == null) return;
|
||||
if (method.body.stats.isEmpty()) return;
|
||||
if (method.body == null || method.body.stats.isEmpty()) {
|
||||
generateEmptyBlockWarning(methodNode, annotation, false);
|
||||
return;
|
||||
}
|
||||
|
||||
final JCStatement constructorCall = method.body.stats.get(0);
|
||||
final boolean isConstructorCall = isConstructorCall(constructorCall);
|
||||
List<JCStatement> contents = isConstructorCall ? method.body.stats.tail : method.body.stats;
|
||||
|
||||
if (contents == null || contents.isEmpty()) {
|
||||
generateEmptyBlockWarning(methodNode, annotation, true);
|
||||
return;
|
||||
}
|
||||
|
||||
for (String exception : exceptions) {
|
||||
contents = List.of(buildTryCatchBlock(methodNode, contents, exception, annotation.get()));
|
||||
}
|
||||
@@ -99,6 +106,14 @@ public class HandleSneakyThrows extends JavacAnnotationHandler<SneakyThrows> {
|
||||
methodNode.rebuild();
|
||||
}
|
||||
|
||||
private void generateEmptyBlockWarning(JavacNode methodNode, JavacNode annotation, boolean hasConstructorCall) {
|
||||
if (hasConstructorCall) {
|
||||
annotation.addWarning("Calls to sibling / super constructors are always excluded from @SneakyThrows; @SneakyThrows has been ignored because there is no other code in this constructor.");
|
||||
} else {
|
||||
annotation.addWarning("This method or constructor is empty; @SneakyThrows has been ignored.");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isConstructorCall(final JCStatement supect) {
|
||||
if (!(supect instanceof JCExpressionStatement)) return false;
|
||||
final JCExpression supectExpression = ((JCExpressionStatement) supect).expr;
|
||||
|
||||
@@ -198,18 +198,22 @@ public class HandleToString extends JavacAnnotationHandler<ToString> {
|
||||
}
|
||||
|
||||
for (JavacNode fieldNode : fields) {
|
||||
JCVariableDecl field = (JCVariableDecl) fieldNode.get();
|
||||
JCExpression expr;
|
||||
|
||||
JCExpression fieldAccessor = createFieldAccessor(maker, fieldNode, fieldAccess);
|
||||
|
||||
if (getFieldType(fieldNode, fieldAccess) instanceof JCArrayTypeTree) {
|
||||
boolean multiDim = ((JCArrayTypeTree)field.vartype).elemtype instanceof JCArrayTypeTree;
|
||||
boolean primitiveArray = ((JCArrayTypeTree)field.vartype).elemtype instanceof JCPrimitiveTypeTree;
|
||||
boolean useDeepTS = multiDim || !primitiveArray;
|
||||
|
||||
JCExpression hcMethod = chainDots(typeNode, "java", "util", "Arrays", useDeepTS ? "deepToString" : "toString");
|
||||
expr = maker.Apply(List.<JCExpression>nil(), hcMethod, List.<JCExpression>of(fieldAccessor));
|
||||
JCExpression fieldType = getFieldType(fieldNode, fieldAccess);
|
||||
|
||||
// The distinction between primitive and object will be useful if we ever add a 'hideNulls' option.
|
||||
boolean fieldIsPrimitive = fieldType instanceof JCPrimitiveTypeTree;
|
||||
boolean fieldIsPrimitiveArray = fieldType instanceof JCArrayTypeTree && ((JCArrayTypeTree) fieldType).elemtype instanceof JCPrimitiveTypeTree;
|
||||
boolean fieldIsObjectArray = !fieldIsPrimitiveArray && fieldType instanceof JCArrayTypeTree;
|
||||
@SuppressWarnings("unused")
|
||||
boolean fieldIsObject = !fieldIsPrimitive && !fieldIsPrimitiveArray && !fieldIsObjectArray;
|
||||
|
||||
if (fieldIsPrimitiveArray || fieldIsObjectArray) {
|
||||
JCExpression tsMethod = chainDots(typeNode, "java", "util", "Arrays", fieldIsObjectArray ? "deepToString" : "toString");
|
||||
expr = maker.Apply(List.<JCExpression>nil(), tsMethod, List.<JCExpression>of(fieldAccessor));
|
||||
} else expr = fieldAccessor;
|
||||
|
||||
if (first) {
|
||||
|
||||
@@ -305,6 +305,7 @@ public class JavacHandlerUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
parentNode.getAst().setChanged();
|
||||
deleteImportFromCompilationUnit(annotation, annotationType.getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Code derived from com.sun.tools.javac.tree.Pretty, from the langtools project.
|
||||
* A version can be found at, for example, http://hg.openjdk.java.net/jdk7/build/langtools
|
||||
*/
|
||||
package lombok.delombok;
|
||||
|
||||
import static com.sun.tools.javac.code.Flags.ANNOTATION;
|
||||
@@ -981,6 +986,29 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
|
||||
public void visitTry(JCTry tree) {
|
||||
try {
|
||||
print("try ");
|
||||
List<?> resources = null;
|
||||
try {
|
||||
Field f = JCTry.class.getField("resources");
|
||||
resources = (List<?>) f.get(tree);
|
||||
} catch (Exception ignore) {
|
||||
// In JDK6 and down this field does not exist; resources will retain its initializer value which is what we want.
|
||||
}
|
||||
|
||||
if (resources != null && resources.nonEmpty()) {
|
||||
boolean first = true;
|
||||
print("(");
|
||||
for (Object var0 : resources) {
|
||||
JCTree var = (JCTree) var0;
|
||||
if (!first) {
|
||||
println();
|
||||
indent();
|
||||
}
|
||||
printStat(var);
|
||||
first = false;
|
||||
}
|
||||
print(") ");
|
||||
}
|
||||
|
||||
printStat(tree.body);
|
||||
for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
|
||||
printStat(l.head);
|
||||
|
||||
@@ -236,10 +236,8 @@ public class PatchExtensionMethod {
|
||||
for (int i = 0, iend = arguments.size(); i < iend; i++) {
|
||||
Expression arg = arguments.get(i);
|
||||
if (fixedBinding.parameters[i].isArrayType() != arg.resolvedType.isArrayType()) break;
|
||||
if (arg.resolvedType.isArrayType()) {
|
||||
if (arg instanceof MessageSend) {
|
||||
((MessageSend) arg).valueCast = arg.resolvedType;
|
||||
}
|
||||
if (arg instanceof MessageSend) {
|
||||
((MessageSend) arg).valueCast = arg.resolvedType;
|
||||
}
|
||||
if (!fixedBinding.parameters[i].isBaseType() && arg.resolvedType.isBaseType()) {
|
||||
int id = arg.resolvedType.id;
|
||||
|
||||
@@ -64,14 +64,10 @@ public class EclipseFinder extends IdeFinder {
|
||||
|
||||
/**
|
||||
* Returns a list of paths of Eclipse installations.
|
||||
* Eclipse installations are found by checking for the existence of 'eclipse.exe' in the following locations:
|
||||
* <ul>
|
||||
* <li>X:\*Program Files*\*Eclipse*</li>
|
||||
* <li>X:\*Eclipse*</li>
|
||||
* </ul>
|
||||
*
|
||||
* Where 'X' is tried for all local disk drives, unless there's a problem calling fsutil, in which case only
|
||||
* C: is tried.
|
||||
* The search process works by scanning for each 'source dir' for either an eclipse installation or a folder containing the text returned
|
||||
* by getDirName(). If such a folder is found, this process is applied recursively. On windows, this process is run on each drive letter
|
||||
* which represents a physical hard disk. If the native windows API call to determine these drive letters fails, only 'C:' is checked.
|
||||
*/
|
||||
private List<String> getSourceDirsOnWindowsWithDriveLetters() {
|
||||
List<String> driveLetters = asList("C");
|
||||
@@ -83,12 +79,22 @@ public class EclipseFinder extends IdeFinder {
|
||||
List<String> sourceDirs = new ArrayList<String>();
|
||||
for (String letter : driveLetters) {
|
||||
for (String possibleSource : getSourceDirsOnWindows()) {
|
||||
sourceDirs.add(letter + ":" + possibleSource);
|
||||
if (!isDriveSpecificOnWindows(possibleSource)) {
|
||||
sourceDirs.add(letter + ":" + possibleSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String possibleSource : getSourceDirsOnWindows()) {
|
||||
if (isDriveSpecificOnWindows(possibleSource)) sourceDirs.add(possibleSource);
|
||||
}
|
||||
|
||||
return sourceDirs;
|
||||
}
|
||||
|
||||
public boolean isDriveSpecificOnWindows(String path) {
|
||||
return path.length() > 1 && path.charAt(1) == ':';
|
||||
}
|
||||
|
||||
protected List<String> getSourceDirsOnMac() {
|
||||
return Arrays.asList("/Applications", System.getProperty("user.home", "."));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2013 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
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
import lombok.installer.IdeFinder;
|
||||
import lombok.installer.IdeLocation;
|
||||
|
||||
import org.mangosdk.spi.ProviderFor;
|
||||
|
||||
/**
|
||||
* JBDS (JBoss Developer Studio) is an eclipse variant.
|
||||
* Other than different executable names, it's the same as eclipse, as far as lombok support goes.
|
||||
*/
|
||||
@ProviderFor(IdeFinder.class)
|
||||
public class JbdsFinder extends EclipseFinder {
|
||||
@Override protected IdeLocation createLocation(String guess) throws CorruptedIdeLocationException {
|
||||
return new JbdsLocationProvider().create0(guess);
|
||||
}
|
||||
|
||||
@Override protected String getDirName() {
|
||||
return "studio";
|
||||
}
|
||||
|
||||
@Override protected String getMacExecutableName() {
|
||||
return "jbdevstudio.app";
|
||||
}
|
||||
|
||||
@Override protected String getUnixExecutableName() {
|
||||
return "jbdevstudio";
|
||||
}
|
||||
|
||||
@Override protected String getWindowsExecutableName() {
|
||||
return "jbdevstudio.exe";
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnWindows() {
|
||||
return Arrays.asList("\\", "\\Program Files", "\\Program Files (x86)", System.getProperty("user.home", "."));
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnMac() {
|
||||
return Arrays.asList("/Applications", System.getProperty("user.home", "."));
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnUnix() {
|
||||
return Arrays.asList(System.getProperty("user.home", "."));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2013 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
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
|
||||
public class JbdsLocation extends EclipseLocation {
|
||||
public JbdsLocation(String nameOfLocation, File pathToEclipseIni) throws CorruptedIdeLocationException {
|
||||
super(nameOfLocation, pathToEclipseIni);
|
||||
}
|
||||
|
||||
@Override public URL getIdeIcon() {
|
||||
return JbdsLocation.class.getResource("jbds.png");
|
||||
}
|
||||
|
||||
@Override protected String getIniFileName() {
|
||||
return "jbdevstudio.ini";
|
||||
}
|
||||
|
||||
@Override protected String getTypeName() {
|
||||
return "JBoss Developer Studio";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2013 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
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.installer.eclipse;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import lombok.installer.CorruptedIdeLocationException;
|
||||
import lombok.installer.IdeLocation;
|
||||
import lombok.installer.IdeLocationProvider;
|
||||
import lombok.installer.IdeFinder.OS;
|
||||
|
||||
import org.mangosdk.spi.ProviderFor;
|
||||
|
||||
@ProviderFor(IdeLocationProvider.class)
|
||||
public class JbdsLocationProvider extends EclipseLocationProvider {
|
||||
@Override protected List<String> getEclipseExecutableNames() {
|
||||
return Arrays.asList("jbdevstudio.app", "jbdevstudio.exe", "jbdevstudioc.exe", "jbdevstudio");
|
||||
}
|
||||
|
||||
@Override protected String getIniName() {
|
||||
return "jbdevstudio.ini";
|
||||
}
|
||||
|
||||
@Override protected IdeLocation makeLocation(String name, File ini) throws CorruptedIdeLocationException {
|
||||
return new JbdsLocation(name, ini);
|
||||
}
|
||||
|
||||
@Override protected String getMacAppName() {
|
||||
return "jbdevstudio.app";
|
||||
}
|
||||
|
||||
@Override protected String getUnixAppName() {
|
||||
return "jbdevstudio";
|
||||
}
|
||||
|
||||
@Override public Pattern getLocationSelectors(OS os) {
|
||||
switch (os) {
|
||||
case MAC_OS_X:
|
||||
return Pattern.compile("^(jbdevstudio|jbdevstudio\\.ini|jbdevstudio\\.app)$", Pattern.CASE_INSENSITIVE);
|
||||
case WINDOWS:
|
||||
return Pattern.compile("^(jbdevstudioc?\\.exe|jbdevstudio\\.ini)$", Pattern.CASE_INSENSITIVE);
|
||||
default:
|
||||
case UNIX:
|
||||
return Pattern.compile("^(jbdevstudio|jbdevstudio\\.ini)$", Pattern.CASE_INSENSITIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class STSFinder extends EclipseFinder {
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnWindows() {
|
||||
return Arrays.asList("\\", "\\springsource", "\\Program Files", "\\Program Files\\springsource", System.getProperty("user.home", "."), System.getProperty("user.home", ".") + "\\springsource");
|
||||
return Arrays.asList("\\", "\\springsource", "\\Program Files", "\\Program Files (x86)", "\\Program Files\\springsource", "\\Program Files (x86)\\springsource", System.getProperty("user.home", "."), System.getProperty("user.home", ".") + "\\springsource");
|
||||
}
|
||||
|
||||
@Override protected List<String> getSourceDirsOnMac() {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
@@ -72,7 +72,7 @@ public abstract class AbstractRunTests {
|
||||
StringReader r = new StringReader(expectedFile);
|
||||
BufferedReader br = new BufferedReader(r);
|
||||
String firstLine = br.readLine();
|
||||
if (firstLine != null && firstLine.startsWith("//ignore")) return false;
|
||||
if (firstLine != null && (firstLine.startsWith("//ignore") || params.shouldIgnoreBasedOnVersion(firstLine))) return false;
|
||||
|
||||
compare(
|
||||
file.getName(),
|
||||
|
||||
@@ -29,15 +29,43 @@ import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.Runner;
|
||||
import org.junit.runner.notification.Failure;
|
||||
import org.junit.runner.notification.RunNotifier;
|
||||
|
||||
import com.sun.tools.javac.main.JavaCompiler;
|
||||
|
||||
public class DirectoryRunner extends Runner {
|
||||
public enum Compiler {
|
||||
DELOMBOK, JAVAC, ECJ;
|
||||
DELOMBOK {
|
||||
@Override public int getVersion() {
|
||||
Matcher m = VERSION_PARSER.matcher(JavaCompiler.version());
|
||||
if (m.matches()) {
|
||||
int major = Integer.parseInt(m.group(1));
|
||||
int minor = Integer.parseInt(m.group(2));
|
||||
if (major == 1) return minor;
|
||||
}
|
||||
|
||||
return 6;
|
||||
}
|
||||
},
|
||||
JAVAC {
|
||||
@Override public int getVersion() {
|
||||
return DELOMBOK.getVersion();
|
||||
}
|
||||
},
|
||||
ECJ {
|
||||
@Override public int getVersion() {
|
||||
return 6;
|
||||
}
|
||||
};
|
||||
|
||||
private static final Pattern VERSION_PARSER = Pattern.compile("^(\\d+)\\.(\\d+).*$");
|
||||
public abstract int getVersion();
|
||||
}
|
||||
|
||||
public static abstract class TestParams {
|
||||
@@ -46,10 +74,52 @@ public class DirectoryRunner extends Runner {
|
||||
public abstract File getBeforeDirectory();
|
||||
public abstract File getAfterDirectory();
|
||||
public abstract File getMessagesDirectory();
|
||||
/** Version of the JDK dialect that the compiler can understand; for example, if you return '7', you should know what try-with-resources is. */
|
||||
public int getVersion() {
|
||||
return getCompiler().getVersion();
|
||||
}
|
||||
|
||||
public boolean accept(File file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static final Pattern P1 = Pattern.compile("^(\\d+)$");
|
||||
private static final Pattern P2 = Pattern.compile("^\\:(\\d+)$");
|
||||
private static final Pattern P3 = Pattern.compile("^(\\d+):$");
|
||||
private static final Pattern P4 = Pattern.compile("^(\\d+):(\\d+)$");
|
||||
|
||||
public boolean shouldIgnoreBasedOnVersion(String firstLine) {
|
||||
int thisVersion = getVersion();
|
||||
if (!firstLine.startsWith("//version ")) return false;
|
||||
|
||||
String spec = firstLine.substring("//version ".length());
|
||||
|
||||
/* Single version: '5' */ {
|
||||
Matcher m = P1.matcher(spec);
|
||||
if (m.matches()) return Integer.parseInt(m.group(1)) != thisVersion;
|
||||
}
|
||||
|
||||
/* Upper bound: ':5' (inclusive) */ {
|
||||
Matcher m = P2.matcher(spec);
|
||||
if (m.matches()) return Integer.parseInt(m.group(1)) < thisVersion;
|
||||
}
|
||||
|
||||
/* Lower bound '5:' (inclusive) */ {
|
||||
Matcher m = P3.matcher(spec);
|
||||
if (m.matches()) return Integer.parseInt(m.group(1)) > thisVersion;
|
||||
}
|
||||
|
||||
/* Range '7:8' (inclusive) */ {
|
||||
Matcher m = P4.matcher(spec);
|
||||
if (m.matches()) {
|
||||
if (Integer.parseInt(m.group(1)) < thisVersion) return true;
|
||||
if (Integer.parseInt(m.group(2)) > thisVersion) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Version validity spec not valid: " + spec);
|
||||
}
|
||||
}
|
||||
|
||||
private static final FileFilter JAVA_FILE_FILTER = new FileFilter() {
|
||||
@@ -135,6 +205,6 @@ public class DirectoryRunner extends Runner {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
String line = reader.readLine();
|
||||
reader.close();
|
||||
return line != null && line.startsWith("//ignore");
|
||||
return line != null && (line.startsWith("//ignore") || params.shouldIgnoreBasedOnVersion(line));
|
||||
}
|
||||
}
|
||||
@@ -129,10 +129,11 @@ public class RunTestsViaEcj extends AbstractRunTests {
|
||||
}
|
||||
}
|
||||
classpath.add("dist/lombok.jar");
|
||||
classpath.add("lib/test/commons-logging.jar");
|
||||
classpath.add("lib/test/slf4j-api.jar");
|
||||
classpath.add("lib/test/slf4j-ext.jar");
|
||||
classpath.add("lib/test/log4j.jar");
|
||||
classpath.add("lib/test/commons-logging-commons-logging.jar");
|
||||
classpath.add("lib/test/org.slf4j-slf4j-api.jar");
|
||||
classpath.add("lib/test/org.slf4j-slf4j-ext.jar");
|
||||
classpath.add("lib/test/log4j-log4j.jar");
|
||||
classpath.add("lib/test/org.apache.logging.log4j-log4j-api.jar");
|
||||
return new FileSystem(classpath.toArray(new String[0]), new String[] {file.getAbsolutePath()}, "UTF-8");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//version 7:
|
||||
import java.io.PrintWriter;
|
||||
public class TryWithResources {
|
||||
{
|
||||
try (final PrintWriter pw = new PrintWriter(System.out);) {
|
||||
pw.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//version 7:
|
||||
import java.io.PrintWriter;
|
||||
public class TryWithResources {
|
||||
{
|
||||
try (PrintWriter pw = new PrintWriter(System.out)) {
|
||||
pw.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
class LoggerCommons {
|
||||
private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LoggerCommons.class);
|
||||
}
|
||||
|
||||
class LoggerCommonsWithImport {
|
||||
private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LoggerCommonsWithImport.class);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
class LoggerJul {
|
||||
private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJul.class.getName());
|
||||
}
|
||||
|
||||
class LoggerJulWithImport {
|
||||
private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJulWithImport.class.getName());
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
class LoggerLog4j {
|
||||
private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LoggerLog4j.class);
|
||||
}
|
||||
|
||||
class LoggerLog4jWithImport {
|
||||
private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LoggerLog4jWithImport.class);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class LoggerLog4j2 {
|
||||
private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LoggerLog4j2.class);
|
||||
}
|
||||
class LoggerLog4j2WithImport {
|
||||
private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LoggerLog4j2WithImport.class);
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
class LoggerSlf4j {
|
||||
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4j.class);
|
||||
}
|
||||
|
||||
class LoggerSlf4jWithImport {
|
||||
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jWithImport.class);
|
||||
}
|
||||
|
||||
class LoggerSlf4jOuter {
|
||||
static class Inner {
|
||||
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Inner.class);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
class LoggerXSlf4j {
|
||||
private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger(LoggerXSlf4j.class);
|
||||
}
|
||||
|
||||
class LoggerXSlf4jWithImport {
|
||||
private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger(LoggerXSlf4jWithImport.class);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
@lombok.extern.log4j.Log4j2 class LoggerLog4j2 {
|
||||
private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LoggerLog4j2.class);
|
||||
<clinit>() {
|
||||
}
|
||||
LoggerLog4j2() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@Log4j2 class LoggerLog4j2WithImport {
|
||||
private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LoggerLog4j2WithImport.class);
|
||||
<clinit>() {
|
||||
}
|
||||
LoggerLog4j2WithImport() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
@lombok.extern.log4j.Log4j2
|
||||
class LoggerLog4j2 {
|
||||
}
|
||||
|
||||
@Log4j2
|
||||
class LoggerLog4j2WithImport {
|
||||
}
|
||||
@@ -44,7 +44,7 @@
|
||||
<div class="edgeLink">Feeling adventurous? Download the latest <a href="download-edge.html">snapshot</a> release.</div>
|
||||
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tr><td class="platform">Maven or Ivy</td>
|
||||
<tr><td class="platform">Maven or Ivy</td>
|
||||
<td class="instruction">Lombok is in maven central. <a href="mavenrepo/index.html">More…</a></td></tr>
|
||||
|
||||
<tr><td class="platform">Javac</td>
|
||||
@@ -53,10 +53,10 @@
|
||||
<tr><td class="platform">NetBeans</td>
|
||||
<td class="instruction">Just put <code>lombok.jar</code> on the classpath and enable annotation processing. <a href="setup/netbeans.html">More…</a></td></tr>
|
||||
|
||||
<tr><td class="platform">Eclipse and STS</td>
|
||||
<td class="instruction">Run <code>lombok.jar</code> as a java app (i.e. doubleclick it, usually) to install. Also add lombok.jar to your project.</td></tr>
|
||||
<tr><td class="platform">Eclipse and variants</td>
|
||||
<td class="instruction">Run <code>lombok.jar</code> as a java app (i.e. doubleclick it, usually) to install. Also add lombok.jar to your project. <span style="font-size: 0.8em;"><em>Supported variants: Springsource Tool Suite, JBoss Developer Studio</em></span></td></tr>
|
||||
|
||||
<tr><td class="platform">IDEA IntelliJ</td>
|
||||
<tr><td class="platform">IDEA IntelliJ</td>
|
||||
<td class="instruction">lombok doesn't (yet) work under IntelliJ. We're working on it though!</td></tr>
|
||||
|
||||
<tr><td class="platform">Javadoc</td>
|
||||
@@ -68,7 +68,7 @@
|
||||
<tr><td class="platform">GWT</td>
|
||||
<td class="instruction">Lombok works with GWT. <a href="setup/gwt.html">More…</a></td></tr>
|
||||
|
||||
<tr><td class="platform">Play! Framework</td>
|
||||
<tr><td class="platform">Play! Framework</td>
|
||||
<td class="instruction">Use Aaron Freeman's <a href="https://github.com/aaronfreeman/play-lombok#readme">lombok play plugin</a>.</td></tr>
|
||||
|
||||
<tr><td class="platform">ecj</td>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<h3>Overview</h3>
|
||||
<p>
|
||||
<em>NEW in lombok 0.10: </em>You can annotate any class with a log annotation to let lombok generate a logger field.<br />
|
||||
The logger is named <code>log</code> and field's type depends on which logger you have selected.
|
||||
The logger is named <code>log</code> and the field's type depends on which logger you have selected.
|
||||
</p><p>
|
||||
There are four choices available:<br />
|
||||
There are six choices available:<br />
|
||||
<dl>
|
||||
<dt><code>@CommonsLog</code></dt>
|
||||
<dd>Creates <code><span class="keyword">private static final </span><a href="http://commons.apache.org/logging/apidocs/org/apache/commons/logging/Log.html">org.apache.commons.logging.Log</a> <span class="staticfield">log</span> = <a href="http://commons.apache.org/logging/apidocs/org/apache/commons/logging/LogFactory.html#getLog(java.lang.Class)">org.apache.commons.logging.LogFactory.getLog</a>(LogExample.<span class="keyword">class</span>);</code></dd>
|
||||
@@ -26,6 +26,8 @@
|
||||
<dd>Creates <code><span class="keyword">private static final </span><a href="http://download.oracle.com/javase/6/docs/api/java/util/logging/Logger.html">java.util.logging.Logger</a> <span class="staticfield">log</span> = <a href="http://download.oracle.com/javase/6/docs/api/java/util/logging/Logger.html#getLogger(java.lang.String)">java.util.logging.Logger.getLogger</a>(LogExample.<span class="keyword">class</span>.getName());</code></dd>
|
||||
<dt><code>@Log4j</code></dt>
|
||||
<dd>Creates <code><span class="keyword">private static final </span><a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Logger.html">org.apache.log4j.Logger</a> <span class="staticfield">log</span> = <a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Logger.html#getLogger(java.lang.Class)">org.apache.log4j.Logger.getLogger</a>(LogExample.<span class="keyword">class</span>);</code></dd>
|
||||
<dt><code>@Log4j2</code></dt>
|
||||
<dd>Creates <code><span class="keyword">private static final </span><a href="http://logging.apache.org/log4j/2.0/log4j-api/apidocs/org/apache/logging/log4j/Logger.html">org.apache.logging.log4j.Logger</a> <span class="staticfield">log</span> = <a href="http://logging.apache.org/log4j/2.0/log4j-api/apidocs/org/apache/logging/log4j/LogManager.html#getLogger(java.lang.Class)">org.apache.logging.log4j.LogManager.getLogger</a>(LogExample.<span class="keyword">class</span>);</code></dd>
|
||||
<dt><code>@Slf4j</code></dt>
|
||||
<dd>Creates <code><span class="keyword">private static final </span><a href="http://www.slf4j.org/api/org/slf4j/Logger.html">org.slf4j.Logger</a> <span class="staticfield">log</span> = <a href="http://www.slf4j.org/apidocs/org/slf4j/LoggerFactory.html#getLogger(java.lang.Class)">org.slf4j.LoggerFactory.getLogger</a>(LogExample.<span class="keyword">class</span>);</code></dd>
|
||||
<dt><code>@XSlf4j</code></dt>
|
||||
|
||||
@@ -64,7 +64,11 @@
|
||||
statement in a try/catch block with just <code>e.printStackTrace()</code> in the catch block. This is so spectacularly non-productive
|
||||
compared to just sneakily throwing the exception onwards, that Roel and Reinier feel more than justified in claiming that the
|
||||
checked exception system is far from perfect, and thus an opt-out mechanism is warranted.
|
||||
</p>
|
||||
</p><p>
|
||||
If you put <code>@SneakyThrows</code> on a constructor, any call to a sibling or super constructor is <em>excluded</em> from the <code>@SneakyThrows</code> treatment. This is a
|
||||
java restriction we cannot work around: Calls to sibling/super constructors MUST be the first statement in the constructor; they cannot be placed inside try/catch blocks.
|
||||
</p><p>
|
||||
<code>@SneakyThrows</code> on an empty method, or a constructor that is empty or only has a call to a sibling / super constructor results in no try/catch block and a warning.
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
|
||||
Reference in new issue
Block a user