More regarding  Bug 321411 -  [hierarchy] Replace OTTypeHierarchy with adapting the original TypeHierarchy
(see comment 5 for details)
diff --git a/plugins/org.eclipse.objectteams.otdt.refactoring/plugin.xml b/plugins/org.eclipse.objectteams.otdt.refactoring/plugin.xml
index f7f8800..b56f6e3 100644
--- a/plugins/org.eclipse.objectteams.otdt.refactoring/plugin.xml
+++ b/plugins/org.eclipse.objectteams.otdt.refactoring/plugin.xml
@@ -64,23 +64,6 @@
                icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
          </team>
       </aspectBinding>
-      <aspectBinding
-            icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/calloutbinding_obj.gif">
-         <basePlugin
-               icon="platform:/plugin/org.eclipse.pde.ui/icons/obj16/plugin_obj.gif"
-               id="org.eclipse.jdt.core">
-         </basePlugin>
-         <team
-               activation="NONE"
-               class="org.eclipse.objectteams.otdt.internal.refactoring.adaptor.pullup.OTTypeHierarchyAdaptor"
-               icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
-         </team>
-         <team
-               activation="NONE"
-               class="org.eclipse.objectteams.otdt.internal.refactoring.adaptor.PhantomTypeAdaptor"
-               icon="platform:/plugin/org.eclipse.objectteams.otdt.ui/icons/ot/team_obj.gif">
-         </team>
-      </aspectBinding>
    </extension>
    <extension
          point="org.eclipse.ui.actionSets">
diff --git a/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/PhantomTypeAdaptor.java b/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/PhantomTypeAdaptor.java
deleted file mode 100644
index 6c3e2be..0000000
--- a/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/PhantomTypeAdaptor.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**

- * 

- */

-package org.eclipse.objectteams.otdt.internal.refactoring.adaptor;

-

-import org.eclipse.jdt.core.IType;

-import org.eclipse.jdt.core.ITypeParameter;

-import org.eclipse.jdt.core.JavaModelException;

-

-import base org.eclipse.objectteams.otdt.core.PhantomType;

-

-/**

- * 

- * This team provides the implementation for some unimplemented methods in

- * {@link PhantomType}, that would otherwise throw an

- * <code>UnsupportedOperationException</code>. The methods are used in

- * {@link RenameTypeAdaptor} to search for <code>PhantomType</code> references

- * with the java search. 

- * FIXME: This team should be removed if the necessary methods

- * are implemented in the original {@link PhantomType}.

- * 

- * @author Johannes Gebauer

- */

-public team class PhantomTypeAdaptor{

-	protected class PhantomType playedBy PhantomType {

-

-		IType getRealType() -> IType getRealType();

-

-		@SuppressWarnings("basecall")

-		callin ITypeParameter[] getTypeParameters() throws JavaModelException {

-			return getRealType().getTypeParameters();

-		}

-		getTypeParameters <- replace getTypeParameters;

-		

-		@SuppressWarnings("basecall")

-		callin boolean isResolved() {

-			return false;

-		}

-		isResolved <- replace isResolved;

-		

-	}

-}

diff --git a/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/RenameTypeAdaptor.java b/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/RenameTypeAdaptor.java
index ce068e5..0d489db 100644
--- a/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/RenameTypeAdaptor.java
+++ b/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/RenameTypeAdaptor.java
@@ -22,6 +22,7 @@
 import org.eclipse.jdt.core.IPackageFragment;

 import org.eclipse.jdt.core.IPackageFragmentRoot;

 import org.eclipse.jdt.core.IType;

+import org.eclipse.jdt.core.ITypeHierarchy;

 import org.eclipse.jdt.core.JavaCore;

 import org.eclipse.jdt.core.JavaModelException;

 import org.eclipse.jdt.internal.corext.refactoring.Checks;

@@ -47,7 +48,7 @@
 import org.eclipse.objectteams.otdt.core.OTModelManager;

 import org.eclipse.objectteams.otdt.core.PhantomType;

 import org.eclipse.objectteams.otdt.core.TypeHelper;

-import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;

+import org.eclipse.objectteams.otdt.core.hierarchy.OTTypeHierarchies;

 

 import base org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor;

 

@@ -69,7 +70,7 @@
 		private IPackageFragment fRoleDirectory;

 		private IType[] fImplicitRelatedTypes;

 		private IType[] fImplicitRelatedPhantomTypes;

-		private OTTypeHierarchy fOTTypeHierarchy;

+		private ITypeHierarchy fTypeHierarchy;

 		private boolean fTypeToRenameIsRole;

 		private String fCachedNewElementName;

 		private JavaModelException fCachedException;

@@ -122,7 +123,7 @@
 			// Special Conditions for Roles

 			if(fTypeToRenameIsRole){

 				jdtStatus.merge(checkForRoleOverriding(pm));

-			    jdtStatus.merge(checkRenameForImplicitRelatedTypes(getFType(), fOTTypeHierarchy, pm));

+			    jdtStatus.merge(checkRenameForImplicitRelatedTypes(getFType(), fTypeHierarchy, pm));

 			}

 			

 			pm.done();

@@ -135,15 +136,14 @@
 		private void initializeOTInformations(IProgressMonitor pm) throws JavaModelException {

 			// Do not initialize again if the preconditions have not changed.

 			// OT informations depend on the type and the new element name.

-			if(fOTTypeHierarchy != null && fOTTypeHierarchy.getFocusType() == getFType() 

+			if(fTypeHierarchy != null && fTypeHierarchy.getType() == getFType() 

 			   &&  getNewElementName().equals(fCachedNewElementName)){

 				return;

 			}

 

 			fCachedNewElementName = getNewElementName();

-			fOTTypeHierarchy = new OTTypeHierarchy(getFType(), getFType().getJavaProject(), true);

-			fOTTypeHierarchy.refresh(pm);

-			findImplicitRelatedTypes(getFType(), fOTTypeHierarchy, null);

+			fTypeHierarchy = getFType().newTypeHierarchy(pm);

+			findImplicitRelatedTypes(getFType(), fTypeHierarchy, null);

 			fTypeToRenameIsRole = TypeHelper.isRole(getFType().getFlags());

 			if(Flags.isTeam(getFType().getFlags())){

 				fRoleDirectory = getRoleDirectoryForTeam(getFType());

@@ -203,23 +203,20 @@
 					otPreloadedElementToNameDefault.putAll(getFPreloadedElementToNameDefault());

 				}

 				

-				//TODO: UnsupportedOperationException in PhantomType(the PhantomTypeAdaptor provides a quick fix)

-				within(new PhantomTypeAdaptor()){

-					// find references for implicit related phantom types

-					for (int i = 0; i < fImplicitRelatedPhantomTypes.length; i++) {

-						setFType(fImplicitRelatedPhantomTypes[i]);

-						setFReferences(null);

-						

-						jdtStatus.merge(base.initializeReferences(monitor));

-						

-						// add all references of the implicit related type

-						otReferences.addAll(Arrays.asList(getFReferences()));

-						

-						// add all similar name references of the implicit related type to the maps

-						otPreloadedElementToName.putAll(getFPreloadedElementToName());

-						otPreloadedElementToSelection.putAll(getFPreloadedElementToSelection());

-						otPreloadedElementToNameDefault.putAll(getFPreloadedElementToNameDefault());

-					}

+				// find references for implicit related phantom types

+				for (int i = 0; i < fImplicitRelatedPhantomTypes.length; i++) {

+					setFType(fImplicitRelatedPhantomTypes[i]);

+					setFReferences(null);

+					

+					jdtStatus.merge(base.initializeReferences(monitor));

+					

+					// add all references of the implicit related type

+					otReferences.addAll(Arrays.asList(getFReferences()));

+					

+					// add all similar name references of the implicit related type to the maps

+					otPreloadedElementToName.putAll(getFPreloadedElementToName());

+					otPreloadedElementToSelection.putAll(getFPreloadedElementToSelection());

+					otPreloadedElementToNameDefault.putAll(getFPreloadedElementToNameDefault());

 				}

 			}finally{

 				// ensure that the original focus type is reset after processing the implicit type references

@@ -242,7 +239,7 @@
 		}

 		initializeReferences <- replace initializeReferences;

 		

-		private RefactoringStatus checkRenameForImplicitRelatedTypes(IType type, OTTypeHierarchy otTypeHierarchy, IProgressMonitor pm) throws CoreException {

+		private RefactoringStatus checkRenameForImplicitRelatedTypes(IType type, ITypeHierarchy otTypeHierarchy, IProgressMonitor pm) throws CoreException {

 			RefactoringStatus status = new RefactoringStatus();

 			for (int i = 0; i < fImplicitRelatedTypes.length; i++) {

 				status.merge(checkShadowingInEnclosingTeams(fImplicitRelatedTypes[i]));

@@ -253,13 +250,12 @@
 			return status;

 		}

 

-		private void findImplicitRelatedTypes(IType type, OTTypeHierarchy otTypeHierarchy, IProgressMonitor pm) throws JavaModelException {

+		private void findImplicitRelatedTypes(IType type, ITypeHierarchy otTypeHierarchy, IProgressMonitor pm) throws JavaModelException {

 			IType topmostType = findTopMostType(type, otTypeHierarchy);

-			OTTypeHierarchy topmostTypeHierarchy = new OTTypeHierarchy(topmostType, topmostType.getJavaProject(), true);

-			topmostTypeHierarchy.refresh(pm);

+			ITypeHierarchy topmostTypeHierarchy = topmostType.newTypeHierarchy(pm);

 			

 			ArrayList<IType> relatedTypes = new ArrayList<IType>();

-			relatedTypes.addAll(Arrays.asList(topmostTypeHierarchy.getAllTSubtypes(topmostType)));

+			relatedTypes.addAll(Arrays.asList(OTTypeHierarchies.getInstance().getAllTSubTypes(topmostTypeHierarchy, topmostType)));

 

 			// exchange the topmost type with the given type

 			if(!topmostType.equals(type)){

@@ -270,9 +266,9 @@
 			fImplicitRelatedTypes = relatedTypes.toArray(new IType[relatedTypes.size()]);

 			

 			// search the implicit related phantom types

-			topmostTypeHierarchy.setPhantomMode(true);

+			OTTypeHierarchies.getInstance().setPhantomMode(topmostTypeHierarchy, true);

 			ArrayList<IType> relatedPhantomTypes = new ArrayList<IType>();

-			relatedPhantomTypes.addAll(Arrays.asList(topmostTypeHierarchy.getAllTSubtypes(topmostType)));

+			relatedPhantomTypes.addAll(Arrays.asList(OTTypeHierarchies.getInstance().getAllTSubTypes(topmostTypeHierarchy, topmostType)));

 			relatedPhantomTypes.removeAll(relatedTypes);

 			relatedPhantomTypes.remove(type);

 			fImplicitRelatedPhantomTypes = relatedPhantomTypes.toArray(new IType[relatedPhantomTypes.size()]);

@@ -286,11 +282,12 @@
 		 * @param type the role type to start the search

 		 * @param otTypeHierarchy for the type

 		 * @return the topmost Role Type for the given type

+		 * @throws JavaModelException if the tsuper hierarchy could not be linearized properly

 		 */

-		private IType findTopMostType(IType type, OTTypeHierarchy otTypeHierarchy) {

-			IType[] superTypes = otTypeHierarchy.getAllTSuperTypes(type);

+		private IType findTopMostType(IType type, ITypeHierarchy otTypeHierarchy) throws JavaModelException {

+			IType[] superTypes = OTTypeHierarchies.getInstance().getAllTSuperTypes(otTypeHierarchy, type);

 			for (int i = 0; i < superTypes.length; i++) {

-				if(otTypeHierarchy.getAllTSuperTypes(superTypes[i]).length == 0){

+				if(OTTypeHierarchies.getInstance().getAllTSuperTypes(otTypeHierarchy, superTypes[i]).length == 0){

 					return superTypes[i];

 				}

 			}

@@ -396,7 +393,7 @@
 					for (int j = 0; j < roles.length; j++) {

 						IType role = roles[j];

 						if(role.getElementName().equals(getNewElementName())){

-							String msg = Messages.format("A role type named ''{0}'' exists in ''{1}'' and would shadow the renamed type (OTLD �1.4(a)).", new String[] { getNewElementName(),

+							String msg = Messages.format("A role type named ''{0}'' exists in ''{1}'' and would shadow the renamed type (OTJLD §1.4(a)).", new String[] { getNewElementName(),

 									type.getFullyQualifiedName('.') });

 							jdtStatus.addError(msg, JavaStatusContext.create(role));

 						}

@@ -480,8 +477,7 @@
 				

 				

 				// search for implicit overriding in the subtypes of the enclosing team

-				OTTypeHierarchy teamHierarchy = new OTTypeHierarchy(enclosingTeam, enclosingTeam.getJavaProject(), true);

-				teamHierarchy.refresh(pm);

+				ITypeHierarchy teamHierarchy = enclosingTeam.newTypeHierarchy(pm);

 				IType[] subtypes = teamHierarchy.getAllSubtypes(enclosingTeam);

 				for (int i = 0; i < subtypes.length; i++) {

 					IType[] declaredRoles = getDeclaredRoles(subtypes[i]);

@@ -549,7 +545,7 @@
 				for (int j = 0; j < nestedRoles.length; j++) {

 					IType role = nestedRoles[j];

 					if(role.getElementName().equals(getNewElementName())){

-						String msg = Messages.format("The role type ''{0}'' would shadow the renamed type (OTLD �1.4(a))."

+						String msg = Messages.format("The role type ''{0}'' would shadow the renamed type (OTJLD §1.4(a))."

 								, new String[] { BasicElementLabels.getJavaElementName(role.getFullyQualifiedName('.')) });

 						status.addError(msg, JavaStatusContext.create(role));

 					}

@@ -567,7 +563,7 @@
 					}

 					IType role = outerRoles[i];

 					if(role.getElementName().equals(getNewElementName())){

-						String msg = Messages.format("The renamed role type would shadow the visible type ''{0}'' (OTLD �1.4(a))."

+						String msg = Messages.format("The renamed role type would shadow the visible type ''{0}'' (OTJLD §1.4(a))."

 								, new String[] { BasicElementLabels.getJavaElementName(role.getFullyQualifiedName('.')) });

 						status.addError(msg, JavaStatusContext.create(role));

 					}

diff --git a/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/pullup/OTTypeHierarchyAdaptor.java b/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/pullup/OTTypeHierarchyAdaptor.java
deleted file mode 100644
index 08637a7..0000000
--- a/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/pullup/OTTypeHierarchyAdaptor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.eclipse.objectteams.otdt.internal.refactoring.adaptor.pullup;

-

-import org.eclipse.jdt.core.IType;

-

-import base org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;

-

-/**

- * @author Johannes Gebauer

- * 

- *         This team is by default deactivated. It can be activated to suppress

- *         the <code>UnsupportedOperationException</code> on

- *         {@link OTTypeHierarchy#getSuperclass(IType)}. The adaptor is useful

- *         to reuse jdt functionality that is not aware of multiple

- *         superclasses.

- */

-@SuppressWarnings("restriction")

-public team class OTTypeHierarchyAdaptor {

-

-	/**

-	 * Prevents {@link OTTypeHierarchy#getSuperclass(IType)} calls on

-	 * OTTypeHierarchies to avoid an <code>UnsupportedOperationException</code>.

-	 */

-	public class OTTypeHierarchyRole playedBy OTTypeHierarchy {

-		IType getExplicitSuperclass(IType type) -> IType getExplicitSuperclass(IType type);

-

-		@SuppressWarnings("basecall")

-		callin IType getSuperclass(IType type) {

-			return this.getExplicitSuperclass(type);

-		}

-

-		getSuperclass <- replace getSuperclass;

-

-	}

-

-}

diff --git a/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/pullup/PullUpAdaptor.java b/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/pullup/PullUpAdaptor.java
index 4ca69ba..755b1a3 100644
--- a/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/pullup/PullUpAdaptor.java
+++ b/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/pullup/PullUpAdaptor.java
@@ -11,8 +11,6 @@
 

 import org.eclipse.core.runtime.CoreException;

 import org.eclipse.core.runtime.IProgressMonitor;

-import org.eclipse.core.runtime.NullProgressMonitor;

-import org.eclipse.core.runtime.SubProgressMonitor;

 import org.eclipse.jdt.core.Flags;

 import org.eclipse.jdt.core.IField;

 import org.eclipse.jdt.core.IMember;

@@ -20,9 +18,6 @@
 import org.eclipse.jdt.core.IType;

 import org.eclipse.jdt.core.ITypeHierarchy;

 import org.eclipse.jdt.core.JavaModelException;

-import org.eclipse.jdt.core.dom.IMethodBinding;

-import org.eclipse.jdt.core.dom.MethodDeclaration;

-import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;

 import org.eclipse.jdt.core.search.IJavaSearchConstants;

 import org.eclipse.jdt.core.search.IJavaSearchScope;

 import org.eclipse.jdt.core.search.MethodDeclarationMatch;

@@ -33,8 +28,6 @@
 import org.eclipse.jdt.core.search.SearchRequestor;

 import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages;

 import org.eclipse.jdt.internal.corext.refactoring.base.JavaStatusContext;

-import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;

-import org.eclipse.jdt.internal.corext.refactoring.structure.TypeVariableMaplet;

 import org.eclipse.jdt.internal.corext.util.Messages;

 import org.eclipse.ltk.core.refactoring.RefactoringStatus;

 import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry;

@@ -44,19 +37,15 @@
 import org.eclipse.objectteams.otdt.core.ICalloutToFieldMapping;

 import org.eclipse.objectteams.otdt.core.IMethodMapping;

 import org.eclipse.objectteams.otdt.core.IOTType;

-import org.eclipse.objectteams.otdt.core.IOTTypeHierarchy;

 import org.eclipse.objectteams.otdt.core.OTModelManager;

 import org.eclipse.objectteams.otdt.core.TypeHelper;

-import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;

+import org.eclipse.objectteams.otdt.core.hierarchy.OTTypeHierarchies;

 import org.eclipse.objectteams.otdt.internal.core.RoleType;

 import org.eclipse.objectteams.otdt.internal.refactoring.util.IAmbuguityMessageCreator;

 import org.eclipse.objectteams.otdt.internal.refactoring.util.IOverloadingMessageCreator;

 import org.eclipse.objectteams.otdt.internal.refactoring.util.RefactoringUtil;

 

 import base org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor;

-import base org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor.PullUpAstNodeMapper;

-import base org.eclipse.jdt.internal.ui.refactoring.PullUpMethodPage;

-import base org.eclipse.jdt.internal.ui.refactoring.PullUpMethodPage.PullUpHierarchyContentProvider;

 
 /**

  * @author Johannes Gebauer

@@ -74,8 +63,6 @@
 		IMember[] getMembersToDelete(IProgressMonitor monitor) -> IMember[] getMembersToDelete(IProgressMonitor monitor);

 		IMethod[] getFDeletedMethods() -> get IMethod[] fDeletedMethods;

 		IMember[] getFMembersToMove() -> get IMember[] fMembersToMove;

-			

-		private ITypeHierarchy _destinationOTTypeHierachy;

 

 		// callouts

 		IType getDestinationType() -> IType getDestinationType();

@@ -107,12 +94,12 @@
 				return status;

 			}

 			

-			OTTypeHierarchy hier = (OTTypeHierarchy)getDestinationTypeHierarchy(pm);

+			ITypeHierarchy hier = getDestinationTypeHierarchy(pm);

 			ArrayList<IType> implicitSubRoles = new ArrayList<IType>();

-			implicitSubRoles.addAll(Arrays.asList(hier.getAllTSubtypes(getDestinationType())));

+			implicitSubRoles.addAll(Arrays.asList(OTTypeHierarchies.getInstance().getAllTSubTypes(hier, getDestinationType())));

 			

 			// remove the subtypes of the declaring type

-			implicitSubRoles.removeAll(Arrays.asList(hier.getAllTSubtypes(getDeclaringType())));

+			implicitSubRoles.removeAll(Arrays.asList(OTTypeHierarchies.getInstance().getAllTSubTypes(hier, getDeclaringType())));

 			

 			pm.beginTask("Checking Shadowing", implicitSubRoles.size());

 			pm.subTask(""); //$NON-NLS-1$

@@ -428,109 +415,8 @@
 		

 		needsVisibilityAdjustment <- replace needsVisibilityAdjustment;

 			

-		/**

-		 * Replaces the jdt hierarchy with the ot hierarchy. 

-		 */

-		@SuppressWarnings("basecall")

-		callin ITypeHierarchy getDestinationOTTypeHierarchy() throws JavaModelException {

-					if(_destinationOTTypeHierachy != null && _destinationOTTypeHierachy.getType().equals(getDestinationType())){

-						return _destinationOTTypeHierachy;

-					}else{

-						if(OTModelManager.hasOTElementFor(getDestinationType())){

-							_destinationOTTypeHierachy = OTModelManager.getOTElement(getDestinationType()).newOTTypeHierarchy(new NullProgressMonitor());

-						}else{

-							_destinationOTTypeHierachy = base.getDestinationOTTypeHierarchy();

-						}

-						return _destinationOTTypeHierachy;

-					}

-		}

-		

-		getDestinationOTTypeHierarchy <- replace getDestinationTypeHierarchy;

-		

-		/**

-		 * Prevents {@link OTTypeHierarchy#getSuperclass(IType)} calls on OTTypeHierarchies to avoid an

-		 *  <code>UnsupportedOperationException</code>.

-		 */

-		callin void copyBodyOfPulledUpMethod(

-				final CompilationUnitRewrite sourceRewrite,

-				final CompilationUnitRewrite targetRewrite, final IMethod method,

-				final MethodDeclaration oldMethod,

-				final MethodDeclaration newMethod,

-				final TypeVariableMaplet[] mapping, final IProgressMonitor monitor)

-				throws JavaModelException {

-			within(new OTTypeHierarchyAdaptor()){

-				base.copyBodyOfPulledUpMethod(sourceRewrite, targetRewrite, method, oldMethod, newMethod, mapping, monitor);

-			}

-		}

-		copyBodyOfPulledUpMethod <- replace copyBodyOfPulledUpMethod;

-		

-		/**

-		 * Prevents {@link OTTypeHierarchy#getSuperclass(IType)} calls on OTTypeHierarchies to avoid an

-		 *  <code>UnsupportedOperationException</code>.

-		 */

-		@SuppressWarnings({"unchecked", "rawtypes" })

-		callin Set getSkippedSuperTypes(final IProgressMonitor monitor) throws JavaModelException {

-			if(Flags.isRole(getDestinationType().getFlags())){

-				// do not add implicit skipped super types twice

-				if (getFCachedSkippedSuperTypes() != null && getDestinationTypeHierarchy(new SubProgressMonitor(monitor, 1)).getType().equals(getDestinationType()))

-					return base.getSkippedSuperTypes(monitor);

-				

-				// calculate implicit skipped super types

-				final IOTTypeHierarchy otHierarchy = (IOTTypeHierarchy) getDestinationTypeHierarchy(new SubProgressMonitor(monitor, 1));

-				List<IType> subtypes = Arrays.asList(otHierarchy.getAllTSubtypes(getDestinationType()));

-				List<IType> superTypes = Arrays.asList(otHierarchy.getAllTSuperTypes(getDeclaringType()));

-				Set<IType> skippedImplicitTypes = new HashSet();

-				

-				// intersect super types and sub types

-				for (IType type : superTypes) {

-					if(subtypes.contains(type)){

-						skippedImplicitTypes.add(type);

-					}

-				}

-

-				within(new OTTypeHierarchyAdaptor()){

-					// calculate explicit skipped supoer types

-					base.getSkippedSuperTypes(monitor);

-					// add implicit skipped super types

-					getFCachedSkippedSuperTypes().addAll(skippedImplicitTypes);

-					return getFCachedSkippedSuperTypes();

-				}

-			}else{

-				within(new OTTypeHierarchyAdaptor()){

-					return base.getSkippedSuperTypes(monitor);

-				}

-			}

-		}

-		getSkippedSuperTypes <- replace getSkippedSuperTypes;

 	}

 	

-	public class PullUpHierarchyContentProvider playedBy PullUpHierarchyContentProvider{

-		/**

-		 * Prevents {@link OTTypeHierarchy#getSuperclass(IType)} calls on OTTypeHierarchies to avoid an

-		 *  <code>UnsupportedOperationException</code>.

-		 */

-		callin Object getParent(final Object element) {

-			within(new OTTypeHierarchyAdaptor()){	

-				return base.getParent(element);

-			}

-		}

-		getParent <- replace getParent;

-

-	}

-	

-	public class PullUpMethodPage playedBy PullUpMethodPage{

-		/**

-		 * Prevents {@link OTTypeHierarchy#getSuperclass(IType)} calls on OTTypeHierarchies to avoid an

-		 *  <code>UnsupportedOperationException</code>.

-		 */

-		callin void checkAllParents(final IType parent) {

-			within(new OTTypeHierarchyAdaptor()){				

-				base.checkAllParents(parent);

-			}

-		}

-		checkAllParents <- replace checkAllParents;

-

-	}

 }

 

 

diff --git a/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/pushdown/PushDownAdaptor.java b/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/pushdown/PushDownAdaptor.java
index a557f7c..2462ad6 100644
--- a/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/pushdown/PushDownAdaptor.java
+++ b/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/adaptor/pushdown/PushDownAdaptor.java
@@ -26,7 +26,6 @@
 import org.eclipse.jdt.core.search.SearchPattern;

 import org.eclipse.jdt.core.search.SearchRequestor;

 import org.eclipse.jdt.internal.core.ResolvedSourceMethod;

-import org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy;

 import org.eclipse.jdt.internal.corext.refactoring.base.JavaStatusContext;

 import org.eclipse.jdt.internal.corext.refactoring.structure.PushDownRefactoringProcessor.MemberActionInfo;

 import org.eclipse.jdt.internal.corext.util.Messages;

@@ -101,7 +100,7 @@
 						

 						// shadowing fields is just forbidden in implicit hierarchies

 						if(TypeHelper.isRole(type.getFlags())){

-							TypeHierarchy implicitHierarchy = (TypeHierarchy) type.newSupertypeHierarchy(pm);

+							ITypeHierarchy implicitHierarchy = type.newSupertypeHierarchy(pm);

 							IType[] implicitSuperTypes = OTTypeHierarchies.getInstance().getAllTSuperTypes(implicitHierarchy, type);

 							

 							for (int j = 0; j < implicitSuperTypes.length; j++) {

@@ -267,7 +266,7 @@
 			RefactoringStatus status = new RefactoringStatus();

 			ITypeHierarchy hier = getHierarchyOfDeclaringClass(pm);

 			

-			OTTypeHierarchies.getInstance().setPhantomMode((TypeHierarchy)hier, true);

+			OTTypeHierarchies.getInstance().setPhantomMode(hier, true);

 			IType[] subTypes = hier.getSubtypes(getDeclaringType());

 			for (int i = 0; i < subTypes.length; i++) {

 				IType subType = subTypes[i];

@@ -276,7 +275,7 @@
 					status.addError(msg, JavaStatusContext.create(subType));

 				}

 			}

-			OTTypeHierarchies.getInstance().setPhantomMode((TypeHierarchy)hier, false);

+			OTTypeHierarchies.getInstance().setPhantomMode(hier, false);

 			return status;

 		}

 		

@@ -288,7 +287,7 @@
 		 * @return the <code>RefactoringStatus</code> indicating overriding

 		 * @throws JavaModelException 

 		 */

-		private RefactoringStatus checkOverriding(IType type ,IProgressMonitor pm) throws JavaModelException{

+		private RefactoringStatus checkOverriding(IType type, IProgressMonitor pm) throws JavaModelException{

 			RefactoringStatus status = new RefactoringStatus();

 			

 			// only roles inherit implicitly

@@ -296,9 +295,8 @@
 				

 				IMember[] membersToPushDown = getMembersToMove();

 				

-				// create the ot hierarchy to check implicit super types

-				TypeHierarchy hierarchy = new TypeHierarchy(type, null, type.getJavaProject(), false);

-				hierarchy.refresh(pm);

+				// create a hierarchy to check implicit super types

+				ITypeHierarchy hierarchy = type.newSupertypeHierarchy(pm);

 				IType[] superRoles = OTTypeHierarchies.getInstance().getTSuperTypes(hierarchy, type);

 				

 				pm.beginTask("Checking Overriding", superRoles.length);

diff --git a/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/util/RefactoringUtil.java b/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/util/RefactoringUtil.java
index 20832c2..9190c1d 100644
--- a/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/util/RefactoringUtil.java
+++ b/plugins/org.eclipse.objectteams.otdt.refactoring/src/org/eclipse/objectteams/otdt/internal/refactoring/util/RefactoringUtil.java
@@ -288,14 +288,14 @@
 	 * declaring type is an interface the method returns <code>false</code> if
 	 * it is only declared in that interface.
 	 */
-	public static IMethod isDeclaredInInterface(IMethod method, OTTypeHierarchy hierarchy, IProgressMonitor pm) throws JavaModelException {
+	public static IMethod isDeclaredInInterface(IMethod method, ITypeHierarchy hierarchy, IProgressMonitor pm) throws JavaModelException {
 		assert isVirtual(method);
 		try {
 			IType[] classes = hierarchy.getAllClasses();
 			IProgressMonitor subPm = new SubProgressMonitor(pm, 3);
 			subPm.beginTask("", classes.length); //$NON-NLS-1$
 			for (int idxAllHierarchyClasses = 0; idxAllHierarchyClasses < classes.length; idxAllHierarchyClasses++) {
-				ITypeHierarchy superTypes = hierarchy.getOTSuperTypeHierarchy(classes[idxAllHierarchyClasses]);
+				ITypeHierarchy superTypes = classes[idxAllHierarchyClasses].newSupertypeHierarchy(subPm);
 				IType[] superinterfaces = superTypes.getAllSuperInterfaces(classes[idxAllHierarchyClasses]);
 
 				for (int idxSuperInterfaces = 0; idxSuperInterfaces < superinterfaces.length; idxSuperInterfaces++) {
@@ -333,9 +333,10 @@
 		return true;
 	}
 
-	public static IMethod overridesAnotherMethod(IMethod method, OTTypeHierarchy hier, IProgressMonitor pm) throws JavaModelException {
+	public static IMethod overridesAnotherMethod(IMethod method, ITypeHierarchy hier, IProgressMonitor pm) throws JavaModelException {
 		IType declaringType = method.getDeclaringType();
 		InheritedMethodsRequestor requestor = new InheritedMethodsRequestor(declaringType, true, true);
+		// FIXME(SH): hier is not used, OTTypeHierarchyTraverser should be replaced.
 		OTTypeHierarchyTraverser traverser = new OTTypeHierarchyTraverser(requestor, OTTypeHierarchyTraverser.SUPER_HIERARCHY,
 				OTTypeHierarchyTraverser.TRAVERSE_EXPLICIT_FIRST, false, false, pm);
 
@@ -860,8 +861,7 @@
 		ICompilationUnit compUnit = focusType.getCompilationUnit();
 		// create OT typehierarchy
 		if (focusTypeHierarchy == null) {
-			focusTypeHierarchy = new OTTypeHierarchy(focusType, compUnit.getJavaProject(), true);
-			focusTypeHierarchy.refresh(pm);
+			focusTypeHierarchy = focusType.newTypeHierarchy(pm);
 		}
 		// get all supertypes of focus type
 		IType[] superTypes = focusTypeHierarchy.getAllSupertypes(focusType);
@@ -994,8 +994,7 @@
 		// destination);
 
 		// create OT typehierarchy
-		OTTypeHierarchy completeHierarchy = new OTTypeHierarchy(focusType, compUnit.getJavaProject(), true);
-		completeHierarchy.refresh(pm);
+		ITypeHierarchy completeHierarchy = focusType.newTypeHierarchy(pm);
 		// get all supertypes of focus type
 		IType[] superTypes = completeHierarchy.getAllSupertypes(focusType);
 		// get all subtypes of focus type
@@ -1175,8 +1174,7 @@
 		if (!Flags.isTeam(declaringType.getFlags())) {
 			// heavyweight check for interfaces
 			if (Flags.isInterface(declaringType.getFlags()) && checkImplementingClasses) {
-				OTTypeHierarchy hier = new OTTypeHierarchy(declaringType, declaringType.getJavaProject(), true);
-				hier.refresh(pm);
+				ITypeHierarchy hier = declaringType.newTypeHierarchy(pm);
 				IType[] impementingClasses = hier.getImplementingClasses(declaringType);
 				boolean teamImplementsInterface = false;
 				for (int idx = 0; idx < impementingClasses.length; idx++) {
@@ -1265,25 +1263,19 @@
 		final IType declaringType = method.getDeclaringType();
 		if (!declaringType.isInterface()) {
 			if ((hierarchy == null) || !declaringType.equals(hierarchy.getType())) {
-				hierarchy = new OTTypeHierarchy(declaringType, declaringType.getJavaProject(), false);
-				hierarchy.refresh(monitor);
+				hierarchy = declaringType.newSupertypeHierarchy(monitor);
 			}
-			if (hierarchy instanceof OTTypeHierarchy) {
-				IMethod inInterface = isDeclaredInInterface(method, (OTTypeHierarchy) hierarchy, monitor);
-				if (inInterface != null && !inInterface.equals(method))
-					topmostMethod = inInterface;
-			}
+			IMethod inInterface = isDeclaredInInterface(method, hierarchy, monitor);
+			if (inInterface != null && !inInterface.equals(method))
+				topmostMethod = inInterface;
 		}
 		if (topmostMethod == null) {
 			if (hierarchy == null) {
-				hierarchy = new OTTypeHierarchy(declaringType, declaringType.getJavaProject(), false);
-				hierarchy.refresh(monitor);
+				hierarchy = declaringType.newSupertypeHierarchy(monitor);
 			}
-			if (hierarchy instanceof OTTypeHierarchy) {
-				IMethod overrides = overridesAnotherMethod(method, (OTTypeHierarchy) hierarchy, monitor);
-				if (overrides != null && !overrides.equals(method))
-					topmostMethod = overrides;
-			}
+			IMethod overrides = overridesAnotherMethod(method, hierarchy, monitor);
+			if (overrides != null && !overrides.equals(method))
+				topmostMethod = overrides;
 		}
 		return topmostMethod;
 	}