Search in sources :

Example 1 with MoveInstanceMethodProcessor

use of com.intellij.refactoring.move.moveInstanceMethod.MoveInstanceMethodProcessor in project intellij-community by JetBrains.

the class MoveInstanceMethodTest method doTest.

private void doTest(boolean isTargetParameter, final int targetIndex, final String newVisibility) throws Exception {
    final String filePath = "/refactoring/moveInstanceMethod/" + getTestName(false) + ".java";
    configureByFile(filePath);
    final PsiElement targetElement = TargetElementUtil.findTargetElement(getEditor(), TargetElementUtil.ELEMENT_NAME_ACCEPTED);
    assertTrue("<caret> is not on method name", targetElement instanceof PsiMethod);
    PsiMethod method = (PsiMethod) targetElement;
    final PsiVariable targetVariable = isTargetParameter ? method.getParameterList().getParameters()[targetIndex] : method.getContainingClass().getFields()[targetIndex];
    new MoveInstanceMethodProcessor(getProject(), method, targetVariable, newVisibility, MoveInstanceMethodHandler.suggestParameterNames(method, targetVariable)).run();
    checkResultByFile(filePath + ".after");
}
Also used : PsiVariable(com.intellij.psi.PsiVariable) PsiMethod(com.intellij.psi.PsiMethod) PsiElement(com.intellij.psi.PsiElement) MoveInstanceMethodProcessor(com.intellij.refactoring.move.moveInstanceMethod.MoveInstanceMethodProcessor)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 PsiMethod (com.intellij.psi.PsiMethod)1 PsiVariable (com.intellij.psi.PsiVariable)1 MoveInstanceMethodProcessor (com.intellij.refactoring.move.moveInstanceMethod.MoveInstanceMethodProcessor)1