private Moniker?TryCreateMonikerVertexForSymbol(ISymbol symbol)
        {
            var moniker = SymbolMoniker.TryCreate(symbol);

            if (moniker == null)
            {
                return(null);
            }

            string?kind;

            if (symbol.Kind == SymbolKind.Namespace)
            {
                kind = null;
            }
            else if (symbol.ContainingAssembly.Equals(_sourceCompilation.Assembly))
            {
                kind = "export";
            }
            else
            {
                kind = "import";
            }

            return(new Moniker(moniker.Scheme, moniker.Identifier, kind, _idFactory));
        }
        private static async Task FindSymbolMonikerReferencesAsync(
            IFindSymbolMonikerUsagesService monikerUsagesService,
            ISymbol definition,
            IFindUsagesContext context,
            CancellationToken cancellationToken)
        {
            var moniker = SymbolMoniker.TryCreate(definition);

            if (moniker == null)
            {
                return;
            }

            // Let the find-refs window know we have outstanding work
            await using var _ = await context.ProgressTracker.AddSingleItemAsync().ConfigureAwait(false);

            var displayParts = GetDisplayParts(definition).AddRange(new[]
            {
                new TaggedText(TextTags.Space, " "),
                new TaggedText(TextTags.Text, EditorFeaturesResources.external),
            });

            var definitionItem = DefinitionItem.CreateNonNavigableItem(
                tags: GlyphTags.GetTags(definition.GetGlyph()),
                displayParts,
                originationParts: DefinitionItem.GetOriginationParts(definition));

            var monikers = ImmutableArray.Create(moniker);

            var first = true;

            await foreach (var referenceItem in monikerUsagesService.FindReferencesByMoniker(
                               definitionItem, monikers, context.ProgressTracker, cancellationToken))
            {
                if (first)
                {
                    // found some results.  Add the definition item to the context.
                    first = false;
                    await context.OnDefinitionFoundAsync(definitionItem).ConfigureAwait(false);
                }

                await context.OnExternalReferenceFoundAsync(referenceItem).ConfigureAwait(false);
            }
        }
Exemplo n.º 3
0
 public MonikerWrapper(SymbolMoniker moniker)
 => _moniker = moniker;
Exemplo n.º 4
0
 public virtual IAsyncEnumerable <DefinitionItem> FindImplementationsByMoniker(SymbolMoniker moniker, IStreamingProgressTracker progress, CancellationToken cancellationToken)
 => EmptyAsyncEnumerable <DefinitionItem> .Instance;
 public virtual IAsyncEnumerable <DefinitionItem> FindImplementationsByMoniker(SymbolMoniker moniker, CancellationToken cancellationToken)
 => EmptyAsyncEnumerable <DefinitionItem> .Instance;