PY-21204 Quickfix "Create function" properly handles injected fragments

by inserting a new function in the containing host file, not inside the
fragment itself.

Also I fixed issues with keeping hard references to PSI elements and
usage of deprecated TemplateBuilder's API.
This commit is contained in:
Mikhail Golubev
2016-11-25 17:45:24 +03:00
parent b09b8a30fd
commit 7f96674bb3
6 changed files with 79 additions and 21 deletions
@@ -207,6 +207,18 @@ public class PyQuickFixTest extends PyTestCase {
doInspectionTest(PyUnresolvedReferencesInspection.class, "Create class 'MyClass'", true, true);
}
// PY-21204
public void testAddClassFromFString() {
runWithLanguageLevel(LanguageLevel.PYTHON36,
() -> doInspectionTest(PyUnresolvedReferencesInspection.class, "Create class 'MyClass'", true, true));
}
// PY-21204
public void testAddFunctionFromFString() {
runWithLanguageLevel(LanguageLevel.PYTHON36,
() -> doInspectionTest(PyUnresolvedReferencesInspection.class, PyBundle.message("QFIX.NAME.unresolved.reference.create.function", "my_function"), true, true));
}
// PY-1602
public void testAddFunctionToModule() {
doInspectionTest(