Search in sources :

Example 1 with DartIntroduceHandler

use of com.jetbrains.lang.dart.ide.refactoring.introduce.DartIntroduceHandler in project intellij-plugins by JetBrains.

the class DartIntroduceTestBase method doTestInplace.

protected void doTestInplace(@Nullable Consumer<DartIntroduceOperation> customization) {
    String name = getTestName(false);
    myFixture.configureByFile(name + getFileExtension());
    final boolean enabled = myFixture.getEditor().getSettings().isVariableInplaceRenameEnabled();
    try {
        TemplateManagerImpl.setTemplateTesting(getProject(), myFixture.getTestRootDisposable());
        myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(true);
        DartIntroduceHandler handler = createHandler();
        final DartIntroduceOperation introduceOperation = new DartIntroduceOperation(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile(), "a");
        introduceOperation.setReplaceAll(true);
        if (customization != null) {
            customization.consume(introduceOperation);
        }
        handler.performAction(introduceOperation);
        TemplateState state = TemplateManagerImpl.getTemplateState(myFixture.getEditor());
        assert state != null;
        state.gotoEnd(false);
        myFixture.checkResultByFile(name + ".after" + getFileExtension(), true);
    } finally {
        myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(enabled);
    }
}
Also used : DartIntroduceOperation(com.jetbrains.lang.dart.ide.refactoring.introduce.DartIntroduceOperation) DartIntroduceHandler(com.jetbrains.lang.dart.ide.refactoring.introduce.DartIntroduceHandler) TemplateState(com.intellij.codeInsight.template.impl.TemplateState)

Example 2 with DartIntroduceHandler

use of com.jetbrains.lang.dart.ide.refactoring.introduce.DartIntroduceHandler in project intellij-plugins by JetBrains.

the class DartIntroduceTestBase method doTest.

protected void doTest(@Nullable Consumer<DartIntroduceOperation> customization, boolean replaceAll) {
    myFixture.configureByFile(getTestName(false) + getFileExtension());
    boolean inplaceEnabled = myFixture.getEditor().getSettings().isVariableInplaceRenameEnabled();
    try {
        myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(false);
        DartIntroduceHandler handler = createHandler();
        final DartIntroduceOperation operation = new DartIntroduceOperation(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile(), "foo");
        operation.setReplaceAll(replaceAll);
        if (customization != null) {
            customization.consume(operation);
        }
        handler.performAction(operation);
        doCheck();
    } finally {
        myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(inplaceEnabled);
    }
}
Also used : DartIntroduceOperation(com.jetbrains.lang.dart.ide.refactoring.introduce.DartIntroduceOperation) DartIntroduceHandler(com.jetbrains.lang.dart.ide.refactoring.introduce.DartIntroduceHandler)

Aggregations

DartIntroduceHandler (com.jetbrains.lang.dart.ide.refactoring.introduce.DartIntroduceHandler)2 DartIntroduceOperation (com.jetbrains.lang.dart.ide.refactoring.introduce.DartIntroduceOperation)2 TemplateState (com.intellij.codeInsight.template.impl.TemplateState)1