mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-21374 Fixed: Yellow 'install packages' bar should be displayed when requirements.txt is opened
Remove language for PyPackageRequirementsInspection in python-core-common.xml so it could be executed in "requirements.txt" file
This commit is contained in:
@@ -384,7 +384,7 @@
|
||||
<localInspection language="Python" shortName="PyTypeCheckerInspection" suppressId="PyTypeChecker" displayName="Type checker" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WARNING" implementationClass="com.jetbrains.python.inspections.PyTypeCheckerInspection"/>
|
||||
<localInspection language="Python" shortName="PyDeprecationInspection" suppressId="PyDeprecation" displayName="Deprecated function, class or module" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WARNING" implementationClass="com.jetbrains.python.inspections.PyDeprecationInspection"/>
|
||||
<localInspection language="Python" shortName="PyMandatoryEncodingInspection" suppressId="PyMandatoryEncoding" displayName="No encoding specified for file" groupKey="INSP.GROUP.python" enabledByDefault="false" level="WARNING" implementationClass="com.jetbrains.python.inspections.PyMandatoryEncodingInspection"/>
|
||||
<localInspection language="Python" shortName="PyPackageRequirementsInspection" suppressId="PyPackageRequirements" bundle="com.jetbrains.python.PyBundle" key="INSP.NAME.requirements" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WARNING" implementationClass="com.jetbrains.python.inspections.PyPackageRequirementsInspection"/>
|
||||
<localInspection shortName="PyPackageRequirementsInspection" suppressId="PyPackageRequirements" bundle="com.jetbrains.python.PyBundle" key="INSP.NAME.requirements" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WARNING" implementationClass="com.jetbrains.python.inspections.PyPackageRequirementsInspection"/>
|
||||
<localInspection language="Python" shortName="PyPep8Inspection" suppressId="PyPep8" displayName="PEP 8 coding style violation" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WEAK WARNING" implementationClass="com.jetbrains.python.inspections.PyPep8Inspection"/>
|
||||
<localInspection language="Python" shortName="PyAttributeOutsideInitInspection" suppressId="PyAttributeOutsideInit" displayName="Instance attribute defined outside __init__" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WEAK WARNING" implementationClass="com.jetbrains.python.inspections.PyAttributeOutsideInitInspection"/>
|
||||
<localInspection language="Python" shortName="PyClassHasNoInitInspection" suppressId="PyClassHasNoInit" displayName="Class has no __init__ method" groupKey="INSP.GROUP.python" enabledByDefault="true" level="WEAK WARNING" implementationClass="com.jetbrains.python.inspections.PyClassHasNoInitInspection"/>
|
||||
|
||||
@@ -88,11 +88,19 @@ public class PyPackageRequirementsInspection extends PyInspection {
|
||||
|
||||
@Override
|
||||
public void visitPyFile(PyFile node) {
|
||||
final Module module = ModuleUtilCore.findModuleForPsiElement(node);
|
||||
if (module != null) {
|
||||
if (isRunningPackagingTasks(module)) {
|
||||
return;
|
||||
}
|
||||
checkPackagesHaveBeenInstalled(node, ModuleUtilCore.findModuleForPsiElement(node));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPlainTextFile(PsiPlainTextFile file) {
|
||||
final Module module = ModuleUtilCore.findModuleForPsiElement(file);
|
||||
if (module != null && file.getVirtualFile().equals(PyPackageUtil.findRequirementsTxt(module))) {
|
||||
checkPackagesHaveBeenInstalled(file, module);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPackagesHaveBeenInstalled(@NotNull PsiElement file, @Nullable Module module) {
|
||||
if (module != null && !isRunningPackagingTasks(module)) {
|
||||
final Sdk sdk = PythonSdkType.findPythonSdk(module);
|
||||
if (sdk != null) {
|
||||
final List<PyRequirement> unsatisfied = findUnsatisfiedRequirements(module, sdk, myIgnoredPackages);
|
||||
@@ -109,7 +117,7 @@ public class PyPackageRequirementsInspection extends PyInspection {
|
||||
final List<LocalQuickFix> quickFixes = new ArrayList<>();
|
||||
quickFixes.add(new PyInstallRequirementsFix(null, module, sdk, unsatisfied));
|
||||
quickFixes.add(new IgnoreRequirementFix(unsatisfiedNames));
|
||||
registerProblem(node, msg,
|
||||
registerProblem(file, msg,
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, null,
|
||||
quickFixes.toArray(new LocalQuickFix[quickFixes.size()]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user