예제 #1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="node">対象Node</param>
        /// <param name="semanticModel">対象ソースのsemanticModel</param>
        /// <param name="parent">親IAnalyzeItem</param>
        /// <param name="container">イベントコンテナ</param>
        public ItemForEach(ForEachStatementSyntax node, SemanticModel semanticModel, IAnalyzeItem parent, EventContainer container) : base(parent, node, semanticModel, container)
        {
            ItemType = ItemTypes.MethodStatement;

            var oparetion   = semanticModel.GetOperation(node) as IForEachLoopOperation;
            var localSymbol = oparetion.Locals.First();

            // ローカルの型設定
            IsVar = node.Type.IsVar;
            LocalTypes.AddRange(GetTypes(localSymbol.Type, semanticModel, node));

            // ローカル設定
            Local.Add(new Expression(localSymbol.Name, Expression.GetSymbolTypeName(localSymbol)));

            // コレクションの型設定
            var conversionOperation = oparetion.Collection as IConversionOperation;

            if (!(conversionOperation is null))
            {
                CollectionTypes.AddRange(GetTypes(conversionOperation.Operand.Type, semanticModel, node));
            }

            //コレクション
            Collection.AddRange(OperationFactory.GetExpressionList(oparetion.Collection.Children.First(), container));

            // 内部処理設定
            var block = node.Statement as BlockSyntax;

            foreach (var statement in block.Statements)
            {
                Members.Add(ItemFactory.Create(statement, semanticModel, container, this));
            }
        }