Search in sources :

Example 1 with Settings

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

the class MakeMethodStaticRefactoringImpl method getFields.

public List<PsiField> getFields() {
    final Settings settings = myProcessor.getSettings();
    List<PsiField> result = new ArrayList<>();
    final List<Settings.FieldParameter> parameterOrderList = settings.getParameterOrderList();
    for (final Settings.FieldParameter fieldParameter : parameterOrderList) {
        result.add(fieldParameter.field);
    }
    return result;
}
Also used : PsiField(com.intellij.psi.PsiField) ArrayList(java.util.ArrayList) Settings(com.intellij.refactoring.makeStatic.Settings)

Example 2 with Settings

use of com.intellij.refactoring.makeStatic.Settings 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 3 with Settings

use of com.intellij.refactoring.makeStatic.Settings 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 4 with Settings

use of com.intellij.refactoring.makeStatic.Settings 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)

Example 5 with Settings

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

the class MakeClassStaticRefactoringImpl method getFields.

public List<PsiField> getFields() {
    final Settings settings = myProcessor.getSettings();
    List<PsiField> result = new ArrayList<>();
    final List<Settings.FieldParameter> parameterOrderList = settings.getParameterOrderList();
    for (final Settings.FieldParameter fieldParameter : parameterOrderList) {
        result.add(fieldParameter.field);
    }
    return result;
}
Also used : PsiField(com.intellij.psi.PsiField) ArrayList(java.util.ArrayList) Settings(com.intellij.refactoring.makeStatic.Settings)

Aggregations

Settings (com.intellij.refactoring.makeStatic.Settings)6 PsiElement (com.intellij.psi.PsiElement)4 ArrayList (java.util.ArrayList)4 PsiClass (com.intellij.psi.PsiClass)2 PsiField (com.intellij.psi.PsiField)2 PsiMethod (com.intellij.psi.PsiMethod)2 CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)2 MakeClassStaticProcessor (com.intellij.refactoring.makeStatic.MakeClassStaticProcessor)2 MakeMethodStaticProcessor (com.intellij.refactoring.makeStatic.MakeMethodStaticProcessor)2 VariableData (com.intellij.refactoring.util.VariableData)2