提交 6bae5406 编写于 作者: C Cyrus Najmabadi

Simplify stack.

上级 bb5f0b6a
......@@ -56,7 +56,7 @@ public void Analyze(SemanticModelAnalysisContext context, OptionSet optionSet)
// Use an actual stack object so that we don't blow the actual stack through recursion.
var root = syntaxTree.GetRoot(cancellationToken);
var stack = new Stack<SyntaxNodeOrToken>();
var stack = new Stack<SyntaxNode>();
stack.Push(root);
while (stack.Count != 0)
......@@ -64,18 +64,16 @@ public void Analyze(SemanticModelAnalysisContext context, OptionSet optionSet)
cancellationToken.ThrowIfCancellationRequested();
var current = stack.Pop();
if (current.IsNode)
foreach (var child in current.ChildNodesAndTokens())
{
var node = current.AsNode();
foreach (var child in node.ChildNodesAndTokens())
if (child.IsNode)
{
stack.Push(child);
stack.Push(child.AsNode());
}
else
{
AnalyzeToken(context, detector, child.AsToken(), cancellationToken);
}
}
else
{
AnalyzeToken(context, detector, current.AsToken(), cancellationToken);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册