Skip to content

Commit 57a9168

Browse files
eclipse-pde-botlaeubi
authored andcommitted
Perform clean code of ds/org.eclipse.pde.ds.annotations
1 parent 52a17fb commit 57a9168

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/AnnotationVisitor.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,10 @@ public boolean visit(AnnotationTypeDeclaration node) {
316316

317317
private Annotation findComponentAnnotation(AbstractTypeDeclaration type) {
318318
for (Object item : type.modifiers()) {
319-
if (!(item instanceof Annotation)) {
319+
if (!(item instanceof Annotation annotation)) {
320320
continue;
321321
}
322322

323-
Annotation annotation = (Annotation) item;
324323
IAnnotationBinding annotationBinding = annotation.resolveAnnotationBinding();
325324
if (annotationBinding == null) {
326325
if (debug.isDebugging()) {
@@ -670,8 +669,7 @@ private void processComponent(IDSModel model, TypeDeclaration type, ITypeBinding
670669
configPid = (String) value;
671670
validateComponentConfigPID(annotation, configPid, -1);
672671
requiredVersion = DSAnnotationVersion.V1_2;
673-
} else if (DSAnnotationVersion.V1_3.isEqualOrHigherThan(specVersion) && value instanceof Object[]) {
674-
Object[] configPidElems = (Object[]) value;
672+
} else if (DSAnnotationVersion.V1_3.isEqualOrHigherThan(specVersion) && value instanceof Object[] configPidElems) {
675673
if (configPidElems.length > 0) {
676674
LinkedHashSet<String> configPids = new LinkedHashSet<>(configPidElems.length);
677675
HashMap<String, Integer> pidDuplicates = errorLevel.isIgnore() ? null : new HashMap<>(configPidElems.length);
@@ -901,11 +899,10 @@ private void processComponent(IDSModel model, TypeDeclaration type, ITypeBinding
901899
if (DSAnnotationVersion.V1_3.isEqualOrHigherThan(specVersion)) {
902900
for (FieldDeclaration field : type.getFields()) {
903901
for (Object modifier : field.modifiers()) {
904-
if (!(modifier instanceof Annotation)) {
902+
if (!(modifier instanceof Annotation fieldAnnotation)) {
905903
continue;
906904
}
907905

908-
Annotation fieldAnnotation = (Annotation) modifier;
909906
IAnnotationBinding fieldAnnotationBinding = fieldAnnotation.resolveAnnotationBinding();
910907
if (fieldAnnotationBinding == null) {
911908
if (debug.isDebugging()) {
@@ -1006,11 +1003,10 @@ private void processComponent(IDSModel model, TypeDeclaration type, ITypeBinding
10061003

10071004
for (MethodDeclaration method : type.getMethods()) {
10081005
for (Object modifier : method.modifiers()) {
1009-
if (!(modifier instanceof Annotation)) {
1006+
if (!(modifier instanceof Annotation methodAnnotation)) {
10101007
continue;
10111008
}
10121009

1013-
Annotation methodAnnotation = (Annotation) modifier;
10141010
IAnnotationBinding methodAnnotationBinding = methodAnnotation.resolveAnnotationBinding();
10151011
if (methodAnnotationBinding == null) {
10161012
if (debug.isDebugging()) {
@@ -1564,8 +1560,7 @@ private <T extends IDSSingleProperty> void updateProperties(IDSModel model, Type
15641560
private String[] collectProperties(String key, Map<String, ?> params) {
15651561
Object value = params.get(key);
15661562
String[] properties;
1567-
if (value instanceof Object[]) { // $NON-NLS-1$
1568-
Object[] elements = (Object[]) value;
1563+
if (value instanceof Object[] elements) { // $NON-NLS-1$
15691564
ArrayList<String> list = new ArrayList<>(elements.length);
15701565
for (Object element : elements) {
15711566
if (element instanceof String) {
@@ -1624,8 +1619,7 @@ private String[] collectPropertiesFiles(String key, ITypeBinding typeBinding, An
16241619
Map<String, ?> params) {
16251620
Object value = params.get(key);
16261621
String[] propertyFiles;
1627-
if (value instanceof Object[]) { // $NON-NLS-1$
1628-
Object[] elements = (Object[]) value;
1622+
if (value instanceof Object[] elements) { // $NON-NLS-1$
16291623
ArrayList<String> list = new ArrayList<>(elements.length);
16301624
for (Object element : elements) {
16311625
if (element instanceof String) {

ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/ProblemReporter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ public void reportProblem(Annotation annotation, String member, int valueIndex,
7373
int start = element.getStartPosition();
7474
int length = element.getLength();
7575

76-
if (valueIndex >= 0 && element instanceof ArrayInitializer) {
77-
ArrayInitializer ai = (ArrayInitializer) element;
76+
if (valueIndex >= 0 && element instanceof ArrayInitializer ai) {
7877
if (valueIndex < ai.expressions().size()) {
7978
Expression expression = (Expression) ai.expressions().get(valueIndex);
8079
start = expression.getStartPosition();

0 commit comments

Comments
 (0)