call in qualifier of assignment LHS should be parsed as reference expression, not target expression (PY-5062)

This commit is contained in:
Dmitry Jemerov
2011-11-21 18:41:39 +01:00
parent b670fc8c7f
commit 43df68cef6
8 changed files with 61 additions and 2 deletions
@@ -307,7 +307,7 @@ public class ExpressionParsing extends Parsing {
else recast_first_identifier = false;
myBuilder.advanceLexer();
checkMatches(PyTokenTypes.IDENTIFIER, message("PARSE.expected.name"));
if (isTargetExpression && ! recast_qualifier && myBuilder.getTokenType() != PyTokenTypes.DOT) {
if (isTargetExpression && ! recast_qualifier && !atAnyOfTokens(PyTokenTypes.DOT, PyTokenTypes.LPAR, PyTokenTypes.LBRACKET)) {
expr.done(PyElementTypes.TARGET_EXPRESSION);
}
else {
@@ -44,7 +44,7 @@ public class PyFileElementType extends IStubFileElementType<PyFileStub> {
@Override
public int getStubVersion() {
return 36;
return 37;
}
@Override
+1
View File
@@ -0,0 +1 @@
etree.SubElement(dictionary, u'Name').text = dict_name
+25
View File
@@ -0,0 +1,25 @@
PyFile:CallInAssignment.py
PyAssignmentStatement
PyTargetExpression: text
PyCallExpression: etree.SubElement
PyReferenceExpression: SubElement
PyReferenceExpression: etree
PsiElement(Py:IDENTIFIER)('etree')
PsiElement(Py:DOT)('.')
PsiElement(Py:IDENTIFIER)('SubElement')
PyArgumentList
PsiElement(Py:LPAR)('(')
PyReferenceExpression: dictionary
PsiElement(Py:IDENTIFIER)('dictionary')
PsiElement(Py:COMMA)(',')
PsiWhiteSpace(' ')
PyStringLiteralExpression: Name
PsiElement(Py:SINGLE_QUOTED_STRING)('u'Name'')
PsiElement(Py:RPAR)(')')
PsiElement(Py:DOT)('.')
PsiElement(Py:IDENTIFIER)('text')
PsiWhiteSpace(' ')
PsiElement(Py:EQ)('=')
PsiWhiteSpace(' ')
PyReferenceExpression: dict_name
PsiElement(Py:IDENTIFIER)('dict_name')
@@ -0,0 +1,13 @@
import xml.etree.ElementTree as etree
def entries_to_xml(entries, dict_id, dict_name, closed):
dictionary = etree.Element(u'Dictionary', IDName=dict_id)
a = etree.SubElement
a(dictionary, u'Name').text = dict_name
a(dictionary, u'Closed').text = repr(closed).lower()
a(dictionary, u'Action').text = u'false'
terms = a(dictionary, u'Terms')
for i, entry in enumerate(entries):
term = a(terms, u'Term')
a(term, u'Category')
words = a(term, u'Words')
return dictionary
@@ -0,0 +1,12 @@
import xml.etree.ElementTree as etree
def entries_to_xml(entries, dict_id, dict_name, closed):
dictionary = etree.Element(u'Dictionary', IDName=dict_id)
<selection>etree.SubElement</selection>(dictionary, u'Name').text = dict_name
etree.SubElement(dictionary, u'Closed').text = repr(closed).lower()
etree.SubElement(dictionary, u'Action').text = u'false'
terms = etree.SubElement(dictionary, u'Terms')
for i, entry in enumerate(entries):
term = etree.SubElement(terms, u'Term')
etree.SubElement(term, u'Category')
words = etree.SubElement(term, u'Words')
return dictionary
@@ -305,6 +305,10 @@ public class PythonParsingTest extends ParsingTestCase {
public void testIncompleteFor() { // PY-3792
doTest();
}
public void testCallInAssignment() { // PY-5062
doTest();
}
public void doTest() {
doTest(LanguageLevel.PYTHON25);
@@ -69,6 +69,10 @@ public class PyIntroduceVariableTest extends PyIntroduceTestCase {
public void testOneSidedSelection() { // PY-4456
doTestCannotPerform();
}
public void testFunctionOccurrences() { // PY-5062
doTest();
}
private void doTestCannotPerform() {
boolean thrownExpectedException = false;