mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed highlighting of unused local classes (PY-5086)
This commit is contained in:
@@ -277,6 +277,7 @@ INSP.unused.locals.parameter.isnot.used=Parameter ''{0}'' value is not used
|
||||
INSP.unused.locals.local.variable.isnot.used=Local variable ''{0}'' value is not used
|
||||
INSP.unused.locals.replace.with.wildcard=Replace with _
|
||||
INSP.unused.locals.local.function.isnot.used=Local function ''{0}'' is not used
|
||||
INSP.unused.locals.local.class.isnot.used=Local class ''{0}'' is not used
|
||||
|
||||
# PyUnboundLocalVariableInspection
|
||||
INSP.NAME.unbound=Unbound local variable
|
||||
|
||||
@@ -226,15 +226,22 @@ public class PyUnusedLocalInspectionVisitor extends PyInspectionVisitor {
|
||||
}
|
||||
if (ignoreUnused) continue;
|
||||
|
||||
// Local function
|
||||
if (element instanceof PyFunction){
|
||||
if (element instanceof PyFunction) {
|
||||
// Local function
|
||||
final PsiElement nameIdentifier = ((PyFunction)element).getNameIdentifier();
|
||||
registerWarning(nameIdentifier == null ? element : nameIdentifier,
|
||||
PyBundle.message("INSP.unused.locals.local.function.isnot.used",
|
||||
((PyFunction)element).getName()));
|
||||
}
|
||||
// Local variable or parameter
|
||||
else if (element instanceof PyClass) {
|
||||
// Local class
|
||||
final PyClass cls = (PyClass)element;
|
||||
final PsiElement name = cls.getNameIdentifier();
|
||||
registerWarning(name != null ? name : element,
|
||||
PyBundle.message("INSP.unused.locals.local.class.isnot.used", cls.getName()));
|
||||
}
|
||||
else {
|
||||
// Local variable or parameter
|
||||
String name = element.getText();
|
||||
if (element instanceof PyNamedParameter || element.getParent() instanceof PyNamedParameter) {
|
||||
PyNamedParameter namedParameter = element instanceof PyNamedParameter
|
||||
|
||||
@@ -253,3 +253,11 @@ def test_same_named_variable_inside_class():
|
||||
def a(self):
|
||||
print(a)
|
||||
return C
|
||||
|
||||
|
||||
# PY-5086
|
||||
def test_only_name_in_local_class():
|
||||
x = 1
|
||||
class <warning descr="Local class 'C' is not used">C</warning>:
|
||||
pass
|
||||
return x
|
||||
|
||||
Reference in New Issue
Block a user