예제 #1
0
        protected override CombinedSyntaxNode[] QueryTargetNodesFunc()
        {
            SyntaxNode?parent = this.BaseNode.Parent;

            parent = parent is LabeledStatementSyntax ? parent.Parent : parent;

            return(parent?.ChildNodes()
                   .Select(x => x is LabeledStatementSyntax label ? label.Statement : x)
                   .QueryVirtualAndCombine(VirtualQueryExtensions.GetAllSupportedQueries())
                   .Where(x =>
                          // all known types should have more narrowed states
                          // (child of StatementSyntax) that is why we have to
                          // exclude them. All not implemented statements will
                          // use this state instead
                          !LocalContext.IsKnownNodeType(x) &&
                          MethodBodyMemberSyntaxNodeMatcher.Instance.Match(x))
                   .ToArray()
                   ?? throw new InvalidOperationException(
                       $"Unable to query the target nodes for {nameof(StatementState)}"));
        }
        protected override CombinedSyntaxNode[] QueryTargetsProtected(CombinedSyntaxNode root)
        {
            if (root.MixedNode is IfConditionSyntax condition)
            {
                return(new CombinedSyntaxNode[]
                {
                    condition.Expression.QueryVirtualAndCombine(
                        NestedBlockVirtualQuery.Instance)
                });
            }

            return(root.BaseNode
                   ?.ChildNodes()
                   .QueryVirtualAndCombine(VirtualQueryExtensions.GetAllSupportedQueries())
                   .Where(MethodBodyMemberSyntaxNodeMatcher.Instance.Match)
                   .GroupBy(x => x.MixedNode.GetType())
                   .Select(x => x.First())
                   .ToArray()
                   ?? Array.Empty <CombinedSyntaxNode>());
        }