diff --git a/idea/src/org/jetbrains/jet/JetNodeTypes.java b/idea/src/org/jetbrains/jet/JetNodeTypes.java index 68b417df53f..dd1900f8137 100644 --- a/idea/src/org/jetbrains/jet/JetNodeTypes.java +++ b/idea/src/org/jetbrains/jet/JetNodeTypes.java @@ -38,6 +38,7 @@ public interface JetNodeTypes { JetNodeType TYPE_ARGUMENT_LIST = new JetNodeType("TYPE_ARGUMENT_LIST"); JetNodeType VALUE_ARGUMENT_LIST = new JetNodeType("VALUE_ARGUMENT_LIST"); JetNodeType VALUE_ARGUMENT = new JetNodeType("VALUE_ARGUMENT"); + JetNodeType TYPE_REFERENCE = new JetNodeType("TYPE_REFERENCE"); IElementType NAMESPACE_NAME = new JetNodeType("NAMESPACE_NAME"); diff --git a/idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java b/idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java index b6e298964db..be9b2e55f64 100644 --- a/idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java +++ b/idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java @@ -25,7 +25,10 @@ public class JetParsing { } } - private static final TokenSet CLASS_NAME_RECOVERY_SET = TokenSet.create(LT, WRAPS_KEYWORD, LPAR, COLON, LBRACE); + private static final TokenSet TOPLEVEL_OBJECT_FIRST = TokenSet.create(TYPE_KEYWORD, CLASS_KEYWORD, + EXTENSION_KEYWORD, FUN_KEYWORD, VAL_KEYWORD, REF_KEYWORD, NAMESPACE_KEYWORD); + + private static final TokenSet CLASS_NAME_RECOVERY_SET = TokenSet.orSet(TokenSet.create(LT, WRAPS_KEYWORD, LPAR, COLON, LBRACE), TOPLEVEL_OBJECT_FIRST); private static final TokenSet TYPE_PARAMETER_GT_RECOVERY_SET = TokenSet.create(WHERE_KEYWORD, WRAPS_KEYWORD, LPAR, COLON, LBRACE, GT); private static final TokenSet PARAMETER_NAME_RECOVERY_SET = TokenSet.create(COLON, EQ, COMMA, RPAR); private static final TokenSet NAMESPACE_NAME_RECOVERY_SET = TokenSet.create(DOT, EOL_OR_SEMICOLON); @@ -148,7 +151,7 @@ public class JetParsing { advance(); // AS_KEYWORD expect(IDENTIFIER, "Expecting identifier", TokenSet.create(SEMICOLON)); } - cosumeIf(SEMICOLON); + consumeIf(SEMICOLON); importDirective.done(IMPORT_DIRECTIVE); } @@ -156,7 +159,7 @@ public class JetParsing { if (at(AS_KEYWORD)) { PsiBuilder.Marker as = mark(); advance(); // AS_KEYWORD - cosumeIf(IDENTIFIER); + consumeIf(IDENTIFIER); as.error("Cannot rename a all imported items to one identifier"); } } @@ -296,63 +299,6 @@ public class JetParsing { attribute.done(ATTRIBUTE); } - /* - * userType - * : simpleUserType{"."} - * ; - * - * simpleUserType - * : SimpleName ("<" (optionalProjection type){","} ">")? - * ; - */ - private void parseUserType() { - PsiBuilder.Marker userType = mark(); - - while (true) { - parseSimpleUserType(); - if (!at(DOT)) break; - advance(); // DOT - } - - userType.done(USER_TYPE); - } - - /* - * simpleUserType - * : SimpleName ("<" (optionalProjection type){","} ">")? - * ; - */ - private void parseSimpleUserType() { - PsiBuilder.Marker type = mark(); - - expect(IDENTIFIER, "Type name expected", TokenSet.create(LT)); - parseTypeArgumentList(); - - type.done(USER_TYPE); - } - - /* - * (optionalProjection type){","} - */ - private void parseTypeArgumentList() { - if (!at(LT)) return; - - PsiBuilder.Marker list = mark(); - - advance(); // LT - - while (true) { - parseModifierList(); - parseTypeRef(); - if (!at(COMMA)) break; - advance(); // COMMA - } - - expect(GT, "Expecting a '>'"); - - list.done(TYPE_ARGUMENT_LIST); - } - /* * valueArguments * : "(" (SimpleName "=")? ("out" | "ref")? expression{","} ")" @@ -434,7 +380,7 @@ public class JetParsing { expect(IDENTIFIER, "Class name expected", CLASS_NAME_RECOVERY_SET); parseTypeParameterList(); - cosumeIf(WRAPS_KEYWORD); + consumeIf(WRAPS_KEYWORD); if (at(LPAR)) { parsePrimaryConstructorParameterList(); } @@ -451,8 +397,41 @@ public class JetParsing { return CLASS; } + private void parseClassBody() { + assert at(LBRACE); + PsiBuilder.Marker body = mark(); + advance(); // LBRACE + + while (!eof()) { + if (at(RBRACE)) { + break; + } + advance(); // TODO + } + expect(RBRACE, "Missing '}"); + body.done(CLASS_BODY); + } + + /* + * typedef + * : modifiers "type" SimpleName typeParameters? "=" type + * ; + */ private JetNodeType parseTypedef() { - advance(); // TODO + assert at(TYPE_KEYWORD); + + advance(); // TYPE_KEYWORD + + expect(IDENTIFIER, "Type name expected", TokenSet.orSet(TokenSet.create(LT, EQ, SEMICOLON), TOPLEVEL_OBJECT_FIRST)); + + parseTypeParameterList(); + + expect(EQ, "Expecting '='", TokenSet.orSet(TOPLEVEL_OBJECT_FIRST, TokenSet.create(SEMICOLON))); + + parseTypeRef(); + + consumeIf(SEMICOLON); + return TYPEDEF; } @@ -471,21 +450,6 @@ public class JetParsing { return EXTENSION; } - private void parseClassBody() { - assert at(LBRACE); - PsiBuilder.Marker body = mark(); - advance(); // LBRACE - - while (!eof()) { - if (at(RBRACE)) { - break; - } - advance(); // TODO - } - expect(RBRACE, "Missing '}"); - body.done(CLASS_BODY); - } - private void parseDelegationSpecifierList() { PsiBuilder.Marker list = mark(); @@ -637,8 +601,122 @@ public class JetParsing { } + /* + * type + * : attributes (userType | functionType | tupleType) + * ; + */ private void parseTypeRef() { - advance(); // tODO: + PsiBuilder.Marker type = mark(); + + parseAttributeList(); + + while (true) { + if (at(IDENTIFIER)) { + parseSimpleUserType(); + } + else if (at(LBRACE)) { + parseSimpleFunctionType(); + } else if (at(LPAR)) { + parseTupleType(); + } else { + error("Type expected"); + break; + } + + if (!at(DOT)) break; + advance(); // DOT + } + type.done(TYPE_REFERENCE); + } + + /* + * userType + * : simpleUserType{"."} + * ; + */ + private void parseUserType() { + PsiBuilder.Marker userType = mark(); + + while (true) { + parseSimpleUserType(); + if (!at(DOT)) break; + advance(); // DOT + } + + userType.done(USER_TYPE); + } + + /* + * simpleUserType + * : SimpleName ("<" (optionalProjection type){","} ">")? + * ; + */ + private void parseSimpleUserType() { + PsiBuilder.Marker type = mark(); + + expect(IDENTIFIER, "Type name expected", TokenSet.create(LT)); + parseTypeArgumentList(); + + type.done(USER_TYPE); + } + + /* + * (optionalProjection type){","} + */ + private void parseTypeArgumentList() { + if (!at(LT)) return; + + PsiBuilder.Marker list = mark(); + + advance(); // LT + + while (true) { + parseModifierList(); + parseTypeRef(); + if (!at(COMMA)) break; + advance(); // COMMA + } + + expect(GT, "Expecting a '>'"); + + list.done(TYPE_ARGUMENT_LIST); + } + + private void parseTupleType() { + assert at(LPAR); + + advance(); // LPAR + + if (!at(RPAR)) { + while (true) { + if (TokenSet.create(IDENTIFIER, LBRACE, LPAR).contains(tt())) { + parseTypeRef(); + } else { + error("Type expected"); + break; + } + if (!at(COMMA)) break; + advance(); // COMMA + } + } + + expect(RPAR, "Expecting ')"); + } + + /* + * simpleFunctionType + * : "{" functionTypeContents "}" + * ; + */ + private void parseSimpleFunctionType() { + assert at(LBRACE); + + advance(); // LPAR + + // TODO + + expect(RBRACE, "Expecting '}"); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -726,7 +804,7 @@ public class JetParsing { return tt; } - private void cosumeIf(JetToken token) { + private void consumeIf(JetToken token) { if (at(token)) advance(); // token } diff --git a/idea/testData/psi/Attributes.txt b/idea/testData/psi/Attributes.txt index 40871595cfc..68c19e9e3dc 100644 --- a/idea/testData/psi/Attributes.txt +++ b/idea/testData/psi/Attributes.txt @@ -45,10 +45,14 @@ JetFile: Attributes.jet PsiElement(IDENTIFIER)('foo') TYPE_ARGUMENT_LIST PsiElement(LT)('<') - PsiElement(IDENTIFIER)('A') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('A') PsiElement(COMMA)(',') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('B') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('B') PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') @@ -80,17 +84,23 @@ JetFile: Attributes.jet PsiElement(IDENTIFIER)('doo') TYPE_ARGUMENT_LIST PsiElement(LT)('<') - PsiElement(IDENTIFIER)('f') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('f') PsiElement(GT)('>') PsiElement(DOT)('.') USER_TYPE PsiElement(IDENTIFIER)('foo') TYPE_ARGUMENT_LIST PsiElement(LT)('<') - PsiElement(IDENTIFIER)('bar') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') PsiElement(COMMA)(',') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('goo') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('goo') PsiElement(GT)('>') PsiElement(DOT)('.') USER_TYPE diff --git a/idea/testData/psi/Attributes_ERR.txt b/idea/testData/psi/Attributes_ERR.txt index aca4d9c69fa..81ecb4b98e5 100644 --- a/idea/testData/psi/Attributes_ERR.txt +++ b/idea/testData/psi/Attributes_ERR.txt @@ -50,10 +50,14 @@ JetFile: Attributes_ERR.jet PsiElement(IDENTIFIER)('foo') TYPE_ARGUMENT_LIST PsiElement(LT)('<') - PsiElement(IDENTIFIER)('A') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('A') PsiElement(COMMA)(',') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('B') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('B') PsiElement(GT)('>') VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') @@ -86,17 +90,23 @@ JetFile: Attributes_ERR.jet PsiElement(IDENTIFIER)('doo') TYPE_ARGUMENT_LIST PsiElement(LT)('<') - PsiElement(IDENTIFIER)('f') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('f') PsiElement(GT)('>') PsiElement(DOT)('.') USER_TYPE PsiElement(IDENTIFIER)('foo') TYPE_ARGUMENT_LIST PsiElement(LT)('<') - PsiElement(IDENTIFIER)('bar') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') PsiElement(COMMA)(',') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('goo') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('goo') PsiElement(GT)('>') PsiElement(DOT)('.') USER_TYPE diff --git a/idea/testData/psi/BabySteps.txt b/idea/testData/psi/BabySteps.txt index ea5dd4d88ee..9192365ddd4 100644 --- a/idea/testData/psi/BabySteps.txt +++ b/idea/testData/psi/BabySteps.txt @@ -24,7 +24,9 @@ JetFile: BabySteps.jet PsiWhiteSpace(' ') PsiElement(COLON)(':') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('doo') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('doo') PsiWhiteSpace(' ') PsiElement(EQ)('=') PsiWhiteSpace(' ') @@ -36,7 +38,9 @@ JetFile: BabySteps.jet DELEGATION_SPECIFIER_LIST DELEGATION_SPECIFIER DELEGATOR_SUPER_CALL - PsiElement(IDENTIFIER)('foo') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('foo') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') NAMED_ARGUMENT @@ -48,7 +52,9 @@ JetFile: BabySteps.jet PsiWhiteSpace(' ') DELEGATION_SPECIFIER DELEGATOR_BY - PsiElement(IDENTIFIER)('bar') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') PsiWhiteSpace(' ') PsiElement(by)('by') PsiWhiteSpace(' ') @@ -57,7 +63,9 @@ JetFile: BabySteps.jet PsiWhiteSpace(' ') DELEGATION_SPECIFIER DELEGATOR_SUPER_CLASS - PsiElement(IDENTIFIER)('bar') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') PsiWhiteSpace(' ') CLASS_BODY PsiElement(LBRACE)('{') diff --git a/idea/testData/psi/TypeDef.jet b/idea/testData/psi/TypeDef.jet new file mode 100644 index 00000000000..9aab7e0e4a7 --- /dev/null +++ b/idea/testData/psi/TypeDef.jet @@ -0,0 +1,14 @@ +namespace foo.bar.goo + +type foo = bar +type foo = bar +type foo = bar +type foo = bar +type foo = bar + +type foo = bar ; +type foo = bar ; + +type foo = bar ; +type foo = bar ; +type foo = bar ; diff --git a/idea/testData/psi/TypeDef.txt b/idea/testData/psi/TypeDef.txt new file mode 100644 index 00000000000..fbe731f75e4 --- /dev/null +++ b/idea/testData/psi/TypeDef.txt @@ -0,0 +1,214 @@ +JetFile: TypeDef.jet + NAMESPACE + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') + NAMESPACE_NAME + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('bar') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('goo') + PsiWhiteSpace('\n\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('foo') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('A') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('B') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('A') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('B') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('A') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace(' ') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace(' ') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('foo') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace(' ') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('A') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('B') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace(' ') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('A') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('B') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('A') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace(' ') + PsiElement(SEMICOLON)(';') \ No newline at end of file diff --git a/idea/testData/psi/TypeDef_ERR.jet b/idea/testData/psi/TypeDef_ERR.jet new file mode 100644 index 00000000000..6c03a8632fa --- /dev/null +++ b/idea/testData/psi/TypeDef_ERR.jet @@ -0,0 +1,17 @@ +type +type foo +type foo = +type ; +type foo ; +type foo = ; +type = foo +type = +type = foo ; +type = ; + +type foo<> = bar +type foo = bar +type foo = bar + +class +type foo = bar \ No newline at end of file diff --git a/idea/testData/psi/TypeDef_ERR.txt b/idea/testData/psi/TypeDef_ERR.txt new file mode 100644 index 00000000000..e5ecb3cf0b7 --- /dev/null +++ b/idea/testData/psi/TypeDef_ERR.txt @@ -0,0 +1,211 @@ +JetFile: TypeDef_ERR.jet + NAMESPACE + TYPEDEF + PsiElement(type)('type') + PsiErrorElement:Type name expected + + PsiWhiteSpace('\n') + TYPE_PARAMETER_LIST + + PsiErrorElement:Expecting '=' + + TYPE_REFERENCE + + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace('\n') + TYPE_PARAMETER_LIST + + PsiErrorElement:Expecting '=' + + TYPE_REFERENCE + + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace('\n') + TYPE_REFERENCE + PsiErrorElement:Type expected + + TYPEDEF + PsiElement(type)('type') + PsiErrorElement:Type name expected + + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiErrorElement:Expecting '=' + + TYPE_REFERENCE + + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiErrorElement:Expecting '=' + + TYPE_REFERENCE + + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiErrorElement:Type name expected + + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiErrorElement:Type name expected + + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace('\n') + TYPE_REFERENCE + PsiErrorElement:Type expected + + TYPEDEF + PsiElement(type)('type') + PsiErrorElement:Type name expected + + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiErrorElement:Type name expected + + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + PsiErrorElement:Type parameter declaration expected + + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiErrorElement:Type parameter declaration expected + + PsiWhiteSpace(' ') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('A') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('B') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiErrorElement:Class name expected + + PsiWhiteSpace('\n') + TYPE_PARAMETER_LIST + + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('bar') \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/parsing/JetParsingTest.java b/idea/tests/org/jetbrains/jet/parsing/JetParsingTest.java index 673b9ed8212..ecbbfd25fa8 100644 --- a/idea/tests/org/jetbrains/jet/parsing/JetParsingTest.java +++ b/idea/tests/org/jetbrains/jet/parsing/JetParsingTest.java @@ -37,4 +37,6 @@ public class JetParsingTest extends ParsingTestCase { public void testSimpleModifiers() throws Exception {doTest(true);} public void testAttributes() throws Exception {doTest(true);} public void testAttributes_ERR() throws Exception {doTest(true);} + public void testTypeDef() throws Exception {doTest(true);} + public void testTypeDef_ERR() throws Exception {doTest(true);} }