Exemplo n.º 1
0
        private IEnumerable <IPackageIndexModelInfo> CollectTypeSuggestions(SyntaxNode node, IEnumerable <TargetFrameworkMetadata> distinctTargetFrameworks)
        {
            var potentialSuggestions = new List <IPackageIndexModelInfo>();

            if (_syntaxHelper.IsType(node))
            {
                var entityNamesToSearchFor = new List <string>();
                var entityName             = node.ToString().NormalizeGenericName();
                entityNamesToSearchFor.Add(entityName);

                if (_syntaxHelper.IsAttribute(node) && !entityName.EndsWith("Attribute"))
                {
                    entityNamesToSearchFor.Add(entityName + "Attribute");
                }

                foreach (var entity in entityNamesToSearchFor)
                {
                    var suggestions = _packageSearcher.SearchType(entity);
                    if (suggestions != null)
                    {
                        potentialSuggestions.AddRange(suggestions);
                    }
                }
            }

            if (potentialSuggestions == null || !potentialSuggestions.Any())
            {
                return(Enumerable.Empty <IPackageIndexModelInfo>());
            }

            return(TargetFrameworkHelper.GetSupportedPackages(potentialSuggestions,
                                                              distinctTargetFrameworks,
                                                              allowHigherVersions: true));
        }
Exemplo n.º 2
0
        private IEnumerable <IPackageIndexModelInfo> CollectNamespaceSuggestions(SyntaxNode node, IEnumerable <TargetFrameworkMetadata> distinctTargetFrameworks)
        {
            string entityName;
            IEnumerable <IPackageIndexModelInfo> potentialSuggestions = null;

            if (_syntaxHelper.IsImport(node, out entityName))
            {
                potentialSuggestions = _packageSearcher.SearchNamespace(entityName);
            }

            if (potentialSuggestions == null || !potentialSuggestions.Any())
            {
                return(Enumerable.Empty <IPackageIndexModelInfo>());
            }

            return(TargetFrameworkHelper.GetSupportedPackages(potentialSuggestions,
                                                              distinctTargetFrameworks,
                                                              allowHigherVersions: true));
        }
Exemplo n.º 3
0
        private IEnumerable <IPackageIndexModelInfo> CollectExtensionSuggestions(SyntaxNode node, IEnumerable <TargetFrameworkMetadata> distinctTargetFrameworks)
        {
            string entityName;
            IEnumerable <IPackageIndexModelInfo> potentialSuggestions = null;

            if (_syntaxHelper.IsExtension(node))
            {
                entityName = node.ToString().NormalizeGenericName();

                potentialSuggestions = _packageSearcher.SearchExtension(entityName);
            }

            if (potentialSuggestions == null || !potentialSuggestions.Any())
            {
                return(Enumerable.Empty <IPackageIndexModelInfo>());
            }

            return(TargetFrameworkHelper.GetSupportedPackages(potentialSuggestions,
                                                              distinctTargetFrameworks,
                                                              allowHigherVersions: true));
        }