Exemplo n.º 1
0
        internal LocationInfo GetLoc(Node node) {
            if (node == null || node.StartIndex >= node.EndIndex) {
                return null;
            }

            var start = node.GetStart(_ast);
            var end = node.GetEnd(_ast);
            return new LocationInfo(_filePath, start.Line, start.Column, end.Line, end.Column);
        }
Exemplo n.º 2
0
        private bool UpdateLineInfo(Node node, bool inheritCoverage = false) {
            if (node == null) {
                return false;
            }

            var start = node.GetStart(_ast);
            var end = node.GetEnd(_ast);
            bool covered;
            bool multiline = false;
            if (start.Line != end.Line) {
                multiline = true;
                // multi line statement, just figure out if we hit anywhere in it,
                // and if so update our coverage state.  We'll continue to descend
                // and mark the individual items that make up the multiple lines.
                bool isCovered = false;
                for (int i = start.Line; i <= end.Line; i++) {
                    isCovered |= IsCovered(i);
                }

                covered = isCovered;
            } else {
                // single line statement
                covered = MarkCoverage(inheritCoverage, start, end, IsCovered(start.Line));
            }

            if (_blockCovered == null) {
                _blockCovered = covered;
                if (covered) {
                    ReportCovered();
                } else {
                    ReportNotCovered();
                }
            }

            return multiline;
        }