if (class1.equals("java.lang.Object") return true; ITypeHierarchy typeHierarchy = type.newTypeHierarchy(new NullProgressMonitor()); IType[] supertypes = typeHierarchy.getAllSupertypes(type); boolean isSuperType = Arrays.asList(supertypes).stream().anyMatch(supertype -> { return supertype.getFullyQualifiedName().equals(class1); });
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 isException(IType iType, IProgressMonitor pm) throws JavaModelException { try{ if (! iType.isClass()) return false; IType[] superTypes= iType.newSupertypeHierarchy(pm).getAllSupertypes(iType); for (int i= 0; i < superTypes.length; i++) { if ("java.lang.Throwable".equals(superTypes[i].getFullyQualifiedName())) //$NON-NLS-1$ return true; } return false; } finally{ pm.done(); } }
public static boolean isException(IType iType, IProgressMonitor pm) throws JavaModelException { try{ if (! iType.isClass()) return false; IType[] superTypes= iType.newSupertypeHierarchy(pm).getAllSupertypes(iType); for (int i= 0; i < superTypes.length; i++) { if ("java.lang.Throwable".equals(superTypes[i].getFullyQualifiedName())) //$NON-NLS-1$ return true; } return false; } finally{ pm.done(); } }
public static boolean isException(IType iType, IProgressMonitor pm) throws JavaModelException { try{ if (! iType.isClass()) return false; IType[] superTypes= iType.newSupertypeHierarchy(pm).getAllSupertypes(iType); for (int i= 0; i < superTypes.length; i++) { if ("java.lang.Throwable".equals(superTypes[i].getFullyQualifiedName())) //$NON-NLS-1$ return true; } return false; } finally{ pm.done(); } }
public static IType[] getAllSuperTypes(IType type, IProgressMonitor pm) throws JavaModelException { try { // workaround for 23656 IType[] superTypes= SuperTypeHierarchyCache.getTypeHierarchy(type).getAllSupertypes(type); if (type.isInterface()) { IType objekt= type.getJavaProject().findType("java.lang.Object");//$NON-NLS-1$ if (objekt != null) { IType[] superInterfacesAndObject= new IType[superTypes.length + 1]; System.arraycopy(superTypes, 0, superInterfacesAndObject, 0, superTypes.length); superInterfacesAndObject[superTypes.length]= objekt; return superInterfacesAndObject; } } return superTypes; } finally { if (pm != null) pm.done(); } }
public static IType[] getAllSuperTypes(IType type, IProgressMonitor pm) throws JavaModelException { try { // workaround for 23656 IType[] superTypes= SuperTypeHierarchyCache.getTypeHierarchy(type).getAllSupertypes(type); if (type.isInterface()) { IType objekt= type.getJavaProject().findType("java.lang.Object");//$NON-NLS-1$ if (objekt != null) { IType[] superInterfacesAndObject= new IType[superTypes.length + 1]; System.arraycopy(superTypes, 0, superInterfacesAndObject, 0, superTypes.length); superInterfacesAndObject[superTypes.length]= objekt; return superInterfacesAndObject; } } return superTypes; } finally { if (pm != null) pm.done(); } }
public static IType[] getAllSuperTypes(IType type, IProgressMonitor pm) throws JavaModelException { // workaround for 23656 IType[] superTypes= SuperTypeHierarchyCache.getTypeHierarchy(type).getAllSupertypes(type); if (type.isInterface()) { IType objekt= type.getJavaProject().findType("java.lang.Object");//$NON-NLS-1$ if (objekt != null) { IType[] superInterfacesAndObject= new IType[superTypes.length + 1]; System.arraycopy(superTypes, 0, superInterfacesAndObject, 0, superTypes.length); superInterfacesAndObject[superTypes.length]= objekt; return superInterfacesAndObject; } } return superTypes; }
public IType[] getCandidateTypes(final RefactoringStatus status, final IProgressMonitor monitor) throws JavaModelException { final IType declaring= getDeclaringType(); final IType[] superTypes= declaring.newSupertypeHierarchy(fOwner, monitor).getAllSupertypes(declaring); final List<IType> list= new ArrayList<>(superTypes.length); int binary= 0; for (int index= 0; index < superTypes.length; index++) { final IType type= superTypes[index]; if (type != null && type.exists() && !type.isReadOnly() && !type.isBinary() && !"java.lang.Object".equals(type.getFullyQualifiedName())) { //$NON-NLS-1$ list.add(type); } else { if (type != null && type.isBinary()) { binary++; } } } if (superTypes.length == 1 && superTypes[0].getFullyQualifiedName().equals("java.lang.Object")) //$NON-NLS-1$ status.addFatalError(RefactoringCoreMessages.PullUPRefactoring_not_java_lang_object); else if (superTypes.length == binary) status.addFatalError(RefactoringCoreMessages.PullUPRefactoring_no_all_binary); Collections.reverse(list); return list.toArray(new IType[list.size()]); }
public IType[] getCandidateTypes(final RefactoringStatus status, final IProgressMonitor monitor) throws JavaModelException { final IType declaring= getDeclaringType(); final IType[] superTypes= declaring.newSupertypeHierarchy(fOwner, monitor).getAllSupertypes(declaring); final List list= new ArrayList(superTypes.length); int binary= 0; for (int index= 0; index < superTypes.length; index++) { final IType type= superTypes[index]; if (type != null && type.exists() && !type.isReadOnly() && !type.isBinary() && !"java.lang.Object".equals(type.getFullyQualifiedName())) { //$NON-NLS-1$ list.add(type); } else { if (type != null && type.isBinary()) { binary++; } } } if (superTypes.length == 1 && superTypes[0].getFullyQualifiedName().equals("java.lang.Object")) //$NON-NLS-1$ status.addFatalError(RefactoringCoreMessages.PullUPRefactoring_not_java_lang_object); else if (superTypes.length == binary) status.addFatalError(RefactoringCoreMessages.PullUPRefactoring_no_all_binary); Collections.reverse(list); return (IType[]) list.toArray(new IType[list.size()]); }
public IType[] getCandidateTypes(final RefactoringStatus status, final IProgressMonitor monitor) throws JavaModelException { final IType declaring= getDeclaringType(); final IType[] superTypes= declaring.newSupertypeHierarchy(fOwner, monitor).getAllSupertypes(declaring); final List<IType> list= new ArrayList<>(superTypes.length); int binary= 0; for (int index= 0; index < superTypes.length; index++) { final IType type= superTypes[index]; if (type != null && type.exists() && !type.isReadOnly() && !type.isBinary() && !"java.lang.Object".equals(type.getFullyQualifiedName())) { //$NON-NLS-1$ list.add(type); } else { if (type != null && type.isBinary()) { binary++; } } } if (superTypes.length == 1 && superTypes[0].getFullyQualifiedName().equals("java.lang.Object")) //$NON-NLS-1$ status.addFatalError(RefactoringCoreMessages.PullUPRefactoring_not_java_lang_object); else if (superTypes.length == binary) status.addFatalError(RefactoringCoreMessages.PullUPRefactoring_no_all_binary); Collections.reverse(list); return list.toArray(new IType[list.size()]); }
private IJavaElement[] getInputForCategories() { if (fInput == null) return new IJavaElement[0]; if (fOutlineContentProvider.isShowingInheritedMembers()) { IJavaElement p= fInput; if (p instanceof ITypeRoot) { p= ((ITypeRoot)p).findPrimaryType(); } while (p != null && !(p instanceof IType)) { p= p.getParent(); } if (!(p instanceof IType)) return new IJavaElement[] {fInput}; ITypeHierarchy hierarchy= getSuperTypeHierarchy((IType)p); if (hierarchy == null) return new IJavaElement[] {fInput}; IType[] supertypes= hierarchy.getAllSupertypes((IType)p); IJavaElement[] result= new IJavaElement[supertypes.length + 1]; result[0]= fInput; System.arraycopy(supertypes, 0, result, 1, supertypes.length); return result; } else { return new IJavaElement[] {fInput}; } }
private IJavaElement[] getInputForCategories() { if (fInput == null) return new IJavaElement[0]; if (fOutlineContentProvider.isShowingInheritedMembers()) { IJavaElement p= fInput; if (p instanceof ITypeRoot) { p= ((ITypeRoot)p).findPrimaryType(); } while (p != null && !(p instanceof IType)) { p= p.getParent(); } if (!(p instanceof IType)) return new IJavaElement[] {fInput}; ITypeHierarchy hierarchy= getSuperTypeHierarchy((IType)p); if (hierarchy == null) return new IJavaElement[] {fInput}; IType[] supertypes= hierarchy.getAllSupertypes((IType)p); IJavaElement[] result= new IJavaElement[supertypes.length + 1]; result[0]= fInput; System.arraycopy(supertypes, 0, result, 1, supertypes.length); return result; } else { return new IJavaElement[] {fInput}; } }
private IJavaElement[] getInputForCategories() { if (fInput == null) return new IJavaElement[0]; if (fOutlineContentProvider.isShowingInheritedMembers()) { IJavaElement p= fInput; if (p instanceof ITypeRoot) { p= ((ITypeRoot)p).findPrimaryType(); } while (p != null && !(p instanceof IType)) { p= p.getParent(); } if (!(p instanceof IType)) return new IJavaElement[] {fInput}; ITypeHierarchy hierarchy= getSuperTypeHierarchy((IType)p); if (hierarchy == null) return new IJavaElement[] {fInput}; IType[] supertypes= hierarchy.getAllSupertypes((IType)p); IJavaElement[] result= new IJavaElement[supertypes.length + 1]; result[0]= fInput; System.arraycopy(supertypes, 0, result, 1, supertypes.length); return result; } else { return new IJavaElement[] {fInput}; } }
private static Reader findDocInHierarchy(IMethod method, boolean useAttachedJavadoc) throws JavaModelException { /* * Catch ExternalJavaProject in which case * no hierarchy can be built. */ if (!method.getJavaProject().exists()) { return null; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newSupertypeHierarchy(null); MethodOverrideTester tester= new MethodOverrideTester(type, hierarchy); IType[] superTypes= hierarchy.getAllSupertypes(type); for (IType curr : superTypes) { IMethod overridden= tester.findOverriddenMethodInType(curr, method); if (overridden != null) { Reader reader = getHTMLContentReader(overridden, false, useAttachedJavadoc); if (reader != null) { return reader; } } } return null; }
private static Reader findDocInHierarchy(IMethod method, boolean isHTML, boolean useAttachedJavadoc) throws JavaModelException { /* * Catch ExternalJavaProject in which case * no hierarchy can be built. */ if (!method.getJavaProject().exists()) return null; IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newSupertypeHierarchy(null); MethodOverrideTester tester= new MethodOverrideTester(type, hierarchy); IType[] superTypes= hierarchy.getAllSupertypes(type); for (int i= 0; i < superTypes.length; i++) { IType curr= superTypes[i]; IMethod overridden= tester.findOverriddenMethodInType(curr, method); if (overridden != null) { Reader reader; if (isHTML) reader= getHTMLContentReader(overridden, false, useAttachedJavadoc); else reader= getContentReader(overridden, false); if (reader != null) return reader; } } return null; }
private static Reader findDocInHierarchy(IMethod method, boolean isHTML, boolean useAttachedJavadoc) throws JavaModelException { /* * Catch ExternalJavaProject in which case * no hierarchy can be built. */ if (!method.getJavaProject().exists()) return null; IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newSupertypeHierarchy(null); MethodOverrideTester tester= new MethodOverrideTester(type, hierarchy); IType[] superTypes= hierarchy.getAllSupertypes(type); for (int i= 0; i < superTypes.length; i++) { IType curr= superTypes[i]; IMethod overridden= tester.findOverriddenMethodInType(curr, method); if (overridden != null) { Reader reader; if (isHTML) reader= getHTMLContentReader(overridden, false, useAttachedJavadoc); else reader= getContentReader(overridden, false); if (reader != null) return reader; } } return null; }
private static Reader findDocInHierarchy(IMethod method, boolean isHTML, boolean useAttachedJavadoc) throws JavaModelException { /* * Catch ExternalJavaProject in which case * no hierarchy can be built. */ if (!method.getJavaProject().exists()) return null; IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newSupertypeHierarchy(null); MethodOverrideTester tester= new MethodOverrideTester(type, hierarchy); IType[] superTypes= hierarchy.getAllSupertypes(type); for (int i= 0; i < superTypes.length; i++) { IType curr= superTypes[i]; IMethod overridden= tester.findOverriddenMethodInType(curr, method); if (overridden != null) { Reader reader; if (isHTML) reader= getHTMLContentReader(overridden, false, useAttachedJavadoc); else reader= getContentReader(overridden, false); if (reader != null) return reader; } } return null; }
/** * Remembers the selection of a right hand side type (proposal type) for a certain left hand side (expected * type) in content assist. * * @param lhs the left hand side / expected type * @param rhs the selected right hand side */ public void remember(IType lhs, IType rhs) { Assert.isLegal(lhs != null); Assert.isLegal(rhs != null); try { if (!isCacheableRHS(rhs)) return; ITypeHierarchy hierarchy= rhs.newSupertypeHierarchy(getProgressMonitor()); if (hierarchy.contains(lhs)) { // TODO remember for every member of the LHS hierarchy or not? Yes for now. IType[] allLHSides= hierarchy.getAllSupertypes(lhs); for (int i= 0; i < allLHSides.length; i++) rememberInternal(allLHSides[i], rhs); rememberInternal(lhs, rhs); } } catch (JavaModelException x) { JavaPlugin.log(x); } }
/** * Remembers the selection of a right hand side type (proposal type) for a certain left hand side (expected * type) in content assist. * * @param lhs the left hand side / expected type * @param rhs the selected right hand side */ public void remember(IType lhs, IType rhs) { Assert.isLegal(lhs != null); Assert.isLegal(rhs != null); try { if (!isCacheableRHS(rhs)) return; ITypeHierarchy hierarchy= rhs.newSupertypeHierarchy(getProgressMonitor()); if (hierarchy.contains(lhs)) { // TODO remember for every member of the LHS hierarchy or not? Yes for now. IType[] allLHSides= hierarchy.getAllSupertypes(lhs); String rhsQualifiedName= rhs.getFullyQualifiedName(); for (int i= 0; i < allLHSides.length; i++) rememberInternal(allLHSides[i], rhsQualifiedName); rememberInternal(lhs, rhsQualifiedName); } } catch (JavaModelException x) { JavaPlugin.log(x); } }