/** * Finds the type with the given fully qualified name (generic type * parameters included) in the hierarchy. * * @param type * The hierarchy type to find the super type in * @param name * The fully qualified name of the super type * @return The found super type, or <code>null</code> */ protected static ITypeBinding findTypeInHierarchy(final ITypeBinding type, final String name) { if (type.isArray() || type.isPrimitive()) return null; if (name.equals(type.getTypeDeclaration().getQualifiedName())) return type; final ITypeBinding binding= type.getSuperclass(); if (binding != null) { final ITypeBinding result= findTypeInHierarchy(binding, name); if (result != null) return result; } final ITypeBinding[] bindings= type.getInterfaces(); for (int index= 0; index < bindings.length; index++) { final ITypeBinding result= findTypeInHierarchy(bindings[index], name); if (result != null) return result; } return null; }
/** * Finds the type with the given fully qualified name (generic type * parameters included) in the hierarchy. * * @param type * The hierarchy type to find the super type in * @param name * The fully qualified name of the super type * @return The found super type, or <code>null</code> */ protected static ITypeBinding findTypeInHierarchy(final ITypeBinding type, final String name) { if (type.isArray() || type.isPrimitive()) return null; if (name.equals(type.getTypeDeclaration().getQualifiedName())) return type; final ITypeBinding binding= type.getSuperclass(); if (binding != null) { final ITypeBinding result= findTypeInHierarchy(binding, name); if (result != null) return result; } final ITypeBinding[] bindings= type.getInterfaces(); for (int index= 0; index < bindings.length; index++) { final ITypeBinding result= findTypeInHierarchy(bindings[index], name); if (result != null) return result; } return null; }
/** * Finds the type with the given fully qualified name (generic type * parameters included) in the hierarchy. * * @param type * The hierarchy type to find the super type in * @param name * The fully qualified name of the super type * @return The found super type, or <code>null</code> */ protected static ITypeBinding findTypeInHierarchy(final ITypeBinding type, final String name) { if (type.isArray() || type.isPrimitive()) return null; if (name.equals(type.getTypeDeclaration().getQualifiedName())) return type; final ITypeBinding binding= type.getSuperclass(); if (binding != null) { final ITypeBinding result= findTypeInHierarchy(binding, name); if (result != null) return result; } final ITypeBinding[] bindings= type.getInterfaces(); for (int index= 0; index < bindings.length; index++) { final ITypeBinding result= findTypeInHierarchy(bindings[index], name); if (result != null) return result; } return null; }
public final void acceptAST(final ICompilationUnit unit, final CompilationUnit node) { try { final CompilationUnitRewrite subRewrite= new CompilationUnitRewrite(fOwner, unit, node); final AbstractTypeDeclaration subDeclaration= ASTNodeSearchUtil.getAbstractTypeDeclarationNode(fSubType, subRewrite.getRoot()); if (subDeclaration != null) { final ITypeBinding subBinding= subDeclaration.resolveBinding(); if (subBinding != null) { final ITypeBinding superBinding= findTypeInHierarchy(subBinding, fSuperType.getFullyQualifiedName('.')); if (superBinding != null) { solveSuperTypeConstraints(subRewrite.getCu(), subRewrite.getRoot(), fSubType, subBinding, superBinding, new SubProgressMonitor(monitor, 100), status); if (!status.hasFatalError()) { rewriteTypeOccurrences(manager, this, subRewrite, subRewrite.getCu(), subRewrite.getRoot(), new HashSet(), status, new SubProgressMonitor(monitor, 200)); final TextChange change= subRewrite.createChange(); if (change != null) manager.manage(subRewrite.getCu(), change); } } } } } catch (CoreException exception) { JavaPlugin.log(exception); status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.UseSuperTypeProcessor_internal_error)); } }
@Override public final void acceptAST(final ICompilationUnit unit, final CompilationUnit node) { try { final CompilationUnitRewrite subRewrite= new CompilationUnitRewrite(fOwner, unit, node); final AbstractTypeDeclaration subDeclaration= ASTNodeSearchUtil.getAbstractTypeDeclarationNode(fSubType, subRewrite.getRoot()); if (subDeclaration != null) { final ITypeBinding subBinding= subDeclaration.resolveBinding(); if (subBinding != null) { final ITypeBinding superBinding= findTypeInHierarchy(subBinding, fSuperType.getFullyQualifiedName('.')); if (superBinding != null) { solveSuperTypeConstraints(subRewrite.getCu(), subRewrite.getRoot(), fSubType, subBinding, superBinding, new SubProgressMonitor(monitor, 100), status); if (!status.hasFatalError()) { rewriteTypeOccurrences(manager, this, subRewrite, subRewrite.getCu(), subRewrite.getRoot(), new HashSet<String>(), status, new SubProgressMonitor(monitor, 200)); final TextChange change= subRewrite.createChange(true); if (change != null) manager.manage(subRewrite.getCu(), change); } } } } } catch (CoreException exception) { JavaPlugin.log(exception); status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.UseSuperTypeProcessor_internal_error)); } }
@Override public final void acceptAST(final ICompilationUnit unit, final CompilationUnit node) { try { final CompilationUnitRewrite subRewrite= new CompilationUnitRewrite(fOwner, unit, node); final AbstractTypeDeclaration subDeclaration= ASTNodeSearchUtil.getAbstractTypeDeclarationNode(fSubType, subRewrite.getRoot()); if (subDeclaration != null) { final ITypeBinding subBinding= subDeclaration.resolveBinding(); if (subBinding != null) { final ITypeBinding superBinding= findTypeInHierarchy(subBinding, fSuperType.getFullyQualifiedName('.')); if (superBinding != null) { solveSuperTypeConstraints(subRewrite.getCu(), subRewrite.getRoot(), fSubType, subBinding, superBinding, new SubProgressMonitor(monitor, 100), status); if (!status.hasFatalError()) { rewriteTypeOccurrences(manager, this, subRewrite, subRewrite.getCu(), subRewrite.getRoot(), new HashSet<String>(), status, new SubProgressMonitor(monitor, 200)); final TextChange change= subRewrite.createChange(true); if (change != null) manager.manage(subRewrite.getCu(), change); } } } } } catch (CoreException exception) { JavaPlugin.log(exception); status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.UseSuperTypeProcessor_internal_error)); } }