More tests for imports
This commit is contained in:
@@ -29,6 +29,7 @@ public interface JetNodeTypes {
|
|||||||
JetNodeType NAMED_ARGUMENT = new JetNodeType("NAMED_ARGUMENT");
|
JetNodeType NAMED_ARGUMENT = new JetNodeType("NAMED_ARGUMENT");
|
||||||
JetNodeType CLASS_BODY = new JetNodeType("CLASS_BODY");
|
JetNodeType CLASS_BODY = new JetNodeType("CLASS_BODY");
|
||||||
JetNodeType IMPORT_DIRECTIVE = new JetNodeType("IMPORT_DIRECTIVE");
|
JetNodeType IMPORT_DIRECTIVE = new JetNodeType("IMPORT_DIRECTIVE");
|
||||||
|
JetNodeType IMPORTED = new JetNodeType("IMPORTED");
|
||||||
|
|
||||||
IElementType NAMESPACE_NAME = new JetNodeType("NAMESPACE_NAME");
|
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));
|
errorWithRecovery("Qualified name must be a '.'-separated identifier list", TokenSet.create(AS_KEYWORD, DOT, MAP, SEMICOLON));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (at(MAP)) {
|
if (at(MAP)) {
|
||||||
advance();
|
advance();
|
||||||
handleUselessRename();
|
handleUselessRename();
|
||||||
}
|
}
|
||||||
else if (at(AS_KEYWORD)) {
|
else if (at(AS_KEYWORD)) {
|
||||||
advance();
|
advance();
|
||||||
expect(IDENTIFIER, "Expecting identifier", TokenSet.create(SEMICOLON));
|
expect(IDENTIFIER, "Expecting identifier", TokenSet.create(SEMICOLON));
|
||||||
}
|
}
|
||||||
cosumeIf(SEMICOLON);
|
cosumeIf(SEMICOLON);
|
||||||
importDirective.done(IMPORT_DIRECTIVE);
|
importDirective.done(IMPORT_DIRECTIVE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
import import.import.import.import as import
|
||||||
@@ -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')
|
||||||
@@ -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 testBabySteps() throws Exception {doTest(true);}
|
||||||
public void testImports() throws Exception {doTest(true);}
|
public void testImports() throws Exception {doTest(true);}
|
||||||
public void testImports_ERR() throws Exception {doTest(true);}
|
public void testImports_ERR() throws Exception {doTest(true);}
|
||||||
|
public void testImportSoftKW() throws Exception {doTest(true);}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user