public override bool Walk(SuiteStatement node) { var prevSuite = _curSuite; _curSuite = node; // recursively walk the statements in the suite if (node.Statements != null) { foreach (var innerNode in node.Statements) { innerNode.Walk(this); } } _curSuite = prevSuite; // then check if we encountered an assert which added an isinstance scope. IsInstanceScope isInstanceScope = _scope as IsInstanceScope; if (isInstanceScope != null && isInstanceScope._effectiveSuite == node) { // pop the isinstance scope _scope = _scope.OuterScope; // transform back into a line number and start the new statement scope on the line // after the suite statement. var lineNo = _tree.IndexToLocation(node.EndIndex).Line; int offset; if (_tree.NewLineLocations.Length == 0) { // single line input offset = 0; } else { offset = lineNo < _tree.NewLineLocations.Length ? _tree.NewLineLocations[lineNo].EndIndex : _tree.NewLineLocations[_tree.NewLineLocations.Length - 1].EndIndex; } var closingScope = new StatementScope(offset, _scope); _scope.Children.Add(closingScope); _scope = closingScope; } return(false); }
public override bool Walk(SuiteStatement node) { var prevSuite = _curSuite; _curSuite = node; // recursively walk the statements in the suite if (node.Statements != null) { foreach (var innerNode in node.Statements) { innerNode.Walk(this); } } _curSuite = prevSuite; // then check if we encountered an assert which added an isinstance scope. IsInstanceScope isInstanceScope = _scope as IsInstanceScope; if (isInstanceScope != null && isInstanceScope._effectiveSuite == node) { // pop the isinstance scope _scope = _scope.OuterScope; // transform back into a line number and start the new statement scope on the line // after the suite statement. var lineNo = _tree.IndexToLocation(node.EndIndex).Line; int offset; if (_tree._lineLocations.Length == 0) { // single line input offset = 0; } else { offset = lineNo < _tree._lineLocations.Length ? _tree._lineLocations[lineNo].EndIndex : _tree._lineLocations[_tree._lineLocations.Length - 1].EndIndex; } var closingScope = new StatementScope(offset, _scope); _scope.Children.Add(closingScope); _scope = closingScope; } return false; }