Search in sources :

Example 1 with LocalToFieldHandler

use of com.intellij.refactoring.introduceField.LocalToFieldHandler in project intellij-community by JetBrains.

the class IntroduceFieldWitSetUpInitializationTest method doTest.

private void doTest() throws Exception {
    configureByFile("/refactoring/introduceField/before" + getTestName(false) + ".java");
    final PsiLocalVariable local = PsiTreeUtil.getParentOfType(getFile().findElementAt(getEditor().getCaretModel().getOffset()), PsiLocalVariable.class);
    new LocalToFieldHandler(getProject(), false) {

        @Override
        protected BaseExpressionToFieldHandler.Settings showRefactoringDialog(final PsiClass aClass, final PsiLocalVariable local, final PsiExpression[] occurences, final boolean isStatic) {
            return new BaseExpressionToFieldHandler.Settings("i", null, occurences, true, false, false, BaseExpressionToFieldHandler.InitializationPlace.IN_SETUP_METHOD, PsiModifier.PRIVATE, local, local.getType(), true, (BaseExpressionToFieldHandler.TargetDestination) null, false, false);
        }
    }.convertLocalToField(local, myEditor);
    checkResultByFile("/refactoring/introduceField/after" + getTestName(false) + ".java");
}
Also used : LocalToFieldHandler(com.intellij.refactoring.introduceField.LocalToFieldHandler) PsiExpression(com.intellij.psi.PsiExpression) PsiClass(com.intellij.psi.PsiClass) PsiLocalVariable(com.intellij.psi.PsiLocalVariable) BaseExpressionToFieldHandler(com.intellij.refactoring.introduceField.BaseExpressionToFieldHandler)

Aggregations

PsiClass (com.intellij.psi.PsiClass)1 PsiExpression (com.intellij.psi.PsiExpression)1 PsiLocalVariable (com.intellij.psi.PsiLocalVariable)1 BaseExpressionToFieldHandler (com.intellij.refactoring.introduceField.BaseExpressionToFieldHandler)1 LocalToFieldHandler (com.intellij.refactoring.introduceField.LocalToFieldHandler)1