diff --git a/python/src/com/jetbrains/python/PyElementTypes.java b/python/src/com/jetbrains/python/PyElementTypes.java index 64bcb9e1de04..cdf91ec9e490 100644 --- a/python/src/com/jetbrains/python/PyElementTypes.java +++ b/python/src/com/jetbrains/python/PyElementTypes.java @@ -14,6 +14,9 @@ public interface PyElementTypes { PyStubElementType FUNCTION_DECLARATION = new PyFunctionElementType(); PyStubElementType CLASS_DECLARATION = new PyClassElementType(); PyStubElementType PARAMETER_LIST = new PyParameterListElementType(); + + TokenSet PARAMETER_LIST_SET = TokenSet.create(PARAMETER_LIST); + PyStubElementType FORMAL_PARAMETER = new PyFormalParameterElementType(); PyElementType DECORATED_FUNCTION_DECLARATION = new PyElementType("DECORATED_FUNCTION_DECLARATION", PyDecoratedFunctionImpl.class); diff --git a/python/src/com/jetbrains/python/psi/PyLambdaExpression.java b/python/src/com/jetbrains/python/psi/PyLambdaExpression.java index e9d2b791b81f..f933c96f4cc9 100644 --- a/python/src/com/jetbrains/python/psi/PyLambdaExpression.java +++ b/python/src/com/jetbrains/python/psi/PyLambdaExpression.java @@ -24,4 +24,5 @@ package com.jetbrains.python.psi; * To change this template use File | Settings | File Templates. */ public interface PyLambdaExpression extends PyExpression { + PyParameterList getParameterList(); } diff --git a/python/src/com/jetbrains/python/psi/impl/PyLambdaExpressionImpl.java b/python/src/com/jetbrains/python/psi/impl/PyLambdaExpressionImpl.java index 5d58fd34998f..63df26d6f0e6 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyLambdaExpressionImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyLambdaExpressionImpl.java @@ -17,9 +17,16 @@ package com.jetbrains.python.psi.impl; import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.ResolveState; +import com.intellij.psi.scope.PsiScopeProcessor; +import com.jetbrains.python.PyElementTypes; import com.jetbrains.python.psi.PyElementVisitor; import com.jetbrains.python.psi.PyLambdaExpression; +import com.jetbrains.python.psi.PyParameter; +import com.jetbrains.python.psi.PyParameterList; import com.jetbrains.python.psi.types.PyType; +import org.jetbrains.annotations.NotNull; /** * Created by IntelliJ IDEA. @@ -40,4 +47,18 @@ public class PyLambdaExpressionImpl extends PyElementImpl implements PyLambdaExp public PyType getType() { return null; } + + public PyParameterList getParameterList() { + return childToPsiNotNull(PyElementTypes.PARAMETER_LIST_SET, 0); + } + + public boolean processDeclarations(@NotNull final PsiScopeProcessor processor, @NotNull final ResolveState state, final PsiElement lastParent, + @NotNull final PsiElement place) { + PyParameter[] parameters = getParameterList().getParameters(); + for(PyParameter param: parameters) { + if (param == lastParent) continue; + if (!processor.execute(param, state)) return false; + } + return true; + } } diff --git a/python/testData/resolve/Lambda.py b/python/testData/resolve/Lambda.py new file mode 100644 index 000000000000..88aaaff23e50 --- /dev/null +++ b/python/testData/resolve/Lambda.py @@ -0,0 +1 @@ +lambda aa: aa[1] \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyResolveTest.java b/python/testSrc/com/jetbrains/python/PyResolveTest.java index 9009bb405ad6..aab30288dd67 100644 --- a/python/testSrc/com/jetbrains/python/PyResolveTest.java +++ b/python/testSrc/com/jetbrains/python/PyResolveTest.java @@ -8,10 +8,7 @@ import com.intellij.openapi.application.PathManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; import com.intellij.testFramework.ResolveTestCase; -import com.jetbrains.python.psi.PyClass; -import com.jetbrains.python.psi.PyFunction; -import com.jetbrains.python.psi.PyTargetExpression; -import com.jetbrains.python.psi.PyAssignmentStatement; +import com.jetbrains.python.psi.*; public class PyResolveTest extends ResolveTestCase { private PsiElement resolve() throws Exception { @@ -70,6 +67,11 @@ public class PyResolveTest extends ResolveTestCase { assertTrue(targetElement.getParent() instanceof PyAssignmentStatement); } + public void testLambda() throws Exception { + PsiElement targetElement = resolve(); + assertTrue(targetElement instanceof PyParameter); + } + @Override protected String getTestDataPath() { return PathManager.getHomePath() + "/plugins/python/testData/resolve/";