More tests for imports

This commit is contained in:
Andrey Breslav
2010-12-15 16:31:15 +03:00
parent 69ade018f9
commit 35a824d2fe
6 changed files with 182 additions and 8 deletions
@@ -29,6 +29,7 @@ public interface JetNodeTypes {
JetNodeType NAMED_ARGUMENT = new JetNodeType("NAMED_ARGUMENT");
JetNodeType CLASS_BODY = new JetNodeType("CLASS_BODY");
JetNodeType IMPORT_DIRECTIVE = new JetNodeType("IMPORT_DIRECTIVE");
JetNodeType IMPORTED = new JetNodeType("IMPORTED");
IElementType NAMESPACE_NAME = new JetNodeType("NAMESPACE_NAME");
}
@@ -124,14 +124,14 @@ public class JetParsing {
errorWithRecovery("Qualified name must be a '.'-separated identifier list", TokenSet.create(AS_KEYWORD, DOT, MAP, SEMICOLON));
}
}
if (at(MAP)) {
advance();
handleUselessRename();
}
else if (at(AS_KEYWORD)) {
advance();
expect(IDENTIFIER, "Expecting identifier", TokenSet.create(SEMICOLON));
}
if (at(MAP)) {
advance();
handleUselessRename();
}
else if (at(AS_KEYWORD)) {
advance();
expect(IDENTIFIER, "Expecting identifier", TokenSet.create(SEMICOLON));
}
cosumeIf(SEMICOLON);
importDirective.done(IMPORT_DIRECTIVE);
}
+1
View File
@@ -0,0 +1 @@
import import.import.import.import as import
+16
View File
@@ -0,0 +1,16 @@
JetFile: ImportSoftKW.jet
NAMESPACE
IMPORT_DIRECTIVE
PsiElement(import)('import')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('import')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('import')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('import')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('import')
PsiWhiteSpace(' ')
PsiElement(AS_KEYWORD)('as')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('import')
+155
View File
@@ -0,0 +1,155 @@
JetFile: Imports_ERR.jet
NAMESPACE
PsiElement(NAMESPACE_KEYWORD)('namespace')
PsiWhiteSpace(' ')
NAMESPACE_NAME
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('goo')
PsiWhiteSpace('\n\n')
IMPORT_DIRECTIVE
PsiElement(import)('import')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(AS_KEYWORD)('as')
PsiWhiteSpace('\n')
PsiElement(IDENTIFIER)('import')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(IDENTIFIER)('foo')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(DOT)('.')
PsiWhiteSpace('\n')
IMPORT_DIRECTIVE
PsiElement(import)('import')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
PsiWhiteSpace('\n')
PsiElement(IDENTIFIER)('import')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(IDENTIFIER)('foo')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(DOT)('.')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(AS_KEYWORD)('as')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace('\n')
IMPORT_DIRECTIVE
PsiElement(import)('import')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar')
PsiElement(MAP)('.*')
PsiWhiteSpace(' ')
PsiErrorElement:Cannot rename a all imported items to one identifier
PsiElement(AS_KEYWORD)('as')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace('\n')
IMPORT_DIRECTIVE
PsiElement(import)('import')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar')
PsiElement(MAP)('.*')
PsiWhiteSpace(' ')
PsiErrorElement:Cannot rename a all imported items to one identifier
PsiElement(AS_KEYWORD)('as')
PsiWhiteSpace('\n\n')
PsiElement(IDENTIFIER)('import')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(AS_KEYWORD)('as')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(SEMICOLON)(';')
PsiWhiteSpace('\n')
IMPORT_DIRECTIVE
PsiElement(import)('import')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiErrorElement:Qualified name must be a '.'-separated identifier list
<empty list>
PsiWhiteSpace(' ')
PsiElement(SEMICOLON)(';')
PsiWhiteSpace('\n')
IMPORT_DIRECTIVE
PsiElement(import)('import')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
PsiErrorElement:Qualified name must be a '.'-separated identifier list
<empty list>
PsiWhiteSpace(' ')
PsiElement(SEMICOLON)(';')
PsiWhiteSpace('\n')
IMPORT_DIRECTIVE
PsiElement(import)('import')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiErrorElement:Qualified name must be a '.'-separated identifier list
<empty list>
PsiWhiteSpace(' ')
PsiElement(AS_KEYWORD)('as')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace(' ')
PsiElement(SEMICOLON)(';')
PsiWhiteSpace('\n')
IMPORT_DIRECTIVE
PsiElement(import)('import')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar')
PsiElement(MAP)('.*')
PsiWhiteSpace(' ')
PsiErrorElement:Cannot rename a all imported items to one identifier
PsiElement(AS_KEYWORD)('as')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace(' ')
PsiElement(SEMICOLON)(';')
PsiWhiteSpace('\n')
IMPORT_DIRECTIVE
PsiElement(import)('import')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar')
PsiElement(MAP)('.*')
PsiWhiteSpace(' ')
PsiErrorElement:Cannot rename a all imported items to one identifier
PsiElement(AS_KEYWORD)('as')
PsiWhiteSpace(' ')
PsiElement(SEMICOLON)(';')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(CLASS_KEYWORD)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('Foo')
PsiWhiteSpace(' ')
TYPE_PARAMETER_LIST
<empty list>
CLASS_BODY
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
@@ -31,4 +31,5 @@ public class JetParsingTest extends ParsingTestCase {
public void testBabySteps() throws Exception {doTest(true);}
public void testImports() throws Exception {doTest(true);}
public void testImports_ERR() throws Exception {doTest(true);}
public void testImportSoftKW() throws Exception {doTest(true);}
}