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))); }
private SimpleMessageEntry( RoslynDefinitionBucket definitionBucket, string message) : base(definitionBucket) { _message = message; }
public static Task<Entry> CreateAsync( RoslynDefinitionBucket definitionBucket, string message) { var referenceEntry = new SimpleMessageEntry(definitionBucket, message); return Task.FromResult<Entry>(referenceEntry); }
private async Task CreateMissingReferenceEntriesIfNecessaryAsync( bool whenGroupingByDefinition) { // Go through and add dummy entries for any definitions that // that we didn't find any references for. var definitions = GetDefinitionsToCreateMissingReferenceItemsFor(whenGroupingByDefinition); foreach (var definition in definitions) { if (definition.IsExternal) { await OnEntryFoundAsync(definition, bucket => SimpleMessageEntry.CreateAsync(bucket, bucket, ServicesVSResources.External_reference_found) !, addToEntriesWhenGroupingByDefinition : whenGroupingByDefinition, addToEntriesWhenNotGroupingByDefinition : !whenGroupingByDefinition).ConfigureAwait(false); } else { // Create a fake reference to this definition that says "no references found to <symbolname>". // // We'll place this under a single bucket called "Symbols without references" and we'll allow // the user to navigate on that text entry to that definition if possible. await OnEntryFoundAsync(SymbolsWithoutReferencesDefinitionItem, bucket => SimpleMessageEntry.CreateAsync( definitionBucket: bucket, navigationBucket: RoslynDefinitionBucket.Create(Presenter, this, definition, expandedByDefault: false), string.Format(ServicesVSResources.No_references_found_to_0, definition.NameDisplayParts.JoinText())) !, addToEntriesWhenGroupingByDefinition : whenGroupingByDefinition, addToEntriesWhenNotGroupingByDefinition : !whenGroupingByDefinition, expandedByDefault : false).ConfigureAwait(false); } } }
private async Task <Entry?> TryCreateEntryAsync( RoslynDefinitionBucket definitionBucket, DefinitionItem definition ) { var documentSpan = definition.SourceSpans[0]; var(guid, projectName, _) = GetGuidAndProjectInfo(documentSpan.Document); var sourceText = await documentSpan.Document .GetTextAsync(CancellationToken) .ConfigureAwait(false); var lineText = AbstractDocumentSpanEntry.GetLineContainingPosition( sourceText, documentSpan.SourceSpan.Start ); var mappedDocumentSpan = await AbstractDocumentSpanEntry .TryMapAndGetFirstAsync(documentSpan, sourceText, CancellationToken) .ConfigureAwait(false); if (mappedDocumentSpan == null) { // this will be removed from the result return(null); } return(new DefinitionItemEntry( this, definitionBucket, projectName, guid, lineText, mappedDocumentSpan.Value )); }
public ExternalReferenceItemEntry( RoslynDefinitionBucket bucket, ExternalReferenceItem reference) : base(bucket) { _reference = reference; }
public AbstractItemEntry( RoslynDefinitionBucket definitionBucket, StreamingFindUsagesPresenter presenter ) : base(definitionBucket) { Presenter = presenter; }
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; // 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)); }
public static Task <Entry> CreateAsync( RoslynDefinitionBucket definitionBucket, string message) { var referenceEntry = new SimpleMessageEntry(definitionBucket, message); return(Task.FromResult <Entry>(referenceEntry)); }
public MetadataDefinitionItemEntry( AbstractTableDataSourceFindUsagesContext context, RoslynDefinitionBucket definitionBucket, IThreadingContext threadingContext) : base(definitionBucket, context.Presenter) { _threadingContext = threadingContext; }
private SimpleMessageEntry( RoslynDefinitionBucket definitionBucket, RoslynDefinitionBucket?navigationBucket, string message) : base(definitionBucket) { _navigationBucket = navigationBucket; _message = message; }
private async Task <Entry> CreateEntryAsync( RoslynDefinitionBucket definitionBucket, DefinitionItem definition) { var documentSpan = definition.SourceSpans[0]; var(guid, projectName, sourceText) = await GetGuidAndProjectNameAndSourceTextAsync(documentSpan.Document).ConfigureAwait(false); return(new DefinitionItemEntry(this, definitionBucket, documentSpan, projectName, guid, sourceText)); }
public DefinitionItemEntry( AbstractTableDataSourceFindUsagesContext context, RoslynDefinitionBucket definitionBucket, DocumentSpan documentSpan, Guid projectGuid, SourceText sourceText) : base(context, definitionBucket, documentSpan, projectGuid, sourceText) { }
public DefinitionItemEntry( AbstractTableDataSourceFindUsagesContext context, RoslynDefinitionBucket definitionBucket, string documentName, Guid projectGuid, SourceText lineText, MappedSpanResult mappedSpanResult) : base(context, definitionBucket, documentName, projectGuid, lineText, mappedSpanResult) { }
protected AbstractDocumentSpanEntry( AbstractTableDataSourceFindUsagesContext context, RoslynDefinitionBucket definitionBucket, Guid projectGuid, SourceText lineText, MappedSpanResult mappedSpanResult ) : base(definitionBucket, context.Presenter) { _boxedProjectGuid = projectGuid; _lineText = lineText; _mappedSpanResult = mappedSpanResult; }
protected RoslynDefinitionBucket GetOrCreateDefinitionBucket(DefinitionItem definition) { lock (Gate) { if (!_definitionToBucket.TryGetValue(definition, out var bucket)) { bucket = RoslynDefinitionBucket.Create(Presenter, this, definition); _definitionToBucket.Add(definition, bucket); } return(bucket); } }
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 RoslynDefinitionBucket GetOrCreateDefinitionBucket(DefinitionItem definition) { lock (_gate) { if (!_definitionToBucket.TryGetValue(definition, out var bucket)) { bucket = new RoslynDefinitionBucket(Presenter, this, definition); _definitionToBucket.Add(definition, bucket); } return(bucket); } }
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; }
protected AbstractDocumentSpanEntry( AbstractTableDataSourceFindUsagesContext context, RoslynDefinitionBucket definitionBucket, DocumentSpan documentSpan, Guid projectGuid, SourceText sourceText) : base(definitionBucket) { _context = context; _documentSpan = documentSpan; _boxedProjectGuid = projectGuid; _sourceText = sourceText; }
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); }
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)); }
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; }
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); }
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))); }
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 DocumentSpanEntry( TableDataSourceFindReferencesContext context, VisualStudioWorkspaceImpl workspace, RoslynDefinitionBucket definitionBucket, DocumentSpan documentSpan, bool isDefinitionLocation, Guid projectGuid, SourceText sourceText, ClassifiedSpansAndHighlightSpan classifiedSpans) : base(definitionBucket) { _context = context; _workspace = workspace; _documentSpan = documentSpan; _isDefinitionLocation = isDefinitionLocation; _boxedProjectGuid = projectGuid; _sourceText = sourceText; _classifiedSpans = classifiedSpans; }
public DocumentLocationEntry( TableDataSourceFindReferencesContext context, VisualStudioWorkspaceImpl workspace, RoslynDefinitionBucket definitionBucket, DocumentLocation documentLocation, bool isDefinitionLocation, Guid projectGuid, SourceText sourceText, TaggedTextAndHighlightSpan taggedLineParts) : base(definitionBucket) { _context = context; _workspace = workspace; _documentLocation = documentLocation; _isDefinitionLocation = isDefinitionLocation; _boxedProjectGuid = projectGuid; _sourceText = sourceText; _taggedLineParts = taggedLineParts; }
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; }
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<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); }
protected Entry(RoslynDefinitionBucket definitionBucket) { DefinitionBucket = definitionBucket; }
private RoslynDefinitionBucket GetOrCreateDefinitionBucket(DefinitionItem definition) { lock (_gate) { RoslynDefinitionBucket bucket; if (!_definitionToBucket.TryGetValue(definition, out bucket)) { bucket = new RoslynDefinitionBucket(Presenter, this, definition); _definitionToBucket.Add(definition, bucket); } return bucket; } }