Skip to content

Commit

Permalink
Merge pull request #10 from eNeRGy164/feature/return-statements
Browse files Browse the repository at this point in the history
Add support for return statements.
  • Loading branch information
eNeRGy164 authored Jan 7, 2020
2 parents 3fa2ef3 + 941b1a4 commit 421ae08
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/LivingDocumentation.Analyzer/Analyzers/InvocationsAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,8 @@ public override void VisitInvocationExpression(InvocationExpressionSyntax node)
methodName = i.Identifier.ValueText;
break;
}
if (methodName == "Fire")
{

}
var invocation = new InvocationDescription(containingType, methodName);
var invocation = new InvocationDescription(containingType, methodName);
this.statements.Add(invocation);

foreach (var argument in node.ArgumentList.Arguments)
Expand All @@ -111,5 +108,21 @@ public override void VisitInvocationExpression(InvocationExpressionSyntax node)

base.VisitInvocationExpression(node);
}

public override void VisitReturnStatement(ReturnStatementSyntax node)
{
var returnDescription = new ReturnDescription(node.Expression?.ToString() ?? string.Empty);
this.statements.Add(returnDescription);

base.VisitReturnStatement(node);
}

public override void VisitArrowExpressionClause(ArrowExpressionClauseSyntax node)
{
var returnDescription = new ReturnDescription(node.Expression.ToString());
this.statements.Add(returnDescription);

base.VisitArrowExpressionClause(node);
}
}
}
18 changes: 18 additions & 0 deletions src/LivingDocumentation.Descriptions/ReturnDescription.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Diagnostics;

namespace LivingDocumentation
{
[DebuggerDisplay("Return {Expression}")]
public class ReturnDescription : Statement
{
public string Expression
{
get;
}

public ReturnDescription(string expression)
{
this.Expression = expression;
}
}
}

0 comments on commit 421ae08

Please sign in to comment.