internal ImmutableArray <Symbol> BindXmlNameAttribute(
            XmlNameAttributeSyntax syntax,
            ref CompoundUseSiteInfo <AssemblySymbol> useSiteInfo
            )
        {
            var identifier = syntax.Identifier;

            if (identifier.IsMissing)
            {
                return(ImmutableArray <Symbol> .Empty);
            }

            var name = identifier.Identifier.ValueText;

            var lookupResult = LookupResult.GetInstance();

            this.LookupSymbolsWithFallback(
                lookupResult,
                name,
                arity: 0,
                useSiteInfo: ref useSiteInfo
                );

            if (lookupResult.Kind == LookupResultKind.Empty)
            {
                lookupResult.Free();
                return(ImmutableArray <Symbol> .Empty);
            }

            // If we found something, it must be viable, since only parameters or type parameters
            // of the current member are considered.
            Debug.Assert(lookupResult.IsMultiViable);

            ArrayBuilder <Symbol> lookupSymbols = lookupResult.Symbols;

            Debug.Assert(
                lookupSymbols[0].Kind == SymbolKind.TypeParameter ||
                lookupSymbols[0].Kind == SymbolKind.Parameter
                );
            Debug.Assert(lookupSymbols.All(sym => sym.Kind == lookupSymbols[0].Kind));

            // We can sort later when we disambiguate.
            ImmutableArray <Symbol> result = lookupSymbols.ToImmutable();

            lookupResult.Free();

            return(result);
        }
Beispiel #2
0
        private static INavigateToSearchResult ConvertResult(
            DeclaredSymbolInfo declaredSymbolInfo, Document document,
            ArrayBuilder <PatternMatch> nameMatches, ArrayBuilder <PatternMatch> containerMatches)
        {
            var matchKind = GetNavigateToMatchKind(nameMatches);

            // A match is considered to be case sensitive if all its constituent pattern matches are
            // case sensitive.
            var isCaseSensitive = nameMatches.All(m => m.IsCaseSensitive) && containerMatches.All(m => m.IsCaseSensitive);
            var kind            = GetItemKind(declaredSymbolInfo);
            var navigableItem   = NavigableItemFactory.GetItemFromDeclaredSymbolInfo(declaredSymbolInfo, document);

            return(new SearchResult(
                       document, declaredSymbolInfo, kind, matchKind, isCaseSensitive, navigableItem,
                       nameMatches.SelectMany(m => m.MatchedSpans).ToImmutableArray()));
        }
        private static SearchResult ConvertResult(
            DeclaredSymbolInfo declaredSymbolInfo, Document document,
            ArrayBuilder <PatternMatch> nameMatches, ArrayBuilder <PatternMatch> containerMatches)
        {
            var matchKind = GetNavigateToMatchKind(nameMatches);

            // A match is considered to be case sensitive if all its constituent pattern matches are
            // case sensitive.
            var isCaseSensitive = nameMatches.All(m => m.IsCaseSensitive) && containerMatches.All(m => m.IsCaseSensitive);
            var kind            = GetItemKind(declaredSymbolInfo);
            var navigableItem   = NavigableItemFactory.GetItemFromDeclaredSymbolInfo(declaredSymbolInfo, document);

            var matchedSpans = ArrayBuilder <TextSpan> .GetInstance();

            foreach (var match in nameMatches)
            {
                matchedSpans.AddRange(match.MatchedSpans);
            }

            return(new SearchResult(
                       document, declaredSymbolInfo, kind, matchKind, isCaseSensitive, navigableItem,
                       matchedSpans.ToImmutableAndFree()));
        }
Beispiel #4
0
            private XNode[] RewriteMany(XNode[] nodes, string currentXmlFilePath, CSharpSyntaxNode originatingSyntax)
            {
                Debug.Assert(nodes != null);

                ArrayBuilder <XNode> builder = null;

                foreach (XNode child in nodes)
                {
                    if (builder == null)
                    {
                        builder = ArrayBuilder <XNode> .GetInstance();
                    }

                    builder.AddRange(Rewrite(child, currentXmlFilePath, originatingSyntax));
                }

                // Nodes returned by this method are going to be attached to a new parent, so it's
                // important that they don't already have parents.  If a node with a parent is
                // attached to a new parent, it is copied and its annotations are dropped.
                Debug.Assert(builder == null || builder.All(node => node.Parent == null));

                return(builder == null?Array.Empty <XNode>() : builder.ToArrayAndFree());
            }
Beispiel #5
0
        /// <summary>
        /// Return the set of display class instances that can be reached
        /// from the given local. A particular display class may be reachable
        /// from multiple locals. In those cases, the instance from the
        /// shortest path (fewest intermediate fields) is returned.
        /// </summary>
        private static int GetDisplayClassInstances(
            HashSet<NamedTypeSymbol> displayClassTypes,
            ArrayBuilder<DisplayClassInstanceAndFields> displayClassInstances,
            int depth)
        {
            Debug.Assert(displayClassInstances.All(p => p.Depth <= depth));

            var atDepth = ArrayBuilder<DisplayClassInstanceAndFields>.GetInstance();
            atDepth.AddRange(displayClassInstances.Where(p => p.Depth == depth));
            Debug.Assert(atDepth.Count > 0);

            int n = 0;
            foreach (var instance in atDepth)
            {
                n += GetDisplayClassInstances(displayClassTypes, displayClassInstances, instance);
            }

            atDepth.Free();
            return n;
        }