Skip to content

Commit

Permalink
GH-2108: Semicolon after a type alias declaration producing bogus emp…
Browse files Browse the repository at this point in the history
…ty statement in AST (#2110)

* fix automatic semicolon insertion for type aliases
  • Loading branch information
mor-n4 authored Apr 13, 2021
1 parent c2933ed commit a3635ac
Show file tree
Hide file tree
Showing 8 changed files with 3,775 additions and 3,702 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63892,6 +63892,7 @@ rule__N4TypeAliasDeclaration__Group__3
}
:
rule__N4TypeAliasDeclaration__Group__3__Impl
rule__N4TypeAliasDeclaration__Group__4
;
finally {
restoreStackSize(stackSize);
Expand All @@ -63912,6 +63913,32 @@ finally {
restoreStackSize(stackSize);
}

rule__N4TypeAliasDeclaration__Group__4
@init {
int stackSize = keepStackSize();
}
:
rule__N4TypeAliasDeclaration__Group__4__Impl
;
finally {
restoreStackSize(stackSize);
}

rule__N4TypeAliasDeclaration__Group__4__Impl
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getN4TypeAliasDeclarationAccess().getSemiParserRuleCall_4()); }
ruleSemi
{ after(grammarAccess.getN4TypeAliasDeclarationAccess().getSemiParserRuleCall_4()); }
)
;
finally {
restoreStackSize(stackSize);
}


rule__N4TypeAliasDeclaration__Group_0__0
@init {
Expand Down

Large diffs are not rendered by default.

Binary file modified plugins/org.eclipse.n4js/src-gen/org/eclipse/n4js/N4JS.xtextbin
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7027,6 +7027,7 @@ ruleN4TypeAliasDeclaration:
ruleTypeParameters?
'='
ruleTypeReferenceNode
ruleSemi
;

// Rule N4MemberDeclaration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30175,6 +30175,13 @@ ruleN4TypeAliasDeclaration returns [EObject current=null]
}
)
)
{
newCompositeNode(grammarAccess.getN4TypeAliasDeclarationAccess().getSemiParserRuleCall_4());
}
ruleSemi
{
afterParserOrEnumRuleCall();
}
)
;

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8649,16 +8649,18 @@ public class N4TypeAliasDeclarationElements extends AbstractParserRuleElementFin
private final Keyword cEqualsSignKeyword_2 = (Keyword)cGroup.eContents().get(2);
private final Assignment cDeclaredTypeRefNodeAssignment_3 = (Assignment)cGroup.eContents().get(3);
private final RuleCall cDeclaredTypeRefNodeTypeReferenceNodeParserRuleCall_3_0 = (RuleCall)cDeclaredTypeRefNodeAssignment_3.eContents().get(0);
private final RuleCall cSemiParserRuleCall_4 = (RuleCall)cGroup.eContents().get(4);

//N4TypeAliasDeclaration <Yield>:
// => ({N4TypeAliasDeclaration} declaredModifiers+=N4ModifierWithoutConst*
// 'type' name=BindingIdentifier<Yield>?) TypeParameters?
// '='
// declaredTypeRefNode=TypeReferenceNode;
// declaredTypeRefNode=TypeReferenceNode
// Semi;
@Override public ParserRule getRule() { return rule; }

//=> ({N4TypeAliasDeclaration} declaredModifiers+=N4ModifierWithoutConst* 'type' name=BindingIdentifier<Yield>?)
//TypeParameters? '=' declaredTypeRefNode=TypeReferenceNode
//TypeParameters? '=' declaredTypeRefNode=TypeReferenceNode Semi
public Group getGroup() { return cGroup; }

//=> ({N4TypeAliasDeclaration} declaredModifiers+=N4ModifierWithoutConst* 'type' name=BindingIdentifier<Yield>?)
Expand Down Expand Up @@ -8696,6 +8698,9 @@ public class N4TypeAliasDeclarationElements extends AbstractParserRuleElementFin

//TypeReferenceNode
public RuleCall getDeclaredTypeRefNodeTypeReferenceNodeParserRuleCall_3_0() { return cDeclaredTypeRefNodeTypeReferenceNodeParserRuleCall_3_0; }

//Semi
public RuleCall getSemiParserRuleCall_4() { return cSemiParserRuleCall_4; }
}
public class N4MemberDeclarationElements extends AbstractParserRuleElementFinder {
private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.n4js.N4JS.N4MemberDeclaration");
Expand Down Expand Up @@ -13702,7 +13707,8 @@ public ParserRule getN4EnumLiteralRule() {
// => ({N4TypeAliasDeclaration} declaredModifiers+=N4ModifierWithoutConst*
// 'type' name=BindingIdentifier<Yield>?) TypeParameters?
// '='
// declaredTypeRefNode=TypeReferenceNode;
// declaredTypeRefNode=TypeReferenceNode
// Semi;
public N4TypeAliasDeclarationElements getN4TypeAliasDeclarationAccess() {
return pN4TypeAliasDeclaration;
}
Expand Down
1 change: 1 addition & 0 deletions plugins/org.eclipse.n4js/src/org/eclipse/n4js/N4JS.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,7 @@ N4TypeAliasDeclaration <Yield>:
TypeParameters?
'='
declaredTypeRefNode=TypeReferenceNode
Semi
;


Expand Down

0 comments on commit a3635ac

Please sign in to comment.