From 85e104a1b92a5bfd09aed68f2e780a1c7e3533cc Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 30 Jun 2010 15:51:26 +0400 Subject: [PATCH] PyImportElement.toString() --- .../python/psi/impl/PyImportElementImpl.java | 6 ++++ python/testData/psi/ImportStmt.txt | 34 +++++++++---------- python/testData/psi/PrintAsFunction26.txt | 2 +- python/testData/psi/WithStatement.txt | 2 +- python/testData/psi/WithStatement2.txt | 4 +-- 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/python/src/com/jetbrains/python/psi/impl/PyImportElementImpl.java b/python/src/com/jetbrains/python/psi/impl/PyImportElementImpl.java index c5ab11d93d50..4ba0aacff468 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyImportElementImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyImportElementImpl.java @@ -234,4 +234,10 @@ public class PyImportElementImpl extends PyBaseElementImpl protected void acceptPyVisitor(PyElementVisitor pyVisitor) { pyVisitor.visitPyImportElement(this); } + + @Override + public String toString() { + final PyQualifiedName qName = getImportedQName(); + return "PyImportElement:" + (qName != null ? qName : "null"); + } } diff --git a/python/testData/psi/ImportStmt.txt b/python/testData/psi/ImportStmt.txt index 0a81bf175c4f..b12c29be2f17 100644 --- a/python/testData/psi/ImportStmt.txt +++ b/python/testData/psi/ImportStmt.txt @@ -4,7 +4,7 @@ PyFile:ImportStmt.py PyImportStatement PsiElement(Py:IMPORT_KEYWORD)('import') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:A PyReferenceExpression: A PsiElement(Py:IDENTIFIER)('A') PsiWhiteSpace(' ') @@ -18,7 +18,7 @@ PyFile:ImportStmt.py PyImportStatement PsiElement(Py:IMPORT_KEYWORD)('import') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:A PyReferenceExpression: A PsiElement(Py:IDENTIFIER)('A') PsiWhiteSpace(' ') @@ -28,7 +28,7 @@ PyFile:ImportStmt.py PsiElement(Py:IDENTIFIER)('D') PsiElement(Py:COMMA)(',') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:A PyReferenceExpression: A PsiElement(Py:IDENTIFIER)('A') PsiWhiteSpace(' ') @@ -42,7 +42,7 @@ PyFile:ImportStmt.py PyImportStatement PsiElement(Py:IMPORT_KEYWORD)('import') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:A.B.C PyReferenceExpression: C PyReferenceExpression: B PyReferenceExpression: A @@ -58,7 +58,7 @@ PyFile:ImportStmt.py PsiElement(Py:IDENTIFIER)('D') PsiElement(Py:COMMA)(',') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:A PyReferenceExpression: A PsiElement(Py:IDENTIFIER)('A') PsiWhiteSpace(' ') @@ -72,7 +72,7 @@ PyFile:ImportStmt.py PyImportStatement PsiElement(Py:IMPORT_KEYWORD)('import') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:as PyReferenceExpression: as PsiElement(Py:IDENTIFIER)('as') PsiWhiteSpace(' ') @@ -86,7 +86,7 @@ PyFile:ImportStmt.py PyImportStatement PsiElement(Py:IMPORT_KEYWORD)('import') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:A PyReferenceExpression: A PsiElement(Py:IDENTIFIER)('A') PsiWhiteSpace('\n') @@ -95,17 +95,17 @@ PyFile:ImportStmt.py PyImportStatement PsiElement(Py:IMPORT_KEYWORD)('import') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:A PyReferenceExpression: A PsiElement(Py:IDENTIFIER)('A') PsiElement(Py:COMMA)(',') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:B PyReferenceExpression: B PsiElement(Py:IDENTIFIER)('B') PsiElement(Py:COMMA)(',') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:C PyReferenceExpression: C PsiElement(Py:IDENTIFIER)('C') PsiWhiteSpace('\n') @@ -114,7 +114,7 @@ PyFile:ImportStmt.py PyImportStatement PsiElement(Py:IMPORT_KEYWORD)('import') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:A.B.C PyReferenceExpression: C PyReferenceExpression: B PyReferenceExpression: A @@ -134,12 +134,12 @@ PyFile:ImportStmt.py PsiWhiteSpace(' ') PsiElement(Py:IMPORT_KEYWORD)('import') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:B PyReferenceExpression: B PsiElement(Py:IDENTIFIER)('B') PsiElement(Py:COMMA)(',') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:C PyReferenceExpression: C PsiElement(Py:IDENTIFIER)('C') PsiWhiteSpace('\n') @@ -153,7 +153,7 @@ PyFile:ImportStmt.py PsiWhiteSpace(' ') PsiElement(Py:IMPORT_KEYWORD)('import') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:B PyReferenceExpression: B PsiElement(Py:IDENTIFIER)('B') PsiWhiteSpace(' ') @@ -172,7 +172,7 @@ PyFile:ImportStmt.py PsiWhiteSpace(' ') PsiElement(Py:IMPORT_KEYWORD)('import') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:B PyReferenceExpression: B PsiElement(Py:IDENTIFIER)('B') PsiWhiteSpace(' ') @@ -182,7 +182,7 @@ PyFile:ImportStmt.py PsiElement(Py:IDENTIFIER)('C') PsiElement(Py:COMMA)(',') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:X PyReferenceExpression: X PsiElement(Py:IDENTIFIER)('X') PsiWhiteSpace(' ') @@ -201,7 +201,7 @@ PyFile:ImportStmt.py PsiWhiteSpace(' ') PsiElement(Py:IMPORT_KEYWORD)('import') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:as PyReferenceExpression: as PsiElement(Py:IDENTIFIER)('as') PsiWhiteSpace(' ') diff --git a/python/testData/psi/PrintAsFunction26.txt b/python/testData/psi/PrintAsFunction26.txt index f13bab80c231..dc6ebe65d523 100644 --- a/python/testData/psi/PrintAsFunction26.txt +++ b/python/testData/psi/PrintAsFunction26.txt @@ -7,7 +7,7 @@ PyFile:PrintAsFunction26.py PsiWhiteSpace(' ') PsiElement(Py:IMPORT_KEYWORD)('import') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:print_function PyReferenceExpression: print_function PsiElement(Py:IDENTIFIER)('print_function') PsiWhiteSpace('\n') diff --git a/python/testData/psi/WithStatement.txt b/python/testData/psi/WithStatement.txt index f3628b5cf874..a5257b83520d 100644 --- a/python/testData/psi/WithStatement.txt +++ b/python/testData/psi/WithStatement.txt @@ -7,7 +7,7 @@ PyFile:WithStatement.py PsiWhiteSpace(' ') PsiElement(Py:IMPORT_KEYWORD)('import') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:with_statement PyReferenceExpression: with_statement PsiElement(Py:IDENTIFIER)('with_statement') PsiWhiteSpace('\n') diff --git a/python/testData/psi/WithStatement2.txt b/python/testData/psi/WithStatement2.txt index 221459a467ab..bac1f3341fe3 100644 --- a/python/testData/psi/WithStatement2.txt +++ b/python/testData/psi/WithStatement2.txt @@ -22,12 +22,12 @@ PyFile:WithStatement2.py PsiWhiteSpace(' ') PsiElement(Py:IMPORT_KEYWORD)('import') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:nested_scopes PyReferenceExpression: nested_scopes PsiElement(Py:IDENTIFIER)('nested_scopes') PsiElement(Py:COMMA)(',') PsiWhiteSpace(' ') - PyImportElement + PyImportElement:with_statement PyReferenceExpression: with_statement PsiElement(Py:IDENTIFIER)('with_statement') PsiWhiteSpace('\n')