From ed8ea0d8043cb8df6ae3fb962ab3a2087f4adeb6 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Fri, 19 Jun 2020 00:47:00 +0200 Subject: #1543: First primitives, then primitive wrappers, then other references --- src/utils/lombok/eclipse/Eclipse.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/utils/lombok/eclipse') diff --git a/src/utils/lombok/eclipse/Eclipse.java b/src/utils/lombok/eclipse/Eclipse.java index 31f2518a..9ec63c79 100644 --- a/src/utils/lombok/eclipse/Eclipse.java +++ b/src/utils/lombok/eclipse/Eclipse.java @@ -29,6 +29,7 @@ import java.util.regex.Pattern; import lombok.core.ClassLiteral; import lombok.core.FieldSelect; +import lombok.core.handlers.HandlerUtil; import lombok.permit.Permit; import org.eclipse.jdt.internal.compiler.ast.ASTNode; @@ -158,16 +159,12 @@ public class Eclipse { return result.toArray(EMPTY_ANNOTATIONS_ARRAY); } - /** Matches any of the 8 primitive names, such as {@code boolean}. */ - private static final Pattern PRIMITIVE_TYPE_NAME_PATTERN = Pattern.compile( - "^(boolean|byte|short|int|long|float|double|char)$"); - /** * Checks if the given type reference represents a primitive type. */ public static boolean isPrimitive(TypeReference ref) { if (ref.dimensions() > 0) return false; - return PRIMITIVE_TYPE_NAME_PATTERN.matcher(toQualifiedName(ref.getTypeName())).matches(); + return HandlerUtil.isPrimitive(toQualifiedName(ref.getTypeName())); } /** -- cgit From 966852e410cfd99e311eca98cee36c163629949e Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 25 Jun 2020 23:02:55 +0200 Subject: [bugfix] building would fail due to an invalid reference from src/utils to src/core. --- src/core/lombok/core/handlers/HandlerUtil.java | 9 +-------- src/utils/lombok/core/JavaIdentifiers.java | 11 +++++++++++ src/utils/lombok/eclipse/Eclipse.java | 4 ++-- src/utils/lombok/javac/Javac.java | 4 ++-- 4 files changed, 16 insertions(+), 12 deletions(-) (limited to 'src/utils/lombok/eclipse') diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java index 46ce3825..1c4437d7 100644 --- a/src/core/lombok/core/handlers/HandlerUtil.java +++ b/src/core/lombok/core/handlers/HandlerUtil.java @@ -745,13 +745,6 @@ public class HandlerUtil { return b.toString(); } - /** Matches any of the 8 primitive names, such as {@code boolean}. */ - private static final Pattern PRIMITIVE_TYPE_NAME_PATTERN = Pattern.compile("^(?:boolean|byte|short|int|long|float|double|char)$"); - - public static boolean isPrimitive(String typeName) { - return PRIMITIVE_TYPE_NAME_PATTERN.matcher(typeName).matches(); - } - /** Matches any of the 8 primitive wrapper names, such as {@code Boolean}. */ private static final Pattern PRIMITIVE_WRAPPER_TYPE_NAME_PATTERN = Pattern.compile("^(?:java\\.lang\\.)?(?:Boolean|Byte|Short|Integer|Long|Float|Double|Character)$"); @@ -759,7 +752,7 @@ public class HandlerUtil { // Modification in this code should be documented // 1. In the changelog this should be marked as an INPROBABLE BREAKING CHANGE, since the hashcode will change // 2. In the javadoc of EqualsAndHashcode.Include#rank - if (isPrimitive(typeName)) return 1000; + if (JavaIdentifiers.isPrimitive(typeName)) return 1000; if (PRIMITIVE_WRAPPER_TYPE_NAME_PATTERN.matcher(typeName).matches()) return 800; return 0; } diff --git a/src/utils/lombok/core/JavaIdentifiers.java b/src/utils/lombok/core/JavaIdentifiers.java index cbe90eed..906ae0e1 100644 --- a/src/utils/lombok/core/JavaIdentifiers.java +++ b/src/utils/lombok/core/JavaIdentifiers.java @@ -21,6 +21,8 @@ */ package lombok.core; +import java.util.regex.Pattern; + /** * Utility functions for validating potential java verifiers. */ @@ -54,4 +56,13 @@ public class JavaIdentifiers { public static boolean isKeyword(String keyword) { return KEYWORDS.contains(keyword); } + + /** Matches any of the 8 primitive names, such as {@code boolean}. */ + private static final Pattern PRIMITIVE_TYPE_NAME_PATTERN = Pattern.compile("^(?:boolean|byte|short|int|long|float|double|char)$"); + + public static boolean isPrimitive(String typeName) { + return PRIMITIVE_TYPE_NAME_PATTERN.matcher(typeName).matches(); + } + + } diff --git a/src/utils/lombok/eclipse/Eclipse.java b/src/utils/lombok/eclipse/Eclipse.java index 9ec63c79..31979955 100644 --- a/src/utils/lombok/eclipse/Eclipse.java +++ b/src/utils/lombok/eclipse/Eclipse.java @@ -29,7 +29,7 @@ import java.util.regex.Pattern; import lombok.core.ClassLiteral; import lombok.core.FieldSelect; -import lombok.core.handlers.HandlerUtil; +import lombok.core.JavaIdentifiers; import lombok.permit.Permit; import org.eclipse.jdt.internal.compiler.ast.ASTNode; @@ -164,7 +164,7 @@ public class Eclipse { */ public static boolean isPrimitive(TypeReference ref) { if (ref.dimensions() > 0) return false; - return HandlerUtil.isPrimitive(toQualifiedName(ref.getTypeName())); + return JavaIdentifiers.isPrimitive(toQualifiedName(ref.getTypeName())); } /** diff --git a/src/utils/lombok/javac/Javac.java b/src/utils/lombok/javac/Javac.java index 234c7f73..cec43705 100644 --- a/src/utils/lombok/javac/Javac.java +++ b/src/utils/lombok/javac/Javac.java @@ -57,7 +57,7 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import lombok.core.ClassLiteral; import lombok.core.FieldSelect; -import lombok.core.handlers.HandlerUtil; +import lombok.core.JavaIdentifiers; import lombok.javac.JavacTreeMaker.TreeTag; import lombok.javac.JavacTreeMaker.TypeTag; import lombok.permit.Permit; @@ -133,7 +133,7 @@ public class Javac { * expression) represents a primitive type. */ public static boolean isPrimitive(JCExpression ref) { - return HandlerUtil.isPrimitive(ref.toString()); + return JavaIdentifiers.isPrimitive(ref.toString()); } /** -- cgit