/** * Determines if the element has qname as a parent class * @param element the element to check for the parent class definition * @param qname the fully qualified name of the (potential) parent class * @return true if qname is a parent class, false otherwise */ private boolean hasSuperclass(IJavaElement element, String qname) { try { IType type = getType(element); if(type != null) { IType[] stypes = type.newSupertypeHierarchy(new NullProgressMonitor()).getAllSuperclasses(type); for(int i = 0; i < stypes.length; i++) { if(stypes[i].getFullyQualifiedName().equals(qname) || stypes[i].getElementName().equals(qname)) { return true; } } } } catch(JavaModelException e) {} return false; }
/** * Determines if the element has qname as a parent class * @param element the element to check for the parent class definition * @param qname the fully qualified name of the (potential) parent class * @return true if qname is a parent class, false otherwise */ private boolean hasSuperclass(IJavaElement element, String qname) { try { IType type = getType(element); if(type != null) { IType[] stypes = type.newSupertypeHierarchy(new NullProgressMonitor()).getAllSuperclasses(type); for(int i = 0; i < stypes.length; i++) { if(stypes[i].getFullyQualifiedName().equals(qname) || stypes[i].getElementName().equals(qname)) { return true; } } } } catch(JavaModelException e) {} return false; }
public static IMethod solveMethod(IType type, String methodName) { try { IMethod[] typemethods= type.getMethods(); for(IMethod m : typemethods) { if(methodName.equals(m.getElementName())) { return m; } } ITypeHierarchy typeHierarchy= type.newSupertypeHierarchy(null); IType[] superTypes= typeHierarchy.getAllSuperclasses(type); for(IType t : superTypes) { IMethod[] methods= t.getMethods(); for(IMethod m : methods) { if(methodName.equals(m.getElementName())) { return m; } } } } catch(JavaModelException jme) { ; //ignore } return null; }
public static IMethod fuzzyFindMethodInTypeHierarchy(IType type, String methodName, String[] paramTypes) throws JavaModelException { List<IMethod> fuzzyResults= new ArrayList<IMethod>(); IMethod[] methods = type.getMethods(); for(IMethod m : methods) { if(methodName.equals(m.getElementName()) && m.exists()) { if(m.getNumberOfParameters() == paramTypes.length) { return m; } else { fuzzyResults.add(m); } } } ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(null); IType[] types = typeHierarchy.getAllSuperclasses(type); for(IType t : types) { methods = t.getMethods(); for(IMethod m : methods) { if(methodName.equals(m.getElementName()) && m.exists()) { return m; } } } return (fuzzyResults.isEmpty() ? null : fuzzyResults.get(0) ); }
IType[] types = typeHierarchy.getAllSuperclasses(type); for(IType t : types) { method = t.getMethod(methodName, paramTypes);
if (superClass != null && superClass.equals(type)) return true; else if (superClass != null && !containsType(hierarchy.getAllSuperclasses(type), superClass )){ addNewValidationMessage(Messages.JavaClassType_not_found); return false;
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }
for (IType t : h.getAllSuperclasses(type)) { ann = getFirstDeclaredAnnotation(t, fullyQualifiedAnnotations); if (exists(ann)) {