From 7b576ab86b3d67dbc469a166b46f632037af33c5 Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Fri, 26 Apr 2013 21:03:41 +0400 Subject: [PATCH] Fixed completion for 'namedtuple' fields in Python 3.3 (PY-8904) --- python/psi-api/src/com/jetbrains/python/PyNames.java | 2 +- .../python/codeInsight/stdlib/PyStdlibTypeProvider.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/psi-api/src/com/jetbrains/python/PyNames.java b/python/psi-api/src/com/jetbrains/python/PyNames.java index cd48eb28b80d..016c6878eb14 100644 --- a/python/psi-api/src/com/jetbrains/python/PyNames.java +++ b/python/psi-api/src/com/jetbrains/python/PyNames.java @@ -110,8 +110,8 @@ public class PyNames { public static final String CALLABLE_BUILTIN = "callable"; public static final String NAMEDTUPLE = "namedtuple"; - public static final String COLLECTIONS_PY = "collections.py"; public static final String COLLECTIONS = "collections"; + public static final String COLLECTIONS_NAMEDTUPLE = COLLECTIONS + "." + NAMEDTUPLE; public static final String ABSTRACTMETHOD = "abstractmethod"; diff --git a/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java b/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java index dcceff5271c7..c6eaaa5762ba 100644 --- a/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java +++ b/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java @@ -57,7 +57,7 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase { final PyCallExpression.PyMarkedCallee callee = call.resolveCallee(PyResolveContext.noImplicits()); if (callee != null) { final Callable callable = callee.getCallable(); - if (PyNames.COLLECTIONS_PY.equals(callable.getContainingFile().getName())) { + if (PyNames.COLLECTIONS_NAMEDTUPLE.equals(callable.getQualifiedName())) { return PyNamedTupleType.fromCall(call, 1); } } @@ -65,8 +65,8 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase { } } else if (referenceTarget instanceof PyFunction && anchor instanceof PyCallExpression) { - if (PyNames.NAMEDTUPLE.equals(((PyFunction)referenceTarget).getName()) && - PyNames.COLLECTIONS_PY.equals(referenceTarget.getContainingFile().getName())) { + final PyFunction function = (PyFunction)referenceTarget; + if (PyNames.NAMEDTUPLE.equals(function.getName()) && PyNames.COLLECTIONS_NAMEDTUPLE.equals(function.getQualifiedName())) { return PyNamedTupleType.fromCall((PyCallExpression)anchor, 2); } }