Merge remote branch 'origin/master'

This commit is contained in:
Ekaterina Tuzova
2011-06-01 10:47:24 +04:00
12 changed files with 72 additions and 25 deletions
+2 -2
View File
@@ -146,8 +146,8 @@ def restore_pm_excepthook():
def update_exception_hook(dbg):
if len(dbg.exception_set) >0:
set_pm_excepthook(tuple(dbg.exception_set))
if dbg.exception_set:
set_pm_excepthook(dict(dbg.exception_set))
else:
restore_pm_excepthook()
+16 -6
View File
@@ -775,10 +775,17 @@ class InternalGetCompletions(InternalThreadCommand):
try:
import console._completer
except:
path = os.environ['PYDEV_COMPLETER_PYTHONPATH']
try:
path = os.environ['PYDEV_COMPLETER_PYTHONPATH']
except :
path = os.path.dirname(__file__)
print (path)
sys.path.append(path)
remove_path = path
import console._completer
try:
import console._completer
except :
pass
try:
@@ -790,10 +797,13 @@ class InternalGetCompletions(InternalThreadCommand):
updated_globals = {}
updated_globals.update(frame.f_globals)
updated_globals.update(frame.f_locals) #locals later because it has precedence over the actual globals
completer = console._completer.Completer(updated_globals, None)
#list(tuple(name, descr, parameters, type))
completions = completer.complete(self.act_tok)
try:
completer = console._completer.Completer(updated_globals, None)
#list(tuple(name, descr, parameters, type))
completions = completer.complete(self.act_tok)
except :
completions = []
def makeValid(s):
+10 -7
View File
@@ -40,13 +40,16 @@ class PyDBFrame:
can_skip = False
#if not len(mainDebugger.always_exception_set):
# if info.pydev_state == STATE_RUN:
# #we can skip if:
# #- we have no stop marked
# #- we should make a step return/step over and we're not in the current frame
# can_skip = (info.pydev_step_cmd is None and info.pydev_step_stop is None)\
# or (info.pydev_step_cmd in (CMD_STEP_RETURN, CMD_STEP_OVER) and info.pydev_step_stop is not frame)
if info.pydev_state == STATE_RUN:
#we can skip if:
#- we have no stop marked
#- we should make a step return/step over and we're not in the current frame
can_skip = (info.pydev_step_cmd is None and info.pydev_step_stop is None)\
or (info.pydev_step_cmd in (CMD_STEP_RETURN, CMD_STEP_OVER) and info.pydev_step_stop is not frame)
if mainDebugger.always_exception_set:
can_skip = False
if mainDebugger.django_breakpoints:
can_skip = False
-1
View File
@@ -5,7 +5,6 @@ import pickle
from django_frame import DjangoTemplateFrame
from pydevd_constants import * #@UnusedWildImport
from types import * #@UnusedWildImport
from console import pydevconsole
from code import compile_command
from code import InteractiveInterpreter
@@ -1,5 +1,6 @@
package com.jetbrains.python.codeInsight.imports;
import com.intellij.codeInsight.intention.HighPriorityAction;
import com.intellij.codeInspection.HintAction;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
@@ -12,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
/**
* @author yole
*/
public class AutoImportHintAction implements LocalQuickFix, HintAction {
public class AutoImportHintAction implements LocalQuickFix, HintAction, HighPriorityAction {
private final AutoImportQuickFix myDelegate;
public AutoImportHintAction(AutoImportQuickFix delegate) {
@@ -3,6 +3,7 @@ package com.jetbrains.python.codeInsight.imports;
import com.intellij.codeInsight.CodeInsightUtilBase;
import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass;
import com.intellij.codeInsight.hint.HintManager;
import com.intellij.codeInsight.intention.HighPriorityAction;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.editor.Editor;
@@ -32,7 +33,7 @@ import java.util.List;
*
* @author dcheryasov
*/
public class AutoImportQuickFix implements LocalQuickFix {
public class AutoImportQuickFix implements LocalQuickFix, HighPriorityAction {
private final PyElement myNode;
private final PsiReference myReference;
@@ -241,7 +241,7 @@ public class PyCallExpressionHelper {
}
private static boolean isQualifiedByInstance(Callable resolved, List<PyExpression> qualifiers, TypeEvalContext context) {
PyDocStringOwner owner = PsiTreeUtil.getParentOfType(resolved, PyDocStringOwner.class);
PyDocStringOwner owner = PsiTreeUtil.getStubOrPsiParentOfType(resolved, PyDocStringOwner.class);
if (!(owner instanceof PyClass)) {
return false;
}
@@ -358,19 +358,20 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
VariantsProcessor processor = new VariantsProcessor(this);
final List<String> dunderAll = getDunderAll();
processor.setAllowedNames(dunderAll);
final List<String> remainingDunderAll = dunderAll == null ? null : new ArrayList<String>(dunderAll);
processDeclarations(processor, ResolveState.initial(), null, this);
List<PyElement> result = new ArrayList<PyElement>();
for (LookupElement lookupElement : processor.getResultList()) {
final Object value = lookupElement.getObject();
if (value instanceof PyElement) {
result.add((PyElement) value);
if (dunderAll != null) {
dunderAll.remove(lookupElement.getLookupString());
if (remainingDunderAll != null) {
remainingDunderAll.remove(lookupElement.getLookupString());
}
}
}
if (dunderAll != null) {
for (String s: dunderAll) {
if (remainingDunderAll != null) {
for (String s: remainingDunderAll) {
result.add(new LightNamedElement(myManager, PythonLanguage.getInstance(), s));
}
}
@@ -428,7 +429,8 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
return ((PyFileStub) stubElement).getDunderAll();
}
if (!myDunderAllCalculated) {
myDunderAll = calculateDunderAll();
final List<String> dunderAll = calculateDunderAll();
myDunderAll = dunderAll == null ? null : Collections.unmodifiableList(dunderAll);
myDunderAllCalculated = true;
}
return myDunderAll;
@@ -283,4 +283,19 @@ public class PyPsiUtils {
}
return element;
}
public static int findArgumentIndex(PyCallExpression call, PsiElement argument) {
final PyExpression[] args = call.getArguments();
for (int i = 0; i < args.length; i++) {
PyExpression expression = args[i];
if (expression instanceof PyKeywordArgumentImpl) {
expression = ((PyKeywordArgumentImpl)expression).getValueExpression();
}
expression = PyUtil.flattenParens(expression);
if (expression == argument) {
return i;
}
}
return -1;
}
}
@@ -25,6 +25,7 @@ import com.jetbrains.python.codeInsight.dataflow.scope.Scope;
import com.jetbrains.python.codeInsight.dataflow.scope.ScopeUtil;
import com.jetbrains.python.documentation.StructuredDocString;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.psi.impl.stubs.CustomTargetExpressionStub;
import com.jetbrains.python.psi.resolve.PyResolveContext;
import com.jetbrains.python.psi.stubs.PyTargetExpressionStub;
import com.jetbrains.python.psi.types.*;
@@ -317,9 +318,13 @@ public class PyTargetExpressionImpl extends PyPresentableElementImpl<PyTargetExp
public PyQualifiedName getCalleeName() {
final PyTargetExpressionStub stub = getStub();
if (stub != null) {
if (stub.getInitializerType() == PyTargetExpressionStub.InitializerType.CallExpression) {
final PyTargetExpressionStub.InitializerType initializerType = stub.getInitializerType();
if (initializerType == PyTargetExpressionStub.InitializerType.CallExpression) {
return stub.getInitializer();
}
else if (initializerType == PyTargetExpressionStub.InitializerType.Custom) {
return stub.getCustomStub(CustomTargetExpressionStub.class).getCalleeName();
}
return null;
}
final PyExpression value = findAssignedValue();
@@ -1,7 +1,9 @@
package com.jetbrains.python.psi.impl.stubs;
import com.intellij.psi.stubs.StubOutputStream;
import com.jetbrains.python.psi.impl.PyQualifiedName;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
@@ -12,4 +14,7 @@ public interface CustomTargetExpressionStub {
@NotNull
Class<? extends CustomTargetExpressionStubType> getTypeClass();
void serialize(StubOutputStream stream) throws IOException;
@Nullable
PyQualifiedName getCalleeName();
}
@@ -6,6 +6,7 @@ import com.intellij.util.io.StringRef;
import com.jetbrains.python.psi.PyExpression;
import com.jetbrains.python.psi.PyReferenceExpression;
import com.jetbrains.python.psi.impl.PropertyBunch;
import com.jetbrains.python.psi.impl.PyQualifiedName;
import com.jetbrains.python.psi.impl.stubs.CustomTargetExpressionStub;
import com.jetbrains.python.psi.impl.stubs.CustomTargetExpressionStubType;
import com.jetbrains.python.psi.impl.stubs.PropertyStubType;
@@ -71,6 +72,11 @@ public class PropertyStubStorage extends PropertyBunch<String> implements Custom
stream.writeName(myDoc);
}
@Override
public PyQualifiedName getCalleeName() {
return null; // ??
}
public static PropertyStubStorage deserialize(StubInputStream stream) throws IOException {
PropertyStubStorage me = new PropertyStubStorage();
me.myGetter = readOne(stream);