private static IEnumerable<ISymbol> GetAllSymbolsWorker(SymbolKeyResolution resolution)
		{
			if (resolution.Symbol != null)
			{
				yield return resolution.Symbol;
			}

			foreach (var symbol in resolution.CandidateSymbols)
			{
				yield return symbol;
			}
		}
Beispiel #2
0
        internal static ISymbol?GetAnySymbol(this SymbolKeyResolution resolution)
        {
            if (resolution.Symbol != null)
            {
                return(resolution.Symbol);
            }

            if (resolution.CandidateSymbols.Length > 0)
            {
                return(resolution.CandidateSymbols[0]);
            }

            return(null);
        }
        private static Location?GetFirstSourceLocation(SymbolKeyResolution resolution)
        {
            foreach (var symbol in resolution)
            {
                foreach (var location in symbol.Locations)
                {
                    if (location.IsInSource)
                    {
                        return(location);
                    }
                }
            }

            return(null);
        }
Beispiel #4
0
        private ISymbol GetResolvedSymbol(SymbolKeyResolution resolution, TextSpan span)
        {
            if (resolution.CandidateReason == CandidateReason.Ambiguous)
            {
                // In order to produce to correct undo stack, completion lets the commit
                // character enter the buffer. That means we can get ambiguity.
                // partial class C { partial void goo() }
                // partial class C { partial goo($$
                // Committing with the open paren will create a second, ambiguous goo.
                // We'll try to prefer the symbol whose declaration doesn't intersect our position
                var nonIntersectingMember = resolution.CandidateSymbols.First(s => s.DeclaringSyntaxReferences.Any(d => !d.Span.IntersectsWith(span)));
                if (nonIntersectingMember != null)
                {
                    return nonIntersectingMember;
                }

                // The user has ambiguous definitions, just take the first one.
                return resolution.CandidateSymbols.First();
            }

            return resolution.Symbol;
        }
 internal Enumerator(SymbolKeyResolution symbolKeyResolution)
 {
     _symbolKeyResolution = symbolKeyResolution;
     _index = -1;
 }
 internal Enumerable(SymbolKeyResolution resolution)
 => _resolution = resolution;
        private ISymbol GetResolvedSymbol(SymbolKeyResolution resolution, TextSpan span)
        {
            if (resolution.CandidateReason == CandidateReason.Ambiguous)
            {
                // In order to produce to correct undo stack, completion lets the commit
                // character enter the buffer. That means we can get ambiguity.
                // partial class C { partial void foo() }
                // partial class C { partial foo($$
                // Committing with the open paren will create a second, ambiguous foo.
                // We'll try to prefer the symbol whose declaration doesn't intersect our position
                var nonIntersectingMember = resolution.CandidateSymbols.First(s => s.DeclaringSyntaxReferences.Any(d => !d.Span.IntersectsWith(span)));
                if (nonIntersectingMember != null)
                {
                    return nonIntersectingMember;
                }

                // The user has ambiguous definitions, just take the first one.
                return resolution.CandidateSymbols.First();
            }

            return resolution.Symbol;
        }