mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-21644 Proper family names for "Install and import package" and "Create function" quickfixes
This commit is contained in:
@@ -81,7 +81,9 @@ QFIX.unresolved.reference=Replace ''{0}'' with ''{1}.{0}''
|
||||
QFIX.unresolved.reference.add.param.$0=Create parameter ''{0}''
|
||||
QFIX.unresolved.reference.add.param=Create parameter for reference
|
||||
|
||||
QFIX.unresolved.reference.create.function.$0=Create function ''{0}''
|
||||
# UnresolvedRefCreateFunctionQuickFix
|
||||
QFIX.unresolved.reference.create.function=Create function
|
||||
QFIX.NAME.unresolved.reference.create.function=Create function ''{0}''
|
||||
|
||||
QFIX.introduce.variable=Introduce variable for statement
|
||||
|
||||
@@ -163,6 +165,10 @@ QFIX.NAME.make.list=Replace tuple with list
|
||||
#PyRemoveUnderscoresInNumericLiteralsQuickFix
|
||||
QFIX.NAME.remove.underscores.in.numeric=Remove underscores in numeric literals
|
||||
|
||||
# InstallAndImportQuickFix
|
||||
QFIX.install.and.import.package=Install and import package
|
||||
QFIX.NAME.install.and.import.package=Install and import package ''{0}''
|
||||
|
||||
# Intentions: INTN
|
||||
INTN.Family.convert.import.unqualify=Convert 'import module' to 'from module import'
|
||||
INTN.Family.convert.import.qualify=Convert 'from module import' to 'import module'
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.profile.codeInspection.ProjectInspectionProfileManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.codeInsight.imports.AddImportHelper;
|
||||
import com.jetbrains.python.codeInsight.stdlib.PyStdlibUtil;
|
||||
import com.jetbrains.python.packaging.*;
|
||||
@@ -39,6 +40,7 @@ import com.jetbrains.python.packaging.ui.PyChooseRequirementsDialog;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyPsiUtils;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -363,10 +365,17 @@ public class PyPackageRequirementsInspection extends PyInspection {
|
||||
mySdk = PythonSdkType.findPythonSdk(myModule);
|
||||
}
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return PyBundle.message("QFIX.NAME.install.and.import.package", myPackageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return "Install and import package " + myPackageName;
|
||||
return PyBundle.message("QFIX.install.and.import.package");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+11
-1
@@ -29,6 +29,7 @@ import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.ParamHelper;
|
||||
import com.jetbrains.python.psi.impl.PyFunctionBuilder;
|
||||
import com.jetbrains.python.psi.impl.PyPsiUtils;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -37,17 +38,26 @@ import org.jetbrains.annotations.NotNull;
|
||||
* QuickFix to create function to unresolved unqualified reference
|
||||
*/
|
||||
public class UnresolvedRefCreateFunctionQuickFix implements LocalQuickFix {
|
||||
private final String myFunctionName;
|
||||
private PyCallExpression myElement;
|
||||
private PyReferenceExpression myReference;
|
||||
|
||||
public UnresolvedRefCreateFunctionQuickFix(PyCallExpression element, PyReferenceExpression reference) {
|
||||
myElement = element;
|
||||
myReference = reference;
|
||||
myFunctionName = reference.getReferencedName();
|
||||
}
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return PyBundle.message("QFIX.NAME.unresolved.reference.create.function", myFunctionName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return PyBundle.message("QFIX.unresolved.reference.create.function.$0", myReference.getText());
|
||||
return PyBundle.message("QFIX.unresolved.reference.create.function");
|
||||
}
|
||||
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
|
||||
@@ -317,14 +317,14 @@ public class PyQuickFixTest extends PyTestCase {
|
||||
// PY-2092
|
||||
public void testUnresolvedRefCreateFunction() {
|
||||
doInspectionTest(PyUnresolvedReferencesInspection.class,
|
||||
PyBundle.message("QFIX.unresolved.reference.create.function.$0", "ref"), true, true);
|
||||
PyBundle.message("QFIX.NAME.unresolved.reference.create.function", "ref"), true, true);
|
||||
}
|
||||
|
||||
public void testUnresolvedRefNoCreateFunction() {
|
||||
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
|
||||
myFixture.configureByFile("UnresolvedRefNoCreateFunction.py");
|
||||
myFixture.checkHighlighting(true, false, false);
|
||||
final IntentionAction intentionAction = myFixture.getAvailableIntention(PyBundle.message("QFIX.unresolved.reference.create.function.$0", "ref"));
|
||||
final IntentionAction intentionAction = myFixture.getAvailableIntention(PyBundle.message("QFIX.NAME.unresolved.reference.create.function", "ref"));
|
||||
assertNull(intentionAction);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user