public CoverageElementGroup(
     CoverageElement parentElement,
     IList <CoverageElement> targets)
 {
     ParentElement = parentElement;
     Targets       = targets;
 }
 private static void InsertIntoVariableInitializer(
         CoverageInfo info, XElement root, LanguageSupport support, string relativePath) {
     var statemetIndex = info.Targets.Count;
     var nodes = support.AstAnalyzer.FindVariableInitializers(root);
     foreach (var node in nodes.ToList()) {
         // ステートメントに測定用コードを埋め込む
         support.AstTransformer.InsertInitializer(node, info.Targets.Count,
                 ElementType.Statement);
         // カバレッジ情報を生成
         var covElem = new CoverageElement(relativePath, node, support.Tagger);
         info.Targets.Add(covElem);
     }
     info.StatementRanges.Add(Tuple.Create(statemetIndex, info.Targets.Count));
 }
        private static List<CoverageElement> InsertIntoConditionAndComparison(
                CoverageInfo info, ICollection<XElement> condNodeList, LanguageSupport support,
                string relativePath) {
            return condNodeList.SelectToList(
                    node => {
                        var elemsAndType = support.AstAnalyzer.GetComparedElements(node);
                        if (elemsAndType != null) {
                            var leftElement = elemsAndType.Item1;
                            var rightElement = elemsAndType.Item2;
                            var type = elemsAndType.Item3;
                            switch (type) {
                            case ComparatorType.Equal:
                                support.AstTransformer.InsertEqual(node, leftElement, rightElement,
                                        info.Targets.Count, ElementType.Condition);
                                break;
                            case ComparatorType.NotEqual:
                                support.AstTransformer.InsertNotEqual(node, leftElement,
                                        rightElement, info.Targets.Count, ElementType.Condition);
                                break;
                            case ComparatorType.LessThan:
                                support.AstTransformer.InsertLessThan(node, leftElement,
                                        rightElement, info.Targets.Count, ElementType.Condition);
                                break;
                            case ComparatorType.GraterThan:
                                support.AstTransformer.InsertGraterThan(node, leftElement,
                                        rightElement, info.Targets.Count, ElementType.Condition);
                                break;
                            default:
                                throw new ArgumentOutOfRangeException();
                            }
                        } else {
                            support.AstTransformer.InsertPredicate(node, info.Targets.Count,
                                    ElementType.Condition);
                        }

                        var covElem = new CoverageElement(relativePath, node, support.Tagger);
                        info.Targets.Add(covElem);
                        return covElem;
                    });
        }
        private static List<CoverageElement> InsertIntoConditionCoverage(
                CoverageInfo info, ICollection<XElement> condNodeList, LanguageSupport support,
                string relativePath) {
            return condNodeList.SelectToList(
                    node => {
                        support.AstTransformer.InsertPredicate(node, info.Targets.Count,
                                ElementType.Condition);

                        var covElem = new CoverageElement(relativePath, node, support.Tagger);
                        info.Targets.Add(covElem);
                        return covElem;
                    });
        }
        private static void InsertIntoBranch(
                CoverageInfo info, XElement node, LanguageSupport support, string relativePath) {
            var branchNodes = support.AstAnalyzer.FindBranches(node);
            var startBranchIndex = info.Targets.Count;
            foreach (var branchNode in branchNodes.ToList()) {
                support.AstTransformer.InsertPredicate(branchNode, info.Targets.Count,
                        ElementType.Decision);

                // 条件分岐のカバレッジ情報を生成
                var element = new CoverageElement(relativePath, branchNode, support.Tagger);
                info.Targets.Add(element);
            }
            info.BranchRanges.Add(Tuple.Create(startBranchIndex, info.Targets.Count));
        }
        private static void InsertIntoBnrachAndComparison(
                CoverageInfo info, XElement root, LanguageSupport support, string relativePath) {
            var analyzer = support.AstAnalyzer;
            var branchNodes = analyzer.FindBranches(root);
            var startBranchIndex = info.Targets.Count;
            var startBranchConditionIndex = info.TargetGroups.Count;
            foreach (var branchNode in branchNodes.ToList()) {
                // 全ての論理項を列挙
                var condNodeList = analyzer.FindConditions(branchNode).ToList();
                // 論理項に測定用コードを埋め込み,カバレッジ情報を生成
                var condElements = InsertIntoConditionCoverage(info, condNodeList, support,
                        relativePath);

                // 条件分岐のカバレッジ情報を生成
                var element = new CoverageElement(relativePath, branchNode, support.Tagger);
                // 条件分岐と論理項のカバレッジ情報をまとめる
                var elementGroup = new CoverageElementGroup(element, condElements);
                info.TargetGroups.Add(elementGroup);

                // 論理項を含む条件式か否かを判断
                support.AstTransformer.InsertPredicate(
                        branchNode, info.Targets.Count,
                        elementGroup.Targets.Count > 0
                                ? ElementType.Decision
                                : ElementType.DecisionAndCondition);
                info.Targets.Add(element);
            }
            info.BranchConditionRanges.Add(Tuple.Create(startBranchConditionIndex,
                    info.TargetGroups.Count));
            info.BranchRanges.Add(Tuple.Create(startBranchIndex, info.Targets.Count));
        }
 private static void InsertIntoSwitchCase(
         CoverageInfo info, XElement node, LanguageSupport support, string relativePath) {
     var analyzer = support.AstAnalyzer;
     var startSwitchIndex = info.TargetGroups.Count;
     var switchNodes = analyzer.FindSwitches(node);
     foreach (var switchNode in switchNodes.ToList()) {
         var caseElements = new List<CoverageElement>();
         var caseNodes = analyzer.FindCaseLabelTails(switchNode);
         foreach (var caseNode in caseNodes.ToList()) {
             // ステートメントに測定用コードを埋め込む
             support.AstTransformer.InsertStatementAfter(
                     caseNode, info.Targets.Count, Done, ElementType.SwitchCase);
             // カバレッジ情報を生成
             var covElem = new CoverageElement(relativePath, caseNode, support.Tagger);
             info.Targets.Add(covElem);
             caseElements.Add(covElem);
         }
         // switchのカバレッジ情報を生成
         var element = new CoverageElement(relativePath, switchNode, support.Tagger);
         // 条件分岐と論理項のカバレッジ情報をまとめる
         var elementGroup = new CoverageElementGroup(element, caseElements);
         info.TargetGroups.Add(elementGroup);
     }
     info.SwitchRanges.Add(Tuple.Create(startSwitchIndex, info.TargetGroups.Count));
 }
 private static void InsertIntoStatement(
         CoverageInfo info, XElement root, LanguageSupport support, string relativePath) {
     var statemetIndex = info.Targets.Count;
     var nodes = support.AstAnalyzer.FindStatements(root);
     foreach (var node in nodes.ToList()) {
         // ステートメントに測定用コードを埋め込む
         var posNode = support.AstAnalyzer.GetBaseElementForStatement(node);
         support.AstTransformer.InsertStatementBefore(
                 posNode, info.Targets.Count, Done, ElementType.Statement);
         // カバレッジ情報を生成
         var covElem = new CoverageElement(relativePath, node, support.Tagger);
         info.Targets.Add(covElem);
     }
     info.StatementRanges.Add(Tuple.Create(statemetIndex, info.Targets.Count));
 }
		public void Execute(CoverageElement lastElement, CoverageState state) {}
		public CoverageElementGroup(
				CoverageElement parentElement,
				IList<CoverageElement> targets) {
			ParentElement = parentElement;
			Targets = targets;
		}
		/// <summary>
		///   Initializes a instance for one coverage element. For example,
		/// </summary>
		/// <param name="parentElement"> </param>
		public CoverageElementGroup(CoverageElement parentElement) {
			ParentElement = parentElement;
			Targets = new List<CoverageElement>();
		}
 public void Execute(CoverageElement lastElement, CoverageState state)
 {
 }
 /// <summary>
 ///   Initializes a instance for one coverage element. For example,
 /// </summary>
 /// <param name="parentElement"> </param>
 public CoverageElementGroup(CoverageElement parentElement)
 {
     ParentElement = parentElement;
     Targets       = new List <CoverageElement>();
 }