Search in sources :

Example 1 with MakeMethodStaticProcessor

use of com.intellij.refactoring.makeStatic.MakeMethodStaticProcessor in project intellij-community by JetBrains.

the class MakeMethodStaticTest method perform.

private static void perform(boolean addClassParameter, boolean delegate) {
    PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED);
    assertTrue(element instanceof PsiMethod);
    PsiMethod method = (PsiMethod) element;
    new MakeMethodStaticProcessor(getProject(), method, new Settings(true, addClassParameter ? "anObject" : null, null, delegate)).run();
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) MakeMethodStaticProcessor(com.intellij.refactoring.makeStatic.MakeMethodStaticProcessor) PsiElement(com.intellij.psi.PsiElement) Settings(com.intellij.refactoring.makeStatic.Settings)

Example 2 with MakeMethodStaticProcessor

use of com.intellij.refactoring.makeStatic.MakeMethodStaticProcessor in project intellij-community by JetBrains.

the class MakeMethodStaticTest method performWithFields.

private static void performWithFields(boolean delegate) {
    PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED);
    assertTrue(element instanceof PsiMethod);
    PsiMethod method = (PsiMethod) element;
    final ArrayList<VariableData> parametersForFields = new ArrayList<>();
    final boolean addClassParameter = MakeStaticUtil.buildVariableData(method, parametersForFields);
    new MakeMethodStaticProcessor(getProject(), method, new Settings(true, addClassParameter ? "anObject" : null, parametersForFields.toArray(new VariableData[parametersForFields.size()]), delegate)).run();
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) ArrayList(java.util.ArrayList) MakeMethodStaticProcessor(com.intellij.refactoring.makeStatic.MakeMethodStaticProcessor) VariableData(com.intellij.refactoring.util.VariableData) PsiElement(com.intellij.psi.PsiElement) Settings(com.intellij.refactoring.makeStatic.Settings)

Aggregations

PsiElement (com.intellij.psi.PsiElement)2 PsiMethod (com.intellij.psi.PsiMethod)2 MakeMethodStaticProcessor (com.intellij.refactoring.makeStatic.MakeMethodStaticProcessor)2 Settings (com.intellij.refactoring.makeStatic.Settings)2 VariableData (com.intellij.refactoring.util.VariableData)1 ArrayList (java.util.ArrayList)1