示例#1
0
        private static LookupResult Resolve(IEnumerable <DeclarationReference> symbols, Package fromPackage)
        {
            var symbolsList = symbols.ToList();
            var visible     = symbolsList.Where(r => r.IsVisibleFrom(fromPackage)).ToList();

            if (visible.Count == 1)
            {
                return(LookupResult.Good(visible.Single()));
            }

            var visibleInPackage = visible.Where(r => r.IsIn(fromPackage)).ToList();

            if (visibleInPackage.Count == 1)
            {
                return(LookupResult.Good(visibleInPackage.Single()));                // TODO issue warning that we have chosen the one in the current package
            }
            if (visibleInPackage.Count > 1 || visible.Count > 1)
            {
                return(LookupResult.Ambiguous(visible));
            }

            // Nothing visible in package
            if (symbolsList.Count > 0)
            {
                return(LookupResult.NotAccessible(symbolsList));
            }

            return(LookupResult.NotDefined());
        }