Skip to content

Commit 53e6a4d

Browse files
authored
Fix redundant cast, deprecation warnings and such (#1115)
1 parent 79932cb commit 53e6a4d

19 files changed

Lines changed: 46 additions & 49 deletions

File tree

org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/inherited/ArgsConstructorProcessor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2021 IBM Corporation and others.
2+
* Copyright (c) 2011, 2023 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -162,7 +162,9 @@ private boolean doesClassContainArgsConstructor(Element el,
162162
}
163163
return false;
164164
}
165-
165+
/**
166+
* @deprecated
167+
*/
166168
private final TypeVisitor<Boolean, List<TypeMirror>> argsVisitor = new SimpleTypeVisitor6<Boolean, List<TypeMirror>>() {
167169
@Override
168170
public Boolean visitExecutable(ExecutableType t,

org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/visitors/VisitorProc.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2007, 2021 BEA Systems, Inc and others.
2+
* Copyright (c) 2007, 2023 BEA Systems, Inc and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -50,6 +50,7 @@ public class VisitorProc extends BaseProcessor
5050
/**
5151
* This visitor is invoked on the top-level types in resources/targets/model.
5252
* We expect to see each of the visitX() methods get hit as a result.
53+
* @deprecated
5354
*/
5455
private static class ElementVisitorTester extends ElementScanner6<Void, Void> {
5556

@@ -130,8 +131,9 @@ public Void visitUnknown(Element e, Void p) {
130131

131132
}
132133

133-
/*
134+
/**
134135
* The specific values checked by this visitor correspond to values in targets.model.pc.TypedAnnos.java
136+
* @deprecated
135137
*/
136138
private static class AnnotationVisitorTester extends AbstractAnnotationValueVisitor6<Void, Void> {
137139

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/AnnotationDiscoveryVisitor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2006, 2020 IBM Corporation and others.
2+
* Copyright (c) 2006, 2023 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -279,8 +279,7 @@ private void resolveAnnotations(BlockScope scope, Annotation[] annotations, Bind
279279
AnnotationBinding [] annotationBindings = element.getPackedAnnotationBindings(); // discovery is never in terms of repeating annotation.
280280
for (AnnotationBinding binding : annotationBindings) {
281281
ReferenceBinding annotationType = binding.getAnnotationType();
282-
if (binding != null
283-
&& Annotation.isAnnotationTargetAllowed(scope, annotationType, currentBinding)
282+
if (Annotation.isAnnotationTargetAllowed(scope, annotationType, currentBinding)
284283
) { // binding should be resolved, but in case it's not, ignore it: it could have been wrapped into a container.
285284
TypeElement anno = (TypeElement)this._factory.newElement(annotationType);
286285
this._annoToElement.put(anno, element);

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchProcessingEnvImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2006, 2015 BEA Systems, Inc.
2+
* Copyright (c) 2006, 2023 BEA Systems, Inc.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -81,7 +81,7 @@ public BatchProcessingEnvImpl(BaseAnnotationProcessorManager dispatchManager, Ma
8181
if (javaFileManager != null) {
8282
this._fileManager = javaFileManager;
8383
} else {
84-
String encoding = (String) batchCompiler.options.get(CompilerOptions.OPTION_Encoding);
84+
String encoding = batchCompiler.options.get(CompilerOptions.OPTION_Encoding);
8585
Charset charset = encoding != null ? Charset.forName(encoding) : null;
8686
JavaFileManager manager = new EclipseFileManager(batchCompiler.compilerLocale, charset);
8787
ArrayList<String> options = new ArrayList<>();

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/dispatch/HookedJavaFileObject.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2006, 2014 BEA Systems, Inc. and others
2+
* Copyright (c) 2006, 2023 BEA Systems, Inc. and others
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -254,8 +254,7 @@ protected void closed() {
254254
this._filer.addNewClassFile(type);
255255
} else {
256256
BinaryTypeBinding binaryBinding = new BinaryTypeBinding(type.getPackage(), binaryType, this._filer._env._compiler.lookupEnvironment, true);
257-
if (binaryBinding != null)
258-
this._filer.addNewClassFile(binaryBinding);
257+
this._filer.addNewClassFile(binaryBinding);
259258
}
260259
}
261260
}

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/DeclaredTypeImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2006, 2018 BEA Systems, Inc.
2+
* Copyright (c) 2006, 2023 BEA Systems, Inc.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -66,7 +66,7 @@ public Element asElement() {
6666
return this._env.getFactory().newElement(prototype, this._elementKindHint);
6767
}
6868
// The JDT compiler does not distinguish between type elements and declared types
69-
return this._env.getFactory().newElement((ReferenceBinding)this._binding, this._elementKindHint);
69+
return this._env.getFactory().newElement(this._binding, this._elementKindHint);
7070
}
7171

7272
@Override

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ErrorTypeImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2007, 2015 IBM Corporation and others.
2+
* Copyright (c) 2007, 2023 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -46,7 +46,7 @@ public class ErrorTypeImpl extends DeclaredTypeImpl implements ErrorType {
4646
*/
4747
@Override
4848
public Element asElement() {
49-
return this._env.getFactory().newElement((ReferenceBinding) this._binding);
49+
return this._env.getFactory().newElement(this._binding);
5050
}
5151

5252
/* (non-Javadoc)

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2007, 2020 BEA Systems, Inc. and others
2+
* Copyright (c) 2007, 2023 BEA Systems, Inc. and others
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -347,6 +347,7 @@ public static Set<Modifier> getModifiers(int modifiers, ElementKind kind, boolea
347347
ClassFileConstants.ACC_OPEN,
348348
ClassFileConstants.ACC_TRANSITIVE
349349
});
350+
break;
350351
default:
351352
break;
352353
}

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeParameterElementImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2007, 2015 BEA Systems, Inc.
2+
* Copyright (c) 2007, 2023 BEA Systems, Inc.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -33,9 +33,9 @@
3333

3434
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
3535
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
36-
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
3736
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
3837
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
38+
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
3939
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
4040

4141
/**
@@ -116,7 +116,7 @@ private List<? extends TypeMirror> calculateBounds() {
116116
}
117117
} else {
118118
// at least we must add java.lang.Object
119-
typeBounds.add(this._env.getFactory().newTypeMirror(this._env.getLookupEnvironment().getType(LookupEnvironment.JAVA_LANG_OBJECT)));
119+
typeBounds.add(this._env.getFactory().newTypeMirror(this._env.getLookupEnvironment().getType(TypeConstants.JAVA_LANG_OBJECT)));
120120
}
121121
return Collections.unmodifiableList(typeBounds);
122122
}

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/TypeVariableImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2006, 2013 IBM Corporation and others.
2+
* Copyright (c) 2006, 2023 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -62,11 +62,11 @@ public TypeMirror getUpperBound() {
6262
// no explicit bound
6363
return this._env.getFactory().newTypeMirror(typeVariableBinding.upperBound());
6464
}
65-
if (firstBound != null && superInterfaces.length == 1 && TypeBinding.equalsEquals(superInterfaces[0], firstBound)) {
65+
if (superInterfaces.length == 1 && TypeBinding.equalsEquals(superInterfaces[0], firstBound)) {
6666
// only one bound that is an interface
6767
return this._env.getFactory().newTypeMirror(typeVariableBinding.upperBound());
6868
}
69-
return this._env.getFactory().newTypeMirror((TypeVariableBinding) this._binding);
69+
return this._env.getFactory().newTypeMirror(this._binding);
7070
}
7171

7272
/* (non-Javadoc)

0 commit comments

Comments
 (0)