Esempio n. 1
0
            protected async Task <Entry> TryCreateDocumentSpanEntryAsync(
                RoslynDefinitionBucket definitionBucket,
                DocumentSpan documentSpan,
                HighlightSpanKind spanKind,
                SymbolUsageInfo symbolUsageInfo,
                ImmutableDictionary <string, string> additionalProperties)
            {
                var document = documentSpan.Document;

                var(guid, projectName, sourceText) = await GetGuidAndProjectNameAndSourceTextAsync(document).ConfigureAwait(false);

                var(excerptResult, lineText) = await ExcerptAsync(sourceText, documentSpan).ConfigureAwait(false);

                var mappedDocumentSpan = await AbstractDocumentSpanEntry.TryMapAndGetFirstAsync(documentSpan, sourceText, CancellationToken).ConfigureAwait(false);

                if (mappedDocumentSpan == null)
                {
                    // this will be removed from the result
                    return(null);
                }

                return(new DocumentSpanEntry(
                           this, definitionBucket, spanKind, projectName,
                           guid, mappedDocumentSpan.Value, excerptResult, lineText, symbolUsageInfo, additionalProperties));
            }
Esempio n. 2
0
            private static void SetHighlightSpan(HighlightSpanKind spanKind, ITextBuffer textBuffer, TextSpan span)
            {
                // Create an appropriate highlight span on that buffer for the reference.
                var key = spanKind == HighlightSpanKind.Definition
                    ? PredefinedPreviewTaggerKeys.DefinitionHighlightingSpansKey
                    : spanKind == HighlightSpanKind.WrittenReference
                        ? PredefinedPreviewTaggerKeys.WrittenReferenceHighlightingSpansKey
                        : PredefinedPreviewTaggerKeys.ReferenceHighlightingSpansKey;

                textBuffer.Properties.RemoveProperty(key);
                textBuffer.Properties.AddProperty(key, new NormalizedSnapshotSpanCollection(span.ToSnapshotSpan(textBuffer.CurrentSnapshot)));
            }
Esempio n. 3
0
 public DocumentSpanEntry(
     AbstractTableDataSourceFindUsagesContext context,
     RoslynDefinitionBucket definitionBucket,
     DocumentSpan documentSpan,
     HighlightSpanKind spanKind,
     Guid projectGuid,
     SourceText sourceText,
     ClassifiedSpansAndHighlightSpan classifiedSpans)
     : base(context, definitionBucket, documentSpan, projectGuid, sourceText)
 {
     _spanKind = spanKind;
     _classifiedSpansAndHighlights = classifiedSpans;
 }
Esempio n. 4
0
            public static DocumentSpanEntry?TryCreate(
                AbstractTableDataSourceFindUsagesContext context,
                RoslynDefinitionBucket definitionBucket,
                DocumentSpan documentSpan,
                HighlightSpanKind spanKind,
                MappedSpanResult mappedSpanResult,
                ExcerptResult excerptResult,
                SourceText lineText,
                SymbolUsageInfo symbolUsageInfo,
                ImmutableDictionary <string, string> customColumnsData
                )
            {
                var document = documentSpan.Document;

                var(guid, projectName, projectFlavor) = GetGuidAndProjectInfo(document);
                var entry = new DocumentSpanEntry(
                    context,
                    definitionBucket,
                    projectName,
                    projectFlavor,
                    guid,
                    spanKind,
                    mappedSpanResult,
                    excerptResult,
                    lineText,
                    symbolUsageInfo,
                    customColumnsData
                    );

                // Because of things like linked files, we may have a reference up in multiple
                // different locations that are effectively at the exact same navigation location
                // for the user. i.e. they're the same file/span.  Showing multiple entries for these
                // is just noisy and gets worse and worse with shared projects and whatnot.  So, we
                // collapse things down to only show a single entry for each unique file/span pair.
                var winningEntry = definitionBucket.GetOrAddEntry(documentSpan, entry);

                // If we were the one that successfully added this entry to the bucket, then pass us
                // back out to be put in the ui.
                if (winningEntry == entry)
                {
                    return(entry);
                }

                // We were not the winner.  Add our flavor to the entry that already exists, but throw
                // away the item we created as we do not want to add it to the ui.
                winningEntry.AddFlavor(projectFlavor);
                return(null);
            }
Esempio n. 5
0
            protected async Task <Entry> CreateDocumentSpanEntryAsync(
                RoslynDefinitionBucket definitionBucket,
                DocumentSpan documentSpan,
                HighlightSpanKind spanKind)
            {
                var document = documentSpan.Document;

                var(guid, projectName, sourceText) = await GetGuidAndProjectNameAndSourceTextAsync(document).ConfigureAwait(false);

                var classifiedSpansAndHighlightSpan =
                    await ClassifiedSpansAndHighlightSpanFactory.ClassifyAsync(documentSpan, CancellationToken).ConfigureAwait(false);

                return(new DocumentSpanEntry(
                           this, definitionBucket, documentSpan, spanKind,
                           projectName, guid, sourceText, classifiedSpansAndHighlightSpan));
            }
            protected async Task <Entry> CreateDocumentSpanEntryAsync(
                RoslynDefinitionBucket definitionBucket,
                DocumentSpan documentSpan,
                HighlightSpanKind spanKind,
                ImmutableDictionary <string, ImmutableArray <string> > customColumnsDataOpt)
            {
                var document = documentSpan.Document;

                var(guid, projectName, sourceText) = await GetGuidAndProjectNameAndSourceTextAsync(document).ConfigureAwait(false);

                var classifiedSpansAndHighlightSpan =
                    await ClassifiedSpansAndHighlightSpanFactory.ClassifyAsync(documentSpan, CancellationToken).ConfigureAwait(false);

                return(new DocumentSpanEntry(
                           this, definitionBucket, documentSpan, spanKind,
                           projectName, guid, sourceText, classifiedSpansAndHighlightSpan, GetAggregatedCustomColumnsData(customColumnsDataOpt)));
            }
            protected async Task<Entry> CreateDocumentSpanEntryAsync(
                RoslynDefinitionBucket definitionBucket,
                DocumentSpan documentSpan,
                HighlightSpanKind spanKind)
            {
                var document = documentSpan.Document;
                var (guid, sourceText) = await GetGuidAndSourceTextAsync(document).ConfigureAwait(false);

                var narrowSpan = documentSpan.SourceSpan;
                var lineSpan = GetLineSpanForReference(sourceText, narrowSpan);

                var taggedLineParts = await GetTaggedTextForDocumentRegionAsync(document, narrowSpan, lineSpan).ConfigureAwait(false);

                return new DocumentSpanEntry(
                    this, definitionBucket, documentSpan, spanKind,
                    guid, sourceText, taggedLineParts);
            }
        static ReferenceUsageType ConvertKind(HighlightSpanKind kind)
        {
            switch (kind)
            {
            case HighlightSpanKind.Definition:
                return(ReferenceUsageType.Declaration);

            case HighlightSpanKind.Reference:
                return(ReferenceUsageType.Read);

            case HighlightSpanKind.WrittenReference:
                return(ReferenceUsageType.ReadWrite);

            default:
                return(ReferenceUsageType.Unknown);
            }
        }
Esempio n. 9
0
 public DocumentSpanEntry(
     AbstractTableDataSourceFindUsagesContext context,
     RoslynDefinitionBucket definitionBucket,
     HighlightSpanKind spanKind,
     string documentName,
     Guid projectGuid,
     MappedSpanResult mappedSpanResult,
     ExcerptResult excerptResult,
     SourceText lineText,
     ImmutableDictionary <string, string> customColumnsData)
     : base(context,
            definitionBucket,
            documentName,
            projectGuid,
            lineText,
            mappedSpanResult)
 {
     _spanKind          = spanKind;
     _excerptResult     = excerptResult;
     _customColumnsData = customColumnsData;
 }
Esempio n. 10
0
            private DocumentSpanEntry(
                AbstractTableDataSourceFindUsagesContext context,
                RoslynDefinitionBucket definitionBucket,
                string rawProjectName,
                string?projectFlavor,
                Guid projectGuid,
                HighlightSpanKind spanKind,
                MappedSpanResult mappedSpanResult,
                ExcerptResult excerptResult,
                SourceText lineText,
                SymbolUsageInfo symbolUsageInfo,
                ImmutableDictionary <string, string> customColumnsData)
                : base(context, definitionBucket, projectGuid, lineText, mappedSpanResult)
            {
                _spanKind             = spanKind;
                _excerptResult        = excerptResult;
                _symbolReferenceKinds = symbolUsageInfo.ToSymbolReferenceKinds();
                _customColumnsData    = customColumnsData;

                _rawProjectName = rawProjectName;
                this.AddFlavor(projectFlavor);
            }
 private async Task AddLocationSpan(Location location, Solution solution, HashSet<ValueTuple<Document, TextSpan>> spanSet, MultiDictionary<Document, HighlightSpan> tagList, HighlightSpanKind kind, CancellationToken cancellationToken)
 {
     var span = await GetLocationSpanAsync(solution, location, cancellationToken).ConfigureAwait(false);
     if (span != null && !spanSet.Contains(span.Value))
     {
         spanSet.Add(span.Value);
         tagList.Add(span.Value.Item1, new HighlightSpan(span.Value.Item2, kind));
     }
 }
Esempio n. 12
0
        private static async Task AddLocationSpan(Location location, Solution solution, HashSet <DocumentSpan> spanSet, MultiDictionary <Document, HighlightSpan> tagList, HighlightSpanKind kind, CancellationToken cancellationToken)
        {
            var span = await GetLocationSpanAsync(solution, location, cancellationToken).ConfigureAwait(false);

            if (span != null && !spanSet.Contains(span.Value))
            {
                spanSet.Add(span.Value);
                tagList.Add(span.Value.Document, new HighlightSpan(span.Value.SourceSpan, kind));
            }
        }
Esempio n. 13
0
 public HighlightSpan(TextSpan textSpan, HighlightSpanKind kind)
 {
     TextSpan = textSpan;
     Kind     = kind;
 }
Esempio n. 14
0
        public static LSP.DocumentHighlightKind HighlightSpanKindToDocumentHighlightKind(HighlightSpanKind kind)
        {
            switch (kind)
            {
            case HighlightSpanKind.Reference:
                return(LSP.DocumentHighlightKind.Read);

            case HighlightSpanKind.WrittenReference:
                return(LSP.DocumentHighlightKind.Write);

            default:
                return(LSP.DocumentHighlightKind.Text);
            }
        }
Esempio n. 15
0
 public HighlightSpan(TextSpan textSpan, HighlightSpanKind kind) : this()
 {
     this.TextSpan = textSpan;
     this.Kind     = kind;
 }
 public HighlightSpan(TextSpan textSpan, HighlightSpanKind kind) : this()
 {
     this.TextSpan = textSpan;
     this.Kind = kind;
 }