String methodName = sourceMethod.getElementName(); for (Object declaration : typeDeclaration.bodyDeclarations()) { if (declaration instanceof org.eclipse.jdt.core.dom.MethodDeclaration) {
private static boolean hasMethod(IMethod[] methods, String name) { for (IMethod method : methods) { if (name.equals(method.getElementName())) { return true; } } return false; }
private static boolean hasMethod(IMethod[] methods, String name) { for (int i = 0; i < methods.length; i++) { IMethod curr = methods[i]; if (curr.getElementName().equals(name) && curr.getParameterTypes().length == 0) { return true; } } return false; }
private boolean isMethodToSuggest(IMethod method) { try { String methodName= method.getElementName(); return method.getNumberOfParameters() == 0 && !Signature.SIG_VOID.equals(method.getReturnType()) && (methodName.startsWith("get") || methodName.startsWith("is")); //$NON-NLS-1$//$NON-NLS-2$ } catch (JavaModelException e) { return false; } }
private boolean isMethodToSuggest(IMethod method) { try { String methodName= method.getElementName(); return method.getNumberOfParameters() == 0 && !Signature.SIG_VOID.equals(method.getReturnType()) && (methodName.startsWith("get") || methodName.startsWith("is")); //$NON-NLS-1$//$NON-NLS-2$ } catch (JavaModelException e) { return false; } }
@Override public String getSimpleName() { IType declaringType = this.method.getDeclaringType(); return declaringType.getElementName() + "#" + this.method.getElementName(); }
public static boolean isRenameProhibited(final IMethod method) throws CoreException { if (method.getElementName().equals("toString") //$NON-NLS-1$ && (method.getNumberOfParameters() == 0) && (method.getReturnType().equals("Ljava.lang.String;") //$NON-NLS-1$ || method.getReturnType().equals("QString;") //$NON-NLS-1$ || method.getReturnType().equals("Qjava.lang.String;"))) { return true; } else { return false; } }
public static boolean isRenameProhibited(final IMethod method) throws CoreException { if (method.getElementName().equals("toString") //$NON-NLS-1$ && (method.getNumberOfParameters() == 0) && (method.getReturnType().equals("Ljava.lang.String;") //$NON-NLS-1$ || method.getReturnType().equals("QString;") //$NON-NLS-1$ || method.getReturnType().equals("Qjava.lang.String;"))) //$NON-NLS-1$ return true; else return false; }
@Override public String getQualifiedName() { IType declaringType = this.method.getDeclaringType(); return declaringType.getFullyQualifiedName() + "#" + this.method.getElementName(); }
protected void initialize(IMethod method) { fMethod= method; if (!fInitialized) { if (method != null) setNewElementName(method.getElementName()); fUpdateReferences= true; initializeWorkingCopyOwner(); } }
private void addMethodRename(final String unQualifiedTypeName, RenamingNameSuggestor sugg, final IMethod currentMethod) throws JavaModelException { if (!currentMethod.isConstructor()) { final String newMethodName= sugg.suggestNewMethodName(currentMethod.getElementName(), unQualifiedTypeName, getNewElementName()); if (newMethodName != null) fPreloadedElementToName.put(currentMethod, newMethodName); } }
private void addMethodRename(final String unQualifiedTypeName, RenamingNameSuggestor sugg, final IMethod currentMethod) throws JavaModelException { if (!currentMethod.isConstructor()) { final String newMethodName = sugg.suggestNewMethodName(currentMethod.getElementName(), unQualifiedTypeName, getNewElementName()); if (newMethodName != null) { fPreloadedElementToName.put(currentMethod, newMethodName); } } }
public static String createMethodSignature(IMethod method){ try { return BasicElementLabels.getJavaElementName(Signature.toString(method.getSignature(), method.getElementName(), method.getParameterNames(), false, ! method.isConstructor())); } catch(JavaModelException e) { return BasicElementLabels.getJavaElementName(method.getElementName()); //fallback } }
private IMethod findSimilarMethod(IMethod meth, Object[] elements) throws JavaModelException { String name= meth.getElementName(); String[] paramTypes= meth.getParameterTypes(); boolean isConstructor= meth.isConstructor(); for (int i= 0; i < elements.length; i++) { Object curr= elements[i]; if (curr instanceof IMethod && JavaModelUtil.isSameMethodSignature(name, paramTypes, isConstructor, (IMethod) curr)) { return (IMethod) curr; } } return null; }
private IMethod findSimilarMethod(IMethod meth, Object[] elements) throws JavaModelException { String name= meth.getElementName(); String[] paramTypes= meth.getParameterTypes(); boolean isConstructor= meth.isConstructor(); for (int i= 0; i < elements.length; i++) { Object curr= elements[i]; if (curr instanceof IMethod && JavaModelUtil.isSameMethodSignature(name, paramTypes, isConstructor, (IMethod) curr)) { return (IMethod) curr; } } return null; }
/** * Finds a method in an array of methods. * Searches for a method with the same name and the same parameter count. * Parameter types are <b>not</b> compared. * @param method * @param methods * @return The first found method or null, if nothing found * @throws JavaModelException */ public static IMethod findMethod(IMethod method, IMethod[] methods) throws JavaModelException { return findMethod(method.getElementName(), method.getParameterTypes().length, method.isConstructor(), methods); }
@Override public void apply(TestLauncher launcher) { IType declaringType = this.method.getDeclaringType(); String typeName = declaringType.getFullyQualifiedName(); String methodName = this.method.getElementName(); launcher.withJvmTestMethods(typeName, methodName); }
/** * @see IMethod#isSimilar(IMethod) */ @Override public boolean isSimilar(IMethod method) { return areSimilarMethods( getElementName(), getParameterTypes(), method.getElementName(), method.getParameterTypes(), null); }
private SearchResultGroup[] getOccurrences(IProgressMonitor pm, RefactoringStatus status, ReferencesInBinaryContext binaryRefs) throws CoreException { SearchPattern pattern= createOccurrenceSearchPattern(); return RefactoringSearchEngine.search(pattern, createRefactoringScope(), new MethodOccurenceCollector(getMethod().getElementName(), binaryRefs), pm, status); }
private RefactoringStatus checkIfMethodDeclaredIn(final IMethod iMethod, final IType type) throws JavaModelException { final IMethod methodInType= JavaModelUtil.findMethod(iMethod.getElementName(), iMethod.getParameterTypes(), iMethod.isConstructor(), type); if (methodInType == null || !methodInType.exists()) return null; final String[] keys= { JavaElementLabels.getTextLabel(methodInType, JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getTextLabel(type, JavaElementLabels.ALL_FULLY_QUALIFIED)}; final String msg= Messages.format(RefactoringCoreMessages.PullUpRefactoring_Method_declared_in_class, keys); final RefactoringStatusContext context= JavaStatusContext.create(methodInType); return RefactoringStatus.createWarningStatus(msg, context); }