use of com.jetbrains.python.refactoring.introduce.IntroduceHandler 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.IntroduceHandler 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.IntroduceHandler 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);
}
}
use of com.jetbrains.python.refactoring.introduce.IntroduceHandler in project intellij-community by JetBrains.
the class PyIntroduceTestCase method buildSuggestions.
protected Collection<String> buildSuggestions(Class<? extends PyExpression> parentClass) {
myFixture.configureByFile(getTestName(true) + ".py");
final IntroduceHandler handler = createHandler();
final PyExpression expr = PsiTreeUtil.getParentOfType(myFixture.getFile().findElementAt(myFixture.getCaretOffset()), parentClass);
assertNotNull(expr);
return handler.getSuggestedNames(expr);
}
Aggregations