Skip to content

Commit

Permalink
up2
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad20012 committed Apr 28, 2022
1 parent 1895023 commit 792826c
Show file tree
Hide file tree
Showing 17 changed files with 205 additions and 219 deletions.
3 changes: 1 addition & 2 deletions src/main/grammars/RustParser.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ TypeArgumentList ::= TypeArgumentListImpl {
ColonTypeArgumentList ::= &'::' TypeArgumentListImpl { elementType = TypeArgumentList }

private TypeArgumentListImpl ::= '::'? '<' !'=' <<list_element AnyTypeArgument>>* '>' { pin = 3 }
private AnyTypeArgument ::= <<typeReferenceOrAssocTypeBinding TypePathGenericArgsNoTypeQual AssocTypeBinding_upper TypePathGenericArgs ImplicitTraitType TraitType_upper>>
private AnyTypeArgument ::= <<typeReferenceOrAssocTypeBinding TypePathGenericArgsNoTypeQual AssocTypeBinding_upper TypeReference>>
| Lifetime
| RestrictedConstExpr
| never (AssocTypeBinding | TypeReference)
Expand Down Expand Up @@ -913,7 +913,6 @@ TypeReference ::= ArrayType
| ForInType { // FIXME O(2^n) for types like `for<'a> A<for<'b> B<for<'c> C<...>>>`
implements = "org.rust.lang.core.macros.RsExpandedElement"
stubClass = "com.intellij.psi.stubs.StubBase"
elementTypeFactory = "org.rust.lang.core.stubs.StubImplementationsKt.factory"
mixin = "org.rust.lang.core.psi.ext.RsTypeReferenceImplMixin"
name = "type"
}
Expand Down
26 changes: 14 additions & 12 deletions src/main/kotlin/org/rust/lang/core/parser/RustParserUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -433,27 +433,29 @@ object RustParserUtil : GeneratedParserUtilBase() {
fun typeReferenceOrAssocTypeBinding(
b: PsiBuilder,
level: Int,
pathP1: Parser,
pathP: Parser,
assocTypeBindingUpperP: Parser,
pathP2: Parser,
implicitTraitTypeP: Parser,
traitTypeUpperP: Parser
typeReferenceP: Parser,
): Boolean {
val refOrBinding = enter_section_(b)
val typeOrAssoc = enter_section_(b)

if (!pathP.parse(b, level)) {
exit_section_(b, typeOrAssoc, null, false)
return typeReferenceP.parse(b, level)
}

if (!pathP1.parse(b, level)) {
val result = baseOrTraitType(b, level, pathP2, implicitTraitTypeP, traitTypeUpperP)
exit_section_(b, refOrBinding, TYPE_REFERENCE, result)
return result
if (nextTokenIsFast(b, PLUS) || nextTokenIsFast(b, EXCL)) {
exit_section_(b, typeOrAssoc, null, false)
return typeReferenceP.parse(b, level)
}

if (!nextTokenIs(b, EQ) && !nextTokenIs(b, COLON)) {
exit_section_(b, refOrBinding, TYPE_REFERENCE, true)
if (!nextTokenIsFast(b, EQ) && !nextTokenIsFast(b, COLON)) {
exit_section_(b, typeOrAssoc, BASE_TYPE, true)
return true
}

val result = assocTypeBindingUpperP.parse(b, level)
exit_section_(b, refOrBinding, ASSOC_TYPE_BINDING, result)
exit_section_(b, typeOrAssoc, ASSOC_TYPE_BINDING, result)
return result
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ FILE
PsiElement(identifier)('E')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('U')
PsiElement(>)('>')
Expand Down Expand Up @@ -112,7 +112,7 @@ FILE
PsiElement(identifier)('T')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('U')
PsiElement(>)('>')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ FILE
PsiElement(identifier)('S')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(Self)('Self')
PsiElement(>)('>')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ FILE
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(::)('::')
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('Z')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ FILE
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(::)('::')
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('f64')
PsiElement(>)('>')
Expand All @@ -319,7 +319,7 @@ FILE
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(::)('::')
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('isize')
PsiElement(>)('>')
Expand All @@ -328,7 +328,7 @@ FILE
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(::)('::')
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('usize')
PsiElement(>)('>')
Expand All @@ -350,13 +350,12 @@ FILE
PsiElement(identifier)('Box')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsArrayTypeImpl(ARRAY_TYPE)
PsiElement([)('[')
RsBaseTypeImpl(BASE_TYPE)
PsiElement(()('(')
PsiElement())(')')
PsiElement(])(']')
RsArrayTypeImpl(ARRAY_TYPE)
PsiElement([)('[')
RsBaseTypeImpl(BASE_TYPE)
PsiElement(()('(')
PsiElement())(')')
PsiElement(])(']')
PsiElement(>)('>')
PsiWhiteSpace(' ')
PsiElement(=)('=')
Expand All @@ -369,17 +368,16 @@ FILE
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(::)('::')
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsArrayTypeImpl(ARRAY_TYPE)
PsiElement([)('[')
RsBaseTypeImpl(BASE_TYPE)
PsiElement(()('(')
PsiElement())(')')
PsiElement(;)(';')
PsiWhiteSpace(' ')
RsLitExprImpl(LIT_EXPR)
PsiElement(INTEGER_LITERAL)('0')
PsiElement(])(']')
RsArrayTypeImpl(ARRAY_TYPE)
PsiElement([)('[')
RsBaseTypeImpl(BASE_TYPE)
PsiElement(()('(')
PsiElement())(')')
PsiElement(;)(';')
PsiWhiteSpace(' ')
RsLitExprImpl(LIT_EXPR)
PsiElement(INTEGER_LITERAL)('0')
PsiElement(])(']')
PsiElement(>)('>')
PsiElement(::)('::')
PsiElement(identifier)('new')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ FILE
PsiElement(identifier)('P')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('U')
PsiElement(>)('>')
Expand All @@ -163,7 +163,7 @@ FILE
PsiElement(identifier)('P')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('U')
PsiElement(>)('>')
Expand All @@ -187,7 +187,7 @@ FILE
PsiElement(identifier)('P')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('U')
PsiElement(>)('>')
Expand Down Expand Up @@ -294,7 +294,7 @@ FILE
PsiElement(QUOTE_IDENTIFIER)(''a')
PsiElement(,)(',')
PsiWhiteSpace(' ')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('T')
PsiElement(>)('>')
Expand Down Expand Up @@ -350,7 +350,7 @@ FILE
PsiElement(identifier)('GenVal')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('T')
PsiElement(>)('>')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ FILE
PsiElement(identifier)('Vec')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('i32')
PsiElement(>)('>')
Expand Down Expand Up @@ -691,7 +691,7 @@ FILE
PsiElement(identifier)('Vec')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('i32')
PsiElement(>)('>')
Expand Down Expand Up @@ -726,7 +726,7 @@ FILE
PsiElement(identifier)('Vec')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('i32')
PsiElement(>)('>')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ FILE
PsiElement(identifier)('Unique')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('T')
PsiElement(>)('>')
Expand Down Expand Up @@ -112,7 +112,7 @@ FILE
PsiElement(identifier)('Unique')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('T')
PsiElement(>)('>')
Expand Down Expand Up @@ -1042,7 +1042,7 @@ FILE
PsiElement(identifier)('Item')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('T')
PsiElement(>)('>')
Expand Down Expand Up @@ -1095,7 +1095,7 @@ FILE
PsiElement(identifier)('Item')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('T')
PsiElement(>)('>')
Expand Down Expand Up @@ -1154,7 +1154,7 @@ FILE
PsiElement(identifier)('Item1')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('T')
PsiElement(>)('>')
Expand All @@ -1172,7 +1172,7 @@ FILE
PsiElement(identifier)('Item2')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('T')
PsiElement(>)('>')
Expand Down Expand Up @@ -1224,7 +1224,7 @@ FILE
PsiElement(identifier)('Item1')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('T')
PsiElement(>)('>')
Expand All @@ -1241,7 +1241,7 @@ FILE
PsiElement(identifier)('Item2')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('T')
PsiElement(>)('>')
Expand Down Expand Up @@ -1300,7 +1300,7 @@ FILE
PsiElement(identifier)('Item')
RsTypeArgumentListImpl(TYPE_ARGUMENT_LIST)
PsiElement(<)('<')
RsTypeReferenceImpl(TYPE_REFERENCE)
RsBaseTypeImpl(BASE_TYPE)
RsPathImpl(PATH)
PsiElement(identifier)('T')
PsiElement(>)('>')
Expand Down

0 comments on commit 792826c

Please sign in to comment.