private static IMethodBinding findAnnotationMember(Annotation annotation, String name) { ITypeBinding annotBinding= annotation.resolveTypeBinding(); if (annotBinding != null) { return Bindings.findMethodInType(annotBinding, name, (String[]) null); } return null; }
public static IMethodBinding findAnnotationMember(Annotation annotation, String name) { ITypeBinding annotBinding= annotation.resolveTypeBinding(); if (annotBinding != null) { return Bindings.findMethodInType(annotBinding, name, (String[]) null); } return null; }
private IMethodBinding getObjectConstructor(AST ast) { final ITypeBinding binding= ast.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ return Bindings.findMethodInType(binding, "Object", new ITypeBinding[0]); //$NON-NLS-1$ }
private IMethodBinding getObjectConstructor(AST ast) { final ITypeBinding binding= ast.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ return Bindings.findMethodInType(binding, "Object", new ITypeBinding[0]); //$NON-NLS-1$ }
private static IMethodBinding findAnnotationMember(Annotation annotation, String name) { ITypeBinding annotBinding= annotation.resolveTypeBinding(); if (annotBinding != null) { return Bindings.findMethodInType(annotBinding, name, (String[]) null); } return null; }
private IMethodBinding getObjectConstructor(CompilationUnit compilationUnit) { final ITypeBinding binding= compilationUnit.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ return Bindings.findMethodInType(binding, "Object", new ITypeBinding[0]); //$NON-NLS-1$ }
public static IMethodBinding findMethodInType(final ITypeBinding type, final String name, final ITypeBinding[] paramTypes) { IMethodBinding origMethod; if (type.isInterface()) { origMethod = Bindings.findMethodInHierarchy(type, name, paramTypes); } else { origMethod = Bindings.findMethodInType(type, name, paramTypes); } return origMethod; }
while (superType.getSuperclass() != null) superType= superType.getSuperclass(); IMethodBinding method= Bindings.findMethodInType(superType, "Object", new ITypeBinding[0]); //$NON-NLS-1$ if (method != null) { if ((proposeDefault || !accountExisting || existingConstructors == null || existingConstructors.isEmpty()) && (!accountExisting || !Bindings.containsSignatureEquivalentConstructor(methods, method)))
while (superType.getSuperclass() != null) superType= superType.getSuperclass(); IMethodBinding method= Bindings.findMethodInType(superType, "Object", new ITypeBinding[0]); //$NON-NLS-1$ if (method != null) { if ((proposeDefault || (!accountExisting || (existingConstructors == null || existingConstructors.isEmpty()))) && (!accountExisting || !Bindings.containsSignatureEquivalentConstructor(methods, method)))
/** * Checks if the new method is already used in the given type. * @param type * @param methodName * @param parameters * @return the status */ public static RefactoringStatus checkMethodInType(ITypeBinding type, String methodName, ITypeBinding[] parameters) { RefactoringStatus result= new RefactoringStatus(); if (methodName.equals(type.getName())) result.addWarning(RefactoringCoreMessages.Checks_methodName_constructor); IMethodBinding method= org.eclipse.jdt.internal.corext.dom.Bindings.findMethodInType(type, methodName, parameters); if (method != null) result.addError(Messages.format(RefactoringCoreMessages.Checks_methodName_exists, new Object[] {methodName, type.getName()}), JavaStatusContext.create(method)); return result; }
/** * Finds the method specified by <code>methodName</code> and <code>parameters</code> in * the type hierarchy denoted by the given type. Returns <code>null</code> if no such method * exists. If the method is defined in more than one super type only the first match is * returned. First the super class is examined and then the implemented interfaces. * @param type the type to search the method in * @param methodName The name of the method to find * @param parameters The parameter types of the method to find. If <code>null</code> is passed, only the name is matched and parameters are ignored. * @return the method binding representing the method */ public static IMethodBinding findMethodInHierarchy(ITypeBinding type, String methodName, String[] parameters) { IMethodBinding method= findMethodInType(type, methodName, parameters); if (method != null) return method; ITypeBinding superClass= type.getSuperclass(); if (superClass != null) { method= findMethodInHierarchy(superClass, methodName, parameters); if (method != null) return method; } ITypeBinding[] interfaces= type.getInterfaces(); for (int i= 0; i < interfaces.length; i++) { method= findMethodInHierarchy(interfaces[i], methodName, parameters); if (method != null) return method; } return null; }
/** * Finds the method specified by <code>methodName</code> and <code>parameters</code> in * the type hierarchy denoted by the given type. Returns <code>null</code> if no such method * exists. If the method is defined in more than one super type only the first match is * returned. First the super class is examined and then the implemented interfaces. * * @param type The type to search the method in * @param methodName The name of the method to find * @param parameters The parameter types of the method to find. If <code>null</code> is passed, only the name is matched and parameters are ignored. * @return the method binding representing the method */ public static IMethodBinding findMethodInHierarchy(ITypeBinding type, String methodName, ITypeBinding[] parameters) { IMethodBinding method= findMethodInType(type, methodName, parameters); if (method != null) return method; ITypeBinding superClass= type.getSuperclass(); if (superClass != null) { method= findMethodInHierarchy(superClass, methodName, parameters); if (method != null) return method; } ITypeBinding[] interfaces= type.getInterfaces(); for (int i= 0; i < interfaces.length; i++) { method= findMethodInHierarchy(interfaces[i], methodName, parameters); if (method != null) return method; } return null; }
/** * Finds the method specified by <code>methodName</code> and <code>parameters</code> in * the type hierarchy denoted by the given type. Returns <code>null</code> if no such method * exists. If the method is defined in more than one super type only the first match is * returned. First the super class is examined and then the implemented interfaces. * * @param type The type to search the method in * @param methodName The name of the method to find * @param parameters The parameter types of the method to find. If <code>null</code> is passed, only the name is matched and parameters are ignored. * @return the method binding representing the method */ public static IMethodBinding findMethodInHierarchy(ITypeBinding type, String methodName, ITypeBinding[] parameters) { IMethodBinding method= findMethodInType(type, methodName, parameters); if (method != null) return method; ITypeBinding superClass= type.getSuperclass(); if (superClass != null) { method= findMethodInHierarchy(superClass, methodName, parameters); if (method != null) return method; } ITypeBinding[] interfaces= type.getInterfaces(); for (int i= 0; i < interfaces.length; i++) { method= findMethodInHierarchy(interfaces[i], methodName, parameters); if (method != null) return method; } return null; }
/** * Finds the method specified by <code>methodName</code> and </code>parameters</code> in * the type hierarchy denoted by the given type. Returns <code>null</code> if no such method * exists. If the method is defined in more than one super type only the first match is * returned. First the super class is examined and than the implemented interfaces. * @param type The type to search the method in * @param methodName The name of the method to find * @param parameters The parameter types of the method to find. If <code>null</code> is passed, only the name is matched and parameters are ignored. * @return the method binding representing the method */ public static IMethodBinding findMethodInHierarchy(ITypeBinding type, String methodName, ITypeBinding[] parameters) { IMethodBinding method= findMethodInType(type, methodName, parameters); if (method != null) return method; ITypeBinding superClass= type.getSuperclass(); if (superClass != null) { method= findMethodInHierarchy(superClass, methodName, parameters); if (method != null) return method; } ITypeBinding[] interfaces= type.getInterfaces(); for (int i= 0; i < interfaces.length; i++) { method= findMethodInHierarchy(interfaces[i], methodName, parameters); if (method != null) return method; } return null; }
/** * Finds the method specified by <code>methodName</code> and </code>parameters</code> in * the type hierarchy denoted by the given type. Returns <code>null</code> if no such method * exists. If the method is defined in more than one super type only the first match is * returned. First the super class is examined and than the implemented interfaces. * @param type the type to search the method in * @param methodName The name of the method to find * @param parameters The parameter types of the method to find. If <code>null</code> is passed, only the name is matched and parameters are ignored. * @return the method binding representing the method */ public static IMethodBinding findMethodInHierarchy(ITypeBinding type, String methodName, String[] parameters) { IMethodBinding method= findMethodInType(type, methodName, parameters); if (method != null) return method; ITypeBinding superClass= type.getSuperclass(); if (superClass != null) { method= findMethodInHierarchy(superClass, methodName, parameters); if (method != null) return method; } ITypeBinding[] interfaces= type.getInterfaces(); for (int i= 0; i < interfaces.length; i++) { method= findMethodInHierarchy(interfaces[i], methodName, parameters); if (method != null) return method; } return null; }
/** * Finds the method specified by <code>methodName</code> and <code>parameters</code> in * the type hierarchy denoted by the given type. Returns <code>null</code> if no such method * exists. If the method is defined in more than one super type only the first match is * returned. First the super class is examined and then the implemented interfaces. * @param type the type to search the method in * @param methodName The name of the method to find * @param parameters The parameter types of the method to find. If <code>null</code> is passed, only the name is matched and parameters are ignored. * @return the method binding representing the method */ public static IMethodBinding findMethodInHierarchy(ITypeBinding type, String methodName, String[] parameters) { IMethodBinding method= findMethodInType(type, methodName, parameters); if (method != null) return method; ITypeBinding superClass= type.getSuperclass(); if (superClass != null) { method= findMethodInHierarchy(superClass, methodName, parameters); if (method != null) return method; } ITypeBinding[] interfaces= type.getInterfaces(); for (int i= 0; i < interfaces.length; i++) { method= findMethodInHierarchy(interfaces[i], methodName, parameters); if (method != null) return method; } return null; }
/** * @param methodName * @return a <code>RefactoringStatus</code> that identifies whether the * the name <code>newMethodName</code> is available to use as the name of * the new factory method within the factory-owner class (either a to-be- * created factory class or the constructor-owning class, depending on the * user options). */ private RefactoringStatus isUniqueMethodName(String methodName) { ITypeBinding declaringClass= fCtorBinding.getDeclaringClass(); if (Bindings.findMethodInType(declaringClass, methodName, fCtorBinding.getParameterTypes()) != null) { String format= Messages.format(RefactoringCoreMessages.IntroduceFactory_duplicateMethodName, BasicElementLabels.getJavaElementName(methodName)); return RefactoringStatus.createErrorStatus(format); } return new RefactoringStatus(); }
/** * @param methodName * @return a <code>RefactoringStatus</code> that identifies whether the * the name <code>newMethodName</code> is available to use as the name of * the new factory method within the factory-owner class (either a to-be- * created factory class or the constructor-owning class, depending on the * user options). */ private RefactoringStatus isUniqueMethodName(String methodName) { ITypeBinding declaringClass= fCtorBinding.getDeclaringClass(); if (Bindings.findMethodInType(declaringClass, methodName, fCtorBinding.getParameterTypes()) != null) { String format= Messages.format(RefactoringCoreMessages.IntroduceFactory_duplicateMethodName, BasicElementLabels.getJavaElementName(methodName)); return RefactoringStatus.createErrorStatus(format); } return new RefactoringStatus(); }
/** * Checks if the new method is already used in the given type. * @param type * @param methodName * @param parameters * @return the status */ public static RefactoringStatus checkMethodInType(ITypeBinding type, String methodName, ITypeBinding[] parameters) { RefactoringStatus result= new RefactoringStatus(); IMethodBinding method= org.eclipse.jdt.internal.corext.dom.Bindings.findMethodInType(type, methodName, parameters); if (method != null) { if (method.isConstructor()) { result.addWarning(Messages.format(RefactoringCoreMessages.Checks_methodName_constructor, new Object[] { BasicElementLabels.getJavaElementName(type.getName()) })); } else { result.addError(Messages.format(RefactoringCoreMessages.Checks_methodName_exists, new Object[] { BasicElementLabels.getJavaElementName(methodName), BasicElementLabels.getJavaElementName(type.getName()) }), JavaStatusContext.create(method)); } } return result; }
/** * Checks if the new method is already used in the given type. * @param type * @param methodName * @param parameters * @return the status */ public static RefactoringStatus checkMethodInType(ITypeBinding type, String methodName, ITypeBinding[] parameters) { RefactoringStatus result= new RefactoringStatus(); IMethodBinding method= org.eclipse.jdt.internal.corext.dom.Bindings.findMethodInType(type, methodName, parameters); if (method != null) { if (method.isConstructor()) { result.addWarning(Messages.format(RefactoringCoreMessages.Checks_methodName_constructor, new Object[] { BasicElementLabels.getJavaElementName(type.getName()) })); } else { result.addError(Messages.format(RefactoringCoreMessages.Checks_methodName_exists, new Object[] { BasicElementLabels.getJavaElementName(methodName), BasicElementLabels.getJavaElementName(type.getName()) }), JavaStatusContext.create(method)); } } return result; }