public static async Task <ClassifiedSpansAndHighlightSpan> ClassifyAsync( DocumentSpan documentSpan, CancellationToken cancellationToken ) { // If the document span is providing us with the classified spans up front, then we // can just use that. Otherwise, go back and actually classify the text for the line // the document span is on. if ( documentSpan.Properties != null && documentSpan.Properties.TryGetValue( ClassifiedSpansAndHighlightSpan.Key, out var value ) ) { return((ClassifiedSpansAndHighlightSpan)value); } return(await ClassifyAsync( documentSpan.Document, documentSpan.SourceSpan, cancellationToken ) .ConfigureAwait(false)); }
private async Task <Entry> CreateDocumentLocationEntryAsync( RoslynDefinitionBucket definitionBucket, DocumentSpan documentSpan, bool isDefinitionLocation, CancellationToken cancellationToken) { var document = documentSpan.Document; // The FAR system needs to know the guid for the project that a def/reference is // from. So we only support this for documents from a VSWorkspace. var workspace = document.Project.Solution.Workspace as VisualStudioWorkspaceImpl; if (workspace == null) { return(null); } var projectGuid = workspace.GetHostProject(document.Project.Id)?.Guid; if (projectGuid == null) { return(null); } var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); var referenceSpan = documentSpan.SourceSpan; var lineSpan = GetLineSpanForReference(sourceText, referenceSpan); var taggedLineParts = await GetTaggedTextForReferenceAsync(document, referenceSpan, lineSpan, cancellationToken).ConfigureAwait(false); return(new DocumentSpanEntry( this, workspace, definitionBucket, documentSpan, isDefinitionLocation, projectGuid.Value, sourceText, taggedLineParts)); }
void UpdateParagraphListStyleState(DocumentSpan documentSpan) { string listStyleId = RichTextEditor.Document.GetCommonParagraphListStyle(documentSpan); UpdateToggleButton(_bulletsButton, _bulletsButton.Tag.ToString() == listStyleId); UpdateToggleButton(_numbersButton, _numbersButton.Tag.ToString() == listStyleId); }
private void UpdateAlignment(DocumentSpan docSpan) { ParagraphSettings pSettings = RichTextEditor.Document.GetCommonParagraphSettings(docSpan); if (pSettings.ParagraphAlignment.HasValue) { var alignment = pSettings.ParagraphAlignment.Value; switch (alignment) { case ParagraphAlignment.Start: { UpdateToggleButton(_alignLeft, true); break; } case ParagraphAlignment.Center: { UpdateToggleButton(_alignCenter, true); break; } case ParagraphAlignment.End: { UpdateToggleButton(_alignRight, true); break; } case ParagraphAlignment.Justify: { UpdateToggleButton(_alignJustify, true); break; } } } }
public SourceReferenceItem(DefinitionItem definition, DocumentSpan sourceSpan, bool isWrittenTo) { Definition = definition; SourceSpan = sourceSpan; IsWrittenTo = isWrittenTo; ReferenceInfo = ReferenceInfoMap.Empty; }
private async Task <Entry> CreateDocumentLocationEntryAsync( RoslynDefinitionBucket definitionBucket, DocumentSpan documentSpan, bool isDefinitionLocation) { var document = documentSpan.Document; // The FAR system needs to know the guid for the project that a def/reference is // from (to support features like filtering). Normally that would mean we could // only support this from a VisualStudioWorkspace. However, we want till work // in cases lke Any-Code (which does not use a VSWorkspace). So we are tolerant // when we have another type of workspace. This means we will show results, but // certain features (like filtering) may not work in that context. var workspace = document.Project.Solution.Workspace as VisualStudioWorkspaceImpl; var guid = workspace?.GetHostProject(document.Project.Id)?.Guid ?? Guid.Empty; var sourceText = await document.GetTextAsync(CancellationToken).ConfigureAwait(false); var referenceSpan = documentSpan.SourceSpan; var lineSpan = GetLineSpanForReference(sourceText, referenceSpan); var taggedLineParts = await GetTaggedTextForReferenceAsync(document, referenceSpan, lineSpan).ConfigureAwait(false); return(new DocumentSpanEntry( this, definitionBucket, documentSpan, isDefinitionLocation, guid, sourceText, taggedLineParts)); }
static async Task <ClassifiedTextElement?> ComputeTextAsync( int id, int?definitionId, DocumentSpan documentSpan, ClassifiedTextElement?definitionText, bool isWrittenTo, CancellationToken cancellationToken) { // General case if (documentSpan != default) { var classifiedSpansAndHighlightSpan = await ClassifiedSpansAndHighlightSpanFactory.ClassifyAsync( documentSpan, cancellationToken).ConfigureAwait(false); var classifiedSpans = classifiedSpansAndHighlightSpan.ClassifiedSpans; var docText = await documentSpan.Document.GetTextAsync(cancellationToken).ConfigureAwait(false); var classifiedTextRuns = GetClassifiedTextRuns(id, definitionId, documentSpan, isWrittenTo, classifiedSpans, docText); return(new ClassifiedTextElement(classifiedTextRuns.ToArray())); } // Certain definitions may not have a DocumentSpan, such as namespace and metadata definitions else if (id == definitionId) { return(definitionText); } return(null);
void UpdateParagraphListStyleState(DocumentSpan documentSpan) { var listStyleId = RichTextEditor.Document.GetCommonParagraphListStyle(documentSpan); UpdateToggleButtonCheckedState(_bulletsTool, _bulletsTool.Tag.ToString() == listStyleId); UpdateToggleButtonCheckedState(_numbersTool, _numbersTool.Tag.ToString() == listStyleId); }
protected async Task <Entry> TryCreateDocumentSpanEntryAsync( RoslynDefinitionBucket definitionBucket, DocumentSpan documentSpan, HighlightSpanKind spanKind, ImmutableDictionary <string, ImmutableArray <string> > propertiesWithMultipleValuesMapOpt, ImmutableArray <FindUsageProperty> 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, GetCustomColumnsData(propertiesWithMultipleValuesMapOpt, additionalProperties))); }
public SourceReferenceItem(DefinitionItem definition, DocumentSpan sourceSpan, AdditionalPropertiesWithMultipleValuesMap referenceInfo) { Definition = definition; SourceSpan = sourceSpan; AdditionalPropertiesWithMultipleValues = referenceInfo ?? AdditionalPropertiesWithMultipleValuesMap.Empty; FindUsagesProperties = ImmutableArray <FindUsageProperty> .Empty; }
void UpdateParagraphAlignmentState(DocumentSpan documentSpan) { ParagraphSettings paragraphSettings = RichTextEditor.Document.GetCommonParagraphSettings(documentSpan); if (paragraphSettings.ParagraphAlignment.HasValue) { var value = paragraphSettings.ParagraphAlignment.Value; switch (value) { case ParagraphAlignment.Start: { UpdateToggleButtonCheckedState(_alignLeftTool, true); break; } case ParagraphAlignment.Center: { UpdateToggleButtonCheckedState(_alignCenterTool, true); break; } case ParagraphAlignment.End: { UpdateToggleButtonCheckedState(_alignRightTool, true); break; } case ParagraphAlignment.Justify: { UpdateToggleButtonCheckedState(_alignJustifyTool, true); break; } } } }
void UpdateVisualState() { _updatingState = true; DocumentSpan docSpan = RichTextEditor.Selection == null ? new DocumentSpan(0, 0) : RichTextEditor.Selection.DocumentSpan; var settings = RichTextEditor.Document.GetCommonCharacterSettings(docSpan); if (settings == null) { _updatingState = false; return; } UpdateFontSizes(settings); UpdateFontFamily(settings); UpdateToggleButton(_boldButton, settings.Bold); UpdateToggleButton(_italicButton, settings.Italics); UpdateUnderlineState(settings); UpdateAlignment(docSpan); UpdateParagraphListStyleState(docSpan); _updatingState = false; }
void ParagraphSettingsPreviewAdapter_DocumentContentChanged(object sender, DocumentContentChangedEventArgs e) { string error; var index = PreviewParagraphIndex; if (index == -1) { previewParagraphIndexSpan = DocumentSpan.All; } else { var previewParagrapth = Editor.Document.GetParagraphs(DocumentSpan.All).ElementAtOrDefault(PreviewParagraphIndex); if (previewParagrapth != null) { previewParagraphIndexSpan = previewParagrapth.GetDocumentSpan(); } } if (previewParagraphSettings != null) { Editor.Document.ApplyParagraphSettings(previewParagraphIndexSpan, previewParagraphSettings, out error); } }
/// <summary> /// Updates the state of the paragraph alignment buttons /// </summary> void UpdateParagraphAlignmentState(DocumentSpan documentSpan) { ParagraphSettings paragraphSettings = Target.Document.GetCommonParagraphSettings(documentSpan); if (paragraphSettings.ParagraphAlignment.HasValue) { var value = paragraphSettings.ParagraphAlignment.Value; switch (value) { case ParagraphAlignment.Start: { UpdateToggleButtonCheckedState(_btnAlignLeft, true); break; } case ParagraphAlignment.Center: { UpdateToggleButtonCheckedState(_btnAlignCenter, true); break; } case ParagraphAlignment.End: { UpdateToggleButtonCheckedState(_btnAlignRight, true); break; } } } }
public static DefinitionItem Create( ImmutableArray <string> tags, ImmutableArray <TaggedText> displayParts, DocumentSpan sourceSpan, bool displayIfNoReferences = true) { return(Create(tags, displayParts, ImmutableArray.Create(sourceSpan), displayIfNoReferences)); }
public static DefinitionItem Create( ImmutableArray<string> tags, ImmutableArray<TaggedText> displayParts, DocumentSpan sourceSpan, bool displayIfNoReferences = true) { return Create(tags, displayParts, ImmutableArray.Create(sourceSpan), displayIfNoReferences); }
public SourceReferenceItem(DefinitionItem definition, DocumentSpan sourceSpan, bool isWrittenTo) { Definition = definition; SourceSpan = sourceSpan; IsWrittenTo = isWrittenTo; AdditionalPropertiesWithMultipleValues = AdditionalPropertiesWithMultipleValuesMap.Empty; FindUsagesProperties = ImmutableArray <FindUsageProperty> .Empty; }
public DefinitionItemEntry( AbstractTableDataSourceFindUsagesContext context, RoslynDefinitionBucket definitionBucket, DocumentSpan documentSpan, Guid projectGuid, SourceText sourceText) : base(context, definitionBucket, documentSpan, projectGuid, sourceText) { }
public VSTypeScriptSourceReferenceItem( VSTypeScriptDefinitionItem definition, DocumentSpan sourceSpan, SymbolUsageInfo symbolUsageInfo) { Definition = definition; SourceSpan = sourceSpan; SymbolUsageInfo = symbolUsageInfo; }
public DocumentSpanEntry GetOrAddEntry(DocumentSpan documentSpan, DocumentSpanEntry entry) { var key = (documentSpan.Document.FilePath, documentSpan.SourceSpan); lock (_locationToEntry) { return(_locationToEntry.GetOrAdd(key, entry)); } }
private bool SelectionIsWithinWord() { DocumentSpan currentCharacterSpan = new DocumentSpan(selection.Start, 1); string currentText = document.GetTextInSpan(currentCharacterSpan); DocumentSpan previousCharacterSpan = new DocumentSpan(Math.Max(0, selection.Start - 1), 1); string previousText = document.GetTextInSpan(previousCharacterSpan); return(previousText != " " && currentText != " "); }
public DocumentSpanEntry( AbstractTableDataSourceFindUsagesContext context, RoslynDefinitionBucket definitionBucket, DocumentSpan documentSpan, bool isDefinitionLocation, Guid projectGuid, SourceText sourceText, ClassifiedSpansAndHighlightSpan classifiedSpans) : base(context, definitionBucket, documentSpan, projectGuid, sourceText) { _isDefinitionLocation = isDefinitionLocation; _classifiedSpansAndHighlights = classifiedSpans; }
private SourceReferenceItem( DefinitionItem definition, DocumentSpan sourceSpan, SymbolUsageInfo symbolUsageInfo, ImmutableDictionary<string, string> additionalProperties, bool isWrittenTo) { Definition = definition; SourceSpan = sourceSpan; SymbolUsageInfo = symbolUsageInfo; IsWrittenTo = isWrittenTo; AdditionalProperties = additionalProperties ?? ImmutableDictionary<string, string>.Empty; }
internal SourceReferenceItem( DefinitionItem definition, DocumentSpan sourceSpan, SymbolUsageInfo symbolUsageInfo ) : this( definition, sourceSpan, symbolUsageInfo, additionalProperties : ImmutableDictionary <string, string> .Empty ) { }
protected AbstractDocumentSpanEntry( AbstractTableDataSourceFindUsagesContext context, RoslynDefinitionBucket definitionBucket, DocumentSpan documentSpan, Guid projectGuid, SourceText sourceText) : base(definitionBucket) { _context = context; _documentSpan = documentSpan; _boxedProjectGuid = projectGuid; _sourceText = sourceText; }
private async TPL.Task <ImmutableArray <DefinitionItem> > GetDefinitionItemsAsync(Document document, int position, CancellationToken cancellationToken) { var lspClient = _roslynLspClientServiceFactory.ActiveLanguageServerClient; if (lspClient == null) { return(ImmutableArray <DefinitionItem> .Empty); } var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); var textDocumentPositionParams = ProtocolConversions.PositionToTextDocumentPositionParams(position, text, document); var response = await lspClient.RequestAsync(LSP.Methods.TextDocumentDefinition.ToLSRequest(), textDocumentPositionParams, cancellationToken).ConfigureAwait(false); var locations = ((JToken)response)?.ToObject <LSP.Location[]>(); if (locations == null) { return(ImmutableArray <DefinitionItem> .Empty); } var definitionItems = ImmutableArray.CreateBuilder <DefinitionItem>(); foreach (var location in locations) { DocumentSpan?documentSpan; if (lspClient.ProtocolConverter.IsExternalDocument(location.Uri)) { var externalDocument = _remoteWorkspace.GetOrAddExternalDocument(location.Uri.LocalPath, document.Project.Language); var externalText = await externalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false); var textSpan = ProtocolConversions.RangeToTextSpan(location.Range, externalText); documentSpan = new DocumentSpan(externalDocument, textSpan); } else { documentSpan = await _remoteWorkspace.GetDocumentSpanFromLocation(location, cancellationToken).ConfigureAwait(false); if (documentSpan == null) { continue; } } definitionItems.Add(DefinitionItem.Create(ImmutableArray <string> .Empty, ImmutableArray <TaggedText> .Empty, documentSpan.Value)); } return(definitionItems.ToImmutable()); }
public DocumentSpanEntry( AbstractTableDataSourceFindUsagesContext context, RoslynDefinitionBucket definitionBucket, DocumentSpan documentSpan, DocumentHighlighting.HighlightSpanKind spanKind, string documentName, Guid projectGuid, SourceText sourceText, ClassifiedSpansAndHighlightSpan classifiedSpans) : base(context, definitionBucket, documentSpan, documentName, projectGuid, sourceText) { _spanKind = spanKind; _classifiedSpansAndHighlights = classifiedSpans; }
private static async Task <LSP.VSReferenceItem?> GenerateVSReferenceItemAsync( int id, int?definitionId, Document document, int position, DocumentSpan documentSpan, ImmutableDictionary <string, string> properties, IMetadataAsSourceFileService metadataAsSourceFileService, string?definitionText, SymbolUsageInfo?symbolUsageInfo, CancellationToken cancellationToken) { var location = await ComputeLocationAsync(document, position, documentSpan, metadataAsSourceFileService, cancellationToken).ConfigureAwait(false); if (location == null) { return(null); } // Getting the text for the Text property. If we somehow can't compute the text, that means we're probably dealing with a metadata // reference, and those don't show up in the results list in Roslyn FAR anyway. var text = await ComputeTextAsync(id, definitionId, documentSpan, definitionText, cancellationToken).ConfigureAwait(false); if (text == null) { return(null); } // TO-DO: The Origin property should be added once Rich-Nav is completed. // https://github.com/dotnet/roslyn/issues/42847 var result = new LSP.VSReferenceItem { ContainingMember = properties.TryGetValue( AbstractReferenceFinder.ContainingMemberInfoPropertyName, out var referenceContainingMember) ? referenceContainingMember : null, ContainingType = properties.TryGetValue( AbstractReferenceFinder.ContainingTypeInfoPropertyName, out var referenceContainingType) ? referenceContainingType : null, DefinitionId = definitionId, DefinitionText = definitionText, // Only definitions should have a non-null DefinitionText DisplayPath = location.Uri.LocalPath, DocumentName = documentSpan == default ? null : documentSpan.Document.Name, Id = id, Kind = symbolUsageInfo.HasValue ? ProtocolConversions.SymbolUsageInfoToReferenceKinds(symbolUsageInfo.Value) : new ReferenceKind[] { }, Location = location, ProjectName = documentSpan == default ? null : documentSpan.Document.Project.Name, ResolutionStatus = ResolutionStatusKind.ConfirmedAsReference, Text = text, }; return(result);
internal SourceReferenceItem( DefinitionItem definition, DocumentSpan sourceSpan, SymbolUsageInfo symbolUsageInfo, ImmutableDictionary <string, string> additionalProperties ) : this( definition, sourceSpan, symbolUsageInfo, additionalProperties, isWrittenTo : symbolUsageInfo.IsWrittenTo() ) { }
// Local functions static async Task <LSP.Location?> ComputeLocationAsync( Document document, int position, DocumentSpan documentSpan, IMetadataAsSourceFileService metadataAsSourceFileService, CancellationToken cancellationToken) { if (documentSpan != default) { // We do have a document span, so compute location normally. return(await ProtocolConversions.DocumentSpanToLocationAsync(documentSpan, cancellationToken).ConfigureAwait(false)); } // If we have no document span, our location may be in metadata or may be a namespace. var symbol = await SymbolFinder.FindSymbolAtPositionAsync(document, position, cancellationToken).ConfigureAwait(false); if (symbol == null || symbol.Locations.IsEmpty || symbol.Kind == SymbolKind.Namespace) { // Either: // (1) We couldn't find the location in metadata and it's not in any of our known documents. // (2) The symbol is a namespace (and therefore has no location). return(null); } var declarationFile = await metadataAsSourceFileService.GetGeneratedFileAsync( document.Project, symbol, allowDecompilation : false, cancellationToken).ConfigureAwait(false); var linePosSpan = declarationFile.IdentifierLocation.GetLineSpan().Span; if (string.IsNullOrEmpty(declarationFile.FilePath)) { return(null); } try { return(new LSP.Location { Uri = ProtocolConversions.GetUriFromFilePath(declarationFile.FilePath), Range = ProtocolConversions.LinePositionToRange(linePosSpan), }); } catch (UriFormatException e) when(FatalError.ReportAndCatch(e)) { // We might reach this point if the file path is formatted incorrectly. return(null); } }
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); }
public DocumentSpanEntry( TableDataSourceFindUsagesContext context, RoslynDefinitionBucket definitionBucket, DocumentSpan documentSpan, bool isDefinitionLocation, SourceText sourceText, ClassifiedSpansAndHighlightSpan classifiedSpans) : base(definitionBucket) { _context = context; _documentSpan = documentSpan; _isDefinitionLocation = isDefinitionLocation; _sourceText = sourceText; _classifiedSpans = classifiedSpans; }
public DocumentSpanEntry( TableDataSourceFindReferencesContext context, VisualStudioWorkspaceImpl workspace, RoslynDefinitionBucket definitionBucket, DocumentSpan documentSpan, bool isDefinitionLocation, Guid projectGuid, SourceText sourceText, TaggedTextAndHighlightSpan taggedLineParts) : base(definitionBucket) { _context = context; _workspace = workspace; _documentSpan = documentSpan; _isDefinitionLocation = isDefinitionLocation; _boxedProjectGuid = projectGuid; _sourceText = sourceText; _taggedLineParts = taggedLineParts; }
private async Task<Entry> CreateDocumentLocationEntryAsync( RoslynDefinitionBucket definitionBucket, DocumentSpan documentSpan, bool isDefinitionLocation, CancellationToken cancellationToken) { var document = documentSpan.Document; // The FAR system needs to know the guid for the project that a def/reference is // from. So we only support this for documents from a VSWorkspace. var workspace = document.Project.Solution.Workspace as VisualStudioWorkspaceImpl; if (workspace == null) { return null; } var projectGuid = workspace.GetHostProject(document.Project.Id)?.Guid; if (projectGuid == null) { return null; } var sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); var referenceSpan = documentSpan.SourceSpan; var lineSpan = GetLineSpanForReference(sourceText, referenceSpan); var taggedLineParts = await GetTaggedTextForReferenceAsync(document, referenceSpan, lineSpan, cancellationToken).ConfigureAwait(false); return new DocumentSpanEntry( this, workspace, definitionBucket, documentSpan, isDefinitionLocation, projectGuid.Value, sourceText, taggedLineParts); }
private async Task<Entry> CreateDocumentLocationEntryAsync( RoslynDefinitionBucket definitionBucket, DocumentSpan documentSpan, bool isDefinitionLocation) { var document = documentSpan.Document; var sourceText = await document.GetTextAsync(CancellationToken).ConfigureAwait(false); var referenceSpan = documentSpan.SourceSpan; var lineSpan = GetLineSpanForReference(sourceText, referenceSpan); var taggedLineParts = await GetTaggedTextForReferenceAsync(document, referenceSpan, lineSpan).ConfigureAwait(false); return new DocumentSpanEntry( this, definitionBucket, documentSpan, isDefinitionLocation, sourceText, taggedLineParts); }
public static DefinitionItem ToDefinitionItem( this ISymbol definition, Solution solution, bool includeHiddenLocations, HashSet<DocumentSpan> uniqueSpans = null) { var displayParts = definition.ToDisplayParts(GetFormat(definition)).ToTaggedText(); var tags = GlyphTags.GetTags(definition.GetGlyph()); var displayIfNoReferences = definition.ShouldShowWithNoReferenceLocations( showMetadataSymbolsWithoutReferences: false); var sourceLocations = ArrayBuilder<DocumentSpan>.GetInstance(); // If it's a namespace, don't create any normal lcoation. Namespaces // come from many different sources, but we'll only show a single // root definition node for it. That node won't be navigable. if (definition.Kind != SymbolKind.Namespace) { foreach (var location in definition.Locations) { if (location.IsInMetadata) { return DefinitionItem.CreateMetadataDefinition( tags, displayParts, solution, definition, displayIfNoReferences); } else if (location.IsInSource) { if (!location.IsVisibleSourceLocation() && !includeHiddenLocations) { continue; } var document = solution.GetDocument(location.SourceTree); if (document != null) { var documentLocation = new DocumentSpan(document, location.SourceSpan); if (sourceLocations.Count == 0) { sourceLocations.Add(documentLocation); } else { if (uniqueSpans == null || uniqueSpans.Add(documentLocation)) { sourceLocations.Add(documentLocation); } } } } } } if (sourceLocations.Count == 0) { // If we got no definition locations, then create a sentinel one // that we can display but which will not allow navigation. return DefinitionItem.CreateNonNavigableItem( tags, displayParts, DefinitionItem.GetOriginationParts(definition), displayIfNoReferences); } return DefinitionItem.Create( tags, displayParts, sourceLocations.ToImmutableAndFree(), displayIfNoReferences); }
public SourceReferenceItem(DefinitionItem definition, DocumentSpan sourceSpan) { Definition = definition; SourceSpan = sourceSpan; }