Esempio n. 1
0
        /// <summary>
        /// Gets all concept instances directly declared in a container.
        /// </summary>
        /// <param name="container">
        /// The container to visit.
        /// </param>
        /// <param name="instances">
        /// The instance array to populate.
        /// </param>
        /// <param name="originalBinder">
        /// The call-site binder.
        /// </param>
        /// <param name="useSiteDiagnostics">
        /// The set of use-site diagnostics to populate with any errors.
        /// </param>
        /// <param name="options">
        /// The concept look-up options to use.
        /// </param>
        private void GetConceptInstancesInContainer(NamespaceOrTypeSymbol container, ArrayBuilder <TypeSymbol> instances, Binder originalBinder, ref HashSet <DiagnosticInfo> useSiteDiagnostics, ConceptSearchOptions options)
        {
            Debug.Assert(container != null, "container being searched should not be null: this should have been checked earlier");

            foreach (var member in container.GetTypeMembers())
            {
                if (!originalBinder.IsAccessible(member, ref useSiteDiagnostics, originalBinder.ContainingType))
                {
                    continue;
                }

                // Assuming that instances don't contain sub-instances.
                if (member.IsInstance)
                {
                    instances.Add(member);
                }
                // We don't usually go into nested instances, but make an
                // exception for the inline instance struct of a class, if any.
                // This is because there would be no other way to get to it.
                else if (!member.IsConcept)
                {
                    var inline = member.GetInlineInstanceStruct();
                    if (inline != null)
                    {
                        instances.Add(inline);
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets all concept instances directly declared in a container.
        /// </summary>
        /// <param name="container">
        /// The container to visit.
        /// </param>
        /// <param name="instances">
        /// The instance array to populate.
        /// </param>
        /// <param name="originalBinder">
        /// The call-site binder.
        /// </param>
        /// <param name="useSiteDiagnostics">
        /// The set of use-site diagnostics to populate with any errors.
        /// </param>
        private void GetConceptInstancesInContainer(NamespaceOrTypeSymbol container, ArrayBuilder <TypeSymbol> instances, Binder originalBinder, ref HashSet <DiagnosticInfo> useSiteDiagnostics)
        {
            foreach (var member in container.GetTypeMembers())
            {
                if (!originalBinder.IsAccessible(member, ref useSiteDiagnostics, originalBinder.ContainingType))
                {
                    continue;
                }

                // Assuming that instances don't contain sub-instances.
                if (member.IsInstance)
                {
                    instances.Add(member);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Gets all concepts directly declared in a container.
        /// </summary>
        /// <param name="container">
        /// The container to visit.
        /// </param>
        /// <param name="concepts">
        /// The instance array to populate.
        /// </param>
        /// <param name="originalBinder">
        /// The call-site binder.
        /// </param>
        /// <param name="useSiteDiagnostics">
        /// The set of use-site diagnostics to populate with any errors.
        /// </param>
        /// <param name="options">
        /// The concept look-up options to use.
        /// </param>
        private void GetConceptsInContainer(NamespaceOrTypeSymbol container, ArrayBuilder <NamedTypeSymbol> concepts, Binder originalBinder, ref HashSet <DiagnosticInfo> useSiteDiagnostics, ConceptSearchOptions options)
        {
            Debug.Assert(container != null, "container being searched should not be null: this should have been checked earlier");
            var useStandaloneInstances = (options & ConceptSearchOptions.AllowStandaloneInstances) != 0;

            foreach (var member in container.GetTypeMembers())
            {
                if (!originalBinder.IsAccessible(member, ref useSiteDiagnostics, originalBinder.ContainingType))
                {
                    continue;
                }

                // Concepts can declare sub-concepts, but (for now) we don't
                // consider them.
                if (member.IsConcept || (useStandaloneInstances && member.IsStandaloneInstance))
                {
                    concepts.Add(member);
                }
            }
        }
Esempio n. 4
0
 public static NamedTypeSymbol GetTypeMember(this NamespaceOrTypeSymbol symbol, string name)
 {
     return(symbol.GetTypeMembers(name).Single());
 }