Merge branch 'master' of git.labs.intellij.net:idea/ultimate

This commit is contained in:
Dmitry Cheryasov
2010-11-28 20:27:19 +02:00
34 changed files with 344 additions and 32 deletions
+10 -1
View File
@@ -346,6 +346,7 @@ class PyDB:
self.processThreadNotAlive(tId)
except:
sys.stderr.write('Error iterating through %s (%s) - %s\n' % (foundThreads, foundThreads.__class__, dir(foundThreads)))
sys.stderr.flush()
raise
finally:
@@ -457,9 +458,11 @@ class PyDB:
if not DictContains(sys.modules, module_name):
sys.stderr.write('pydev debugger: Unable to find module to reload: "'+module_name+'".\n')
sys.stderr.write('pydev debugger: This usually means you are trying to reload the __main__ module (which cannot be reloaded).\n')
sys.stderr.flush()
else:
sys.stderr.write('pydev debugger: Reloading: '+module_name+'\n')
sys.stderr.flush()
xreload(sys.modules[module_name])
@@ -536,11 +539,13 @@ class PyDB:
if not os.path.exists(file):
sys.stderr.write('pydev debugger: warning: trying to add breakpoint'\
' to file that does not exist: %s (will have no effect)\n' % (file,))
sys.stderr.flush()
line = int(line)
if DEBUG_TRACE_BREAKPOINTS > 0:
sys.stderr.write('Added breakpoint:%s - line:%s - func_name:%s\n' % (file, line, func_name))
sys.stderr.flush()
if DictContains(self.breakpoints, file):
breakDict = self.breakpoints[file]
@@ -575,11 +580,13 @@ class PyDB:
del self.breakpoints[file][line] #remove the breakpoint in that line
if DEBUG_TRACE_BREAKPOINTS > 0:
sys.stderr.write('Removed breakpoint:%s\n' % (file,))
sys.stderr.flush()
except KeyError:
#ok, it's not there...
if DEBUG_TRACE_BREAKPOINTS > 0:
#Sometimes, when adding a breakpoint, it adds a remove command before (don't really know why)
sys.stderr.write("breakpoint not found: %s - %s\n" % (file, line))
sys.stderr.flush()
elif cmd_id == CMD_EVALUATE_EXPRESSION or cmd_id == CMD_EXEC_EXPRESSION:
#command to evaluate the given expression
@@ -823,8 +830,9 @@ class PyDB:
if hasattr(sys, 'exc_clear'): #jython does not have it
sys.exc_clear() #don't keep the traceback (let's keep it clear for when we go to the point of executing client code)
if not sys.platform.startswith("java") and not sys.platform.startswith("cli"):
if not IS_PY3K and not sys.platform.startswith("java") and not sys.platform.startswith("cli"):
sys.stderr.write("pydev debugger: warning: psyco not available for speedups (the debugger will still work correctly, but a bit slower)\n")
sys.stderr.flush()
def run(self, file, globals=None, locals=None):
@@ -1087,6 +1095,7 @@ def settrace(host='localhost', stdoutToServer=False, stderrToServer=False, port=
if __name__ == '__main__':
sys.stderr.write("pydev debugger: starting\n")
sys.stderr.flush()
# parse the command line. --file is our last argument that is required
try:
setup = processCommandLine(sys.argv)
+5 -1
View File
@@ -1,3 +1,4 @@
from pydevd_constants import *
import sys
_original_excepthook = None
@@ -110,7 +111,10 @@ def get_class( kls ):
parts = kls.split('.')
module = ".".join(parts[:-1])
if (module == ""):
module = "__builtin__"
if IS_PY3K:
module = "builtins"
else:
module = "__builtin__"
m = __import__( module )
for comp in parts[-1:]:
m = getattr(m, comp)
+6 -1
View File
@@ -349,6 +349,7 @@ def StartClient(host, port):
return s
except:
sys.stderr.write("Could not connect to %s: %s\n" % (host, port))
sys.stderr.flush()
traceback.print_exc()
sys.exit(1)
@@ -408,7 +409,7 @@ class NetCommandFactory:
cmd = NetCommand(CMD_ERROR, seq, text)
if DEBUG_TRACE_LEVEL > 2:
sys.stderr.write("Error: %s" % (text,))
return cmd;
return cmd
def makeThreadCreatedMessage(self, thread):
cmdText = "<xml>" + self.threadToXML(thread) + "</xml>"
@@ -728,6 +729,9 @@ class InternalConsoleExec(InternalThreadCommand):
sys.stderr.write('%s\n' % (exc,))
cmd = dbg.cmdFactory.makeErrorMessage(self.sequence, "Error evaluating console expression " + exc)
dbg.writer.addCommand(cmd)
finally:
sys.stderr.flush()
sys.stdout.flush()
#=======================================================================================================================
# InternalGetCompletions
@@ -806,6 +810,7 @@ def PydevdFindThreadById(thread_id):
sys.stderr.write("Could not find thread %s\n" % thread_id)
sys.stderr.write("Available: %s\n" % [GetThreadId(t) for t in threads])
sys.stderr.flush()
except:
traceback.print_exc()
@@ -100,6 +100,7 @@ try:
sys.stderr.write('pydev debugger: The debugger may still function, but it will work slower and may miss breakpoints.\n')
sys.stderr.write('pydev debugger: Related bug: http://bugs.python.org/issue1666807\n')
sys.stderr.write('-------------------------------------------------------------------------------\n')
sys.stderr.flush()
NORM_SEARCH_CACHE = {}
+1
View File
@@ -109,6 +109,7 @@ class PyDBFrame:
except:
sys.stderr.write('Error while evaluating expression\n')
traceback.print_exc()
sys.stderr.flush()
return self.trace_dispatch
expression = breakpoint[line][3]
+1
View File
@@ -58,6 +58,7 @@ def _InternalSetTrace(tracing_func):
#only warn about each message once...
TracingFunctionHolder._warnings_shown[message] = 1
sys.stderr.write('%s\n' % (message,))
sys.stderr.flush()
TracingFunctionHolder._original_tracing(tracing_func)
+1
View File
@@ -227,6 +227,7 @@ def frameVarsToXML(frame):
except Exception:
traceback.print_exc()
sys.stderr.write("Unexpected error, recovered safely.\n")
sys.stderr.flush()
return xml
def iterFrames(initialFrame):
@@ -86,7 +86,7 @@ public class PyDebugValue extends XValue {
result.append('[').append(removeId(myName)).append(']');
}
else if (("set".equals(myParent.getType())) && !isLen(myName)) {
result.append("[").append(myName).append("]");
//set doesn't support indexing
}
else if (isLen(myName)) {
result.append('.').append(myName).append("()");
@@ -3,7 +3,7 @@ package com.jetbrains.python.debugger.pydev;
public abstract class AbstractFrameCommand extends AbstractThreadCommand {
protected final String myFrameId;
private final String myFrameId;
protected AbstractFrameCommand(final RemoteDebugger debugger, final int commandCode, final String threadId, final String frameId) {
super(debugger, commandCode, threadId);
@@ -2,7 +2,7 @@ package com.jetbrains.python.debugger.pydev;
public abstract class AbstractThreadCommand extends AbstractCommand {
protected final String myThreadId;
private final String myThreadId;
protected AbstractThreadCommand(final RemoteDebugger debugger, final int commandCode, final String threadId) {
super(debugger, commandCode);
@@ -21,4 +21,8 @@ public abstract class AbstractThreadCommand extends AbstractCommand {
command == SUSPEND_THREAD;
}
public String getThreadId() {
return myThreadId;
}
}
@@ -16,7 +16,7 @@ public class ConsoleExecCommand extends AbstractFrameCommand {
@Override
protected void buildPayload(Payload payload) {
super.buildPayload(payload);
payload.add(myThreadId).add(myFrameId).add("FRAME").add(myExpression);
payload.add("FRAME").add(myExpression);
}
@Override
@@ -16,8 +16,4 @@ public class ResumeCommand extends AbstractThreadCommand {
public ResumeCommand(final RemoteDebugger debugger, final String threadId, final Mode mode) {
super(debugger, mode.code, threadId);
}
public String getThreadId() {
return myThreadId;
}
}
+6 -1
View File
@@ -148,6 +148,11 @@
<category>Python</category>
</intentionAction>
<intentionAction>
<className>com.jetbrains.python.codeInsight.intentions.PyConvertLambdaToFunctionIntention</className>
<category>Python</category>
</intentionAction>
<stubElementTypeHolder class="com.jetbrains.python.PyElementTypes"/>
<inspectionToolProvider implementation="com.jetbrains.python.inspections.PythonInspectionToolProvider"/>
@@ -306,7 +311,7 @@
<renamePsiElementProcessor implementation="com.jetbrains.django.refactoring.RenameDjangoParameterProcessor"/>
<elementDescriptionProvider implementation="com.jetbrains.django.refactoring.DjangoElementDescriptionProvider"/>
<completion.contributor language="Python" implementationClass="com.jetbrains.django.lang.template.DjangoUrlsCompletionContributor"/>
<completion.contributor language="Python" implementationClass="com.jetbrains.django.completion.DjangoUrlsCompletionContributor"/>
<liveTemplatePreprocessor implementation="com.jetbrains.django.lang.template.DjangoTemplatePreprocessor"/>
@@ -59,6 +59,12 @@ QFIX.statement.effect.introduce.variable=Introduce variable
QFIX.unresolved.reference=Reference can be resolved added self
QFIX.unresolved.reference.create.function=Create function for reference
QFIX.introduce.variable=Introduce variable for statement
QFIX.unresolved.reference.add.future=Add 'from __future__ import with_statement''
# Intentions: INTN
INTN.Family.convert.import.unqualify=Convert 'import module' to 'from module import'
INTN.Family.convert.import.qualify=Convert 'from module import' to 'import module'
@@ -130,7 +136,9 @@ INTN.convert.dict.literal.to.dict.constructor=Convert dict literal to dict const
INTN.quoted.string=Convert between single-quoted and double-quoted strings
INTN.quoted.string.single.to.double=Convert single-quoted string to double-quoted string
INTN.quoted.string.double.to.single=Convert double-quoted string to sungle-quoted string
INTN.quoted.string.double.to.single=Convert double-quoted string to single-quoted string
INTN.convert.lambda.to.function=Convert lambda to function
# Conflict checker
CONFLICT.name.$0.obscured=Name ''{0}'' obscured by local definitions
@@ -17,9 +17,9 @@ import org.jetbrains.annotations.NotNull;
*
* QuickFix to replace statement that has no effect with function call
*/
public class StatementEffectQuickFix implements LocalQuickFix {
public class StatementEffectFunctionCallQuickFix implements LocalQuickFix {
public StatementEffectQuickFix() {
public StatementEffectFunctionCallQuickFix() {
}
@NotNull
@@ -0,0 +1,52 @@
package com.jetbrains.python.actions;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.psi.PsiElement;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.psi.*;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/**
* User: catherine
*
* Quickfix to introduce variable if statement seems to have no effect
*/
public class StatementEffectIntroduceVariableQuickFix implements LocalQuickFix {
PyExpression myExpression;
public StatementEffectIntroduceVariableQuickFix(PyExpression expression) {
myExpression = expression;
}
@NotNull
public String getName() {
return PyBundle.message("QFIX.introduce.variable");
}
@NonNls
@NotNull
public String getFamilyName() {
return PyBundle.message("INSP.GROUP.python");
}
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
String name = "var";
if (myExpression != null) {
Application application = ApplicationManager.getApplication();
if (application != null && !application.isUnitTestMode()) {
name = Messages.showInputDialog(project, "Enter new variable name",
"New variable name", Messages.getQuestionIcon());
if (name == null) return;
}
if (name.isEmpty()) return;
PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project);
myExpression.replace(elementGenerator.createFromText(LanguageLevel.forElement(myExpression), PyAssignmentStatement.class,
name + " = " + myExpression.getText()));
}
}
}
@@ -0,0 +1,40 @@
package com.jetbrains.python.actions;
import com.intellij.codeInsight.CodeInsightUtilBase;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.psi.*;
import org.jetbrains.annotations.NotNull;
/**
* User: catherine
*
* QuickFix to add 'from __future__ import with_statement'' if python version is less than 2.6
*/
public class UnresolvedRefAddFutureImportQuickFix implements LocalQuickFix {
private PyReferenceExpression myElement;
public UnresolvedRefAddFutureImportQuickFix(PyReferenceExpression element) {
myElement = element;
}
@NotNull
public String getName() {
return PyBundle.message("QFIX.unresolved.reference.add.future");
}
@NotNull
public String getFamilyName() {
return PyBundle.message("INSP.GROUP.python");
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
PyFile file = (PyFile)myElement.getContainingFile();
if (!CodeInsightUtilBase.prepareFileForWrite(file)) return;
PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project);
PyFromImportStatement statement = elementGenerator.createFromText(LanguageLevel.forElement(myElement), PyFromImportStatement.class,
"from __future__ import with_statement");
file.addBefore(statement, file.getStatements().get(0));
}
}
@@ -0,0 +1,48 @@
package com.jetbrains.python.actions;
import com.intellij.codeInsight.CodeInsightUtilBase;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.psi.*;
import org.jetbrains.annotations.NotNull;
/**
* User: catherine
*
* QuickFix to create function to unresolved unqualified reference
*/
public class UnresolvedRefCreateFunctionQuickFix implements LocalQuickFix {
private PyReferenceExpression myElement;
public UnresolvedRefCreateFunctionQuickFix(PyReferenceExpression element) {
myElement = element;
}
@NotNull
public String getName() {
return PyBundle.message("QFIX.unresolved.reference.create.function");
}
@NotNull
public String getFamilyName() {
return PyBundle.message("INSP.GROUP.python");
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
if (!CodeInsightUtilBase.preparePsiElementForWrite(myElement)) return;
PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project);
PyFunction function = elementGenerator.createFromText(LanguageLevel.forElement(myElement), PyFunction.class,
"def " + myElement.getText() + "():\n pass");
PyStatement statement = PsiTreeUtil.getParentOfType(myElement, PyStatement.class);
if (statement != null) {
PsiElement parent = statement.getParent();
if (parent != null)
parent.addBefore(function, statement);
}
}
}
@@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
/**
* User: catherine
*
* QuickFix to remove redundant parentheses from if/while/except statement
* QuickFix to add self to unresolved reference
*/
public class UnresolvedReferenceAddSelfQuickFix implements LocalQuickFix {
private PyReferenceExpression myElement;
@@ -33,9 +33,8 @@ public class UnresolvedReferenceAddSelfQuickFix implements LocalQuickFix {
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
if (!CodeInsightUtilBase.preparePsiElementForWrite(myElement)) return;
PyReferenceExpression ref = myElement;
PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project);
PyExpression expression = elementGenerator.createExpressionFromText("self." + ref.getText());
PyExpression expression = elementGenerator.createExpressionFromText("self." + myElement.getText());
myElement.replace(expression);
}
}
@@ -0,0 +1,95 @@
package com.jetbrains.python.codeInsight.intentions;
import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.psi.*;
import org.jetbrains.annotations.NotNull;
/**
* User: catherine
* Intention to convert lambda to function
*/
public class PyConvertLambdaToFunctionIntention extends BaseIntentionAction {
@NotNull
public String getFamilyName() {
return PyBundle.message("INTN.convert.lambda.to.function");
}
@NotNull
public String getText() {
return PyBundle.message("INTN.convert.lambda.to.function");
}
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
PyLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyLambdaExpression.class);
if (lambdaExpression != null) {
if (lambdaExpression.getBody() != null)
return true;
}
return false;
}
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
PyLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyLambdaExpression.class);
PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project);
if (lambdaExpression != null) {
String name = "function";
PsiElement parent = lambdaExpression.getParent();
if (parent instanceof PyAssignmentStatement) {
name = ((PyAssignmentStatement)parent).getLeftHandSideExpression().getText();
}
else {
Application application = ApplicationManager.getApplication();
if (application != null && !application.isUnitTestMode()) {
name = Messages.showInputDialog(project, "Enter new function name",
"New function name", Messages.getQuestionIcon());
if (name == null) return;
}
}
if (name.isEmpty()) return;
PyExpression body = lambdaExpression.getBody();
PyParameter[] parameters = lambdaExpression.getParameterList().getParameters();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("def ");
stringBuilder.append(name);
stringBuilder.append("(");
int size = parameters.length;
for (int i = 0; i != size; ++i) {
PyParameter parameter = parameters[i];
stringBuilder.append(parameter.getName());
if ( i != size - 1)
stringBuilder.append(",");
}
stringBuilder.append("):\n return ");
stringBuilder.append(body.getText());
PyFunction function = elementGenerator.createFromText(LanguageLevel.forElement(lambdaExpression),
PyFunction.class, stringBuilder.toString());
PyStatement statement = PsiTreeUtil.getParentOfType(lambdaExpression, PyStatement.class);
if (statement != null) {
PsiElement parentOfStatement = statement.getParent();
if (parentOfStatement != null)
parentOfStatement.addBefore(function, statement);
}
if (parent instanceof PyAssignmentStatement) {
parent.delete();
}
else {
lambdaExpression.replace(elementGenerator.createFromText(LanguageLevel.forElement(lambdaExpression), PyExpression.class,
name));
}
}
}
}
@@ -2,12 +2,12 @@ package com.jetbrains.python.inspections;
import com.intellij.codeInspection.LocalInspectionToolSession;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.ResolveResult;
import com.intellij.psi.util.PsiTreeUtil;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.actions.StatementEffectQuickFix;
import com.jetbrains.python.actions.StatementEffectFunctionCallQuickFix;
import com.jetbrains.python.actions.StatementEffectIntroduceVariableQuickFix;
import com.jetbrains.python.console.PydevConsoleRunner;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.psi.resolve.PyResolveContext;
@@ -16,8 +16,6 @@ import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.sql.Statement;
/**
* @author Alexey.Ivanov
*/
@@ -64,7 +62,7 @@ public class PyStatementEffectInspection extends PyInspection {
return;
}
}
registerProblem(expression, "Statement seems to have no effect");
registerProblem(expression, "Statement seems to have no effect", new StatementEffectIntroduceVariableQuickFix(expression));
}
private boolean hasEffect(@Nullable PyExpression expression) {
@@ -125,7 +123,7 @@ public class PyStatementEffectInspection extends PyInspection {
ResolveResult[] results = referenceExpression.getReference().multiResolve(true);
for (ResolveResult res : results) {
if (res.getElement() instanceof PyFunction) {
registerProblem(expression, "Statement seems to have no effect and can be replaced with function call to have effect", new StatementEffectQuickFix());
registerProblem(expression, "Statement seems to have no effect and can be replaced with function call to have effect", new StatementEffectFunctionCallQuickFix());
return true;
}
}
@@ -133,7 +133,7 @@ public class PyUnresolvedReferencesInspection extends PyInspection {
super.visitPyStarImportElement(node);
myAllImports.add(node);
}
@Override
public void visitPyElement(final PyElement node) {
super.visitPyElement(node);
@@ -191,6 +191,11 @@ public class PyUnresolvedReferencesInspection extends PyInspection {
}
else {
if (LanguageLevel.forElement(node).isOlderThan(LanguageLevel.PYTHON26)) {
if (refname.equals("with")) {
actions.add(new UnresolvedRefAddFutureImportQuickFix(refex));
}
}
PyClass containedClass = PsiTreeUtil.getParentOfType(node, PyClass.class);
if (containedClass != null) {
for (PyTargetExpression target : containedClass.getInstanceAttributes()) {
@@ -199,6 +204,7 @@ public class PyUnresolvedReferencesInspection extends PyInspection {
}
}
}
actions.add(new UnresolvedRefCreateFunctionQuickFix(refex));
}
// unqualified:
// may be module's
@@ -373,7 +373,7 @@ public class PythonSdkType extends SdkType {
public static VirtualFile findSkeletonsDir(Sdk sdk) {
final VirtualFile[] virtualFiles = sdk.getRootProvider().getFiles(BUILTIN_ROOT_TYPE);
for (VirtualFile virtualFile : virtualFiles) {
if (virtualFile.getPath().contains(SKELETON_DIR_NAME)) {
if (virtualFile.isValid() && virtualFile.getPath().contains(SKELETON_DIR_NAME)) {
return virtualFile;
}
}
@@ -156,13 +156,11 @@ public class PythonDocTestConfigurationProducer extends RuntimeConfigurationProd
@Nullable
private RunnerAndConfigurationSettings createConfigurationFromFile(Location location, PsiElement element) {
PsiElement file = element.getContainingFile();
if (file == null) return null;
if (file == null || !(file instanceof PyFile)) return null;
if (file instanceof PyFile) {
final PyFile pyFile = (PyFile)file;
final List<PyElement> testCases = PythonDocTestUtil.getDocTestCasesFromFile(pyFile);
if (testCases.isEmpty()) return null;
}
final PyFile pyFile = (PyFile)file;
final List<PyElement> testCases = PythonDocTestUtil.getDocTestCasesFromFile(pyFile);
if (testCases.isEmpty()) return null;
final RunnerAndConfigurationSettings settings = makeConfigurationSettings(location, "doc tests from file");
final PythonDocTestRunConfiguration configuration = (PythonDocTestRunConfiguration)settings.getConfiguration();
@@ -0,0 +1 @@
<warning descr="Statement seems to have no effect">a<caret>+ b</warning>
@@ -0,0 +1 @@
var = a + b
@@ -0,0 +1 @@
<warning descr="Unresolved reference 'ref'">ref</warning>
@@ -0,0 +1,4 @@
def ref():
pass
ref
@@ -0,0 +1,2 @@
<warning descr="Unresolved reference 'with'">with</warning><error descr="end of statement expected"> </error>open("x.txt")<error descr="end of statement expected"> </error><warning descr="Unresolved reference 'as'">as</warning><error descr="end of statement expected"> </error><warning descr="Unresolved reference 'f'">f</warning><error descr="end of statement expected">:</error><EOLError descr="statement expected, found Py:COLON"></EOLError>
<error descr="statement expected, found Py:INDENT">d</error>ata = <warning descr="Unresolved reference 'f'">f</warning>.read()
@@ -0,0 +1,4 @@
from __future__ import with_statement
with open("x.txt") as f:
data = f.read()
@@ -0,0 +1,6 @@
def func(seq):
def function(x, y):
return (x + y) / y
newlist = reduce(function
, seq)
@@ -0,0 +1,2 @@
def func(seq):
newlist = reduce(lambda x<caret>, y: (x+y)/y, seq)
@@ -124,4 +124,8 @@ public class PyIntentionTest extends PyLightFixtureTestCase {
public void testQuotedString() {
doTest(PyBundle.message("INTN.quoted.string.double.to.single"));
}
public void testConvertLambdaToFunction() {
doTest(PyBundle.message("INTN.convert.lambda.to.function"));
}
}
@@ -6,6 +6,7 @@ import com.intellij.testFramework.TestDataPath;
import com.jetbrains.python.codeInsight.PyCodeInsightSettings;
import com.jetbrains.python.fixtures.PyLightFixtureTestCase;
import com.jetbrains.python.inspections.*;
import com.jetbrains.python.psi.LanguageLevel;
import org.jetbrains.annotations.NonNls;
/**
@@ -188,6 +189,21 @@ public class PyQuickFixTest extends PyLightFixtureTestCase {
PyBundle.message("QFIX.statement.effect"), true, true);
}
public void testStatementEffectIntroduceVariable() { // PY-1265
doInspectionTest("StatementEffectIntroduceVariable.py", PyStatementEffectInspection.class,
PyBundle.message("QFIX.statement.effect.introduce.variable"), true, true);
}
public void testUnresolvedWith() { // PY-2083
setLanguageLevel(LanguageLevel.PYTHON25);
doInspectionTest("UnresolvedWith.py", PyUnresolvedReferencesInspection.class,
PyBundle.message("QFIX.unresolved.reference.add.future"), true, true);
}
public void testUnresolvedRefCreateFunction() { // PY-2092
doInspectionTest("UnresolvedRefCreateFunction.py", PyUnresolvedReferencesInspection.class,
PyBundle.message("QFIX.unresolved.reference.create.function"), true, true);
}
@Override
@NonNls
protected String getTestDataPath() {