use of com.jetbrains.python.refactoring.introduce.IntroduceOperation in project intellij-community by JetBrains.
the class PyIntroduceTestCase method doTestInplace.
protected void doTestInplace(@Nullable Consumer<IntroduceOperation> customization) {
String name = getTestName(true);
myFixture.configureByFile(name + ".py");
final boolean enabled = myFixture.getEditor().getSettings().isVariableInplaceRenameEnabled();
try {
TemplateManagerImpl.setTemplateTesting(myFixture.getProject(), myFixture.getTestRootDisposable());
myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(true);
IntroduceHandler handler = createHandler();
final IntroduceOperation introduceOperation = new IntroduceOperation(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile(), "a");
introduceOperation.setReplaceAll(true);
if (customization != null) {
customization.consume(introduceOperation);
}
handler.performAction(introduceOperation);
WriteCommandAction.runWriteCommandAction(myFixture.getProject(), () -> {
TemplateState state = TemplateManagerImpl.getTemplateState(myFixture.getEditor());
assert state != null;
state.gotoEnd(false);
});
myFixture.checkResultByFile(name + ".after.py", true);
} finally {
myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(enabled);
}
}
use of com.jetbrains.python.refactoring.introduce.IntroduceOperation in project intellij-community by JetBrains.
the class PyIntroduceVariableTest method testMultiReference.
// PY-10964
public void testMultiReference() {
myFixture.configureByFile(getTestName(true) + ".py");
boolean inplaceEnabled = myFixture.getEditor().getSettings().isVariableInplaceRenameEnabled();
try {
myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(true);
IntroduceHandler handler = createHandler();
final IntroduceOperation operation = new IntroduceOperation(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile(), "a_");
operation.setReplaceAll(true);
handler.performAction(operation);
myFixture.checkResultByFile(getTestName(true) + ".after.py");
} finally {
myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(inplaceEnabled);
}
}
use of com.jetbrains.python.refactoring.introduce.IntroduceOperation in project intellij-community by JetBrains.
the class PyIntroduceFieldHandler method invoke.
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
final IntroduceOperation operation = new IntroduceOperation(project, editor, file, null);
operation.addAvailableInitPlace(InitPlace.CONSTRUCTOR);
if (isTestClass(file, editor)) {
operation.addAvailableInitPlace(InitPlace.SET_UP);
}
performAction(operation);
}
use of com.jetbrains.python.refactoring.introduce.IntroduceOperation in project intellij-community by JetBrains.
the class PyIntroduceTestCase method doTest.
protected void doTest(@Nullable Consumer<IntroduceOperation> customization) {
myFixture.configureByFile(getTestName(true) + ".py");
boolean inplaceEnabled = myFixture.getEditor().getSettings().isVariableInplaceRenameEnabled();
try {
myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(false);
IntroduceHandler handler = createHandler();
final IntroduceOperation operation = new IntroduceOperation(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile(), "a");
operation.setReplaceAll(true);
if (customization != null) {
customization.consume(operation);
}
handler.performAction(operation);
myFixture.checkResultByFile(getTestName(true) + ".after.py");
} finally {
myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(inplaceEnabled);
}
}
Aggregations