diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedDeclarationImpl.java index a612dcee4fa..0fddeb87022 100644 --- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedDeclarationImpl.java +++ b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/ASTBasedDeclarationImpl.java @@ -28,7 +28,6 @@ import org.eclipse.jdt.core.dom.IAnnotationBinding; import org.eclipse.jdt.core.dom.SingleVariableDeclaration; import org.eclipse.jdt.core.dom.VariableDeclaration; -import org.eclipse.jdt.core.dom.VariableDeclarationFragment; import com.sun.mirror.declaration.AnnotationMirror; import com.sun.mirror.declaration.Modifier; @@ -76,7 +75,7 @@ public Collection getModifiers() else if( _astNode instanceof SingleVariableDeclaration ) modBits = ((SingleVariableDeclaration)_astNode).getModifiers(); else{ - ASTNode parent = ((VariableDeclarationFragment)_astNode).getParent(); + ASTNode parent = _astNode.getParent(); if( _astNode instanceof BodyDeclaration ) modBits = ((BodyDeclaration)parent).getModifiers(); } @@ -148,7 +147,7 @@ private IAnnotationBinding[] getAnnotationInstancesFromAST() extendsMods = ((SingleVariableDeclaration)_astNode).modifiers(); break; case ASTNode.VARIABLE_DECLARATION_FRAGMENT: - final ASTNode parent = ((VariableDeclarationFragment)_astNode).getParent(); + final ASTNode parent = _astNode.getParent(); if( parent instanceof BodyDeclaration ) extendsMods = ((BodyDeclaration)parent).modifiers(); break; diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MemberDeclarationImpl.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MemberDeclarationImpl.java index 6e883f8ce59..6625632e27f 100644 --- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MemberDeclarationImpl.java +++ b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/declaration/MemberDeclarationImpl.java @@ -59,13 +59,13 @@ private IAnnotationBinding[] getAnnotationInstances() switch( binding.getKind() ) { case IBinding.TYPE: - instances = ((ITypeBinding)binding).getAnnotations(); + instances = binding.getAnnotations(); break; case IBinding.METHOD: - instances = ((IMethodBinding)binding).getAnnotations(); + instances = binding.getAnnotations(); break; case IBinding.VARIABLE: - instances = ((IVariableBinding)binding).getAnnotations(); + instances = binding.getAnnotations(); break; case IBinding.PACKAGE: // TODO: support package annotation diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/TestCodeUtil.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/TestCodeUtil.java index 810a70a0d3b..22e3cdcb0ec 100644 --- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/TestCodeUtil.java +++ b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/util/TestCodeUtil.java @@ -24,7 +24,7 @@ private TestCodeUtil() { } public static boolean isTestCode(ICompilationUnit cu) { - IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) ((IJavaElement) cu) + IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) cu .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); if (packageFragmentRoot != null) { try { diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ModuleElementImpl.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ModuleElementImpl.java index da73d9101b8..e78f05658f9 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ModuleElementImpl.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/apt/model/ModuleElementImpl.java @@ -175,7 +175,7 @@ public R accept(ElementVisitor visitor, P param) { } @Override protected AnnotationBinding[] getAnnotationBindings() { - return ((ModuleBinding) this._binding).getAnnotations(); + return this._binding.getAnnotations(); } abstract class PackageDirectiveImpl { diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java index f1e94a9c97d..ac94a2af8eb 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java @@ -107,7 +107,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl boolean analyseResources = currentScope.compilerOptions().analyseResourceLeaks; boolean hasResourceWrapperType = analyseResources && this.resolvedType instanceof ReferenceBinding - && ((ReferenceBinding)this.resolvedType).hasTypeBit(TypeIds.BitWrapperCloseable); + && this.resolvedType.hasTypeBit(TypeIds.BitWrapperCloseable); for (int i = 0, count = this.arguments.length; i < count; i++) { Expression argument = this.arguments[i]; flowInfo = diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java index 2d20957884c..80e4ba23f64 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java @@ -430,13 +430,13 @@ public static void analyseCloseableAllocation(BlockScope scope, FlowInfo flowInf if (flowInfo.reachMode() != FlowInfo.REACHABLE) return; // client has checked that the resolvedType is an AutoCloseable, hence the following cast is safe: - if (((ReferenceBinding)allocation.resolvedType).hasTypeBit(TypeIds.BitResourceFreeCloseable)) { + if (allocation.resolvedType.hasTypeBit(TypeIds.BitResourceFreeCloseable)) { // remove unnecessary attempts (closeable is not relevant) if (allocation.closeTracker != null) { allocation.closeTracker.withdraw(); allocation.closeTracker = null; } - } else if (((ReferenceBinding)allocation.resolvedType).hasTypeBit(TypeIds.BitWrapperCloseable)) { + } else if (allocation.resolvedType.hasTypeBit(TypeIds.BitWrapperCloseable)) { boolean isWrapper = true; if (allocation.arguments != null && allocation.arguments.length > 0) { // find the wrapped resource represented by its tracking var: @@ -511,7 +511,7 @@ public static FlowInfo analyseCloseableAcquisition(BlockScope scope, FlowInfo fl return flowInfo; } // client has checked that the resolvedType is an AutoCloseable, hence the following cast is safe: - if (((ReferenceBinding)acquisition.resolvedType).hasTypeBit(TypeIds.BitResourceFreeCloseable) + if (acquisition.resolvedType.hasTypeBit(TypeIds.BitResourceFreeCloseable) && !isBlacklistedMethod(acquisition)) { // remove unnecessary attempts (closeable is not relevant) if (acquisition.closeTracker != null) { @@ -1093,7 +1093,7 @@ protected boolean handle(FakedTrackingVariable closeTracker, FlowInfo flow, ASTN /** Answer wither the given type binding is a subtype of java.lang.AutoCloseable. */ public static boolean isAnyCloseable(TypeBinding typeBinding) { return typeBinding instanceof ReferenceBinding - && ((ReferenceBinding)typeBinding).hasTypeBit(TypeIds.BitAutoCloseable|TypeIds.BitCloseable); + && typeBinding.hasTypeBit(TypeIds.BitAutoCloseable|TypeIds.BitCloseable); } /** Answer wither the given type binding is a subtype of java.lang.AutoCloseable. */ diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java index 960d904ca75..bc675119594 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java @@ -457,9 +457,9 @@ public static TypeBinding getCollectionElementType(BlockScope scope, TypeBinding if (collectionType.isArrayType()) { // for(E e : E[]) return ((ArrayBinding) collectionType).elementsType(); } else if (collectionType instanceof ReferenceBinding) { - ReferenceBinding iterableType = ((ReferenceBinding)collectionType).findSuperTypeOriginatingFrom(T_JavaLangIterable, false /*Iterable is not a class*/); + ReferenceBinding iterableType = collectionType.findSuperTypeOriginatingFrom(T_JavaLangIterable, false /*Iterable is not a class*/); if (iterableType == null && isTargetJsr14) { - iterableType = ((ReferenceBinding)collectionType).findSuperTypeOriginatingFrom(T_JavaUtilCollection, false /*Iterable is not a class*/); + iterableType = collectionType.findSuperTypeOriginatingFrom(T_JavaUtilCollection, false /*Iterable is not a class*/); } if (iterableType == null) return null; @@ -570,22 +570,22 @@ public void resolve(BlockScope upperScope) { this.collection.computeConversion(this.scope, expectedCollectionType, collectionType); } } else if (collectionType instanceof ReferenceBinding) { - ReferenceBinding iterableType = ((ReferenceBinding)collectionType).findSuperTypeOriginatingFrom(T_JavaLangIterable, false /*Iterable is not a class*/); + ReferenceBinding iterableType = collectionType.findSuperTypeOriginatingFrom(T_JavaLangIterable, false /*Iterable is not a class*/); if (iterableType == null && isTargetJsr14) { - iterableType = ((ReferenceBinding)collectionType).findSuperTypeOriginatingFrom(T_JavaUtilCollection, false /*Iterable is not a class*/); + iterableType = collectionType.findSuperTypeOriginatingFrom(T_JavaUtilCollection, false /*Iterable is not a class*/); } checkIterable: { if (iterableType == null) break checkIterable; this.iteratorReceiverType = collectionType.erasure(); if (isTargetJsr14) { - if (((ReferenceBinding)this.iteratorReceiverType).findSuperTypeOriginatingFrom(T_JavaUtilCollection, false) == null) { + if (this.iteratorReceiverType.findSuperTypeOriginatingFrom(T_JavaUtilCollection, false) == null) { this.iteratorReceiverType = iterableType; // handle indirect inheritance thru variable secondary bound this.collection.computeConversion(this.scope, iterableType, collectionType); } else { this.collection.computeConversion(this.scope, collectionType, collectionType); } - } else if (((ReferenceBinding)this.iteratorReceiverType).findSuperTypeOriginatingFrom(T_JavaLangIterable, false) == null) { + } else if (this.iteratorReceiverType.findSuperTypeOriginatingFrom(T_JavaLangIterable, false) == null) { this.iteratorReceiverType = iterableType; // handle indirect inheritance thru variable secondary bound this.collection.computeConversion(this.scope, iterableType, collectionType); } else { diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java index 5e89620124b..2aae1b181d1 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java @@ -125,7 +125,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl boolean analyseResources = currentScope.compilerOptions().analyseResourceLeaks; boolean hasResourceWrapperType = analyseResources && this.resolvedType instanceof ReferenceBinding - && ((ReferenceBinding)this.resolvedType).hasTypeBit(TypeIds.BitWrapperCloseable); + && this.resolvedType.hasTypeBit(TypeIds.BitWrapperCloseable); for (int i = 0, count = this.arguments.length; i < count; i++) { flowInfo = this.arguments[i].analyseCode(currentScope, flowContext, flowInfo); if (analyseResources && !hasResourceWrapperType) { // allocation of wrapped closeables is analyzed specially diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java index f2fe2e72a5f..5c88b9ec9c4 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java @@ -115,7 +115,7 @@ public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclo if (!memberType.isValidBinding()) { hasError = true; scope.problemReporter().invalidEnclosingType(this, memberType, enclosingType); - memberType = ((ReferenceBinding)memberType).closestMatch(); + memberType = memberType.closestMatch(); if (memberType == null) { return null; } diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java index de112587018..535041e67fb 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java @@ -243,7 +243,7 @@ public void addPattern(RecordPattern rp, int i) { TypeBinding ref = SwitchStatement.this.expression.resolvedType; if (!(ref instanceof ReferenceBinding)) return; - RecordComponentBinding[] comps = ((ReferenceBinding)ref).components(); + RecordComponentBinding[] comps = ref.components(); if (comps == null || comps.length <= i) // safety-net for incorrect code. return; if (this.next == null) @@ -425,12 +425,12 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl this.scope.enclosingCase = this.cases[caseIndex]; // record entering in a switch case block caseIndex++; if (prevCaseStmtIndex == i - 1) { - if (((CaseStatement) this.statements[prevCaseStmtIndex]).containsPatternVariable()) + if (this.statements[prevCaseStmtIndex].containsPatternVariable()) this.scope.problemReporter().illegalFallthroughFromAPattern(this.statements[prevCaseStmtIndex]); } prevCaseStmtIndex = i; if (fallThroughState == FALLTHROUGH && complaintLevel <= NOT_COMPLAINED) { - if (((CaseStatement) statement).containsPatternVariable()) + if (statement.containsPatternVariable()) this.scope.problemReporter().IllegalFallThroughToPattern(this.scope.enclosingCase); else if ((statement.bits & ASTNode.DocumentedFallthrough) == 0) { // the case is not fall-through protected by a line comment this.scope.problemReporter().possibleFallThroughCase(this.scope.enclosingCase); diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/Constant.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/Constant.java index 27173b324e7..ab27bc512bb 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/Constant.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/Constant.java @@ -491,7 +491,7 @@ public static final Constant computeConstantOperationEQUAL_EQUAL(Constant left, if (rightId == T_JavaLangString) { //String are interned in th compiler==>thus if two string constant //get to be compared, it is an equal on the vale which is done - return BooleanConstant.fromValue(((StringConstant)left).hasSameValue(right)); + return BooleanConstant.fromValue(left.hasSameValue(right)); } break; case T_null : diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java index 97bf9d53505..b6b1f3cb8f7 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java @@ -910,7 +910,7 @@ public Object[] getEmulationPath(ReferenceBinding targetEnclosingType, boolean o if (enclosingArgument != null) { FieldBinding syntheticField = sourceType.getSyntheticField(enclosingArgument); if (syntheticField != null) { - if (TypeBinding.equalsEquals(syntheticField.type, targetEnclosingType) || (!onlyExactMatch && ((ReferenceBinding)syntheticField.type).findSuperTypeOriginatingFrom(targetEnclosingType) != null)) + if (TypeBinding.equalsEquals(syntheticField.type, targetEnclosingType) || (!onlyExactMatch && syntheticField.type.findSuperTypeOriginatingFrom(targetEnclosingType) != null)) return new Object[] { syntheticField }; } } diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java index c8391b75c5b..dcb41ac6856 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java @@ -1178,8 +1178,8 @@ public String toString() { } else { buf.append('\n'); for (Entry entry : this.captures.entrySet()) { - String lhs = String.valueOf(((TypeBinding)entry.getKey()).shortReadableName()); - String rhs = String.valueOf(((TypeBinding)entry.getValue()).shortReadableName()); + String lhs = String.valueOf(entry.getKey().shortReadableName()); + String rhs = String.valueOf(entry.getValue().shortReadableName()); buf.append('\t').append(lhs).append(" = capt(").append(rhs).append(")\n"); //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java index 093a250204a..b002c03e3e3 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/IntersectionTypeBinding18.java @@ -212,7 +212,7 @@ public boolean isSubtypeOf(TypeBinding other, boolean simulatingBugJDK8026527) { if (TypeBinding.equalsEquals(this, other)) return true; if (other instanceof ReferenceBinding) { - TypeBinding[] rightIntersectingTypes = ((ReferenceBinding) other).getIntersectingTypes(); + TypeBinding[] rightIntersectingTypes = other.getIntersectingTypes(); if (rightIntersectingTypes != null && rightIntersectingTypes.length > 1) { int numRequired = rightIntersectingTypes.length; TypeBinding[] required = new TypeBinding[numRequired]; diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java index 6dc6f648f42..32df901927e 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java @@ -919,7 +919,7 @@ public boolean hasMemberTypes() { public boolean hasTypeBit(int bit) { TypeBinding erasure = erasure(); if (erasure instanceof ReferenceBinding) - return ((ReferenceBinding) erasure).hasTypeBit(bit); + return erasure.hasTypeBit(bit); return false; } diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java index bf2de8a280f..0beb1853e2a 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java @@ -1599,7 +1599,7 @@ protected boolean isSubTypeOfRTL(TypeBinding other) { return (lower != null && isSubtypeOf(lower, false)); } if (other instanceof ReferenceBinding) { - TypeBinding[] intersecting = ((ReferenceBinding) other).getIntersectingTypes(); + TypeBinding[] intersecting = other.getIntersectingTypes(); if (intersecting != null) { for (TypeBinding binding : intersecting) { if (!isSubtypeOf(binding, false)) diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Scope.java index 6454ba86a0d..ce12830d0be 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Scope.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/Scope.java @@ -1656,7 +1656,7 @@ public MethodBinding findMethod(ReferenceBinding receiverType, char[] selector, if (method != null && method.isValidBinding() && method.isVarargs()) { TypeBinding elementType = method.parameters[method.parameters.length - 1].leafComponentType(); if (elementType instanceof ReferenceBinding) { - if (!((ReferenceBinding) elementType).erasure().canBeSeenBy(this)) { + if (!elementType.erasure().canBeSeenBy(this)) { return new ProblemMethodBinding(method, method.selector, invocationSite.genericTypeArguments(), ProblemReasons.VarargsElementTypeNotVisible); } } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java index 50725199053..d0d3b374509 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS4Test.java @@ -9346,7 +9346,7 @@ public void test0272() throws JavaModelException { assertEquals("Not an expression statement", ASTNode.EXPRESSION_STATEMENT, statement2.getNodeType()); Expression expression2 = ((ExpressionStatement) statement2).getExpression(); assertEquals("Not a method invocation", ASTNode.METHOD_INVOCATION, expression2.getNodeType()); - ITypeBinding typeBinding = ((MethodInvocation) expression2).resolveTypeBinding(); + ITypeBinding typeBinding = expression2.resolveTypeBinding(); assertTrue("Not a capture", typeBinding.isCapture()); assertNull("No binary type", typeBinding.getBinaryName()); } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS8Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS8Test.java index 67957399250..6ade032e52c 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS8Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15JLS8Test.java @@ -9334,7 +9334,7 @@ public void test0272() throws JavaModelException { assertEquals("Not an expression statement", ASTNode.EXPRESSION_STATEMENT, statement2.getNodeType()); Expression expression2 = ((ExpressionStatement) statement2).getExpression(); assertEquals("Not a method invocation", ASTNode.METHOD_INVOCATION, expression2.getNodeType()); - ITypeBinding typeBinding = ((MethodInvocation) expression2).resolveTypeBinding(); + ITypeBinding typeBinding = expression2.resolveTypeBinding(); assertTrue("Not a capture", typeBinding.isCapture()); assertNull("No binary type", typeBinding.getBinaryName()); } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java index 8e7b0cda48a..4f00d2300b4 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java @@ -9381,7 +9381,7 @@ public void test0272() throws JavaModelException { assertEquals("Not an expression statement", ASTNode.EXPRESSION_STATEMENT, statement2.getNodeType()); Expression expression2 = ((ExpressionStatement) statement2).getExpression(); assertEquals("Not a method invocation", ASTNode.METHOD_INVOCATION, expression2.getNodeType()); - ITypeBinding typeBinding = ((MethodInvocation) expression2).resolveTypeBinding(); + ITypeBinding typeBinding = expression2.resolveTypeBinding(); assertTrue("Not a capture", typeBinding.isCapture()); assertNull("No binary type", typeBinding.getBinaryName()); } @@ -11372,7 +11372,7 @@ public void test0350() throws JavaModelException { true, true); ExpressionStatement statement = (ExpressionStatement) getASTNode(unit, 0, 1, 0); - ITypeBinding binding = ((MethodInvocation) statement.getExpression()).resolveTypeBinding(); + ITypeBinding binding = statement.getExpression().resolveTypeBinding(); assertTrue("Should be seen as a wildcard (really an intersection type)", binding.isWildcardType()); assertNull("should be null", binding.getGenericTypeOfWildcardType()); } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java index abf805f2d90..f02be4473d0 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java @@ -1098,7 +1098,7 @@ public void test0007() throws JavaModelException { MethodDeclaration method = (MethodDeclaration) node; Type receiver = method.getReceiverType(); assertEquals("Not a simple type", ASTNode.SIMPLE_TYPE, receiver.getNodeType()); - assertEquals("Incorrect receiver signature", "@Marker @Marker2 X", ((SimpleType) receiver).toString()); + assertEquals("Incorrect receiver signature", "@Marker @Marker2 X", receiver.toString()); assertEquals("Incorrect annotations on receiver", 2, ((SimpleType) receiver).annotations().size()); assertNull("Incorrect receiver qualfier", method.getReceiverQualifier()); } @@ -1126,7 +1126,7 @@ public void test0008() throws JavaModelException { MethodDeclaration method = innerType.getMethods()[0]; Type receiver = method.getReceiverType(); assertEquals("Not a simple type", ASTNode.SIMPLE_TYPE, receiver.getNodeType()); - assertEquals("Incorrect receiver signature", "@Marker @Marker2 X", ((SimpleType) receiver).toString()); + assertEquals("Incorrect receiver signature", "@Marker @Marker2 X", receiver.toString()); assertEquals("Incorrect annotations on receiver", 2, ((SimpleType) receiver).annotations().size()); assertNotNull("Incorrect receiver qualfier", method.getReceiverQualifier()); assertEquals("Incorrect receiver qualfier", "X", method.getReceiverQualifier().getFullyQualifiedName()); @@ -2097,12 +2097,12 @@ public void testBug403132() throws JavaModelException { MethodDeclaration method = (MethodDeclaration) node; Type receiver = method.getReceiverType(); assertEquals("Not a qualified type", ASTNode.QUALIFIED_TYPE, receiver.getNodeType()); - assertEquals("Incorrect receiver", "@A X.@B Y", ((QualifiedType) receiver).toString()); + assertEquals("Incorrect receiver", "@A X.@B Y", receiver.toString()); assertEquals("Incorrect method signature", "public Z(@A X.@B Y Y.this,String str){\n}\n", method.toString()); method = (MethodDeclaration) type.bodyDeclarations().get(1); receiver = method.getReceiverType(); - assertEquals("Incorrect receiver", "@A X.@B Y.@C Z", ((QualifiedType) receiver).toString()); + assertEquals("Incorrect receiver", "@A X.@B Y.@C Z", receiver.toString()); assertEquals("Incorrect method signature", "public void foo(@A X.@B Y.@C Z this,String str){\n}\n", method.toString()); } public void testParameterizedReceiverType() throws JavaModelException { @@ -3857,8 +3857,8 @@ public void test416559() throws JavaModelException { VariableDeclaration variableDeclaration = (VariableDeclaration) lambdaExpression.parameters().get(0); IVariableBinding variableBinding = variableDeclaration.resolveBinding(); IMethodBinding methodBinding = lambdaExpression.resolveMethodBinding(); - String methodKey = ((IBinding) methodBinding).getKey(); - String variableKey = ((IBinding) variableBinding).getKey(); + String methodKey = methodBinding.getKey(); + String variableKey = variableBinding.getKey(); assertTrue(variableKey.regionMatches(0, methodKey, 0, methodKey.length())); fragments = field[1].fragments(); @@ -3868,7 +3868,7 @@ public void test416559() throws JavaModelException { variableDeclaration = (VariableDeclaration) lambdaExpression.parameters().get(0); variableBinding = variableDeclaration.resolveBinding(); - assertNotSame(variableKey.intern(), ((IBinding) variableBinding).getKey().intern()); + assertNotSame(variableKey.intern(), variableBinding.getKey().intern()); } /* * https://bugs.eclipse.org/bugs/show_bug.cgi?id=420458 diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java index e53b8dbc720..372a57e5757 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java @@ -1327,7 +1327,7 @@ public void testBug530803_1() throws Exception { // common check for both parts: Consumer validateBinding = (IBinding binding) -> { assertTrue("Not ModuleBinding", binding instanceof IModuleBinding); - IAnnotationBinding[] annotations = ((IModuleBinding) binding).getAnnotations(); + IAnnotationBinding[] annotations = binding.getAnnotations(); assertEquals("Number of annotations", 1, annotations.length); assertEquals("Annotation type", "Deprecated", annotations[0].getAnnotationType().getName()); }; diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java index bf44ae61d85..2db09a5979b 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java @@ -1352,7 +1352,7 @@ public void testCreateBindings24() throws CoreException { assertBindingsEqual( "Lpack/package-info;", bindings); - IAnnotationBinding[] annotations = ((ITypeBinding) bindings[0]).getAnnotations(); + IAnnotationBinding[] annotations = bindings[0].getAnnotations(); assertBindingsEqual( "@Ljava/lang/Deprecated;", annotations); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java index f1dc8f06cf8..66102ee4be3 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java @@ -1678,7 +1678,7 @@ public void testBug153133() throws JavaModelException { // Need to get type members constructors for (int i = 0; i < length; i++) { assertTrue(members[i] instanceof IMember); - if (((IMember)members[i]).getElementType() == IJavaElement.TYPE) { + if (members[i].getElementType() == IJavaElement.TYPE) { IType typeMember = (IType) members[i]; String typeName = typeMember.getElementName(); IMethod[] methods = typeMember.getMethods(); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CopyMoveElementsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CopyMoveElementsTests.java index b978724491a..f422184b33b 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CopyMoveElementsTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CopyMoveElementsTests.java @@ -405,7 +405,7 @@ public void testCopyFieldsMultiStatus() throws CoreException { typeDest.getJavaModel().copy(fieldsSource, dests, null, null, false, null); } catch (JavaModelException jme) { assertTrue("Should be multistatus", jme.getStatus().isMultiStatus()); - assertTrue("Should be an invalid destination", ((IJavaModelStatus)jme.getStatus().getChildren()[0]).getCode()== IJavaModelStatusConstants.INVALID_DESTINATION); + assertTrue("Should be an invalid destination", jme.getStatus().getChildren()[0].getCode()== IJavaModelStatusConstants.INVALID_DESTINATION); e = true; } assertTrue("Should have been an exception", e); @@ -457,7 +457,7 @@ public void testCopyFieldsMultiStatusInDifferentProject() throws CoreException { typeDest.getJavaModel().copy(fieldsSource, dests, null, null, false, null); } catch (JavaModelException jme) { assertTrue("Should be multistatus", jme.getStatus().isMultiStatus()); - assertTrue("Should be an invalid destination", ((IJavaModelStatus)jme.getStatus().getChildren()[0]).getCode()== IJavaModelStatusConstants.INVALID_DESTINATION); + assertTrue("Should be an invalid destination", jme.getStatus().getChildren()[0].getCode()== IJavaModelStatusConstants.INVALID_DESTINATION); e = true; } assertTrue("Should have been an exception", e); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/FactoryTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/FactoryTests.java index 152b276118b..c9c0cfd0cd2 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/FactoryTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/FactoryTests.java @@ -76,7 +76,7 @@ public void testCreateCompilationUnits() throws CoreException { assertTrue("wrong object B created", objectB instanceof ICompilationUnit); assertTrue("compilation unit B does not exist", objectB.exists()); - assertEquals("should share project", ((ICompilationUnit)objectA).getJavaProject(), ((ICompilationUnit)objectB).getJavaProject()); + assertEquals("should share project", objectA.getJavaProject(), objectB.getJavaProject()); } finally { this.deleteProject("P"); } @@ -103,7 +103,7 @@ public void testCreateCompilationUnitsNotOnClasspath() throws CoreException { assertTrue("wrong object B created", objectB instanceof ICompilationUnit); assertTrue("compilation unit B should not exist", !objectB.exists()); - assertEquals("should share project", ((ICompilationUnit)objectA).getJavaProject(), ((ICompilationUnit)objectB).getJavaProject()); + assertEquals("should share project", objectA.getJavaProject(), objectB.getJavaProject()); IJavaElement objectC = JavaCore.create(fileC); assertTrue("tooling object C not created", objectC != null); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/GetSourceTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/GetSourceTests.java index 835bb984bdb..ff913f549b9 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/GetSourceTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/GetSourceTests.java @@ -13,8 +13,6 @@ *******************************************************************************/ package org.eclipse.jdt.core.tests.model; -import junit.framework.Test; - import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.IAnnotation; import org.eclipse.jdt.core.ICompilationUnit; @@ -23,11 +21,12 @@ import org.eclipse.jdt.core.ILocalVariable; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IPackageDeclaration; -import org.eclipse.jdt.core.ISourceReference; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.ITypeParameter; import org.eclipse.jdt.core.JavaModelException; +import junit.framework.Test; + public class GetSourceTests extends ModifyingResourceTests { ICompilationUnit cu; @@ -309,7 +308,7 @@ public void testImport() throws JavaModelException { public void testLocalVariable1() throws JavaModelException { ILocalVariable var = getLocalVariable("/P/p/X.java", "var1 = 2;", "var1"); - String actualSource = ((ISourceReference)var).getSource(); + String actualSource = var.getSource(); String expectedSource = "final int var1 = 2;"; assertSourceEquals("Unexpected source'", expectedSource, actualSource); } @@ -320,7 +319,7 @@ public void testLocalVariable1() throws JavaModelException { public void testLocalVariable2() throws JavaModelException { ILocalVariable var = getLocalVariable("/P/p/X.java", "var2;", "var2"); - String actualSource = ((ISourceReference)var).getSource(); + String actualSource = var.getSource(); String expectedSource = "Object var2;"; assertSourceEquals("Unexpected source'", expectedSource, actualSource); } @@ -331,7 +330,7 @@ public void testLocalVariable2() throws JavaModelException { public void testLocalVariable3() throws JavaModelException { ILocalVariable var = getLocalVariable("/P/p/X.java", "i = 0;", "i"); - String actualSource = ((ISourceReference)var).getSource(); + String actualSource = var.getSource(); String expectedSource = "int i = 0"; // semi-colon is not part of the local declaration in a for statement assertSourceEquals("Unexpected source'", expectedSource, actualSource); } @@ -342,7 +341,7 @@ public void testLocalVariable3() throws JavaModelException { public void testLocalVariable4() throws JavaModelException { ILocalVariable var = getLocalVariable("/P/p/X.java", "s) {", "s"); - String actualSource = ((ISourceReference)var).getSource(); + String actualSource = var.getSource(); String expectedSource = "String s"; assertSourceEquals("Unexpected source'", expectedSource, actualSource); } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/Java9ElementTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/Java9ElementTests.java index bcbd446eef5..485a575d14c 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/Java9ElementTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/Java9ElementTests.java @@ -984,7 +984,7 @@ public void testFindModule1() throws CoreException, IOException { assertNotNull("module", modTest); assertEquals("module name", "test", modTest.getElementName()); IJavaElement root = parentChain(modTest, new int[] { COMPILATION_UNIT, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT }); - String rootPath = ((IPackageFragmentRoot) root).getPath().toString(); + String rootPath = root.getPath().toString(); assertEquals("package fragment root path", "/Test/src", rootPath); // search source module in project dependency: @@ -992,7 +992,7 @@ public void testFindModule1() throws CoreException, IOException { assertNotNull("module", modZero); assertEquals("module name", "mod.zero", modZero.getElementName()); root = parentChain(modZero, new int[] { COMPILATION_UNIT, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT }); - rootPath = ((IPackageFragmentRoot) root).getPath().toString(); + rootPath = root.getPath().toString(); assertEquals("package fragment root path", "/mod.zero/src", rootPath); // search binary module in jar dependency: @@ -1000,7 +1000,7 @@ public void testFindModule1() throws CoreException, IOException { assertNotNull("module", modOne); assertEquals("module name", "mod.one", modOne.getElementName()); root = parentChain(modOne, new int[] { CLASS_FILE, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT }); - rootPath = ((IPackageFragmentRoot) root).getPath().toString(); + rootPath = root.getPath().toString(); assertEquals("package fragment root path", "/Test/mod.one.jar", rootPath); IModuleDescription notSuchModule = javaProject.findModule("does.not.exist", null); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests18.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests18.java index 982bee48042..4b9806c9939 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests18.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests18.java @@ -16,7 +16,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.BindingKey; -import org.eclipse.jdt.core.ICodeAssist; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.ILocalVariable; @@ -1031,7 +1030,7 @@ public void testBug408230a() throws CoreException { ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); String selectString = "barg"; - IJavaElement [] variable = ((ICodeAssist) unit).codeSelect(source.lastIndexOf(selectString), selectString.length()); + IJavaElement [] variable = unit.codeSelect(source.lastIndexOf(selectString), selectString.length()); assertEquals(1, variable.length); } finally { deleteProject("P"); @@ -1056,7 +1055,7 @@ public void testBug408230b() throws CoreException { ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); String selectString = "barg"; - IJavaElement [] variable = ((ICodeAssist) unit).codeSelect(source.lastIndexOf(selectString), selectString.length()); + IJavaElement [] variable = unit.codeSelect(source.lastIndexOf(selectString), selectString.length()); assertEquals(1, variable.length); } finally { deleteProject("P"); @@ -1081,7 +1080,7 @@ public void testBug408230c() throws CoreException { ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); String selectString = "barg"; - IJavaElement [] variable = ((ICodeAssist) unit).codeSelect(source.lastIndexOf(selectString), selectString.length()); + IJavaElement [] variable = unit.codeSelect(source.lastIndexOf(selectString), selectString.length()); assertEquals(1, variable.length); } finally { deleteProject("P"); @@ -1104,7 +1103,7 @@ public void testBug408230d() throws CoreException { ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); String selectString = "barg"; - IJavaElement [] variable = ((ICodeAssist) unit).codeSelect(source.lastIndexOf(selectString), selectString.length()); + IJavaElement [] variable = unit.codeSelect(source.lastIndexOf(selectString), selectString.length()); assertEquals(1, variable.length); } finally { deleteProject("P"); @@ -1127,7 +1126,7 @@ public void testBug408230e() throws CoreException { ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); String selectString = "aarg"; - IJavaElement [] variable = ((ICodeAssist) unit).codeSelect(source.lastIndexOf(selectString), selectString.length()); + IJavaElement [] variable = unit.codeSelect(source.lastIndexOf(selectString), selectString.length()); assertEquals(1, variable.length); } finally { deleteProject("P"); @@ -1150,7 +1149,7 @@ public void testBug408230f() throws CoreException { ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); String selectString = "aarg"; - IJavaElement [] variable = ((ICodeAssist) unit).codeSelect(source.lastIndexOf(selectString), selectString.length()); + IJavaElement [] variable = unit.codeSelect(source.lastIndexOf(selectString), selectString.length()); assertEquals(1, variable.length); } finally { deleteProject("P"); @@ -1176,7 +1175,7 @@ public void testBug408230g() throws CoreException { ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); String selectString = "aarg"; - IJavaElement [] variable = ((ICodeAssist) unit).codeSelect(source.lastIndexOf(selectString), selectString.length()); + IJavaElement [] variable = unit.codeSelect(source.lastIndexOf(selectString), selectString.length()); assertEquals(1, variable.length); } finally { deleteProject("P"); @@ -1202,7 +1201,7 @@ public void testBug408230h() throws CoreException { ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); String selectString = "aarg"; - IJavaElement [] variable = ((ICodeAssist) unit).codeSelect(source.lastIndexOf(selectString), selectString.length()); + IJavaElement [] variable = unit.codeSelect(source.lastIndexOf(selectString), selectString.length()); assertEquals(1, variable.length); } finally { deleteProject("P"); @@ -1228,7 +1227,7 @@ public void testBug408230i() throws CoreException { ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); String selectString = "aarg"; - IJavaElement [] variable = ((ICodeAssist) unit).codeSelect(source.lastIndexOf(selectString), selectString.length()); + IJavaElement [] variable = unit.codeSelect(source.lastIndexOf(selectString), selectString.length()); assertEquals(1, variable.length); } finally { deleteProject("P"); @@ -1254,7 +1253,7 @@ public void testBug408230j() throws CoreException { ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); String selectString = "aarg"; - IJavaElement [] variable = ((ICodeAssist) unit).codeSelect(source.lastIndexOf(selectString), selectString.length()); + IJavaElement [] variable = unit.codeSelect(source.lastIndexOf(selectString), selectString.length()); assertEquals(1, variable.length); } finally { deleteProject("P"); @@ -1280,7 +1279,7 @@ public void testBug408230k() throws CoreException { ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); String selectString = "aarg"; - IJavaElement [] variable = ((ICodeAssist) unit).codeSelect(source.lastIndexOf(selectString), selectString.length()); + IJavaElement [] variable = unit.codeSelect(source.lastIndexOf(selectString), selectString.length()); assertEquals(1, variable.length); } finally { deleteProject("P"); @@ -1306,7 +1305,7 @@ public void testBug408230l() throws CoreException { ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); String selectString = "aarg"; - IJavaElement [] variable = ((ICodeAssist) unit).codeSelect(source.lastIndexOf(selectString), selectString.length()); + IJavaElement [] variable = unit.codeSelect(source.lastIndexOf(selectString), selectString.length()); assertEquals(1, variable.length); } finally { deleteProject("P"); @@ -1332,7 +1331,7 @@ public void testBug408230m() throws CoreException { ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); String selectString = "aarg"; - IJavaElement [] variable = ((ICodeAssist) unit).codeSelect(source.lastIndexOf(selectString), selectString.length()); + IJavaElement [] variable = unit.codeSelect(source.lastIndexOf(selectString), selectString.length()); assertEquals(1, variable.length); } finally { deleteProject("P"); @@ -1358,7 +1357,7 @@ public void testBug408230n() throws CoreException { ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); String selectString = "aarg"; - IJavaElement [] variable = ((ICodeAssist) unit).codeSelect(source.lastIndexOf(selectString), selectString.length()); + IJavaElement [] variable = unit.codeSelect(source.lastIndexOf(selectString), selectString.length()); assertEquals(1, variable.length); } finally { deleteProject("P"); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java index 0808618fb1d..38c83e78d9c 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java @@ -21,7 +21,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.ICodeAssist; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; @@ -362,7 +361,7 @@ public void testParamAnnotations() throws CoreException { waitForAutoBuild(); ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); - IJavaElement[] variable = ((ICodeAssist) unit).codeSelect(source.indexOf("processor"), "processor".length()); + IJavaElement[] variable = unit.codeSelect(source.indexOf("processor"), "processor".length()); assertEquals(1, variable.length); String annotationString = "@Default [in processor [in Test(String) [in X [in X.java [in p [in src [in P]]]]]]]"; @@ -432,7 +431,7 @@ public void testParamAnnotations3() throws CoreException { waitForAutoBuild(); ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); - IJavaElement[] variable = ((ICodeAssist) unit).codeSelect(source.indexOf("processor"), "processor".length()); + IJavaElement[] variable = unit.codeSelect(source.indexOf("processor"), "processor".length()); assertEquals(1, variable.length); String annotationString1 = "@Default [in processor [in Test(int, String, int) [in X [in X.java [in p [in src [in P]]]]]]]"; diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java index c1772876bdf..e9aec2960b4 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java @@ -655,25 +655,25 @@ public void testNonExistingCU() throws JavaModelException { try { // getBuffer() workingCopy = nonExistingCU.getWorkingCopy(null); - assertSourceEquals("Buffer should be empty", "", ((IOpenable)workingCopy).getBuffer().getContents()); + assertSourceEquals("Buffer should be empty", "", workingCopy.getBuffer().getContents()); // exists() - assertTrue("Working copy should exists", ((IJavaElement)workingCopy).exists()); + assertTrue("Working copy should exists", workingCopy.exists()); // getCorrespondingResource() - assertEquals("Corresponding resource should be null", null, ((IJavaElement)workingCopy).getCorrespondingResource()); + assertEquals("Corresponding resource should be null", null, workingCopy.getCorrespondingResource()); // getPrimaryElement() assertEquals("Unexpected orginal element", nonExistingCU, workingCopy.getPrimaryElement()); // getPath() - assertEquals("Unexpected path", new Path("/P/src/x/y/NonExisting.java"), ((IJavaElement)workingCopy).getPath()); + assertEquals("Unexpected path", new Path("/P/src/x/y/NonExisting.java"), workingCopy.getPath()); // getResource() - assertEquals("Unexpected resource", nonExistingCU.getResource(), ((IJavaElement)workingCopy).getResource()); + assertEquals("Unexpected resource", nonExistingCU.getResource(), workingCopy.getResource()); // isConsistent() - assertTrue("Working copy should be consistent", ((IOpenable)workingCopy).isConsistent()); + assertTrue("Working copy should be consistent", workingCopy.isConsistent()); // restore() boolean exception = false; @@ -685,19 +685,19 @@ public void testNonExistingCU() throws JavaModelException { assertTrue("Should not be able to restore from primary element", exception); // makeConsistent() - ((IOpenable)workingCopy).getBuffer().setContents( + workingCopy.getBuffer().setContents( "public class X {\n" + "}"); - assertTrue("Working copy should not be consistent", !((IOpenable)workingCopy).isConsistent()); - ((IOpenable)workingCopy).makeConsistent(null); - assertTrue("Working copy should be consistent", ((IOpenable)workingCopy).isConsistent()); + assertTrue("Working copy should not be consistent", !workingCopy.isConsistent()); + workingCopy.makeConsistent(null); + assertTrue("Working copy should be consistent", workingCopy.isConsistent()); // save() - ((IOpenable)workingCopy).getBuffer().setContents( + workingCopy.getBuffer().setContents( "public class Y {\n" + "}"); - ((IOpenable)workingCopy).save(null, false); - assertTrue("Working copy should be consistent after save", ((IOpenable)workingCopy).isConsistent()); + workingCopy.save(null, false); + assertTrue("Working copy should be consistent after save", workingCopy.isConsistent()); assertTrue("Primary cu should not exist", !nonExistingCU.exists()); // commitWorkingCopy() diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java index 4c0c0224016..ad5baaca595 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java @@ -47,7 +47,6 @@ import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; import org.eclipse.text.edits.MalformedTreeException; -import org.eclipse.text.edits.MultiTextEdit; import org.eclipse.text.edits.TextEdit; import org.osgi.service.prefs.BackingStoreException; @@ -1289,7 +1288,7 @@ public void testNoEdits() throws Exception { TextEdit edit = imports.rewriteImports(null); - assertEquals(0, ((MultiTextEdit) edit).getChildrenSize()); + assertEquals(0, edit.getChildrenSize()); } public void testAddImportWithCommentBetweenImportsAndType() throws Exception { diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java index 21656c23c4e..721fdb3f253 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java @@ -4523,7 +4523,7 @@ else if (scope instanceof ClassScope) } addExpectedType(expected, scope); } else { - TypeVariableBinding[] typeVariables = ((ReferenceBinding)ref.resolvedType).typeVariables(); + TypeVariableBinding[] typeVariables = ref.resolvedType.typeVariables(); int length = ref.typeArguments == null ? 0 : ref.typeArguments.length; if(typeVariables != null && typeVariables.length >= length) { int index = length - 1; @@ -4551,7 +4551,7 @@ else if (scope instanceof ClassScope) } addExpectedType(expected, scope); } else { - TypeVariableBinding[] typeVariables = ((ReferenceBinding)ref.resolvedType).typeVariables(); + TypeVariableBinding[] typeVariables = ref.resolvedType.typeVariables(); if(typeVariables != null) { int iLength = arguments == null ? 0 : arguments.length; done: for (int i = 0; i < iLength; i++) { @@ -13858,7 +13858,7 @@ private boolean isValidParent(ASTNode parent, ASTNode node, Scope scope){ if(parent instanceof ParameterizedSingleTypeReference) { ParameterizedSingleTypeReference ref = (ParameterizedSingleTypeReference) parent; - TypeVariableBinding[] typeVariables = ((ReferenceBinding)ref.resolvedType).typeVariables(); + TypeVariableBinding[] typeVariables = ref.resolvedType.typeVariables(); int length = ref.typeArguments == null ? 0 : ref.typeArguments.length; int nodeIndex = -1; for(int i = length - 1 ; i > -1 ; i--) { @@ -13882,7 +13882,7 @@ private boolean isValidParent(ASTNode parent, ASTNode node, Scope scope){ } } else if(parent instanceof ParameterizedQualifiedTypeReference) { ParameterizedQualifiedTypeReference ref = (ParameterizedQualifiedTypeReference) parent; - TypeVariableBinding[] typeVariables = ((ReferenceBinding)ref.resolvedType).typeVariables(); + TypeVariableBinding[] typeVariables = ref.resolvedType.typeVariables(); TypeReference[][] arguments = ref.typeArguments; int iLength = arguments == null ? 0 : arguments.length; for (int i = 0; i < iLength; i++) { diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NameQualifiedType.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NameQualifiedType.java index a37aaf1c46c..44274199705 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NameQualifiedType.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NameQualifiedType.java @@ -172,9 +172,9 @@ final boolean subtreeMatch0(ASTMatcher matcher, Object other) { ASTNode clone0(AST target) { NameQualifiedType result = new NameQualifiedType(target); result.setSourceRange(getStartPosition(), getLength()); - result.setQualifier((Name) ((ASTNode) getQualifier()).clone(target)); + result.setQualifier((Name) getQualifier().clone(target)); result.annotations().addAll(ASTNode.copySubtrees(target, annotations())); - result.setName((SimpleName) ((ASTNode) getName()).clone(target)); + result.setName((SimpleName) getName().clone(target)); return result; } diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ParameterizedType.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ParameterizedType.java index 7646aea4565..18c58f75f55 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ParameterizedType.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ParameterizedType.java @@ -144,7 +144,7 @@ final int getNodeType0() { ASTNode clone0(AST target) { ParameterizedType result = new ParameterizedType(target); result.setSourceRange(getStartPosition(), getLength()); - result.setType((Type) ((ASTNode) getType()).clone(target)); + result.setType((Type) getType().clone(target)); result.typeArguments().addAll( ASTNode.copySubtrees(target, typeArguments())); return result; diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/QualifiedType.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/QualifiedType.java index 4a7085ef59e..2ed73574f09 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/QualifiedType.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/QualifiedType.java @@ -224,12 +224,12 @@ final int getNodeType0() { ASTNode clone0(AST target) { QualifiedType result = new QualifiedType(target); result.setSourceRange(getStartPosition(), getLength()); - result.setQualifier((Type) ((ASTNode) getQualifier()).clone(target)); + result.setQualifier((Type) getQualifier().clone(target)); if (this.ast.apiLevel >= AST.JLS8_INTERNAL) { result.annotations().addAll( ASTNode.copySubtrees(target, annotations())); } - result.setName((SimpleName) ((ASTNode) getName()).clone(target)); + result.setName((SimpleName) getName().clone(target)); return result; } diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclarationStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclarationStatement.java index cbc00b2b673..261f3a4be58 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclarationStatement.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclarationStatement.java @@ -320,9 +320,9 @@ public ITypeBinding resolveBinding() { // forward request to the wrapped type declaration AbstractTypeDeclaration d = getDeclaration(); if (d instanceof TypeDeclaration) { - return ((TypeDeclaration) d).resolveBinding(); + return d.resolveBinding(); } else if (d instanceof AnnotationTypeDeclaration) { - return ((AnnotationTypeDeclaration) d).resolveBinding(); + return d.resolveBinding(); } else { // shouldn't happen return null; diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeParameter.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeParameter.java index 28073fbe8dc..9347bd921b5 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeParameter.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeParameter.java @@ -182,7 +182,7 @@ ASTNode clone0(AST target) { result.modifiers().addAll( ASTNode.copySubtrees(target, modifiers())); } - result.setName((SimpleName) ((ASTNode) getName()).clone(target)); + result.setName((SimpleName) getName().clone(target)); result.typeBounds().addAll( ASTNode.copySubtrees(target, typeBounds())); return result; diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java index 0a85ca4807e..d9a4d44868e 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java @@ -159,7 +159,7 @@ protected boolean buildStructure(OpenableElementInfo info, final IProgressMonito } // underlying resource is null in the case of a working copy on a class file in a jar if (underlyingResource != null) - unitInfo.timestamp = ((IFile)underlyingResource).getModificationStamp(); + unitInfo.timestamp = underlyingResource.getModificationStamp(); // compute other problems if needed CompilationUnitDeclaration compilationUnitDeclaration = null; @@ -1377,7 +1377,7 @@ protected void toStringInfo(int tab, StringBuilder buffer, Object info, boolean */ protected void updateTimeStamp(CompilationUnit original) throws JavaModelException { long timeStamp = - ((IFile) original.getResource()).getModificationStamp(); + original.getResource().getModificationStamp(); if (timeStamp == IResource.NULL_STAMP) { throw new JavaModelException( new JavaModelStatus(IJavaModelStatusConstants.INVALID_RESOURCE)); diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java index b53e0148293..53ef8be49ed 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java @@ -1903,7 +1903,7 @@ private void popUntilPrefixOf(IPath path) { while (this.currentElement != null) { IPath currentElementPath = null; if (this.currentElement instanceof IPackageFragmentRoot) { - currentElementPath = ((IPackageFragmentRoot)this.currentElement).getPath(); + currentElementPath = this.currentElement.getPath(); } else { IResource currentElementResource = this.currentElement.resource(); if (currentElementResource != null) { diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java index 0d8bd6fa4e5..4dfa2f4942f 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java @@ -431,7 +431,7 @@ protected IJavaElement getSourceElementAt(int position) throws JavaModelExceptio SourceRefElement candidate = null; do { // check name range - range = ((IField)child).getNameRange(); + range = child.getNameRange(); if (position <= range.getOffset() + range.getLength()) { candidate = child; } else { diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java index 82b0eb82d26..32f6f9f5019 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.Map; -import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -201,9 +200,8 @@ public JavaModel getJavaModel() { public IJavaProject getJavaProject(IResource resource) { switch(resource.getType()){ case IResource.FOLDER: - return new JavaProject(((IFolder)resource).getProject(), this); case IResource.FILE: - return new JavaProject(((IFile)resource).getProject(), this); + return new JavaProject(resource.getProject(), this); case IResource.PROJECT: return new JavaProject((IProject)resource, this); default: diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java index 02845a52b4a..dfdcdb71af6 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java @@ -1666,7 +1666,7 @@ public boolean isActive() { public String toString() { StringBuilder buffer = new StringBuilder(); buffer.append("Info for "); //$NON-NLS-1$ - buffer.append(((JavaElement)this.workingCopy).toStringWithAncestors()); + buffer.append(this.workingCopy.toStringWithAncestors()); buffer.append("\nUse count = "); //$NON-NLS-1$ buffer.append(this.useCount); buffer.append("\nProblem requestor:\n "); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java index b105b70dcf7..3ac1de85994 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java @@ -710,7 +710,7 @@ public void computePackageFragmentRoots( String rootID = ((ClasspathEntry)resolvedEntry).rootID(); if (rootIDs.contains(rootID)) return; - if(excludeTestCode && ((ClasspathEntry)resolvedEntry).isTest()) { + if(excludeTestCode && resolvedEntry.isTest()) { return; } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModularClassFile.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModularClassFile.java index 4b8a07d599c..ea255ebd238 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModularClassFile.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModularClassFile.java @@ -63,7 +63,7 @@ protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, BinaryModule module = new BinaryModule(this, moduleInfo); newElements.put(module, moduleInfo); info.setChildren(new IJavaElement[] {module}); - ((ClassFileInfo) info).setModule(module); + info.setModule(module); ((PackageFragmentRootInfo) getPackageFragmentRoot().getElementInfo()).setModule(module); return true; } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java index 5749425a292..3a891d3eaf5 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java @@ -438,7 +438,7 @@ public char[][] fullInclusionPatternChars() { public String getElementName() { IResource res = resource(); if (res instanceof IFolder) - return ((IFolder) res).getName(); + return res.getName(); return ""; //$NON-NLS-1$ } /** diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java index aca70d7c5f0..0ebe3b538e8 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java @@ -981,7 +981,7 @@ protected IType resolveTypeByLocation(char[] packageName, char[] typeName, int a IType type= null; // TODO (david) post 3.0 should remove isOpen check, and investigate reusing ICompilationUnit#getElementAt. may need to optimize #getElementAt to remove recursions - if (this.openable instanceof CompilationUnit && ((CompilationUnit)this.openable).isOpen()) { + if (this.openable instanceof CompilationUnit && this.openable.isOpen()) { CompilationUnit wc = (CompilationUnit) this.openable; try { if(((packageName == null || packageName.length == 0) && wc.getPackageDeclarations().length == 0) || diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DOMFinder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DOMFinder.java index 250860f4e0b..c0ef0f1b18f 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DOMFinder.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DOMFinder.java @@ -79,7 +79,7 @@ public ASTNode search() throws JavaModelException { ISourceRange range = null; if (this.element instanceof IMember && !(this.element instanceof IInitializer) && !(this.element instanceof LambdaMethod) && !(this.element instanceof org.eclipse.jdt.internal.core.LambdaExpression)) - range = ((IMember) this.element).getNameRange(); + range = this.element.getNameRange(); else if (this.element instanceof ITypeParameter || this.element instanceof ILocalVariable) range = this.element.getNameRange(); else diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java index c4304e6bab0..44b66c504a5 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java @@ -1954,7 +1954,7 @@ private String[] bootstrapArgumentsDescription(IBootstrapMethodsEntry entry, ICo } break; case IConstantPoolConstant.CONSTANT_MethodType: - arguments[i] = new String(((ConstantPoolEntry2) constantPoolEntry).getMethodDescriptor()); + arguments[i] = new String(constantPoolEntry.getMethodDescriptor()); break; case IConstantPoolConstant.CONSTANT_Class: arguments[i] = new String(constantPoolEntry.getClassInfoName()); diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java index 299d1e0a168..c32c62f8694 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java @@ -597,7 +597,7 @@ public void processDelta(IJavaElementDelta delta, int eventType) { path = ((IJavaProject)element).getProject().getFullPath().toString(); break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: - path = ((IPackageFragmentRoot)element).getPath().toString(); + path = element.getPath().toString(); break; default: return;