diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2020-06-25 23:33:16 +0200 |
---|---|---|
committer | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2020-06-25 23:33:16 +0200 |
commit | 625acfa2a4ce49863ea562dd676500b5bb7898fc (patch) | |
tree | bb03082edf951f4e2849940fe44acc8361856d0a /src/utils | |
parent | a3d71d68473d23f5cf722d8c1bff31781d6d9c66 (diff) | |
parent | 966852e410cfd99e311eca98cee36c163629949e (diff) | |
download | lombok-625acfa2a4ce49863ea562dd676500b5bb7898fc.tar.gz lombok-625acfa2a4ce49863ea562dd676500b5bb7898fc.tar.bz2 lombok-625acfa2a4ce49863ea562dd676500b5bb7898fc.zip |
Merge branch 'newbuild'
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/lombok/core/JavaIdentifiers.java | 11 | ||||
-rw-r--r-- | src/utils/lombok/core/SpiLoadUtil.java | 4 | ||||
-rw-r--r-- | src/utils/lombok/eclipse/Eclipse.java | 4 | ||||
-rw-r--r-- | src/utils/lombok/javac/Javac.java | 4 |
4 files changed, 18 insertions, 5 deletions
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/core/SpiLoadUtil.java b/src/utils/lombok/core/SpiLoadUtil.java index e685acd6..0feb7f12 100644 --- a/src/utils/lombok/core/SpiLoadUtil.java +++ b/src/utils/lombok/core/SpiLoadUtil.java @@ -129,9 +129,10 @@ public class SpiLoadUtil { private static void readServicesFromUrl(Collection<String> list, URL url) throws IOException { InputStream in = url.openStream(); + BufferedReader r = null; try { if (in == null) return; - BufferedReader r = new BufferedReader(new InputStreamReader(in, "UTF-8")); + r = new BufferedReader(new InputStreamReader(in, "UTF-8")); while (true) { String line = r.readLine(); if (line == null) break; @@ -143,6 +144,7 @@ public class SpiLoadUtil { } } finally { try { + if (r != null) r.close(); if (in != null) in.close(); } catch (Throwable ignore) {} } 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()); } /** |