use of org.eclipse.jdt.core.IMethod in project che by eclipse.
the class SearchTestHelper method getMethod.
static IMethod getMethod(String TypeName, String methodName, String[] parameterTypes) throws JavaModelException {
IType type = getType(TypeName);
if (type == null)
return null;
IMethod method = type.getMethod(methodName, parameterTypes);
return method;
}
use of org.eclipse.jdt.core.IMethod in project che by eclipse.
the class RenameVirtualMethodInClassTest method helper2_0.
private void helper2_0(String methodName, String newMethodName, String[] signatures, boolean shouldPass, boolean updateReferences, boolean createDelegate) throws Exception {
final ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
final IType classA = getType(cu, "A");
final IMethod method = classA.getMethod(methodName, signatures);
final RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_METHOD);
descriptor.setJavaElement(method);
descriptor.setNewName(newMethodName);
descriptor.setUpdateReferences(updateReferences);
descriptor.setKeepOriginal(createDelegate);
descriptor.setDeprecateDelegate(createDelegate);
final RefactoringStatus status = new RefactoringStatus();
final Refactoring refactoring = descriptor.createRefactoring(status);
assertNotNull("Refactoring should not be null", refactoring);
assertTrue("status should be ok", status.isOK());
assertEquals("was supposed to pass", null, performRefactoring(refactoring));
if (!shouldPass) {
assertTrue("incorrect renaming because of java model", !getFileContents(getOutputTestFileName("A")).equals(cu.getSource()));
return;
}
String expectedRenaming = getFileContents(getOutputTestFileName("A"));
String actuaRenaming = cu.getSource();
assertEqualLines("incorrect renaming", expectedRenaming, actuaRenaming);
assertTrue("anythingToUndo", RefactoringCore.getUndoManager().anythingToUndo());
assertTrue("! anythingToRedo", !RefactoringCore.getUndoManager().anythingToRedo());
//assertEquals("1 to undo", 1, Refactoring.getUndoManager().getRefactoringLog().size());
RefactoringCore.getUndoManager().performUndo(null, new NullProgressMonitor());
assertEqualLines("invalid undo", getFileContents(getInputTestFileName("A")), cu.getSource());
assertTrue("! anythingToUndo", !RefactoringCore.getUndoManager().anythingToUndo());
assertTrue("anythingToRedo", RefactoringCore.getUndoManager().anythingToRedo());
//assertEquals("1 to redo", 1, Refactoring.getUndoManager().getRedoStack().size());
RefactoringCore.getUndoManager().performRedo(null, new NullProgressMonitor());
assertEqualLines("invalid redo", getFileContents(getOutputTestFileName("A")), cu.getSource());
}
use of org.eclipse.jdt.core.IMethod in project che by eclipse.
the class RenameStaticMethodTest method helper1_0.
private void helper1_0(String methodName, String newMethodName, String[] signatures) throws Exception {
IType classA = getType(createCUfromTestFile(getPackageP(), "A"), "A");
IMethod method = classA.getMethod(methodName, signatures);
RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_METHOD);
descriptor.setJavaElement(method);
descriptor.setNewName(newMethodName);
descriptor.setUpdateReferences(true);
RefactoringStatus result = performRefactoring(descriptor);
assertNotNull("precondition was supposed to fail", result);
}
use of org.eclipse.jdt.core.IMethod in project che by eclipse.
the class RenameStaticMethodTest method test10.
@Test
public void test10() throws Exception {
// printTestDisabledMessage("bug 40628");
// if (true) return;
ICompilationUnit cuA = createCUfromTestFile(getPackageP(), "A");
ICompilationUnit cuB = createCUfromTestFile(getPackageP(), "B");
IType classB = getType(cuB, "B");
IMethod method = classB.getMethod("method", new String[0]);
RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_METHOD);
descriptor.setUpdateReferences(true);
descriptor.setJavaElement(method);
descriptor.setNewName("newmethod");
assertEquals("was supposed to pass", null, performRefactoring(descriptor));
assertEqualLines("invalid renaming in A", getFileContents(getOutputTestFileName("A")), cuA.getSource());
assertEqualLines("invalid renaming in B", getFileContents(getOutputTestFileName("B")), cuB.getSource());
}
use of org.eclipse.jdt.core.IMethod in project che by eclipse.
the class RenameTypeParameterTest method helper1.
private void helper1(String parameterName, String newParameterName, String typeName, String methodName, String[] methodSignature, boolean references) throws Exception {
IType declaringType = getType(createCUfromTestFile(getPackageP(), "A"), typeName);
IMethod[] declaringMethods = getMethods(declaringType, new String[] { methodName }, new String[][] { methodSignature });
RenameTypeParameterProcessor processor = new RenameTypeParameterProcessor(declaringMethods[0].getTypeParameter(parameterName));
RenameRefactoring refactoring = new RenameRefactoring(processor);
processor.setNewElementName(newParameterName);
processor.setUpdateReferences(references);
RefactoringStatus result = performRefactoring(refactoring);
assertNotNull("precondition was supposed to fail", result);
}
Aggregations