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); } } diff --git a/python/src/com/jetbrains/python/parsing/FunctionParsing.java b/python/src/com/jetbrains/python/parsing/FunctionParsing.java index 7bb12f969585..d7c0202ee57f 100644 --- a/python/src/com/jetbrains/python/parsing/FunctionParsing.java +++ b/python/src/com/jetbrains/python/parsing/FunctionParsing.java @@ -1,11 +1,9 @@ package com.jetbrains.python.parsing; import com.intellij.lang.PsiBuilder; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.psi.tree.IElementType; import com.jetbrains.python.PyElementTypes; import com.jetbrains.python.PyTokenTypes; -import org.jetbrains.annotations.Nullable; import static com.jetbrains.python.PyBundle.message; @@ -13,9 +11,7 @@ import static com.jetbrains.python.PyBundle.message; * @author yole */ public class FunctionParsing extends Parsing { - private static final Logger LOG = Logger.getInstance("#com.jetbrains.python.parsing.FunctionParsing"); private static final IElementType FUNCTION_TYPE = PyElementTypes.FUNCTION_DECLARATION; - private static final IElementType PARAMETER_LIST_TYPE = PyElementTypes.PARAMETER_LIST; public FunctionParsing(ParsingContext context) { super(context); @@ -31,31 +27,16 @@ public class FunctionParsing extends Parsing { return FUNCTION_TYPE; } - @Nullable - protected IElementType getNameType() { - return null; - } - protected void parseFunctionInnards(PsiBuilder.Marker functionMarker) { myBuilder.advanceLexer(); - final IElementType elementType = getNameType(); - final PsiBuilder.Marker mark = myBuilder.mark(); - boolean nameFound = false; if (myBuilder.getTokenType() == PyTokenTypes.IDENTIFIER) { myBuilder.advanceLexer(); - nameFound = true; } else { myBuilder.error(message("PARSE.expected.func.name")); } parseParameterList(); parseReturnTypeAnnotation(); - if (elementType != null && nameFound) { - mark.done(elementType); - } - else { - mark.drop(); - } checkMatches(PyTokenTypes.COLON, message("PARSE.expected.colon")); getStatementParser().parseSuite(functionMarker, getFunctionType(), myContext.emptyParsingScope().withFunction(true)); }