From 02a89cf7feb1cd5899530aa12d4de76d622e38fe Mon Sep 17 00:00:00 2001 From: Rawi01 Date: Mon, 14 Oct 2024 22:17:09 +0200 Subject: [PATCH 1/3] Check exact message line numbers in tests --- .../src/lombok/CompilerMessageMatcher.java | 5 ++--- .../DelegateFlagUsage.java.messages | 2 +- .../DelegateOnStatic.java.messages | 4 ++-- .../DelegateRecursion.java.messages | 2 +- ...lsAndHashCodeOfAndExcludeWarn.java.messages | 4 ++-- ...sionMethodAmbiguousFunctional.java.messages | 2 +- ...perBuilderWithJsonDeserialize.java.messages | 2 +- .../LockedInRecord.java.messages | 2 +- .../NonNullOnParameter.java.messages | 2 +- .../OnXFlagUsage.java.messages | 12 ++++++------ .../SynchronizedInRecord.java.messages | 2 +- .../messages-delombok/ValErrors.java.messages | 4 ++-- .../ValInBasicFor.java.messages | 2 +- .../VarInForOldMulti.java.messages | 2 +- .../VarNullInit.java.messages | 2 +- .../messages-delombok/VarWarning.java.messages | 2 +- ...lsAndHashCodeOfAndExcludeWarn.java.messages | 4 ++-- ...perBuilderWithJsonDeserialize.java.messages | 2 +- .../NonNullOnParameter.java.messages | 6 +++--- .../messages-ecj/NonNullPlain.java.messages | 2 +- .../messages-ecj/OnXFlagUsage.java.messages | 12 ++++++------ .../LockedTypeMismatch.java.messages | 4 ++-- .../NonNullOnParameter.java.messages | 2 +- .../ValInvalidParameter.java.messages | 18 +++++++++--------- 24 files changed, 50 insertions(+), 51 deletions(-) diff --git a/test/core/src/lombok/CompilerMessageMatcher.java b/test/core/src/lombok/CompilerMessageMatcher.java index c00263f4f9..923b45e623 100644 --- a/test/core/src/lombok/CompilerMessageMatcher.java +++ b/test/core/src/lombok/CompilerMessageMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2013 The Project Lombok Authors. + * Copyright (C) 2012-2024 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 @@ -67,8 +67,7 @@ public static CompilerMessageMatcher asCompilerMessageMatcher(CompilerMessage me public boolean matches(CompilerMessage message) { outer: for (int i = 0; i < lineNumbers.size(); i++) { - //Allow an off-by-1 in line numbers; when running tests that sometimes happens for as yet unknown reasons. - if (message.getLine() != lineNumbers.get(i) && message.getLine() -1 != lineNumbers.get(i)) continue; + if (message.getLine() != lineNumbers.get(i)) continue; for (String token : messages.get(i)) { if (!message.getMessage().contains(token)) continue outer; } diff --git a/test/transform/resource/messages-delombok/DelegateFlagUsage.java.messages b/test/transform/resource/messages-delombok/DelegateFlagUsage.java.messages index a6b786322e..54e48e664d 100644 --- a/test/transform/resource/messages-delombok/DelegateFlagUsage.java.messages +++ b/test/transform/resource/messages-delombok/DelegateFlagUsage.java.messages @@ -1 +1 @@ -4 Use of @Delegate is flagged according to lombok configuration. \ No newline at end of file +5 Use of @Delegate is flagged according to lombok configuration. diff --git a/test/transform/resource/messages-delombok/DelegateOnStatic.java.messages b/test/transform/resource/messages-delombok/DelegateOnStatic.java.messages index 51dcf5014e..45ae7c5750 100644 --- a/test/transform/resource/messages-delombok/DelegateOnStatic.java.messages +++ b/test/transform/resource/messages-delombok/DelegateOnStatic.java.messages @@ -1,2 +1,2 @@ -6 @Delegate is legal only on instance fields or no-argument instance methods. -10 @Delegate is legal only on instance fields or no-argument instance methods. \ No newline at end of file +7 @Delegate is legal only on instance fields or no-argument instance methods. +11 @Delegate is legal only on instance fields or no-argument instance methods. diff --git a/test/transform/resource/messages-delombok/DelegateRecursion.java.messages b/test/transform/resource/messages-delombok/DelegateRecursion.java.messages index bf4d84106e..b3179954f9 100644 --- a/test/transform/resource/messages-delombok/DelegateRecursion.java.messages +++ b/test/transform/resource/messages-delombok/DelegateRecursion.java.messages @@ -1 +1 @@ -4 @Delegate does not support recursion (delegating to a type that itself has @Delegate members). Member "inner" is @Delegate in type "DelegateRecursionCenter" +5 @Delegate does not support recursion (delegating to a type that itself has @Delegate members). Member "inner" is @Delegate in type "DelegateRecursionCenter" diff --git a/test/transform/resource/messages-delombok/EqualsAndHashCodeOfAndExcludeWarn.java.messages b/test/transform/resource/messages-delombok/EqualsAndHashCodeOfAndExcludeWarn.java.messages index 2c4fbd68ba..706282f906 100644 --- a/test/transform/resource/messages-delombok/EqualsAndHashCodeOfAndExcludeWarn.java.messages +++ b/test/transform/resource/messages-delombok/EqualsAndHashCodeOfAndExcludeWarn.java.messages @@ -1,2 +1,2 @@ -1 This field does not exist. -6 This field does not exist, or would have been excluded anyway. \ No newline at end of file +2 This field does not exist. +7 This field does not exist, or would have been excluded anyway. diff --git a/test/transform/resource/messages-delombok/ExtensionMethodAmbiguousFunctional.java.messages b/test/transform/resource/messages-delombok/ExtensionMethodAmbiguousFunctional.java.messages index 9fa3414f76..0b22d4046c 100644 --- a/test/transform/resource/messages-delombok/ExtensionMethodAmbiguousFunctional.java.messages +++ b/test/transform/resource/messages-delombok/ExtensionMethodAmbiguousFunctional.java.messages @@ -1 +1 @@ -9 reference to ambiguous is ambiguous both method ambiguous(T,java.util.function.Function) in ExtensionMethodAmbiguousFunctional.Extensions and method ambiguous(T,java.util.function.Consumer) in ExtensionMethodAmbiguousFunctional.Extensions match +10 reference to ambiguous is ambiguous both method ambiguous(T,java.util.function.Function) in ExtensionMethodAmbiguousFunctional.Extensions and method ambiguous(T,java.util.function.Consumer) in ExtensionMethodAmbiguousFunctional.Extensions match diff --git a/test/transform/resource/messages-delombok/JacksonizedSuperBuilderWithJsonDeserialize.java.messages b/test/transform/resource/messages-delombok/JacksonizedSuperBuilderWithJsonDeserialize.java.messages index 5c69304fed..1947a26ee6 100644 --- a/test/transform/resource/messages-delombok/JacksonizedSuperBuilderWithJsonDeserialize.java.messages +++ b/test/transform/resource/messages-delombok/JacksonizedSuperBuilderWithJsonDeserialize.java.messages @@ -1 +1 @@ -1 @JsonDeserialize already exists on class. Either delete @JsonDeserialize, or remove @Jacksonized and manually configure Jackson. \ No newline at end of file +2 @JsonDeserialize already exists on class. Either delete @JsonDeserialize, or remove @Jacksonized and manually configure Jackson. diff --git a/test/transform/resource/messages-delombok/LockedInRecord.java.messages b/test/transform/resource/messages-delombok/LockedInRecord.java.messages index 0165764d47..1e921a76e2 100644 --- a/test/transform/resource/messages-delombok/LockedInRecord.java.messages +++ b/test/transform/resource/messages-delombok/LockedInRecord.java.messages @@ -1 +1 @@ -5 @Locked is legal only on methods in classes and enums. +6 @Locked is legal only on methods in classes and enums. diff --git a/test/transform/resource/messages-delombok/NonNullOnParameter.java.messages b/test/transform/resource/messages-delombok/NonNullOnParameter.java.messages index 042c97f856..0fe49dadbe 100644 --- a/test/transform/resource/messages-delombok/NonNullOnParameter.java.messages +++ b/test/transform/resource/messages-delombok/NonNullOnParameter.java.messages @@ -1 +1 @@ -22 @NonNull is meaningless on a primitive. +23 @NonNull is meaningless on a primitive. diff --git a/test/transform/resource/messages-delombok/OnXFlagUsage.java.messages b/test/transform/resource/messages-delombok/OnXFlagUsage.java.messages index c4187b9fd0..fbb1ea2cd0 100644 --- a/test/transform/resource/messages-delombok/OnXFlagUsage.java.messages +++ b/test/transform/resource/messages-delombok/OnXFlagUsage.java.messages @@ -1,6 +1,6 @@ -9 Use of @Getter(onMethod=...) is flagged according to lombok configuration. -10 Use of @Setter(onMethod=...) is flagged according to lombok configuration. -10 Use of @Setter(onParam=...) is flagged according to lombok configuration. -11 Use of @NoArgsConstructor(onConstructor=...) is flagged according to lombok configuration. -12 Use of @AllArgsConstructor(onConstructor=...) is flagged according to lombok configuration. -18 Use of @RequiredArgsConstructor(onConstructor=...) is flagged according to lombok configuration. \ No newline at end of file +10 Use of @Getter(onMethod=...) is flagged according to lombok configuration. +11 Use of @Setter(onMethod=...) is flagged according to lombok configuration. +11 Use of @Setter(onParam=...) is flagged according to lombok configuration. +12 Use of @NoArgsConstructor(onConstructor=...) is flagged according to lombok configuration. +13 Use of @AllArgsConstructor(onConstructor=...) is flagged according to lombok configuration. +19 Use of @RequiredArgsConstructor(onConstructor=...) is flagged according to lombok configuration. diff --git a/test/transform/resource/messages-delombok/SynchronizedInRecord.java.messages b/test/transform/resource/messages-delombok/SynchronizedInRecord.java.messages index d40e68b309..af4b11f893 100644 --- a/test/transform/resource/messages-delombok/SynchronizedInRecord.java.messages +++ b/test/transform/resource/messages-delombok/SynchronizedInRecord.java.messages @@ -1 +1 @@ -5 @Synchronized is legal only on methods in classes and enums. +6 @Synchronized is legal only on methods in classes and enums. diff --git a/test/transform/resource/messages-delombok/ValErrors.java.messages b/test/transform/resource/messages-delombok/ValErrors.java.messages index 0777143b90..734d3a5a9b 100644 --- a/test/transform/resource/messages-delombok/ValErrors.java.messages +++ b/test/transform/resource/messages-delombok/ValErrors.java.messages @@ -1,2 +1,2 @@ -6 Cannot use 'val' here because initializer expression does not have a representable type: Type cannot be resolved -10 'val' is not compatible with array initializer expressions. Use the full form (new int[] { ... } instead of just { ... }) +7 Cannot use 'val' here because initializer expression does not have a representable type: Type cannot be resolved +11 'val' is not compatible with array initializer expressions. Use the full form (new int[] { ... } instead of just { ... }) diff --git a/test/transform/resource/messages-delombok/ValInBasicFor.java.messages b/test/transform/resource/messages-delombok/ValInBasicFor.java.messages index 60f8f70c44..334a2713ab 100644 --- a/test/transform/resource/messages-delombok/ValInBasicFor.java.messages +++ b/test/transform/resource/messages-delombok/ValInBasicFor.java.messages @@ -1 +1 @@ -7 'val' is not allowed in old-style for loops +8 'val' is not allowed in old-style for loops diff --git a/test/transform/resource/messages-delombok/VarInForOldMulti.java.messages b/test/transform/resource/messages-delombok/VarInForOldMulti.java.messages index f65fe8239c..917ca0a094 100644 --- a/test/transform/resource/messages-delombok/VarInForOldMulti.java.messages +++ b/test/transform/resource/messages-delombok/VarInForOldMulti.java.messages @@ -1 +1 @@ -6 'var' is not allowed in old-style for loops if there is more than 1 initializer +7 'var' is not allowed in old-style for loops if there is more than 1 initializer diff --git a/test/transform/resource/messages-delombok/VarNullInit.java.messages b/test/transform/resource/messages-delombok/VarNullInit.java.messages index 5a2a6ae11d..a82c77cfb2 100644 --- a/test/transform/resource/messages-delombok/VarNullInit.java.messages +++ b/test/transform/resource/messages-delombok/VarNullInit.java.messages @@ -1 +1 @@ -5 variable initializer is 'null' \ No newline at end of file +6 variable initializer is 'null' diff --git a/test/transform/resource/messages-delombok/VarWarning.java.messages b/test/transform/resource/messages-delombok/VarWarning.java.messages index 886e98f44e..fe6e79a290 100644 --- a/test/transform/resource/messages-delombok/VarWarning.java.messages +++ b/test/transform/resource/messages-delombok/VarWarning.java.messages @@ -1 +1 @@ -6 Use of var is flagged according to lombok configuration \ No newline at end of file +7 Use of var is flagged according to lombok configuration. diff --git a/test/transform/resource/messages-ecj/EqualsAndHashCodeOfAndExcludeWarn.java.messages b/test/transform/resource/messages-ecj/EqualsAndHashCodeOfAndExcludeWarn.java.messages index 2c4fbd68ba..706282f906 100644 --- a/test/transform/resource/messages-ecj/EqualsAndHashCodeOfAndExcludeWarn.java.messages +++ b/test/transform/resource/messages-ecj/EqualsAndHashCodeOfAndExcludeWarn.java.messages @@ -1,2 +1,2 @@ -1 This field does not exist. -6 This field does not exist, or would have been excluded anyway. \ No newline at end of file +2 This field does not exist. +7 This field does not exist, or would have been excluded anyway. diff --git a/test/transform/resource/messages-ecj/JacksonizedSuperBuilderWithJsonDeserialize.java.messages b/test/transform/resource/messages-ecj/JacksonizedSuperBuilderWithJsonDeserialize.java.messages index 5c69304fed..1947a26ee6 100644 --- a/test/transform/resource/messages-ecj/JacksonizedSuperBuilderWithJsonDeserialize.java.messages +++ b/test/transform/resource/messages-ecj/JacksonizedSuperBuilderWithJsonDeserialize.java.messages @@ -1 +1 @@ -1 @JsonDeserialize already exists on class. Either delete @JsonDeserialize, or remove @Jacksonized and manually configure Jackson. \ No newline at end of file +2 @JsonDeserialize already exists on class. Either delete @JsonDeserialize, or remove @Jacksonized and manually configure Jackson. diff --git a/test/transform/resource/messages-ecj/NonNullOnParameter.java.messages b/test/transform/resource/messages-ecj/NonNullOnParameter.java.messages index 4b7d18b3fd..b4cf664e5b 100644 --- a/test/transform/resource/messages-ecj/NonNullOnParameter.java.messages +++ b/test/transform/resource/messages-ecj/NonNullOnParameter.java.messages @@ -1,3 +1,3 @@ -15 Dead code -22 @NonNull is meaningless on a primitive. -28 Dead code \ No newline at end of file +16 Dead code +23 @NonNull is meaningless on a primitive. +29 Dead code diff --git a/test/transform/resource/messages-ecj/NonNullPlain.java.messages b/test/transform/resource/messages-ecj/NonNullPlain.java.messages index 1c33c7018d..f6709a64dc 100644 --- a/test/transform/resource/messages-ecj/NonNullPlain.java.messages +++ b/test/transform/resource/messages-ecj/NonNullPlain.java.messages @@ -1 +1 @@ -7 @NonNull is meaningless on a primitive. \ No newline at end of file +8 @NonNull is meaningless on a primitive. diff --git a/test/transform/resource/messages-ecj/OnXFlagUsage.java.messages b/test/transform/resource/messages-ecj/OnXFlagUsage.java.messages index c4187b9fd0..fbb1ea2cd0 100644 --- a/test/transform/resource/messages-ecj/OnXFlagUsage.java.messages +++ b/test/transform/resource/messages-ecj/OnXFlagUsage.java.messages @@ -1,6 +1,6 @@ -9 Use of @Getter(onMethod=...) is flagged according to lombok configuration. -10 Use of @Setter(onMethod=...) is flagged according to lombok configuration. -10 Use of @Setter(onParam=...) is flagged according to lombok configuration. -11 Use of @NoArgsConstructor(onConstructor=...) is flagged according to lombok configuration. -12 Use of @AllArgsConstructor(onConstructor=...) is flagged according to lombok configuration. -18 Use of @RequiredArgsConstructor(onConstructor=...) is flagged according to lombok configuration. \ No newline at end of file +10 Use of @Getter(onMethod=...) is flagged according to lombok configuration. +11 Use of @Setter(onMethod=...) is flagged according to lombok configuration. +11 Use of @Setter(onParam=...) is flagged according to lombok configuration. +12 Use of @NoArgsConstructor(onConstructor=...) is flagged according to lombok configuration. +13 Use of @AllArgsConstructor(onConstructor=...) is flagged according to lombok configuration. +19 Use of @RequiredArgsConstructor(onConstructor=...) is flagged according to lombok configuration. diff --git a/test/transform/resource/messages-idempotent/LockedTypeMismatch.java.messages b/test/transform/resource/messages-idempotent/LockedTypeMismatch.java.messages index 195f1466b4..f5819b1ac0 100644 --- a/test/transform/resource/messages-idempotent/LockedTypeMismatch.java.messages +++ b/test/transform/resource/messages-idempotent/LockedTypeMismatch.java.messages @@ -1,2 +1,2 @@ -27 cannot find symbol -31 cannot find symbol +28 cannot find symbol method readLock() location: java.util.concurrent.locks.Lock +32 cannot find symbol method readLock() location: java.util.concurrent.locks.Lock diff --git a/test/transform/resource/messages-idempotent/NonNullOnParameter.java.messages b/test/transform/resource/messages-idempotent/NonNullOnParameter.java.messages index 57556bf3d4..e2a9b468a3 100644 --- a/test/transform/resource/messages-idempotent/NonNullOnParameter.java.messages +++ b/test/transform/resource/messages-idempotent/NonNullOnParameter.java.messages @@ -1 +1 @@ -33 @NonNull is meaningless on a primitive. \ No newline at end of file +34 @NonNull is meaningless on a primitive. diff --git a/test/transform/resource/messages-idempotent/ValInvalidParameter.java.messages b/test/transform/resource/messages-idempotent/ValInvalidParameter.java.messages index 539d29cdf8..8fea4d3646 100644 --- a/test/transform/resource/messages-idempotent/ValInvalidParameter.java.messages +++ b/test/transform/resource/messages-idempotent/ValInvalidParameter.java.messages @@ -1,9 +1,9 @@ -3 cannot find symbol -4 cannot find symbol -5 cannot find symbol -6 cannot find symbol -7 cannot find symbol -8 cannot find symbol -9 method b2 in class ValInvalidParameter cannot be applied to given types; -10 reference to a is ambiguous -11 reference to a is ambiguous \ No newline at end of file +4 cannot find symbol symbol: class NonExistingClass location: class ValInvalidParameter +5 cannot find symbol symbol: class NonExistingClass location: class ValInvalidParameter +6 cannot find symbol symbol: method nonExisitingMethod(java.lang.Integer) location: class ValInvalidParameter +7 cannot find symbol symbol: variable nonExistingObject location: class ValInvalidParameter +8 cannot find symbol symbol: method nonExistingMethod() location: class java.lang.Integer +9 cannot find symbol symbol: class NonExistingClass location: class ValInvalidParameter +10 method b2 in class ValInvalidParameter cannot be applied to given types; required: int,int found: int reason: actual and formal argument lists differ in length +11 reference to a is ambiguous both method a(java.lang.String) in ValInvalidParameter and method a(java.lang.Integer) in ValInvalidParameter match +12 reference to a is ambiguous both method a(java.lang.String) in ValInvalidParameter and method a(java.lang.Integer) in ValInvalidParameter match From 4aa58fb21101b6643af477151b35842fffcb70cd Mon Sep 17 00:00:00 2001 From: Rawi01 Date: Mon, 14 Oct 2024 22:43:20 +0200 Subject: [PATCH 2/3] Update ecj message line numbers --- .../messages-ecj/DelegateFlagUsage.java.messages | 2 +- .../messages-ecj/DelegateOnGetter.java.messages | 4 ++-- .../messages-ecj/DelegateOnStatic.java.messages | 4 ++-- .../messages-ecj/DelegateRecursion.java.messages | 2 +- ...alAnonymousSubclassWithGenerics.java.messages | 2 +- .../ValInvalidParameter.java.messages | 16 ++++++++-------- .../messages-ecj/ValLambda.java.messages | 4 ++-- .../messages-ecj/ValRawType.java.messages | 2 +- .../messages-ecj/VarInForOldMulti.java.messages | 2 +- .../messages-ecj/VarModifier.java.messages | 4 ++-- .../messages-ecj/VarNullInit.java.messages | 2 +- .../messages-ecj/VarWarning.java.messages | 2 +- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/test/transform/resource/messages-ecj/DelegateFlagUsage.java.messages b/test/transform/resource/messages-ecj/DelegateFlagUsage.java.messages index 6c8f693e6e..54e48e664d 100644 --- a/test/transform/resource/messages-ecj/DelegateFlagUsage.java.messages +++ b/test/transform/resource/messages-ecj/DelegateFlagUsage.java.messages @@ -1 +1 @@ -4 Use of @Delegate is flagged according to lombok configuration. +5 Use of @Delegate is flagged according to lombok configuration. diff --git a/test/transform/resource/messages-ecj/DelegateOnGetter.java.messages b/test/transform/resource/messages-ecj/DelegateOnGetter.java.messages index 16453094cb..ef40527b25 100644 --- a/test/transform/resource/messages-ecj/DelegateOnGetter.java.messages +++ b/test/transform/resource/messages-ecj/DelegateOnGetter.java.messages @@ -1,2 +1,2 @@ -1 The type Delegate is deprecated -6 The type Delegate is deprecated +2 The type Delegate is deprecated +7 The type Delegate is deprecated diff --git a/test/transform/resource/messages-ecj/DelegateOnStatic.java.messages b/test/transform/resource/messages-ecj/DelegateOnStatic.java.messages index 51dcf5014e..45ae7c5750 100644 --- a/test/transform/resource/messages-ecj/DelegateOnStatic.java.messages +++ b/test/transform/resource/messages-ecj/DelegateOnStatic.java.messages @@ -1,2 +1,2 @@ -6 @Delegate is legal only on instance fields or no-argument instance methods. -10 @Delegate is legal only on instance fields or no-argument instance methods. \ No newline at end of file +7 @Delegate is legal only on instance fields or no-argument instance methods. +11 @Delegate is legal only on instance fields or no-argument instance methods. diff --git a/test/transform/resource/messages-ecj/DelegateRecursion.java.messages b/test/transform/resource/messages-ecj/DelegateRecursion.java.messages index bf4d84106e..b3179954f9 100644 --- a/test/transform/resource/messages-ecj/DelegateRecursion.java.messages +++ b/test/transform/resource/messages-ecj/DelegateRecursion.java.messages @@ -1 +1 @@ -4 @Delegate does not support recursion (delegating to a type that itself has @Delegate members). Member "inner" is @Delegate in type "DelegateRecursionCenter" +5 @Delegate does not support recursion (delegating to a type that itself has @Delegate members). Member "inner" is @Delegate in type "DelegateRecursionCenter" diff --git a/test/transform/resource/messages-ecj/ValAnonymousSubclassWithGenerics.java.messages b/test/transform/resource/messages-ecj/ValAnonymousSubclassWithGenerics.java.messages index 37f876391c..a70f61bf29 100644 --- a/test/transform/resource/messages-ecj/ValAnonymousSubclassWithGenerics.java.messages +++ b/test/transform/resource/messages-ecj/ValAnonymousSubclassWithGenerics.java.messages @@ -1 +1 @@ -17 The serializable class does not declare a static final serialVersionUID field of type long \ No newline at end of file +18 The serializable class does not declare a static final serialVersionUID field of type long diff --git a/test/transform/resource/messages-ecj/ValInvalidParameter.java.messages b/test/transform/resource/messages-ecj/ValInvalidParameter.java.messages index cbf2d7c4e6..6758e11973 100644 --- a/test/transform/resource/messages-ecj/ValInvalidParameter.java.messages +++ b/test/transform/resource/messages-ecj/ValInvalidParameter.java.messages @@ -1,9 +1,9 @@ -5 NonExistingClass cannot be resolved to a type 6 NonExistingClass cannot be resolved to a type -7 The method nonExisitingMethod(Integer) is undefined for the type ValInvalidParameter -8 nonExistingObject cannot be resolved -9 The method nonExistingMethod() is undefined for the type Integer -10 NonExistingClass cannot be resolved to a type -11 The method b2(int, int) in the type ValInvalidParameter is not applicable for the arguments (int) -12 The method a(String) is ambiguous for the type ValInvalidParameter -13 The method a(String) is ambiguous for the type ValInvalidParameter \ No newline at end of file +7 NonExistingClass cannot be resolved to a type +8 The method nonExisitingMethod(Integer) is undefined for the type ValInvalidParameter +9 nonExistingObject cannot be resolved +10 The method nonExistingMethod() is undefined for the type Integer +11 NonExistingClass cannot be resolved to a type +12 The method b2(int, int) in the type ValInvalidParameter is not applicable for the arguments (int) +13 The method a(String) is ambiguous for the type ValInvalidParameter +14 The method a(String) is ambiguous for the type ValInvalidParameter diff --git a/test/transform/resource/messages-ecj/ValLambda.java.messages b/test/transform/resource/messages-ecj/ValLambda.java.messages index fa7231efed..6bfb52d952 100644 --- a/test/transform/resource/messages-ecj/ValLambda.java.messages +++ b/test/transform/resource/messages-ecj/ValLambda.java.messages @@ -1,2 +1,2 @@ -24 Function is a raw type. References to generic type Function should be parameterized -25 Function is a raw type. References to generic type Function should be parameterized \ No newline at end of file +25 Function is a raw type. References to generic type Function should be parameterized +26 Function is a raw type. References to generic type Function should be parameterized diff --git a/test/transform/resource/messages-ecj/ValRawType.java.messages b/test/transform/resource/messages-ecj/ValRawType.java.messages index 2a1fbba647..95fef20373 100644 --- a/test/transform/resource/messages-ecj/ValRawType.java.messages +++ b/test/transform/resource/messages-ecj/ValRawType.java.messages @@ -1 +1 @@ -13 List is a raw type. References to generic type List should be parameterized +14 List is a raw type. References to generic type List should be parameterized diff --git a/test/transform/resource/messages-ecj/VarInForOldMulti.java.messages b/test/transform/resource/messages-ecj/VarInForOldMulti.java.messages index 0bfd6e65a9..917ca0a094 100644 --- a/test/transform/resource/messages-ecj/VarInForOldMulti.java.messages +++ b/test/transform/resource/messages-ecj/VarInForOldMulti.java.messages @@ -1 +1 @@ -6 'var' is not allowed in old-style for loops if there is more than 1 initializer \ No newline at end of file +7 'var' is not allowed in old-style for loops if there is more than 1 initializer diff --git a/test/transform/resource/messages-ecj/VarModifier.java.messages b/test/transform/resource/messages-ecj/VarModifier.java.messages index 051d1ad708..1931c2cdc1 100644 --- a/test/transform/resource/messages-ecj/VarModifier.java.messages +++ b/test/transform/resource/messages-ecj/VarModifier.java.messages @@ -1,3 +1,3 @@ -1 The type var is deprecated -7 The type var is deprecated +2 The type var is deprecated 8 The type var is deprecated +9 The type var is deprecated diff --git a/test/transform/resource/messages-ecj/VarNullInit.java.messages b/test/transform/resource/messages-ecj/VarNullInit.java.messages index 5a2a6ae11d..a82c77cfb2 100644 --- a/test/transform/resource/messages-ecj/VarNullInit.java.messages +++ b/test/transform/resource/messages-ecj/VarNullInit.java.messages @@ -1 +1 @@ -5 variable initializer is 'null' \ No newline at end of file +6 variable initializer is 'null' diff --git a/test/transform/resource/messages-ecj/VarWarning.java.messages b/test/transform/resource/messages-ecj/VarWarning.java.messages index 25096b845e..fe6e79a290 100644 --- a/test/transform/resource/messages-ecj/VarWarning.java.messages +++ b/test/transform/resource/messages-ecj/VarWarning.java.messages @@ -1 +1 @@ -6 Use of var is flagged according to lombok configuration. \ No newline at end of file +7 Use of var is flagged according to lombok configuration. From 5caea325100c2b76dee6a5d63c1328523a9da671 Mon Sep 17 00:00:00 2001 From: Rawi01 Date: Sat, 19 Oct 2024 11:49:29 +0200 Subject: [PATCH 3/3] [fixes #3761] Update annotation value index --- src/core/lombok/core/AnnotationValues.java | 3 ++- test/core/src/lombok/CompilerMessageMatcher.java | 12 +++++++++--- .../before/EqualsAndHashCodeOfAndExcludeError.java | 14 ++++++++++++++ ...qualsAndHashCodeOfAndExcludeError.java.messages | 2 ++ ...qualsAndHashCodeOfAndExcludeError.java.messages | 2 ++ 5 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 test/transform/resource/before/EqualsAndHashCodeOfAndExcludeError.java create mode 100644 test/transform/resource/messages-delombok/EqualsAndHashCodeOfAndExcludeError.java.messages create mode 100644 test/transform/resource/messages-ecj/EqualsAndHashCodeOfAndExcludeError.java.messages diff --git a/src/core/lombok/core/AnnotationValues.java b/src/core/lombok/core/AnnotationValues.java index 390e9b71b3..19026ca51a 100644 --- a/src/core/lombok/core/AnnotationValues.java +++ b/src/core/lombok/core/AnnotationValues.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2022 The Project Lombok Authors. + * Copyright (C) 2009-2024 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 @@ -182,6 +182,7 @@ public List getAsStringList(String methodName) { "I can't make sense of this annotation value. Try using a fully qualified literal.", idx); } out.add((String) result); + idx++; } return Collections.unmodifiableList(out); diff --git a/test/core/src/lombok/CompilerMessageMatcher.java b/test/core/src/lombok/CompilerMessageMatcher.java index 923b45e623..76eb2ee92c 100644 --- a/test/core/src/lombok/CompilerMessageMatcher.java +++ b/test/core/src/lombok/CompilerMessageMatcher.java @@ -36,6 +36,7 @@ public class CompilerMessageMatcher { /** Line Number (starting at 1) */ private final List lineNumbers = new ArrayList(); + private final List positions = new ArrayList(); private final List> messages = new ArrayList>(); private boolean optional; @@ -48,6 +49,7 @@ public boolean isOptional() { public static CompilerMessageMatcher asCompilerMessageMatcher(CompilerMessage message) { CompilerMessageMatcher cmm = new CompilerMessageMatcher(); cmm.lineNumbers.add((int) message.getLine()); + cmm.positions.add(message.getPosition()); cmm.messages.add(Arrays.asList(message.getMessage().split("\\s+"))); return cmm; } @@ -55,7 +57,9 @@ public static CompilerMessageMatcher asCompilerMessageMatcher(CompilerMessage me @Override public String toString() { StringBuilder out = new StringBuilder(); for (int i = 0; i < lineNumbers.size(); i++) { - out.append(lineNumbers.get(i)).append(" "); + out.append(lineNumbers.get(i)); + if (positions.get(i) != null) out.append(":").append(positions.get(i)); + out.append(" "); for (String part : messages.get(i)) out.append(part).append(" "); if (out.length() > 0) out.setLength(out.length() - 1); out.append(" |||| "); @@ -68,6 +72,7 @@ public boolean matches(CompilerMessage message) { outer: for (int i = 0; i < lineNumbers.size(); i++) { if (message.getLine() != lineNumbers.get(i)) continue; + if (positions.get(i) != null && !positions.get(i).equals(message.getPosition())) continue; for (String token : messages.get(i)) { if (!message.getMessage().contains(token)) continue outer; } @@ -87,7 +92,7 @@ public static List readAll(InputStream rawIn) throws IOE return out; } - private static final Pattern PATTERN = Pattern.compile("^(-?\\d+) (.*)$"); + private static final Pattern PATTERN = Pattern.compile("^(-?\\d+)(?::(\\d+))? (.*)$"); private static CompilerMessageMatcher read(String line) { line = line.trim(); @@ -107,7 +112,8 @@ private static CompilerMessageMatcher read(String line) { Matcher m = PATTERN.matcher(part); if (!m.matches()) throw new IllegalArgumentException("Typo in test file: " + line); cmm.lineNumbers.add(Integer.parseInt(m.group(1))); - cmm.messages.add(Arrays.asList(m.group(2).split("\\s+"))); + cmm.positions.add(m.group(2) != null ? Long.parseLong(m.group(2)) : null); + cmm.messages.add(Arrays.asList(m.group(3).split("\\s+"))); } return cmm; diff --git a/test/transform/resource/before/EqualsAndHashCodeOfAndExcludeError.java b/test/transform/resource/before/EqualsAndHashCodeOfAndExcludeError.java new file mode 100644 index 0000000000..cbfb135568 --- /dev/null +++ b/test/transform/resource/before/EqualsAndHashCodeOfAndExcludeError.java @@ -0,0 +1,14 @@ +// skip-compare-contents +@lombok.EqualsAndHashCode(of={"x", Const.A}) +final class EqualsAndHashCodeErrorOf { + int x; +} + +@lombok.EqualsAndHashCode(exclude={"x", Const.A}) +final class EqualsAndHashCodeErrorExclude { + int x; +} + +class Const { + static final String A = "A"; +} \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/EqualsAndHashCodeOfAndExcludeError.java.messages b/test/transform/resource/messages-delombok/EqualsAndHashCodeOfAndExcludeError.java.messages new file mode 100644 index 0000000000..18e7a32b49 --- /dev/null +++ b/test/transform/resource/messages-delombok/EqualsAndHashCodeOfAndExcludeError.java.messages @@ -0,0 +1,2 @@ +2:60 You must use constant literals in lombok annotations; they cannot be references to (static) fields. +7:160 You must use constant literals in lombok annotations; they cannot be references to (static) fields. \ No newline at end of file diff --git a/test/transform/resource/messages-ecj/EqualsAndHashCodeOfAndExcludeError.java.messages b/test/transform/resource/messages-ecj/EqualsAndHashCodeOfAndExcludeError.java.messages new file mode 100644 index 0000000000..18e7a32b49 --- /dev/null +++ b/test/transform/resource/messages-ecj/EqualsAndHashCodeOfAndExcludeError.java.messages @@ -0,0 +1,2 @@ +2:60 You must use constant literals in lombok annotations; they cannot be references to (static) fields. +7:160 You must use constant literals in lombok annotations; they cannot be references to (static) fields. \ No newline at end of file