aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorRawi01 <Rawi01@users.noreply.github.com>2020-12-23 09:45:14 +0100
committerRawi01 <Rawi01@users.noreply.github.com>2020-12-23 09:45:14 +0100
commite131cf6b42add619b88fe60c2bff143b5276d55a (patch)
tree1622bbb376e8d9f667e9575b7e3d0395c0587c73 /src/core
parent8ba5df7161f7a6ef24b67d783f3a4fd6c2359fee (diff)
downloadlombok-e131cf6b42add619b88fe60c2bff143b5276d55a.tar.gz
lombok-e131cf6b42add619b88fe60c2bff143b5276d55a.tar.bz2
lombok-e131cf6b42add619b88fe60c2bff143b5276d55a.zip
[refactor] Replace duplicate code with new method, add null check
Diffstat (limited to 'src/core')
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index 5da7abfd..62c71f5b 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -292,9 +292,7 @@ public class EclipseHandlerUtil {
MarkerAnnotation ann = new MarkerAnnotation(copyType(annotation.type, source), pS);
setGeneratedBy(ann, source);
ann.declarationSourceEnd = ann.sourceEnd = ann.statementEnd = pE;
- try {
- reflectSet(ANNOTATION__MEMBER_VALUE_PAIR_NAME, ann, reflect(ANNOTATION__MEMBER_VALUE_PAIR_NAME, annotation));
- } catch (Exception ignore) { /* Various eclipse versions don't have it */ }
+ copyMemberValuePairName(ann, annotation);
return ann;
}
@@ -303,9 +301,7 @@ public class EclipseHandlerUtil {
setGeneratedBy(ann, source);
ann.declarationSourceEnd = ann.sourceEnd = ann.statementEnd = pE;
ann.memberValue = copyAnnotationMemberValue(((SingleMemberAnnotation) annotation).memberValue);
- try {
- reflectSet(ANNOTATION__MEMBER_VALUE_PAIR_NAME, ann, reflect(ANNOTATION__MEMBER_VALUE_PAIR_NAME, annotation));
- } catch (Exception ignore) { /* Various eclipse versions don't have it */ }
+ copyMemberValuePairName(ann, annotation);
return ann;
}
@@ -321,15 +317,21 @@ public class EclipseHandlerUtil {
for (int i = 0; i < inPairs.length; i++) ann.memberValuePairs[i] =
new MemberValuePair(inPairs[i].name, inPairs[i].sourceStart, inPairs[i].sourceEnd, copyAnnotationMemberValue(inPairs[i].value));
}
- try {
- reflectSet(ANNOTATION__MEMBER_VALUE_PAIR_NAME, ann, reflect(ANNOTATION__MEMBER_VALUE_PAIR_NAME, annotation));
- } catch (Exception ignore) { /* Various eclipse versions don't have it */ }
+ copyMemberValuePairName(ann, annotation);
return ann;
}
return annotation;
}
+ private static void copyMemberValuePairName(Annotation source, Annotation target) {
+ if (ANNOTATION__MEMBER_VALUE_PAIR_NAME == null) return;
+
+ try {
+ reflectSet(ANNOTATION__MEMBER_VALUE_PAIR_NAME, source, reflect(ANNOTATION__MEMBER_VALUE_PAIR_NAME, target));
+ } catch (Exception ignore) { /* Various eclipse versions don't have it */ }
+ }
+
static class EclipseReflectiveMembers {
public static final Field STRING_LITERAL__LINE_NUMBER;
public static final Field ANNOTATION__MEMBER_VALUE_PAIR_NAME;