use of org.eclipse.jdt.core.IMethod in project che by eclipse.
the class RenameMethodProcessor method checkRelatedMethods.
private RefactoringStatus checkRelatedMethods() throws CoreException {
RefactoringStatus result = new RefactoringStatus();
for (Iterator<IMethod> iter = fMethodsToRename.iterator(); iter.hasNext(); ) {
IMethod method = iter.next();
result.merge(Checks.checkIfConstructorName(method, getNewElementName(), method.getDeclaringType().getElementName()));
String[] msgData = new String[] { BasicElementLabels.getJavaElementName(method.getElementName()), BasicElementLabels.getJavaElementName(method.getDeclaringType().getFullyQualifiedName('.')) };
if (!method.exists()) {
result.addFatalError(Messages.format(RefactoringCoreMessages.RenameMethodRefactoring_not_in_model, msgData));
continue;
}
if (method.isBinary())
result.addFatalError(Messages.format(RefactoringCoreMessages.RenameMethodRefactoring_no_binary, msgData));
if (method.isReadOnly())
result.addFatalError(Messages.format(RefactoringCoreMessages.RenameMethodRefactoring_no_read_only, msgData));
if (JdtFlags.isNative(method))
result.addError(Messages.format(RefactoringCoreMessages.RenameMethodRefactoring_no_native_1, msgData));
}
return result;
}
use of org.eclipse.jdt.core.IMethod in project che by eclipse.
the class RenameMethodProcessor method classesDeclareMethodName.
//-------
private static IMethod[] classesDeclareMethodName(ITypeHierarchy hier, List<IType> classes, IMethod method, String newName) throws CoreException {
Set<IMethod> result = new HashSet<IMethod>();
IType type = method.getDeclaringType();
List<IType> subtypes = Arrays.asList(hier.getAllSubtypes(type));
int parameterCount = method.getParameterTypes().length;
boolean isMethodPrivate = JdtFlags.isPrivate(method);
for (Iterator<IType> iter = classes.iterator(); iter.hasNext(); ) {
IType clazz = iter.next();
IMethod[] methods = clazz.getMethods();
boolean isSubclass = subtypes.contains(clazz);
for (int j = 0; j < methods.length; j++) {
IMethod foundMethod = Checks.findMethod(newName, parameterCount, false, new IMethod[] { methods[j] });
if (foundMethod == null)
continue;
if (isSubclass || type.equals(clazz))
result.add(foundMethod);
else if ((!isMethodPrivate) && (!JdtFlags.isPrivate(methods[j])))
result.add(foundMethod);
}
}
return result.toArray(new IMethod[result.size()]);
}
use of org.eclipse.jdt.core.IMethod in project che by eclipse.
the class RenameMethodProcessor method getDeclarationCUs.
private ICompilationUnit[] getDeclarationCUs() {
Set<ICompilationUnit> cus = new HashSet<ICompilationUnit>();
for (Iterator<IMethod> iter = fMethodsToRename.iterator(); iter.hasNext(); ) {
IMethod method = iter.next();
cus.add(method.getCompilationUnit());
}
return cus.toArray(new ICompilationUnit[cus.size()]);
}
use of org.eclipse.jdt.core.IMethod in project che by eclipse.
the class RenameMethodProcessor method searchForDeclarationsOfClashingMethods.
private IMethod[] searchForDeclarationsOfClashingMethods(IProgressMonitor pm) throws CoreException {
final List<IMethod> results = new ArrayList<IMethod>();
SearchPattern pattern = createNewMethodPattern();
IJavaSearchScope scope = RefactoringScopeFactory.create(getMethod().getJavaProject());
SearchRequestor requestor = new SearchRequestor() {
@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
Object method = match.getElement();
if (// check for bug 90138: [refactoring] [rename] Renaming method throws internal exception
method instanceof IMethod)
results.add((IMethod) method);
else
//$NON-NLS-1$
JavaPlugin.logErrorMessage("Unexpected element in search match: " + match.toString());
}
};
new SearchEngine().search(pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, pm);
return results.toArray(new IMethod[results.size()]);
}
use of org.eclipse.jdt.core.IMethod in project che by eclipse.
the class RenameMethodProcessor method computeRenameModifications.
@Override
protected RenameModifications computeRenameModifications() throws CoreException {
RenameModifications result = new RenameModifications();
RenameArguments args = new RenameArguments(getNewElementName(), getUpdateReferences());
for (Iterator<IMethod> iter = fMethodsToRename.iterator(); iter.hasNext(); ) {
IMethod method = iter.next();
result.rename(method, args);
}
return result;
}
Aggregations