Typedefs and recovery
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)('{')
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace foo.bar.goo
|
||||
|
||||
type foo = bar
|
||||
type foo<T> = bar
|
||||
type foo<T : foo> = bar
|
||||
type foo<A, B> = bar
|
||||
type foo<A, B : A> = bar
|
||||
|
||||
type foo = bar ;
|
||||
type foo<T> = bar ;
|
||||
|
||||
type foo<T : foo> = bar ;
|
||||
type foo<A, B> = bar ;
|
||||
type foo<A, B : A> = bar ;
|
||||
@@ -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
|
||||
<empty 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
|
||||
<empty 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)(';')
|
||||
@@ -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<T, > = bar
|
||||
type foo<A : , B> = bar
|
||||
|
||||
class
|
||||
type foo = bar
|
||||
@@ -0,0 +1,211 @@
|
||||
JetFile: TypeDef_ERR.jet
|
||||
NAMESPACE
|
||||
TYPEDEF
|
||||
PsiElement(type)('type')
|
||||
PsiErrorElement:Type name expected
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
PsiErrorElement:Expecting '='
|
||||
<empty list>
|
||||
TYPE_REFERENCE
|
||||
<empty list>
|
||||
TYPEDEF
|
||||
PsiElement(type)('type')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
PsiWhiteSpace('\n')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
PsiErrorElement:Expecting '='
|
||||
<empty list>
|
||||
TYPE_REFERENCE
|
||||
<empty list>
|
||||
TYPEDEF
|
||||
PsiElement(type)('type')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace('\n')
|
||||
TYPE_REFERENCE
|
||||
PsiErrorElement:Type expected
|
||||
<empty list>
|
||||
TYPEDEF
|
||||
PsiElement(type)('type')
|
||||
PsiErrorElement:Type name expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
PsiErrorElement:Expecting '='
|
||||
<empty list>
|
||||
TYPE_REFERENCE
|
||||
<empty list>
|
||||
PsiElement(SEMICOLON)(';')
|
||||
PsiWhiteSpace('\n')
|
||||
TYPEDEF
|
||||
PsiElement(type)('type')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
PsiErrorElement:Expecting '='
|
||||
<empty list>
|
||||
TYPE_REFERENCE
|
||||
<empty list>
|
||||
PsiElement(SEMICOLON)(';')
|
||||
PsiWhiteSpace('\n')
|
||||
TYPEDEF
|
||||
PsiElement(type)('type')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
PsiErrorElement:Type expected
|
||||
<empty list>
|
||||
PsiElement(SEMICOLON)(';')
|
||||
PsiWhiteSpace('\n')
|
||||
TYPEDEF
|
||||
PsiElement(type)('type')
|
||||
PsiErrorElement:Type name expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
PsiWhiteSpace('\n')
|
||||
TYPEDEF
|
||||
PsiElement(type)('type')
|
||||
PsiErrorElement:Type name expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace('\n')
|
||||
TYPE_REFERENCE
|
||||
PsiErrorElement:Type expected
|
||||
<empty list>
|
||||
TYPEDEF
|
||||
PsiElement(type)('type')
|
||||
PsiErrorElement:Type name expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(SEMICOLON)(';')
|
||||
PsiWhiteSpace('\n')
|
||||
TYPEDEF
|
||||
PsiElement(type)('type')
|
||||
PsiErrorElement:Type name expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
PsiErrorElement:Type expected
|
||||
<empty list>
|
||||
PsiElement(SEMICOLON)(';')
|
||||
PsiWhiteSpace('\n\n')
|
||||
TYPEDEF
|
||||
PsiElement(type)('type')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
TYPE_PARAMETER_LIST
|
||||
PsiElement(LT)('<')
|
||||
PsiErrorElement:Type parameter declaration expected
|
||||
<empty list>
|
||||
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
|
||||
<empty list>
|
||||
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
|
||||
<empty list>
|
||||
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
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
TYPEDEF
|
||||
PsiElement(type)('type')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
PsiElement(IDENTIFIER)('bar')
|
||||
@@ -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);}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user