Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghuan committed Jan 7, 2019
1 parent 011a3b4 commit 303a468
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@
#*.RTF diff=astextplain


test/* linguist-vendored
test/**/*.lua linguist-vendored
2 changes: 1 addition & 1 deletion CSharp.lua/LuaAst/LuaLocalDeclarationStatementSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public sealed class LuaLocalDeclarationStatementSyntax : LuaStatementSyntax {
public LuaVariableDeclarationSyntax Declaration { get; }

public LuaLocalDeclarationStatementSyntax(LuaVariableDeclarationSyntax declaration) {
Declaration = declaration;
Declaration = declaration ?? throw new ArgumentNullException(nameof(declaration));
}

internal override void Render(LuaRenderer renderer) {
Expand Down
19 changes: 18 additions & 1 deletion CSharp.lua/LuaSyntaxNodeTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1772,10 +1772,27 @@ private void CheckPrevIsInvokeStatement(ExpressionSyntax node) {
for (int i = curBlock.Statements.Count - 1; i >= 0; --i) {
var statement = curBlock.Statements[i];
if (!(statement is LuaBlankLinesStatement) && !(statement is LuaCommentStatement)) {
bool hasInsertColon = false;
if (statement is LuaExpressionStatementSyntax expressionStatement) {
if (expressionStatement.Expression is LuaInvocationExpressionSyntax) {
curBlock.Statements.Add(LuaStatementSyntax.Colon);
hasInsertColon = true;
}
else if (expressionStatement.Expression is LuaAssignmentExpressionSyntax assignmentExpression) {
if (assignmentExpression.Right is LuaInvocationExpressionSyntax) {
hasInsertColon = true;
}
}
}
else if (statement is LuaLocalDeclarationStatementSyntax declarationStatement) {
if (declarationStatement.Declaration is LuaVariableListDeclarationSyntax variableList) {
var last = variableList.Variables.Last();
if (last.Initializer != null && last.Initializer.Value is LuaInvocationExpressionSyntax) {
hasInsertColon = true;
}
}
}
if (hasInsertColon) {
curBlock.Statements.Add(LuaStatementSyntax.Colon);
}
break;
}
Expand Down

0 comments on commit 303a468

Please sign in to comment.