示例#1
0
                public void AddItem(INamedTypeSymbol symbol, string containingNamespace, bool isPublic)
                {
                    // We want to cache items with EditoBrowsableState == Advanced regardless of current "hide adv members" option value
                    var(isBrowsable, isEditorBrowsableStateAdvanced) = symbol.IsEditorBrowsableWithState(
                        hideAdvancedMembers: false,
                        _editorBrowsableInfo.Compilation,
                        _editorBrowsableInfo);

                    if (!isBrowsable)
                    {
                        // Hide this item from completion
                        return;
                    }

                    var isGeneric = symbol.Arity > 0;

                    // Need to determine if a type is an attribute up front since we want to filter out
                    // non-attribute types when in attribute context. We can't do this lazily since we don't hold
                    // on to symbols. However, the cost of calling `IsAttribute` on every top-level type symbols
                    // is prohibitively high, so we opt for the heuristic that would do the simple textual "Attribute"
                    // suffix check first, then the more expensive symbolic check. As a result, all unimported
                    // attribute types that don't have "Attribute" suffix would be filtered out when in attribute context.
                    var isAttribute = symbol.Name.HasAttributeSuffix(isCaseSensitive: false) && symbol.IsAttribute();

                    var item = ImportCompletionItem.Create(
                        symbol.Name,
                        symbol.Arity,
                        containingNamespace,
                        symbol.GetGlyph(),
                        _genericTypeSuffix,
                        CompletionItemFlags.CachedAndExpanded,
                        extensionMethodData: null);

                    _itemsBuilder.Add(new TypeImportCompletionItemInfo(item, isPublic, isGeneric, isAttribute, isEditorBrowsableStateAdvanced));
                }
示例#2
0
                public void AddItem(INamedTypeSymbol symbol, string containingNamespace, bool isPublic)
                {
                    var isGeneric = symbol.Arity > 0;

                    // Need to determine if a type is an attribute up front since we want to filter out
                    // non-attribute types when in attribute context. We can't do this lazily since we don't hold
                    // on to symbols. However, the cost of calling `IsAttribute` on every top-level type symbols
                    // is prohibitively high, so we opt for the heuristic that would do the simple textual "Attribute"
                    // suffix check first, then the more expensive symbolic check. As a result, all unimported
                    // attribute types that don't have "Attribute" suffix would be filtered out when in attribute context.
                    var isAttribute = symbol.Name.HasAttributeSuffix(isCaseSensitive: false) && symbol.IsAttribute();

                    var item = ImportCompletionItem.Create(symbol, containingNamespace, _genericTypeSuffix);

                    _itemsBuilder.Add(new TypeImportCompletionItemInfo(item, isPublic, isGeneric, isAttribute));
                }