Search in sources :

Example 1 with IntroduceParameterHandler

use of com.intellij.refactoring.introduceParameter.IntroduceParameterHandler in project intellij-community by JetBrains.

the class IntroduceParameterTest method doTestThroughHandler.

private void doTestThroughHandler() {
    configureByFile("/refactoring/introduceParameter/before" + getTestName(false) + ".java");
    boolean enabled = true;
    try {
        configureByFile("/refactoring/introduceParameter/before" + getTestName(false) + ".java");
        enabled = myEditor.getSettings().isVariableInplaceRenameEnabled();
        myEditor.getSettings().setVariableInplaceRenameEnabled(false);
        new IntroduceParameterHandler().invoke(getProject(), myEditor, myFile, DataContext.EMPTY_CONTEXT);
        checkResultByFile("/refactoring/introduceParameter/after" + getTestName(false) + ".java");
    } finally {
        myEditor.getSettings().setVariableInplaceRenameEnabled(enabled);
    }
}
Also used : IntroduceParameterHandler(com.intellij.refactoring.introduceParameter.IntroduceParameterHandler)

Example 2 with IntroduceParameterHandler

use of com.intellij.refactoring.introduceParameter.IntroduceParameterHandler in project intellij-community by JetBrains.

the class IntroduceFunctionalParameterTest method doTest.

private void doTest(String conflict) {
    boolean enabled = true;
    try {
        configureByFile("/refactoring/introduceFunctionalParameter/before" + getTestName(false) + ".java");
        enabled = myEditor.getSettings().isVariableInplaceRenameEnabled();
        myEditor.getSettings().setVariableInplaceRenameEnabled(false);
        final SelectionModel selectionModel = getEditor().getSelectionModel();
        if (selectionModel.hasSelection()) {
            PsiElement[] elements = ExtractMethodHandler.getElements(getProject(), getEditor(), getFile());
            new IntroduceParameterHandler().introduceStrategy(getProject(), getEditor(), getFile(), elements);
        }
        checkResultByFile("/refactoring/introduceFunctionalParameter/after" + getTestName(false) + ".java");
        if (conflict != null) {
            fail("Conflict expected");
        }
    } catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
        if (conflict == null) {
            throw e;
        }
        assertEquals(conflict, e.getMessage());
    } finally {
        myEditor.getSettings().setVariableInplaceRenameEnabled(enabled);
    }
}
Also used : IntroduceParameterHandler(com.intellij.refactoring.introduceParameter.IntroduceParameterHandler) SelectionModel(com.intellij.openapi.editor.SelectionModel) PsiElement(com.intellij.psi.PsiElement)

Aggregations

IntroduceParameterHandler (com.intellij.refactoring.introduceParameter.IntroduceParameterHandler)2 SelectionModel (com.intellij.openapi.editor.SelectionModel)1 PsiElement (com.intellij.psi.PsiElement)1