From 990006bea2fc2bca688a87df327a5e9eebccbd64 Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Wed, 8 May 2013 18:46:27 +0400 Subject: [PATCH] Fast stub only TypeEvalContext for checking intentions availability and for resolve --- .../codeInsight/intentions/ImportFromToImportIntention.java | 6 ++++-- .../intentions/PyDictConstructorToLiteralFormIntention.java | 2 +- .../jetbrains/python/psi/impl/CallArgumentsMappingImpl.java | 2 +- .../com/jetbrains/python/psi/resolve/ResolveImportUtil.java | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/ImportFromToImportIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/ImportFromToImportIntention.java index 509513ff32cc..b8de041f6085 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/ImportFromToImportIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/ImportFromToImportIntention.java @@ -145,10 +145,12 @@ public class ImportFromToImportIntention implements IntentionAction { PyReferenceExpression ref = import_element.getImportReferenceExpression(); if (ref != null && ref.isValid()) { PsiElement target = ref.getReference().resolve(); - if (target instanceof PyExpression && TypeEvalContext.fast().getType((PyExpression)target) instanceof PyModuleType) return false; + final TypeEvalContext context = TypeEvalContext.fastStubOnly(file); + if (target instanceof PyExpression && context.getType((PyExpression)target) instanceof PyModuleType) { + return false; + } } } - } } if (info.myModuleReference != null) { diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyDictConstructorToLiteralFormIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyDictConstructorToLiteralFormIntention.java index c25580b1fd8d..4b6f460b179c 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyDictConstructorToLiteralFormIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyDictConstructorToLiteralFormIntention.java @@ -41,7 +41,7 @@ public class PyDictConstructorToLiteralFormIntention extends BaseIntentionAction PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PyCallExpression.class); if (expression != null && expression.isCalleeText("dict")) { - final TypeEvalContext context = TypeEvalContext.fast(); + final TypeEvalContext context = TypeEvalContext.fastStubOnly(file); PyType type = context.getType(expression); if (type != null && type.isBuiltin(context)) { PyExpression[] argumentList = expression.getArguments(); diff --git a/python/src/com/jetbrains/python/psi/impl/CallArgumentsMappingImpl.java b/python/src/com/jetbrains/python/psi/impl/CallArgumentsMappingImpl.java index 376fa5fe669d..b1805715a3e7 100644 --- a/python/src/com/jetbrains/python/psi/impl/CallArgumentsMappingImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/CallArgumentsMappingImpl.java @@ -54,7 +54,7 @@ public class CallArgumentsMappingImpl implements CallArgumentsMapping { @Nullable TypeEvalContext type_context ) { PyExpression[] arguments = myArgumentList.getArguments(); - if (type_context == null) type_context = TypeEvalContext.fast(); + if (type_context == null) type_context = TypeEvalContext.fastStubOnly(null); myMarkedCallee = resolved_callee; List unmatched_args = new LinkedList(); Collections.addAll(unmatched_args, arguments); diff --git a/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java b/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java index 466c58c6f9fa..c344ebe6ac18 100644 --- a/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java +++ b/python/src/com/jetbrains/python/psi/resolve/ResolveImportUtil.java @@ -271,7 +271,7 @@ public class ResolveImportUtil { dir = (PsiDirectory)parent; } else if (parent != null) { - PyType refType = PyReferenceExpressionImpl.getReferenceTypeFromProviders(parent, TypeEvalContext.fast(), null); + PyType refType = PyReferenceExpressionImpl.getReferenceTypeFromProviders(parent, TypeEvalContext.fastStubOnly(null), null); if (refType != null) { final List result = refType.resolveMember(referencedName, null, AccessDirection.READ, PyResolveContext.defaultContext());