Exemplo n.º 1
0
            private async Task CreateNoResultsFoundEntryIfNecessaryAsync()
            {
                string message;

                lock (Gate)
                {
                    // If we got definitions, then no need to show the 'no results found' message.
                    if (this.Definitions.Count > 0)
                    {
                        return;
                    }

                    message = NoDefinitionsFoundMessage;
                }

                var definitionBucket = GetOrCreateDefinitionBucket(CreateNoResultsDefinitionItem(message), expandedByDefault: true);
                var entry            = await SimpleMessageEntry.CreateAsync(definitionBucket, navigationBucket : null, message).ConfigureAwait(false);

                lock (Gate)
                {
                    EntriesWhenGroupingByDefinition    = EntriesWhenGroupingByDefinition.Add(entry);
                    EntriesWhenNotGroupingByDefinition = EntriesWhenNotGroupingByDefinition.Add(entry);
                    CurrentVersionNumber++;
                }

                NotifyChange();
            }
            protected override async Task OnDefinitionFoundWorkerAsync(DefinitionItem definition)
            {
                var definitionBucket = GetOrCreateDefinitionBucket(definition);

                var entries = ArrayBuilder <Entry> .GetInstance();

                if (definition.SourceSpans.Length == 1)
                {
                    // If we only have a single location, then use the DisplayParts of the
                    // definition as what to show.  That way we show enough information for things
                    // methods.  i.e. we'll show "void TypeName.MethodName(args...)" allowing
                    // the user to see the type the method was created in.
                    var entry = await TryCreateEntryAsync(definitionBucket, definition).ConfigureAwait(false);

                    entries.AddIfNotNull(entry);
                }
                else if (definition.SourceSpans.Length == 0)
                {
                    // No source spans means metadata references.
                    // Display it for Go to Base and try to navigate to metadata.
                    entries.Add(new MetadataDefinitionItemEntry(this, definitionBucket));
                }
                else
                {
                    // If we have multiple spans (i.e. for partial types), then create a
                    // DocumentSpanEntry for each.  That way we can easily see the source
                    // code where each location is to help the user decide which they want
                    // to navigate to.
                    foreach (var sourceSpan in definition.SourceSpans)
                    {
                        var entry = await TryCreateDocumentSpanEntryAsync(
                            definitionBucket,
                            sourceSpan,
                            HighlightSpanKind.Definition,
                            symbolUsageInfo : SymbolUsageInfo.None,
                            additionalProperties : definition.DisplayableProperties)
                                    .ConfigureAwait(false);

                        entries.AddIfNotNull(entry);
                    }
                }

                if (entries.Count > 0)
                {
                    lock (Gate)
                    {
                        EntriesWhenGroupingByDefinition    = EntriesWhenGroupingByDefinition.AddRange(entries);
                        EntriesWhenNotGroupingByDefinition = EntriesWhenNotGroupingByDefinition.AddRange(entries);
                    }

                    NotifyChange();
                }

                entries.Free();
            }
Exemplo n.º 3
0
            private async ValueTask OnEntryFoundAsync(
                DefinitionItem definition,
                Func <RoslynDefinitionBucket, Task <Entry?> > createEntryAsync,
                bool addToEntriesWhenGroupingByDefinition,
                bool addToEntriesWhenNotGroupingByDefinition,
                bool expandedByDefault = true
                )
            {
                Debug.Assert(
                    addToEntriesWhenGroupingByDefinition || addToEntriesWhenNotGroupingByDefinition
                    );
                CancellationToken.ThrowIfCancellationRequested();

                // OK, we got a *reference* to some definition item.  This may have been a reference for some definition
                // that we haven't created any declaration entries for (i.e. because it had DisplayIfNoReferences =
                // false).  Because we've now found a reference, we want to make sure all its declaration entries are
                // added.
                await AddDeclarationEntriesAsync(definition, expandedByDefault)
                .ConfigureAwait(false);

                // First find the bucket corresponding to our definition.
                var definitionBucket = GetOrCreateDefinitionBucket(definition, expandedByDefault);
                var entry            = await createEntryAsync(definitionBucket).ConfigureAwait(false);

                // Proceed, even if we didn't create an entry.  It's possible that we augmented
                // an existing entry and we want the UI to refresh to show the results of that.

                lock (Gate)
                {
                    if (entry != null)
                    {
                        // Once we can make the new entry, add it to the appropriate list.
                        if (addToEntriesWhenGroupingByDefinition)
                        {
                            EntriesWhenGroupingByDefinition = EntriesWhenGroupingByDefinition.Add(
                                entry
                                );
                        }

                        if (addToEntriesWhenNotGroupingByDefinition)
                        {
                            EntriesWhenNotGroupingByDefinition =
                                EntriesWhenNotGroupingByDefinition.Add(entry);
                        }
                    }

                    CurrentVersionNumber++;
                }

                // Let all our subscriptions know that we've updated.
                NotifyChange();
            }
Exemplo n.º 4
0
            protected async Task OnEntryFoundAsync(
                DefinitionItem definition,
                Func <RoslynDefinitionBucket, Task <Entry> > createEntryAsync,
                bool addToEntriesWhenGroupingByDefinition,
                bool addToEntriesWhenNotGroupingByDefinition)
            {
                Debug.Assert(addToEntriesWhenGroupingByDefinition || addToEntriesWhenNotGroupingByDefinition);
                CancellationToken.ThrowIfCancellationRequested();

                // OK, we got a *reference* to some definition item.  This may have been
                // a reference for some definition that we haven't created any declaration
                // entries for (i.e. because it had DisplayIfNoReferences = false).  Because
                // we've now found a reference, we want to make sure all its declaration
                // entries are added.
                await AddDeclarationEntriesAsync(definition).ConfigureAwait(false);

                // First find the bucket corresponding to our definition.
                var definitionBucket = GetOrCreateDefinitionBucket(definition);
                var entry            = await createEntryAsync(definitionBucket).ConfigureAwait(false);

                if (entry == null)
                {
                    return;
                }

                lock (Gate)
                {
                    // Once we can make the new entry, add it to the appropriate list.
                    if (addToEntriesWhenGroupingByDefinition)
                    {
                        EntriesWhenGroupingByDefinition = EntriesWhenGroupingByDefinition.Add(entry);
                    }

                    if (addToEntriesWhenNotGroupingByDefinition)
                    {
                        EntriesWhenNotGroupingByDefinition = EntriesWhenNotGroupingByDefinition.Add(entry);
                    }

                    CurrentVersionNumber++;
                }

                // Let all our subscriptions know that we've updated.
                NotifyChange();
            }
            protected override async Task OnDefinitionFoundWorkerAsync(DefinitionItem definition)
            {
                var definitionBucket = GetOrCreateDefinitionBucket(definition);

                var entries = ArrayBuilder <Entry> .GetInstance();

                if (definition.SourceSpans.Length == 1)
                {
                    // If we only have a single location, then use the DisplayParts of the
                    // definition as what to show.  That way we show enough information for things
                    // methods.  i.e. we'll show "void TypeName.MethodName(args...)" allowing
                    // the user to see the type the method was created in.
                    var entry = await CreateEntryAsync(definitionBucket, definition).ConfigureAwait(false);

                    entries.Add(entry);
                }
                else
                {
                    // If we have multiple spans (i.e. for partial types), then create a
                    // DocumentSpanEntry for each.  That way we can easily see the source
                    // code where each location is to help the user decide which they want
                    // to navigate to.
                    foreach (var sourceSpan in definition.SourceSpans)
                    {
                        var entry = await CreateDocumentSpanEntryAsync(
                            definitionBucket, sourceSpan, isDefinitionLocation : true).ConfigureAwait(false);

                        entries.Add(entry);
                    }
                }

                if (entries.Count > 0)
                {
                    lock (Gate)
                    {
                        EntriesWhenGroupingByDefinition    = EntriesWhenGroupingByDefinition.AddRange(entries);
                        EntriesWhenNotGroupingByDefinition = EntriesWhenNotGroupingByDefinition.AddRange(entries);
                    }

                    NotifyChange();
                }

                entries.Free();
            }