From af16ba23cd46fa3d3b096daa8d725df2b4d78976 Mon Sep 17 00:00:00 2001 From: ttzn Date: Wed, 24 Mar 2021 23:52:08 +0100 Subject: @StandardException feature working draft * move feature under experimental * replace ProviderFor with Provides * add doc material (to be completed) * add author --- src/core/lombok/StandardException.java | 34 ---------------------- .../eclipse/handlers/HandleStandardException.java | 8 ++--- .../lombok/experimental/StandardException.java | 34 ++++++++++++++++++++++ .../javac/handlers/HandleStandardException.java | 9 +++--- 4 files changed, 41 insertions(+), 44 deletions(-) delete mode 100644 src/core/lombok/StandardException.java create mode 100644 src/core/lombok/experimental/StandardException.java (limited to 'src') diff --git a/src/core/lombok/StandardException.java b/src/core/lombok/StandardException.java deleted file mode 100644 index 0456a649..00000000 --- a/src/core/lombok/StandardException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2010-2017 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; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.SOURCE) -public @interface StandardException { -} diff --git a/src/core/lombok/eclipse/handlers/HandleStandardException.java b/src/core/lombok/eclipse/handlers/HandleStandardException.java index 9996f4fa..e7f25edb 100755 --- a/src/core/lombok/eclipse/handlers/HandleStandardException.java +++ b/src/core/lombok/eclipse/handlers/HandleStandardException.java @@ -23,16 +23,16 @@ package lombok.eclipse.handlers; import lombok.AccessLevel; import lombok.ConfigurationKeys; -import lombok.StandardException; +import lombok.experimental.StandardException; import lombok.core.AST.Kind; import lombok.core.AnnotationValues; import lombok.eclipse.Eclipse; import lombok.eclipse.EclipseAnnotationHandler; import lombok.eclipse.EclipseNode; import lombok.eclipse.handlers.EclipseHandlerUtil.*; +import lombok.spi.Provides; import org.eclipse.jdt.internal.compiler.ast.*; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; -import org.mangosdk.spi.ProviderFor; import java.lang.reflect.Modifier; import java.util.*; @@ -42,7 +42,7 @@ import static lombok.eclipse.Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG; import static lombok.eclipse.Eclipse.pos; import static lombok.eclipse.handlers.EclipseHandlerUtil.*; -@ProviderFor(EclipseAnnotationHandler.class) +@Provides public class HandleStandardException extends EclipseAnnotationHandler { private static final String NAME = StandardException.class.getSimpleName(); @@ -175,12 +175,10 @@ public class HandleStandardException extends EclipseAnnotationHandler parameters, EclipseNode sourceNode) { - ASTNode source = sourceNode.get(); TypeDeclaration typeDeclaration = ((TypeDeclaration) type.get()); boolean isEnum = (((TypeDeclaration) type.get()).modifiers & ClassFileConstants.AccEnum) != 0; - if (isEnum) level = AccessLevel.PRIVATE; boolean addConstructorProperties; diff --git a/src/core/lombok/experimental/StandardException.java b/src/core/lombok/experimental/StandardException.java new file mode 100644 index 00000000..9f8a4e65 --- /dev/null +++ b/src/core/lombok/experimental/StandardException.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2010-2017 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.experimental; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.SOURCE) +public @interface StandardException { +} diff --git a/src/core/lombok/javac/handlers/HandleStandardException.java b/src/core/lombok/javac/handlers/HandleStandardException.java index 6a382788..598f1aa7 100644 --- a/src/core/lombok/javac/handlers/HandleStandardException.java +++ b/src/core/lombok/javac/handlers/HandleStandardException.java @@ -30,7 +30,7 @@ import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Name; import lombok.AccessLevel; import lombok.ConfigurationKeys; -import lombok.StandardException; +import lombok.experimental.StandardException; import lombok.core.AST.Kind; import lombok.core.AnnotationValues; import lombok.delombok.LombokOptionsFactory; @@ -39,13 +39,13 @@ import lombok.javac.JavacAnnotationHandler; import lombok.javac.JavacNode; import lombok.javac.JavacTreeMaker; import lombok.javac.handlers.JavacHandlerUtil.*; -import org.mangosdk.spi.ProviderFor; +import lombok.spi.Provides; import static lombok.core.handlers.HandlerUtil.handleFlagUsage; import static lombok.javac.Javac.CTC_VOID; import static lombok.javac.handlers.JavacHandlerUtil.*; -@ProviderFor(JavacAnnotationHandler.class) +@Provides public class HandleStandardException extends JavacAnnotationHandler { private static final String NAME = StandardException.class.getSimpleName(); @@ -161,7 +161,6 @@ public class HandleStandardException extends JavacAnnotationHandler"), null, List.nil(), params.toList(), List.nil(), - maker.Block(0L, statements.toList()), null), source.get(), typeNode.getContext()); + maker.Block(0L, statements.toList()), null), source); } public static boolean isLocalType(JavacNode type) { -- cgit