private static IList <TChild> CreateConstraintList <TChild>(
            Node <GenericParameterDeclarationWithCodeAnalysis, GenericParameterDeclarationSyntax> node,
            Func <string, bool> filter,
            Func <UnspecifiedTypeReferenceWithCodeAnalysis, TChild> getChild)
            where TChild : class, IHasNode <TypeSyntax>, IUnspecifiedTypeReferenceWrapper
        {
            IChildSyntaxList <GenericParameterDeclarationSyntax, TypeParameterConstraintSyntax> constraintSyntaxList =
                ListFactory.CreateChildSyntaxList(
                    node,
                    syntax => syntax.Constraints,
                    (parentSyntax, childSyntax) => parentSyntax.WithConstraints(childSyntax));
            IChildSyntaxList <GenericParameterDeclarationSyntax, TypeConstraintSyntax> filteredConstraintSyntaxList =
                new FilteredChildSyntaxList <GenericParameterDeclarationSyntax, TypeParameterConstraintSyntax, TypeConstraintSyntax>(
                    constraintSyntaxList,
                    syntax => filter(syntax.Type.ToName()));
            IList <GenericParameterConstraint> constraintList = new ChildNodeList <
                GenericParameterDeclarationWithCodeAnalysis,
                GenericParameterDeclarationSyntax,
                GenericParameterConstraint,
                TypeConstraintSyntax>(
                node,
                filteredConstraintSyntaxList,
                () => new GenericParameterConstraint());

            return(new WrappedList <GenericParameterConstraint, TChild>(
                       constraintList,
                       parent => getChild(parent.Type),
                       child => child.Node.GetParent <GenericParameterConstraint>() ?? new GenericParameterConstraint(child.TypeReference)));
        }
 internal SolutionWithCodeAnalysis(Workspace workspace, Solution solution)
 {
     node     = new Node <SolutionWithCodeAnalysis, Solution>(this, solution);
     projects = new ChildNodeList <SolutionWithCodeAnalysis, Solution, ProjectWithCodeAnalysis, Project>(
         node,
         new ProjectSyntaxList(node),
         () => new ProjectWithCodeAnalysis());
 }
Esempio n. 3
0
 internal ProjectWithCodeAnalysis()
 {
     node      = new Node <ProjectWithCodeAnalysis, Project>(this);
     documents = new ChildNodeList <ProjectWithCodeAnalysis, Project, DocumentWithCodeAnalysis, Document>(
         node,
         new DocumentSyntaxList(node),
         () => new DocumentWithCodeAnalysis());
 }
        internal AttributeWithCodeAnalysis()
        {
            node          = new Node <AttributeWithCodeAnalysis, AttributeSyntax>(this);
            attributeType = new CachedChildNode <AttributeWithCodeAnalysis, AttributeSyntax, ClassReferenceWithCodeAnalysis, NameSyntax>(
                node,
                () => new ClassReferenceWithCodeAnalysis(new UnspecifiedTypeReferenceWithCodeAnalysis()),
                syntax => syntax.Name,
                (parentSyntax, childSyntax) => parentSyntax.WithName(childSyntax));
            SeparatedSyntaxList <AttributeArgumentSyntax> getArguments() =>
            node.Syntax.ArgumentList?.Arguments ?? SyntaxFactory.SeparatedList <AttributeArgumentSyntax>();

            namedValues = new ChildNodeList <AttributeWithCodeAnalysis, AttributeSyntax, NamedAttributeValueWithCodeAnalysis, AttributeArgumentSyntax>(
                node,
                new ImmutableAttributeArgumentListWrapper(getArguments, SetArguments, true),
                () => new NamedAttributeValueWithCodeAnalysis());
            unnamedValues = new ChildNodeList <AttributeWithCodeAnalysis, AttributeSyntax, UnnamedAttributeValueWithCodeAnalysis, AttributeArgumentSyntax>(
                node,
                new ImmutableAttributeArgumentListWrapper(getArguments, SetArguments, false),
                () => new UnnamedAttributeValueWithCodeAnalysis());
        }