diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2019-08-13 15:04:43 +0200 |
---|---|---|
committer | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2019-08-22 22:42:48 +0200 |
commit | 15df143df6d35dd64459d717a451a039eb26d761 (patch) | |
tree | 70fc0be372fd02491f9c5e9d7d68ffe7901da6d8 /src/core/lombok/javac/handlers/HandleToString.java | |
parent | ff1c01d9e9e66d898c30939b497490b04fe6163c (diff) | |
download | lombok-15df143df6d35dd64459d717a451a039eb26d761.tar.gz lombok-15df143df6d35dd64459d717a451a039eb26d761.tar.bz2 lombok-15df143df6d35dd64459d717a451a039eb26d761.zip |
[checkerframework]
A bit of a shadow feature because the checker framework folks need to do some work on their side.
this update makes lombok generate a few checker framework annotations (if configured to do so)
which let the checker framework add warnings and errors for example if you misuse builders, or ignore
the return values of withers, etc.
Diffstat (limited to 'src/core/lombok/javac/handlers/HandleToString.java')
-rw-r--r-- | src/core/lombok/javac/handlers/HandleToString.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/core/lombok/javac/handlers/HandleToString.java b/src/core/lombok/javac/handlers/HandleToString.java index 3780da79..d0d36e06 100644 --- a/src/core/lombok/javac/handlers/HandleToString.java +++ b/src/core/lombok/javac/handlers/HandleToString.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2018 The Project Lombok Authors. + * Copyright (C) 2009-2019 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 @@ -31,6 +31,7 @@ import lombok.ConfigurationKeys; import lombok.ToString; import lombok.core.AnnotationValues; import lombok.core.configuration.CallSuperType; +import lombok.core.configuration.CheckerFrameworkVersion; import lombok.core.AST.Kind; import lombok.core.handlers.InclusionExclusionUtils; import lombok.core.handlers.InclusionExclusionUtils.Included; @@ -93,7 +94,7 @@ public class HandleToString extends JavacAnnotationHandler<ToString> { boolean includeFieldNames = true; try { Boolean configuration = typeNode.getAst().readConfiguration(ConfigurationKeys.TO_STRING_INCLUDE_FIELD_NAMES); - includeFieldNames = configuration != null ? configuration : ((Boolean)ToString.class.getMethod("includeFieldNames").getDefaultValue()).booleanValue(); + includeFieldNames = configuration != null ? configuration : ((Boolean) ToString.class.getMethod("includeFieldNames").getDefaultValue()).booleanValue(); } catch (Exception ignore) {} Boolean doNotUseGettersConfiguration = typeNode.getAst().readConfiguration(ConfigurationKeys.TO_STRING_DO_NOT_USE_GETTERS); @@ -160,7 +161,9 @@ public class HandleToString extends JavacAnnotationHandler<ToString> { JavacTreeMaker maker = typeNode.getTreeMaker(); JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(typeNode, "Override"), List.<JCExpression>nil()); - JCModifiers mods = maker.Modifiers(Flags.PUBLIC, List.of(overrideAnnotation)); + List<JCAnnotation> annsOnMethod = List.of(overrideAnnotation); + if (getCheckerFrameworkVersion(typeNode).generateSideEffectFree()) annsOnMethod = annsOnMethod.prepend(maker.Annotation(genTypeRef(typeNode, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil())); + JCModifiers mods = maker.Modifiers(Flags.PUBLIC, annsOnMethod); JCExpression returnType = genJavaLangTypeRef(typeNode, "String"); boolean first = true; |