mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -36,6 +36,9 @@ public class RemoteDebugger implements ProcessDebugger {
|
||||
|
||||
private static final SecureRandom ourRandom = new SecureRandom();
|
||||
|
||||
|
||||
private static final int CONNECTION_TIMEOUT = 60000;
|
||||
|
||||
private final IPyDebugProcess myDebugProcess;
|
||||
private final ServerSocket myServerSocket;
|
||||
private final int myTimeout;
|
||||
@@ -71,6 +74,7 @@ public class RemoteDebugger implements ProcessDebugger {
|
||||
public void waitForConnect() throws Exception {
|
||||
try {
|
||||
//noinspection SocketOpenedButNotSafelyClosed
|
||||
myServerSocket.setSoTimeout(CONNECTION_TIMEOUT);
|
||||
mySocket = myServerSocket.accept();
|
||||
myConnected = true;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<orderEntry type="library" name="Velocity" level="project" />
|
||||
<orderEntry type="module" module-name="python-helpers" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="chronon-embedder" />
|
||||
<orderEntry type="module" module-name="python-remote-interpreter" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -53,7 +53,8 @@ public class PyBlock implements ASTBlock {
|
||||
PyElementTypes.TUPLE_EXPRESSION,
|
||||
PyElementTypes.PARENTHESIZED_EXPRESSION,
|
||||
PyElementTypes.SLICE_EXPRESSION,
|
||||
PyElementTypes.SUBSCRIPTION_EXPRESSION);
|
||||
PyElementTypes.SUBSCRIPTION_EXPRESSION,
|
||||
PyElementTypes.GENERATOR_EXPRESSION);
|
||||
|
||||
private static final TokenSet ourBrackets = TokenSet.create(PyTokenTypes.LPAR, PyTokenTypes.RPAR,
|
||||
PyTokenTypes.LBRACE, PyTokenTypes.RBRACE,
|
||||
|
||||
@@ -17,8 +17,6 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.jetbrains.cython.CythonLanguageDialect;
|
||||
import com.jetbrains.cython.CythonNames;
|
||||
import com.jetbrains.cython.psi.CythonFile;
|
||||
import com.jetbrains.cython.types.CythonBuiltinType;
|
||||
import com.jetbrains.cython.types.CythonType;
|
||||
@@ -423,12 +421,6 @@ public class PyUnresolvedReferencesInspection extends PyInspection {
|
||||
if (PyNames.COMPARISON_OPERATORS.contains(refname)) {
|
||||
return;
|
||||
}
|
||||
if (CythonLanguageDialect.isInsideCythonFile(element) &&
|
||||
(CythonNames.BASE_C_TYPES.contains(text) ||
|
||||
CythonNames.BASE_CYTHON_TYPES.contains(text) ||
|
||||
CythonNames.BUILTINS.contains(text))) {
|
||||
return;
|
||||
}
|
||||
if (refex.getQualifier() != null) {
|
||||
final PyClassTypeImpl object_type = (PyClassTypeImpl)PyBuiltinCache.getInstance(node).getObjectType();
|
||||
if ((object_type != null) && object_type.getPossibleInstanceMembers().contains(refname)) return;
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.jetbrains.python.PyElementTypes;
|
||||
import com.jetbrains.python.psi.PyElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -53,6 +54,10 @@ public class Parsing {
|
||||
return myBuilder.getTokenType() == tokenType;
|
||||
}
|
||||
|
||||
protected boolean atToken(@NotNull final IElementType tokenType, @NotNull String tokenText) {
|
||||
return myBuilder.getTokenType() == tokenType && tokenText.equals(myBuilder.getTokenText());
|
||||
}
|
||||
|
||||
protected boolean atAnyOfTokens(final IElementType... tokenTypes) {
|
||||
IElementType currentTokenType = myBuilder.getTokenType();
|
||||
for (IElementType tokenType : tokenTypes) {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class PyPathEvaluator {
|
||||
return argValue == null ? null : new File(argValue).getParent();
|
||||
}
|
||||
else if (call.isCalleeText(PyNames.JOIN) && args.length >= 1) {
|
||||
return evaluatePathInJoin(containingFilePath, args, args.length);
|
||||
return evaluatePathInJoin(containingFilePath, args, args.length, visited);
|
||||
}
|
||||
else if (call.isCalleeText(PyNames.ABSPATH) && args.length == 1) {
|
||||
String argValue = evaluate(args[0], containingFilePath, visited);
|
||||
@@ -97,10 +97,10 @@ public class PyPathEvaluator {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String evaluatePathInJoin(String containingFilePath, PyExpression[] args, int endElement) {
|
||||
public static String evaluatePathInJoin(String containingFilePath, PyExpression[] args, int endElement, Set<PyExpression> visited) {
|
||||
String result = null;
|
||||
for (int i = 0; i < endElement; i++) {
|
||||
String arg = evaluate(args[i], containingFilePath, new HashSet<PyExpression>());
|
||||
String arg = evaluate(args[i], containingFilePath, visited);
|
||||
if (arg == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.jetbrains.cython.CythonLanguageDialect;
|
||||
import com.jetbrains.cython.psi.CythonCImportElement;
|
||||
import com.jetbrains.cython.psi.CythonFromCImportStatement;
|
||||
import com.jetbrains.cython.psi.CythonImportReference;
|
||||
import com.jetbrains.cython.psi.CythonReference;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.PythonDialectsTokenSetProvider;
|
||||
@@ -55,7 +56,8 @@ public class PyReferenceExpressionImpl extends PyElementImpl implements PyRefere
|
||||
final PyExpression qualifier = getQualifier();
|
||||
|
||||
// Handle import reference
|
||||
if (CythonLanguageDialect.isInsideCythonFile(this)) {
|
||||
final boolean inCythonFile = CythonLanguageDialect.isInsideCythonFile(this);
|
||||
if (inCythonFile) {
|
||||
if (PsiTreeUtil.getParentOfType(this, CythonCImportElement.class, CythonFromCImportStatement.class) != null) {
|
||||
return new CythonImportReference(this, context);
|
||||
}
|
||||
@@ -65,21 +67,23 @@ public class PyReferenceExpressionImpl extends PyElementImpl implements PyRefere
|
||||
return PyImportReference.forElement(this, importParent, context);
|
||||
}
|
||||
|
||||
if (file != null) {
|
||||
// Return special reference
|
||||
final ConsoleCommunication communication = file.getCopyableUserData(PydevConsoleRunner.CONSOLE_KEY);
|
||||
if (communication != null) {
|
||||
if (qualifier != null) {
|
||||
return new PydevConsoleReference(this, communication, qualifier.getText() + ".");
|
||||
}
|
||||
return new PydevConsoleReference(this, communication, "");
|
||||
// Return special reference
|
||||
final ConsoleCommunication communication = file.getCopyableUserData(PydevConsoleRunner.CONSOLE_KEY);
|
||||
if (communication != null) {
|
||||
if (qualifier != null) {
|
||||
return new PydevConsoleReference(this, communication, qualifier.getText() + ".");
|
||||
}
|
||||
return new PydevConsoleReference(this, communication, "");
|
||||
}
|
||||
|
||||
if (qualifier != null) {
|
||||
return new PyQualifiedReference(this, context);
|
||||
}
|
||||
|
||||
if (inCythonFile) {
|
||||
return new CythonReference(this, context);
|
||||
}
|
||||
|
||||
return new PyReferenceImpl(this, context);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,7 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkModificator;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.remotesdk.RemoteCredentials;
|
||||
import com.intellij.remotesdk.RemoteInterpreterException;
|
||||
import com.intellij.remotesdk.RemoteSdkData;
|
||||
import com.intellij.remotesdk.RemoteSshProcess;
|
||||
import com.intellij.remotesdk.*;
|
||||
import com.intellij.util.NullableConsumer;
|
||||
import com.intellij.util.PathMappingSettings;
|
||||
import com.jetbrains.python.PythonHelpersLocator;
|
||||
@@ -30,7 +27,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author traff
|
||||
*/
|
||||
public abstract class PythonRemoteInterpreterManager {
|
||||
public abstract class PythonRemoteInterpreterManager implements RemoteSdkFactory<PyRemoteSdkAdditionalData> {
|
||||
public final static ExtensionPointName<PythonRemoteInterpreterManager> EP_NAME =
|
||||
ExtensionPointName.create("Pythonid.remoteInterpreterManager");
|
||||
public static final String WEB_DEPLOYMENT_PLUGIN_IS_DISABLED =
|
||||
|
||||
@@ -143,13 +143,7 @@ public class Pep8ExternalAnnotator extends ExternalAnnotator<Pep8ExternalAnnotat
|
||||
if (annotationResult == null || !file.isValid()) return;
|
||||
final String text = file.getText();
|
||||
for (Problem problem : annotationResult.problems) {
|
||||
String stripTrailingSpaces = EditorSettingsExternalizable.getInstance().getStripTrailingSpaces();
|
||||
if (!stripTrailingSpaces.equals(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE)) {
|
||||
// ignore trailing spaces errors if they're going to disappear after save
|
||||
if (problem.myCode.equals("W291") || problem.myCode.equals("W293")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (ignoreDueToSettings(file.getProject(), problem)) continue;
|
||||
int offset = StringUtil.lineColToOffset(text, problem.myLine - 1, problem.myColumn - 1);
|
||||
PsiElement problemElement = file.findElementAt(offset);
|
||||
if (!(problemElement instanceof PsiWhiteSpace) && !(problem.myCode.startsWith("E3"))) {
|
||||
@@ -187,6 +181,21 @@ public class Pep8ExternalAnnotator extends ExternalAnnotator<Pep8ExternalAnnotat
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean ignoreDueToSettings(Project project, Problem problem) {
|
||||
String stripTrailingSpaces = EditorSettingsExternalizable.getInstance().getStripTrailingSpaces();
|
||||
if (!stripTrailingSpaces.equals(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE)) {
|
||||
// ignore trailing spaces errors if they're going to disappear after save
|
||||
if (problem.myCode.equals("W291") || problem.myCode.equals("W293")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
boolean useTabs = CodeStyleSettingsManager.getSettings(project).useTabCharacter(PythonFileType.INSTANCE);
|
||||
if (useTabs && problem.myCode.equals("W191")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final Pattern PROBLEM_PATTERN = Pattern.compile(".+:(\\d+):(\\d+): ([EW]\\d{3}) (.+)");
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
def supprice():
|
||||
if True:
|
||||
if True:
|
||||
agdrn = sum(VARS[drn + price] * md.c[drn][1] * md.c[drn][3] *
|
||||
exp(md.c[drn][2] * VARS['SEEPAGE'] - md.c[drn][3] * pmp)
|
||||
for drn in md.agdrn_nodes if drn in md.c)
|
||||
@@ -0,0 +1,6 @@
|
||||
def supprice():
|
||||
if True:
|
||||
if True:
|
||||
agdrn = sum(VARS[drn + price] * md.c[drn][1] * md.c[drn][3] *
|
||||
exp(md.c[drn][2] * VARS['SEEPAGE'] - md.c[drn][3] * pmp)
|
||||
for drn in md.agdrn_nodes if drn in md.c)
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class C():
|
||||
def __init__(self):
|
||||
self.str = str(1) #pass
|
||||
@@ -0,0 +1,9 @@
|
||||
local_var = "foo"
|
||||
|
||||
class C:
|
||||
local_var = local_var #pass
|
||||
|
||||
def foo(self):
|
||||
print(self.local_var)
|
||||
|
||||
C().foo()
|
||||
@@ -0,0 +1,10 @@
|
||||
# PY-1138
|
||||
from models import ChartRequest
|
||||
from components.dbutil import DbSession
|
||||
|
||||
def foo(requestId):
|
||||
with DbSession() as db:
|
||||
req = db.query(ChartRequest).get(requestId)
|
||||
assert req is not None, u"Invalid request"
|
||||
print req
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
def foo1():
|
||||
a = 1
|
||||
try:
|
||||
for i in range(10):
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
b = a #pass
|
||||
|
||||
|
||||
def foo2():
|
||||
a = 1
|
||||
try:
|
||||
for i in range(10):
|
||||
pass
|
||||
except Exception:
|
||||
c = a #pass
|
||||
finally:
|
||||
b = a #pass
|
||||
@@ -0,0 +1,7 @@
|
||||
def f(x):
|
||||
def d(f):
|
||||
return f
|
||||
@d #pass
|
||||
def g(d):
|
||||
return d
|
||||
return g(x)
|
||||
@@ -0,0 +1,5 @@
|
||||
def f():
|
||||
z = 2
|
||||
def g(z=z): #pass
|
||||
return z
|
||||
return g
|
||||
@@ -0,0 +1,8 @@
|
||||
def f(g):
|
||||
try:
|
||||
x = g()
|
||||
except Exception:
|
||||
x = g()
|
||||
finally:
|
||||
pass
|
||||
print(x) #pass
|
||||
@@ -0,0 +1,9 @@
|
||||
def f(g):
|
||||
x = 1
|
||||
try:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
x = g()
|
||||
print(x) #pass
|
||||
@@ -0,0 +1,6 @@
|
||||
def f():
|
||||
try:
|
||||
result = bool(2)
|
||||
finally:
|
||||
pass
|
||||
return result #pass
|
||||
@@ -0,0 +1,8 @@
|
||||
def f(c):
|
||||
for i in [1, 2, 3]:
|
||||
if c:
|
||||
x = 0
|
||||
break
|
||||
else:
|
||||
x = 1
|
||||
return x #pass
|
||||
@@ -0,0 +1,6 @@
|
||||
foo = True
|
||||
|
||||
|
||||
def bar():
|
||||
if foo: #pass
|
||||
print 1
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class C(object):
|
||||
pass
|
||||
|
||||
|
||||
class D(object):
|
||||
def f(self):
|
||||
def g(x):
|
||||
x = C()
|
||||
x.y = 1 #pass
|
||||
return x
|
||||
return g
|
||||
@@ -0,0 +1,5 @@
|
||||
x = 1
|
||||
|
||||
class C:
|
||||
def __init__(self):
|
||||
self.x = x #pass
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
def x(arg):
|
||||
def foo(): pass
|
||||
if arg: foo = None
|
||||
callee(foo) #pass
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
def g():
|
||||
pass
|
||||
|
||||
|
||||
class C:
|
||||
pass
|
||||
|
||||
|
||||
class D:
|
||||
def m(self):
|
||||
self.g = g() #pass
|
||||
self.C = C() #pass
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
def f(x):
|
||||
try:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
print(x) #pass
|
||||
@@ -0,0 +1,30 @@
|
||||
a = 1
|
||||
|
||||
def foo():
|
||||
print(<warning descr="Local variable 'a' might be referenced before assignment">a</warning>) #fail
|
||||
a = 21
|
||||
print(a) #pass
|
||||
|
||||
|
||||
foo()
|
||||
print(a)
|
||||
|
||||
if bla_bla(): #pass
|
||||
b = 1
|
||||
print(<warning descr="Name 'b' can be not defined">b</warning>) #fail
|
||||
print(b) #pass
|
||||
c = 1
|
||||
|
||||
def buzz():
|
||||
print(c) #pass
|
||||
|
||||
buzz()
|
||||
|
||||
print BLA_BLA_BLA #pass
|
||||
|
||||
if foo():
|
||||
d = 1
|
||||
else:
|
||||
d = 2
|
||||
|
||||
print(d) #pass
|
||||
@@ -0,0 +1,2 @@
|
||||
from re import *
|
||||
print(UNICODE)
|
||||
@@ -0,0 +1,3 @@
|
||||
def f():
|
||||
import sys
|
||||
sys.exit(1) #pass
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
def f(c):
|
||||
if c:
|
||||
x = 1
|
||||
<warning descr="Local variable 'x' might be referenced before assignment">x</warning> += 1 #fail
|
||||
return x
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
def f(c):
|
||||
if c:
|
||||
import sys
|
||||
return <warning descr="Local variable 'sys' might be referenced before assignment">sys</warning>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
def f(c, x):
|
||||
if c:
|
||||
from re import compile as g
|
||||
else:
|
||||
pass
|
||||
return <warning descr="Local variable 'g' might be referenced before assignment">g</warning>(x) #fail
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
def f(c, x):
|
||||
if c:
|
||||
import os.path
|
||||
else:
|
||||
pass
|
||||
return <warning descr="Local variable 'os' might be referenced before assignment">os</warning>.path.isfile(x) #fail
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
def a2():
|
||||
try:
|
||||
a = 2
|
||||
except Exception:
|
||||
pass
|
||||
print(<warning descr="Local variable 'a' might be referenced before assignment">a</warning>) #fail
|
||||
@@ -0,0 +1,6 @@
|
||||
def f():
|
||||
try:
|
||||
raise KeyError("ms")
|
||||
except KeyError as e:
|
||||
print(e) #pass
|
||||
print(<warning descr="Local variable 'e' might be referenced before assignment">e</warning>) #fail
|
||||
@@ -0,0 +1,3 @@
|
||||
for i, x in enumerate([]):
|
||||
print(i, x)
|
||||
print(<warning descr="Name 'i' can be not defined">i</warning>) # fail
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
def f(xs):
|
||||
# vs is unbound
|
||||
return [(k, v) for v in <warning descr="Local variable 'vs' might be referenced before assignment">vs</warning>
|
||||
for k, vs in xs.items()]
|
||||
@@ -0,0 +1,24 @@
|
||||
def f1():
|
||||
nonlocal <warning descr="Nonlocal variable 'x' must be bound in an outer function scope">x</warning> #fail
|
||||
|
||||
|
||||
def f2():
|
||||
def g():
|
||||
nonlocal <warning descr="Nonlocal variable 'x' must be bound in an outer function scope">x</warning> #fail
|
||||
print(x)
|
||||
|
||||
|
||||
x = 1
|
||||
|
||||
def f3():
|
||||
nonlocal <warning descr="Nonlocal variable 'x' must be bound in an outer function scope">x</warning> #fail
|
||||
x = 2
|
||||
|
||||
|
||||
def f4():
|
||||
x = 0
|
||||
def g():
|
||||
nonlocal x #pass
|
||||
x = 2
|
||||
return x
|
||||
return g()
|
||||
@@ -0,0 +1,7 @@
|
||||
def f():
|
||||
bytes, str = <warning descr="Local variable 'str' might be referenced before assignment">str</warning>, unicode #fail
|
||||
|
||||
class C(object):
|
||||
bytes, str = str, unicode #pass
|
||||
|
||||
bytes, str = str, unicode #pass
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
def f(g, h, x):
|
||||
if x > 1:
|
||||
z = g
|
||||
elif x:
|
||||
z = h
|
||||
# local z may be unbound, inspection fails only when z is in function call
|
||||
return <warning descr="Local variable 'z' might be referenced before assignment">z</warning>() #fail
|
||||
@@ -0,0 +1,7 @@
|
||||
def f(y, c, xs):
|
||||
if c:
|
||||
raise Exception()
|
||||
for x in xs:
|
||||
with y:
|
||||
pass
|
||||
print(x) #pass
|
||||
@@ -1,58 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>test.py</file>
|
||||
<line>4</line>
|
||||
<description>"Local variable 'a' might be referenced before assignment"</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.py</file>
|
||||
<line>14</line>
|
||||
<description>"Name 'b' can be not defined"</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.py</file>
|
||||
<line>51</line>
|
||||
<description>"Name 'i' can be not defined"</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.py</file>
|
||||
<line>77</line>
|
||||
<description>"Local variable 'z' might be referenced before assignment"</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.py</file>
|
||||
<line>83</line>
|
||||
<description>"Local variable 'vs' might be referenced before assignment"</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.py</file>
|
||||
<line>123</line>
|
||||
<description>"Local variable 'sys' might be referenced before assignment"</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.py</file>
|
||||
<line>132</line>
|
||||
<description>"Local variable 'g' might be referenced before assignment"</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.py</file>
|
||||
<line>141</line>
|
||||
<description>"Local variable 'os' might be referenced before assignment"</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.py</file>
|
||||
<line>148</line>
|
||||
<description>"Local variable 'x' might be referenced before assignment"</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.py</file>
|
||||
<line>192</line>
|
||||
<description>"Local variable 'a' might be referenced before assignment"</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.py</file>
|
||||
<line>220</line>
|
||||
<description>"Local variable 'str' might be referenced before assignment"</description>
|
||||
</problem>
|
||||
</problems>
|
||||
@@ -260,6 +260,10 @@ public class PyFormatterTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAlignInGenerators() { // PY-8822
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testContinuationIndentForCallInStatementPart() { // PY-8577
|
||||
doTest();
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ public class PythonAllTestsSuite {
|
||||
PyCompatibilityInspectionTest.class,
|
||||
PyUnresolvedReferencesInspectionTest.class,
|
||||
PyCallingNonCallableInspectionTest.class,
|
||||
PyUnboundLocalVariableInspectionTest.class,
|
||||
PyUnusedImportTest.class,
|
||||
PyDeprecationTest.class,
|
||||
PythonHighlightingLexerTest.class,
|
||||
|
||||
@@ -129,16 +129,6 @@ public class PythonInspectionsTest extends PyTestCase {
|
||||
doTestWithLanguageLevel(getTestName(false), inspection, LanguageLevel.PYTHON24);
|
||||
}
|
||||
|
||||
public void testPyUnboundLocalVariableInspection() {
|
||||
LocalInspectionTool inspection = new PyUnboundLocalVariableInspection();
|
||||
doTestWithLanguageLevel(getTestName(false), inspection, LanguageLevel.PYTHON27);
|
||||
}
|
||||
|
||||
public void testPyUnboundLocalVariableInspectionPy3k() {
|
||||
LocalInspectionTool inspection = new PyUnboundLocalVariableInspection();
|
||||
doTestWithPy3k(getTestName(false), inspection);
|
||||
}
|
||||
|
||||
public void testPyDocstringInspection() {
|
||||
LocalInspectionTool inspection = new PyDocstringInspection();
|
||||
doTest(getTestName(false), inspection);
|
||||
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
package com.jetbrains.python.inspections;
|
||||
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class PyUnboundLocalVariableInspectionTest extends PyTestCase {
|
||||
private static final String TEST_DIRECTORY = "inspections/PyUnboundLocalVariableInspection/";
|
||||
|
||||
public void testSimple() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-1138
|
||||
public void testControlFlowInAssert() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-1176
|
||||
public void testLocalFunctionAndVariable() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-1359
|
||||
public void testUnboundLoopVariable() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-1408
|
||||
public void testUnboundExceptAs() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON33, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doTest();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// PY-1434
|
||||
public void testClassLevelSameName() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-1435
|
||||
public void testInstanceFieldAndGlobal() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-3343
|
||||
public void testUnboundVariableFunctionCall() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-3407
|
||||
public void testUnboundNestedComprehension() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-3503
|
||||
public void testControlFlowInTryExceptFinally() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-3550
|
||||
public void testDefaultArgument() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-3583
|
||||
public void testUnboundConditionalImport() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-3603
|
||||
public void testUnboundNonLocal() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON33, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doTest();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// PY-3671
|
||||
public void testUnboundConditionalImportAlias() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-3665
|
||||
public void testUnboundConditionalImportQualified() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-3651
|
||||
public void testUnboundAugmentedAssignment() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-3702
|
||||
public void testSysExit() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-3895
|
||||
public void testDecoratorAndParameter() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-4102
|
||||
public void testDefinedInTryUsedAfter() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-4150
|
||||
public void testParamAfterTryExcept() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-4151
|
||||
public void testUnboundDefinedInTryUsedAfterExcept() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-4152
|
||||
public void testDefinedInTryAndExcept() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-4157
|
||||
public void testDefinedInTryElse() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-4197
|
||||
public void testUnboundSwapStrUnicode() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-4229
|
||||
public void testInstanceAttributeOutsideClass() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-4297
|
||||
public void testOuterFunctionsAndSelfAttributes() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-4623
|
||||
public void testBuiltinAndSelfAttribute() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-4609
|
||||
public void testImplicitIfNotNone() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-4239
|
||||
public void testForBreakElse() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-5592
|
||||
public void testStarImportTopLevel() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-7966
|
||||
public void testUseAfterWithAndRaise() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile(TEST_DIRECTORY + getTestName(false) + ".py");
|
||||
myFixture.enableInspections(PyUnboundLocalVariableInspection.class);
|
||||
myFixture.checkHighlighting(true, false, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user