mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-10207 Inner classes should not fire up "acces to protected member" inspections
This commit is contained in:
@@ -56,6 +56,14 @@ public class PyProtectedMemberInspection extends PyInspection {
|
||||
final PyClass resolvedClass = PsiTreeUtil.getParentOfType(resolvedExpression, PyClass.class);
|
||||
if (parentClass.isSubclass(resolvedClass))
|
||||
return;
|
||||
|
||||
PyClass outerClass = PsiTreeUtil.getParentOfType(parentClass, PyClass.class);
|
||||
while (outerClass != null) {
|
||||
if (outerClass.isSubclass(resolvedClass))
|
||||
return;
|
||||
|
||||
outerClass = PsiTreeUtil.getParentOfType(outerClass, PyClass.class);
|
||||
}
|
||||
}
|
||||
registerProblem(node, PyBundle.message("INSP.protected.member.$0.access", name));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
class AbstractExperimentManager(object):
|
||||
|
||||
def _call_on_plugins(self, method_name, *args, **kwargs):
|
||||
pass
|
||||
|
||||
class EventExperimentManager(AbstractExperimentManager):
|
||||
|
||||
|
||||
class __SomeEvent(object):
|
||||
|
||||
def __init__(self, parent):
|
||||
"""
|
||||
:param EventExperimentManager parent: Parent
|
||||
"""
|
||||
self.parent = parent
|
||||
|
||||
def __call__(self, event):
|
||||
self.parent._call_on_plugins("foo")
|
||||
@@ -18,10 +18,15 @@ public class PyProtectedMemberInspectionTest extends PyTestCase {
|
||||
public void testTrueNegative() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDoubleUnderscore() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testOuterClass() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile("inspections/PyProtectedMemberInspection/" + getTestName(true) + ".py");
|
||||
myFixture.enableInspections(PyProtectedMemberInspection.class);
|
||||
|
||||
Reference in New Issue
Block a user