Search in sources :

Example 1 with MakeClassStaticProcessor

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

the class MakeClassStaticTest method perform.

private void perform() throws Exception {
    configureByFile(TEST_ROOT + getTestName(false) + ".java");
    PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED);
    assertTrue(element instanceof PsiClass);
    PsiClass aClass = (PsiClass) element;
    boolean addClassParameter = MakeStaticUtil.isParameterNeeded(aClass);
    new MakeClassStaticProcessor(getProject(), aClass, new Settings(true, addClassParameter ? "anObject" : null, null)).run();
    checkResultByFile(TEST_ROOT + getTestName(false) + "_after.java");
}
Also used : PsiClass(com.intellij.psi.PsiClass) MakeClassStaticProcessor(com.intellij.refactoring.makeStatic.MakeClassStaticProcessor) PsiElement(com.intellij.psi.PsiElement) Settings(com.intellij.refactoring.makeStatic.Settings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings)

Example 2 with MakeClassStaticProcessor

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

the class MakeClassStaticTest method performWithFields.

private void performWithFields() throws Exception {
    configureByFile(TEST_ROOT + getTestName(false) + ".java");
    PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED);
    assertTrue(element instanceof PsiClass);
    PsiClass aClass = (PsiClass) element;
    final ArrayList<VariableData> parametersForFields = new ArrayList<>();
    final boolean addClassParameter = MakeStaticUtil.buildVariableData(aClass, parametersForFields);
    new MakeClassStaticProcessor(getProject(), aClass, new Settings(true, addClassParameter ? "anObject" : null, parametersForFields.toArray(new VariableData[parametersForFields.size()]))).run();
    checkResultByFile(TEST_ROOT + getTestName(false) + "_after.java");
}
Also used : PsiClass(com.intellij.psi.PsiClass) ArrayList(java.util.ArrayList) VariableData(com.intellij.refactoring.util.VariableData) MakeClassStaticProcessor(com.intellij.refactoring.makeStatic.MakeClassStaticProcessor) PsiElement(com.intellij.psi.PsiElement) Settings(com.intellij.refactoring.makeStatic.Settings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings)

Aggregations

PsiClass (com.intellij.psi.PsiClass)2 PsiElement (com.intellij.psi.PsiElement)2 CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)2 MakeClassStaticProcessor (com.intellij.refactoring.makeStatic.MakeClassStaticProcessor)2 Settings (com.intellij.refactoring.makeStatic.Settings)2 VariableData (com.intellij.refactoring.util.VariableData)1 ArrayList (java.util.ArrayList)1