mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-11 03:13:38 +00:00
Merge pull request #2685 from Rawi01/copy-name-npe
Replace duplicate code with new method, add null check
This commit is contained in:
1 file changed
+11
-9
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user