public ITypeHierarchy getDeclaringSuperTypeHierarchy(final IProgressMonitor monitor) throws JavaModelException { try { if (fCachedDeclaringSuperTypeHierarchy != null) return fCachedDeclaringSuperTypeHierarchy; fCachedDeclaringSuperTypeHierarchy= getDeclaringType().newSupertypeHierarchy(fOwner, monitor); return fCachedDeclaringSuperTypeHierarchy; } finally { monitor.done(); } }
public ITypeHierarchy getDeclaringSuperTypeHierarchy(final IProgressMonitor monitor) throws JavaModelException { try { if (fCachedDeclaringSuperTypeHierarchy != null) return fCachedDeclaringSuperTypeHierarchy; fCachedDeclaringSuperTypeHierarchy= getDeclaringType().newSupertypeHierarchy(fOwner, monitor); return fCachedDeclaringSuperTypeHierarchy; } finally { monitor.done(); } }
public ITypeHierarchy getDeclaringSuperTypeHierarchy(final IProgressMonitor monitor) throws JavaModelException { try { if (fCachedDeclaringSuperTypeHierarchy != null) return fCachedDeclaringSuperTypeHierarchy; fCachedDeclaringSuperTypeHierarchy= getDeclaringType().newSupertypeHierarchy(fOwner, monitor); return fCachedDeclaringSuperTypeHierarchy; } finally { monitor.done(); } }
IType type = ...; ITypeHierarchy a = type.newSupertypeHierarchy(new NullProgressMonitor()); IType[] superTypes = a.getAllSupertypes(type); if(superTypes.length == 1 && superTypes[0].getKey().equals("Ljava/lang/Object;")){ this.isSuperClassObject = true; } else{ this.isSuperClassObject = false; }
public static boolean isTestImplementor(IType type) throws JavaModelException { ITypeHierarchy typeHier= type.newSupertypeHierarchy(null); IType[] superInterfaces= typeHier.getAllInterfaces(); for (int i= 0; i < superInterfaces.length; i++) { if (JUnitCorePlugin.TEST_INTERFACE_NAME.equals(superInterfaces[i].getFullyQualifiedName('.'))) { return true; } } return false; }
public Collection findInterfaces(IType type, IProgressMonitor progressMonitor) { ITypeHierarchy typeHierarchy; try { typeHierarchy = type.newSupertypeHierarchy(progressMonitor); IType[] interfaces = typeHierarchy.getAllSuperInterfaces(type); HashSet result = new HashSet(Arrays.asList(interfaces)); return result; } catch (JavaModelException e) { JavaPlugin.log(e); } return null; } }
public static boolean isTestImplementor(IType type) throws JavaModelException { ITypeHierarchy typeHier= type.newSupertypeHierarchy(null); IType[] superInterfaces= typeHier.getAllInterfaces(); for (int i= 0; i < superInterfaces.length; i++) { if (JUnitCorePlugin.TEST_INTERFACE_NAME.equals(superInterfaces[i].getFullyQualifiedName('.'))) { return true; } } return false; }
private static IType findMostSpecific(Collection<IType> candidates) throws JavaModelException { ITypeHierarchy superHierarchy = null; for (IType t : candidates) { if (superHierarchy == null || !superHierarchy.contains(t)) { superHierarchy = t.newSupertypeHierarchy(null); } } if (superHierarchy == null) { return null; } return superHierarchy.getType(); }
private IStatus checkException(final IType type) throws JavaModelException { ITypeHierarchy hierarchy= type.newSupertypeHierarchy(new NullProgressMonitor()); IType curr= type; while (curr != null) { String name= curr.getFullyQualifiedName(); if ("java.lang.Throwable".equals(name)) //$NON-NLS-1$ return StatusInfo.OK_STATUS; curr= hierarchy.getSuperclass(curr); } return JavaUIStatus.createError(IStatus.ERROR, RefactoringMessages.ChangeExceptionsControl_not_exception, null); }
private IStatus checkException(final IType type) throws JavaModelException { ITypeHierarchy hierarchy= type.newSupertypeHierarchy(new NullProgressMonitor()); IType curr= type; while (curr != null) { String name= curr.getFullyQualifiedName(); if ("java.lang.Throwable".equals(name)) //$NON-NLS-1$ return StatusInfo.OK_STATUS; curr= hierarchy.getSuperclass(curr); } return JavaUIStatus.createError(IStatus.ERROR, RefactoringMessages.ChangeExceptionsControl_not_exception, null); }
private IStatus checkException(final IType type) throws JavaModelException { ITypeHierarchy hierarchy= type.newSupertypeHierarchy(new NullProgressMonitor()); IType curr= type; while (curr != null) { String name= curr.getFullyQualifiedName(); if ("java.lang.Throwable".equals(name)) //$NON-NLS-1$ return StatusInfo.OK_STATUS; curr= hierarchy.getSuperclass(curr); } return JavaUIStatus.createError(IStatus.ERROR, RefactoringMessages.ChangeExceptionsControl_not_exception, null); }
private ITypeHierarchy createTypeHierarchy(IJavaElement element, IProgressMonitor pm) throws JavaModelException { if (element.getElementType() == IJavaElement.TYPE) { IType type= (IType) element; if (fIsSuperTypesOnly) { return type.newSupertypeHierarchy(pm); } else { return type.newTypeHierarchy(pm); } } else {
/** * Get a hierarchy for the given type */ public static ITypeHierarchy getTypeHierarchy(IType type, IProgressMonitor progressMonitor) throws JavaModelException { ITypeHierarchy hierarchy= findTypeHierarchyInCache(type); if (hierarchy == null) { fgCacheMisses++; hierarchy= type.newSupertypeHierarchy(progressMonitor); addTypeHierarchyToCache(hierarchy); } else { fgCacheHits++; } return hierarchy; }
protected void loadSuperTypeHierarchy() throws JavaModelException { ITypeHierarchy superTypeHierarchy = m_type.newSupertypeHierarchy(null); IType firstType = superTypeHierarchy.getSuperclass(m_type); if (S2eUtils.exists(firstType)) { String superTypeFqn = firstType.getFullyQualifiedName(); if (!IScoutRuntimeTypes.DynamicNls.equals(superTypeFqn) && !Object.class.getName().equals(superTypeFqn)) { m_propertySupport.setProperty(PROP_SUPER_TYPE, firstType); } } }
private void modifyAccessToEnclosingInstance(final CompilationUnitRewrite targetRewrite, final AbstractTypeDeclaration declaration, final RefactoringStatus status, final IProgressMonitor monitor) throws JavaModelException { Assert.isNotNull(targetRewrite); Assert.isNotNull(declaration); Assert.isNotNull(monitor); final Set handledMethods= new HashSet(); final Set handledFields= new HashSet(); final MemberAccessNodeCollector collector= new MemberAccessNodeCollector(fType.getDeclaringType().newSupertypeHierarchy(new SubProgressMonitor(monitor, 1))); declaration.accept(collector); modifyAccessToMethodsFromEnclosingInstance(targetRewrite, handledMethods, collector.getMethodInvocations(), declaration, status); modifyAccessToFieldsFromEnclosingInstance(targetRewrite, handledFields, collector.getFieldAccesses(), declaration, status); modifyAccessToFieldsFromEnclosingInstance(targetRewrite, handledFields, collector.getSimpleFieldNames(), declaration, status); }
private static boolean isEclipseNLSUsed(IType accessor) { IJavaProject javaProject= accessor.getJavaProject(); if (javaProject == null || !javaProject.exists()) return false; try { IType nls= javaProject.findType("org.eclipse.osgi.util.NLS"); //$NON-NLS-1$ if(nls==null) return false; ITypeHierarchy supertypeHierarchy= accessor.newSupertypeHierarchy(null); return supertypeHierarchy.contains(nls); } catch (JavaModelException e) { return false; } }
private boolean isInstanceFieldCreationMandatory() throws JavaModelException { final MemberAccessNodeCollector collector= new MemberAccessNodeCollector(fType.getDeclaringType().newSupertypeHierarchy(new NullProgressMonitor())); findTypeDeclaration(fType, fSourceRewrite.getRoot()).accept(collector); return containsNonStatic(collector.getFieldAccesses()) || containsNonStatic(collector.getMethodInvocations()) || containsNonStatic(collector.getSimpleFieldNames()); }
private RefactoringStatus checkAccesses(final IProgressMonitor monitor) throws JavaModelException { final RefactoringStatus result= new RefactoringStatus(); try { monitor.beginTask(RefactoringCoreMessages.PullUpRefactoring_checking_referenced_elements, 4); final ITypeHierarchy hierarchy= getDestinationType().newSupertypeHierarchy(fOwner, new SubProgressMonitor(monitor, 1)); result.merge(checkAccessedTypes(new SubProgressMonitor(monitor, 1), hierarchy)); result.merge(checkAccessedFields(new SubProgressMonitor(monitor, 1), hierarchy)); result.merge(checkAccessedMethods(new SubProgressMonitor(monitor, 1), hierarchy)); } finally { monitor.done(); } return result; }
private RefactoringStatus checkAccesses(final IProgressMonitor monitor) throws JavaModelException { final RefactoringStatus result= new RefactoringStatus(); try { monitor.beginTask(RefactoringCoreMessages.PullUpRefactoring_checking_referenced_elements, 4); final ITypeHierarchy hierarchy= getDestinationType().newSupertypeHierarchy(fOwner, new SubProgressMonitor(monitor, 1)); result.merge(checkAccessedTypes(new SubProgressMonitor(monitor, 1), hierarchy)); result.merge(checkAccessedFields(new SubProgressMonitor(monitor, 1), hierarchy)); result.merge(checkAccessedMethods(new SubProgressMonitor(monitor, 1), hierarchy)); } finally { monitor.done(); } return result; }
private RefactoringStatus checkAccesses(final IProgressMonitor monitor) throws JavaModelException { final RefactoringStatus result= new RefactoringStatus(); try { monitor.beginTask(RefactoringCoreMessages.PullUpRefactoring_checking_referenced_elements, 4); final ITypeHierarchy hierarchy= getDestinationType().newSupertypeHierarchy(fOwner, new SubProgressMonitor(monitor, 1)); result.merge(checkAccessedTypes(new SubProgressMonitor(monitor, 1), hierarchy)); result.merge(checkAccessedFields(new SubProgressMonitor(monitor, 1), hierarchy)); result.merge(checkAccessedMethods(new SubProgressMonitor(monitor, 1), hierarchy)); } finally { monitor.done(); } return result; }