mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'python-fixes'
This commit is contained in:
@@ -74,8 +74,7 @@ public class PyRedeclarationInspection extends PyInspection {
|
||||
}
|
||||
|
||||
private static boolean isConditional(@NotNull PsiElement node) {
|
||||
return PsiTreeUtil.getParentOfType(node, PyIfStatement.class, PyConditionalExpression.class, PyLoopStatement.class,
|
||||
PyComprehensionElement.class, PyTryExceptStatement.class) != null;
|
||||
return PsiTreeUtil.getParentOfType(node, PyIfStatement.class, PyConditionalExpression.class, PyTryExceptStatement.class) != null;
|
||||
}
|
||||
|
||||
private static boolean isDecorated(@NotNull PyDecoratable node) {
|
||||
@@ -118,17 +117,20 @@ public class PyRedeclarationInspection extends PyInspection {
|
||||
if (rwInstruction.getAccess().isWriteAccess()) {
|
||||
final List<LocalQuickFix> quickFixes = new ArrayList<LocalQuickFix>();
|
||||
final PsiElement originalElement = rwInstruction.getElement();
|
||||
if (originalElement != null && suggestRename(element, originalElement)) {
|
||||
quickFixes.add(new PyRenameElementQuickFix());
|
||||
if (originalElement != null && originalElement != element) {
|
||||
if (suggestRename(element, originalElement)) {
|
||||
quickFixes.add(new PyRenameElementQuickFix());
|
||||
}
|
||||
final PsiElement identifier = element.getNameIdentifier();
|
||||
registerProblem(identifier != null ? identifier : element,
|
||||
PyBundle.message("INSP.redeclared.name", name),
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
|
||||
null,
|
||||
quickFixes.toArray(new LocalQuickFix[quickFixes.size()]));
|
||||
return ControlFlowUtil.Operation.BREAK;
|
||||
}
|
||||
final PsiElement identifier = element.getNameIdentifier();
|
||||
registerProblem(identifier != null ? identifier : element,
|
||||
PyBundle.message("INSP.redeclared.name", name),
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
|
||||
null,
|
||||
quickFixes.toArray(new LocalQuickFix[quickFixes.size()]));
|
||||
}
|
||||
return ControlFlowUtil.Operation.BREAK;
|
||||
return ControlFlowUtil.Operation.CONTINUE;
|
||||
}
|
||||
}
|
||||
return ControlFlowUtil.Operation.NEXT;
|
||||
|
||||
@@ -43,7 +43,7 @@ def test_local_variable():
|
||||
x = 2
|
||||
|
||||
|
||||
def conditional(c):
|
||||
def test_conditional(c):
|
||||
def foo():
|
||||
pass
|
||||
|
||||
@@ -51,12 +51,39 @@ def conditional(c):
|
||||
def foo():
|
||||
pass
|
||||
|
||||
while c:
|
||||
def foo():
|
||||
pass
|
||||
|
||||
try:
|
||||
def foo():
|
||||
pass
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def test_while_loop(c):
|
||||
def foo():
|
||||
pass
|
||||
|
||||
while c:
|
||||
def <warning descr="Redeclared 'foo' defined above without usage">foo</warning>():
|
||||
pass
|
||||
|
||||
|
||||
class TestForLoopNoRedeclaraion:
|
||||
for foo in [1, 2, 3]:
|
||||
x = 1
|
||||
|
||||
|
||||
class TestForLoopTarget:
|
||||
def foo():
|
||||
pass
|
||||
|
||||
for <warning descr="Redeclared 'foo' defined above without usage">foo</warning> in [1, 2, 3]:
|
||||
x = 1
|
||||
|
||||
|
||||
class TestForLoopBody:
|
||||
def foo():
|
||||
pass
|
||||
|
||||
for _ in [1, 2, 3]:
|
||||
def <warning descr="Redeclared 'foo' defined above without usage">foo</warning>():
|
||||
pass
|
||||
|
||||
@@ -433,7 +433,7 @@ public class PyQuickFixTest extends PyTestCase {
|
||||
public void testRenameShadowingBuiltins() {
|
||||
final String fileName = "RenameShadowingBuiltins.py";
|
||||
myFixture.configureByFile(fileName);
|
||||
myFixture.enableInspections(PyShadowingNamesInspection.class);
|
||||
myFixture.enableInspections(PyShadowingBuiltinsInspection.class);
|
||||
myFixture.checkHighlighting(true, false, true);
|
||||
final IntentionAction intentionAction = myFixture.getAvailableIntention("Rename element");
|
||||
assertNotNull(intentionAction);
|
||||
|
||||
Reference in New Issue
Block a user