提交 d14741f0 编写于 作者: C CyrusNajmabadi 提交者: GitHub

Merge pull request #18520 from Pilchie/Fix18382-FARWebGrouping

Use the project display name in FAR to support grouping
...@@ -122,7 +122,10 @@ internal abstract partial class AbstractProject : ForegroundThreadAffinitizedObj ...@@ -122,7 +122,10 @@ internal abstract partial class AbstractProject : ForegroundThreadAffinitizedObj
ContentTypeRegistryService = componentModel.GetService<IContentTypeRegistryService>(); ContentTypeRegistryService = componentModel.GetService<IContentTypeRegistryService>();
this.RunningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable)); this.RunningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable));
this.DisplayName = projectSystemName;
var displayName = hierarchy != null && hierarchy.TryGetName(out var name) ? name : projectSystemName;
this.DisplayName = displayName;
this.ProjectTracker = projectTracker; this.ProjectTracker = projectTracker;
ProjectSystemName = projectSystemName; ProjectSystemName = projectSystemName;
...@@ -133,7 +136,7 @@ internal abstract partial class AbstractProject : ForegroundThreadAffinitizedObj ...@@ -133,7 +136,7 @@ internal abstract partial class AbstractProject : ForegroundThreadAffinitizedObj
// Set the default value for last design time build result to be true, until the project system lets us know that it failed. // Set the default value for last design time build result to be true, until the project system lets us know that it failed.
LastDesignTimeBuildSucceeded = true; LastDesignTimeBuildSucceeded = true;
UpdateProjectDisplayNameAndFilePath(projectSystemName, projectFilePath); UpdateProjectDisplayNameAndFilePath(displayName, projectFilePath);
if (ProjectFilePath != null) if (ProjectFilePath != null)
{ {
......
...@@ -22,6 +22,21 @@ internal interface IVisualStudioHostProject ...@@ -22,6 +22,21 @@ internal interface IVisualStudioHostProject
Guid Guid { get; } Guid Guid { get; }
Workspace Workspace { get; } Workspace Workspace { get; }
/// <summary>
/// The public display name of the project. This name is not unique and may be shared
/// between multiple projects, especially in cases like Venus where the intellisense
/// projects will match the name of their logical parent project.
/// </summary>
string DisplayName { get; }
/// <summary>
/// The name of the project according to the project system. In "regular" projects this is
/// equivalent to <see cref="DisplayName"/>, but in Venus cases these will differ. The
/// ProjectSystemName is the 2_Default.aspx project name, whereas the regular display name
/// matches the display name of the project the user actually sees in the solution explorer.
/// These can be assumed to be unique within the Visual Studio workspace.
/// </summary>
string ProjectSystemName { get; } string ProjectSystemName { get; }
IVisualStudioHostDocument GetDocumentOrAdditionalDocument(DocumentId id); IVisualStudioHostDocument GetDocumentOrAdditionalDocument(DocumentId id);
......
...@@ -77,7 +77,8 @@ public ProjectInfo CreateProjectInfoForCurrentState() ...@@ -77,7 +77,8 @@ public ProjectInfo CreateProjectInfoForCurrentState()
public Workspace Workspace => _workspace; public Workspace Workspace => _workspace;
public string ProjectSystemName => "MiscellaneousFiles"; public string DisplayName => "MiscellaneousFiles";
public string ProjectSystemName => DisplayName;
public IVisualStudioHostDocument GetDocumentOrAdditionalDocument(DocumentId id) public IVisualStudioHostDocument GetDocumentOrAdditionalDocument(DocumentId id)
{ {
......
...@@ -245,7 +245,7 @@ public sealed override Task OnDefinitionFoundAsync(DefinitionItem definition) ...@@ -245,7 +245,7 @@ public sealed override Task OnDefinitionFoundAsync(DefinitionItem definition)
protected abstract Task OnDefinitionFoundWorkerAsync(DefinitionItem definition); protected abstract Task OnDefinitionFoundWorkerAsync(DefinitionItem definition);
protected async Task<(Guid, SourceText)> GetGuidAndSourceTextAsync(Document document) protected async Task<(Guid, string projectName, SourceText)> GetGuidAndProjectNameAndSourceTextAsync(Document document)
{ {
// The FAR system needs to know the guid for the project that a def/reference is // 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 // from (to support features like filtering). Normally that would mean we could
...@@ -254,10 +254,13 @@ protected async Task<(Guid, SourceText)> GetGuidAndSourceTextAsync(Document docu ...@@ -254,10 +254,13 @@ protected async Task<(Guid, SourceText)> GetGuidAndSourceTextAsync(Document docu
// when we have another type of workspace. This means we will show results, but // when we have another type of workspace. This means we will show results, but
// certain features (like filtering) may not work in that context. // certain features (like filtering) may not work in that context.
var workspace = document.Project.Solution.Workspace as VisualStudioWorkspaceImpl; var workspace = document.Project.Solution.Workspace as VisualStudioWorkspaceImpl;
var guid = workspace?.GetHostProject(document.Project.Id)?.Guid ?? Guid.Empty; var hostProject = workspace?.GetHostProject(document.Project.Id);
var projectName = hostProject?.DisplayName ?? document.Project.Name;
var guid = hostProject?.Guid ?? Guid.Empty;
var sourceText = await document.GetTextAsync(CancellationToken).ConfigureAwait(false); var sourceText = await document.GetTextAsync(CancellationToken).ConfigureAwait(false);
return (guid, sourceText); return (guid, projectName, sourceText);
} }
protected async Task<Entry> CreateDocumentSpanEntryAsync( protected async Task<Entry> CreateDocumentSpanEntryAsync(
...@@ -266,7 +269,7 @@ protected async Task<(Guid, SourceText)> GetGuidAndSourceTextAsync(Document docu ...@@ -266,7 +269,7 @@ protected async Task<(Guid, SourceText)> GetGuidAndSourceTextAsync(Document docu
HighlightSpanKind spanKind) HighlightSpanKind spanKind)
{ {
var document = documentSpan.Document; var document = documentSpan.Document;
var (guid, sourceText) = await GetGuidAndSourceTextAsync(document).ConfigureAwait(false); var (guid, projectName, sourceText) = await GetGuidAndProjectNameAndSourceTextAsync(document).ConfigureAwait(false);
var narrowSpan = documentSpan.SourceSpan; var narrowSpan = documentSpan.SourceSpan;
var lineSpan = GetLineSpanForReference(sourceText, narrowSpan); var lineSpan = GetLineSpanForReference(sourceText, narrowSpan);
...@@ -275,7 +278,7 @@ protected async Task<(Guid, SourceText)> GetGuidAndSourceTextAsync(Document docu ...@@ -275,7 +278,7 @@ protected async Task<(Guid, SourceText)> GetGuidAndSourceTextAsync(Document docu
return new DocumentSpanEntry( return new DocumentSpanEntry(
this, definitionBucket, documentSpan, spanKind, this, definitionBucket, documentSpan, spanKind,
guid, sourceText, taggedLineParts); projectName, guid, sourceText, taggedLineParts);
} }
private TextSpan GetLineSpanForReference(SourceText sourceText, TextSpan referenceSpan) private TextSpan GetLineSpanForReference(SourceText sourceText, TextSpan referenceSpan)
......
...@@ -81,9 +81,9 @@ protected override async Task OnDefinitionFoundWorkerAsync(DefinitionItem defini ...@@ -81,9 +81,9 @@ protected override async Task OnDefinitionFoundWorkerAsync(DefinitionItem defini
RoslynDefinitionBucket definitionBucket, DefinitionItem definition) RoslynDefinitionBucket definitionBucket, DefinitionItem definition)
{ {
var documentSpan = definition.SourceSpans[0]; var documentSpan = definition.SourceSpans[0];
var (guid, sourceText) = await GetGuidAndSourceTextAsync(documentSpan.Document).ConfigureAwait(false); var (guid, projectName, sourceText) = await GetGuidAndProjectNameAndSourceTextAsync(documentSpan.Document).ConfigureAwait(false);
return new DefinitionItemEntry(this, definitionBucket, documentSpan, guid, sourceText); return new DefinitionItemEntry(this, definitionBucket, documentSpan, projectName, guid, sourceText);
} }
} }
} }
......
...@@ -24,6 +24,7 @@ private abstract class AbstractDocumentSpanEntry : Entry ...@@ -24,6 +24,7 @@ private abstract class AbstractDocumentSpanEntry : Entry
private readonly AbstractTableDataSourceFindUsagesContext _context; private readonly AbstractTableDataSourceFindUsagesContext _context;
private readonly DocumentSpan _documentSpan; private readonly DocumentSpan _documentSpan;
private readonly string _projectName;
private readonly object _boxedProjectGuid; private readonly object _boxedProjectGuid;
protected readonly SourceText _sourceText; protected readonly SourceText _sourceText;
...@@ -31,13 +32,14 @@ private abstract class AbstractDocumentSpanEntry : Entry ...@@ -31,13 +32,14 @@ private abstract class AbstractDocumentSpanEntry : Entry
AbstractTableDataSourceFindUsagesContext context, AbstractTableDataSourceFindUsagesContext context,
RoslynDefinitionBucket definitionBucket, RoslynDefinitionBucket definitionBucket,
DocumentSpan documentSpan, DocumentSpan documentSpan,
string projectName,
Guid projectGuid, Guid projectGuid,
SourceText sourceText) SourceText sourceText)
: base(definitionBucket) : base(definitionBucket)
{ {
_context = context; _context = context;
_documentSpan = documentSpan; _documentSpan = documentSpan;
_projectName = projectName;
_boxedProjectGuid = projectGuid; _boxedProjectGuid = projectGuid;
_sourceText = sourceText; _sourceText = sourceText;
} }
...@@ -58,7 +60,7 @@ protected override object GetValueWorker(string keyName) ...@@ -58,7 +60,7 @@ protected override object GetValueWorker(string keyName)
case StandardTableKeyNames.Column: case StandardTableKeyNames.Column:
return _sourceText.Lines.GetLinePosition(SourceSpan.Start).Character; return _sourceText.Lines.GetLinePosition(SourceSpan.Start).Character;
case StandardTableKeyNames.ProjectName: case StandardTableKeyNames.ProjectName:
return Document.Project.Name; return _projectName;
case StandardTableKeyNames.ProjectGuid: case StandardTableKeyNames.ProjectGuid:
return _boxedProjectGuid; return _boxedProjectGuid;
case StandardTableKeyNames.Text: case StandardTableKeyNames.Text:
......
...@@ -22,9 +22,10 @@ private class DefinitionItemEntry : AbstractDocumentSpanEntry ...@@ -22,9 +22,10 @@ private class DefinitionItemEntry : AbstractDocumentSpanEntry
AbstractTableDataSourceFindUsagesContext context, AbstractTableDataSourceFindUsagesContext context,
RoslynDefinitionBucket definitionBucket, RoslynDefinitionBucket definitionBucket,
DocumentSpan documentSpan, DocumentSpan documentSpan,
string documentName,
Guid projectGuid, Guid projectGuid,
SourceText sourceText) SourceText sourceText)
: base(context, definitionBucket, documentSpan, projectGuid, sourceText) : base(context, definitionBucket, documentSpan, documentName, projectGuid, sourceText)
{ {
} }
......
...@@ -39,10 +39,11 @@ private class DocumentSpanEntry : AbstractDocumentSpanEntry ...@@ -39,10 +39,11 @@ private class DocumentSpanEntry : AbstractDocumentSpanEntry
RoslynDefinitionBucket definitionBucket, RoslynDefinitionBucket definitionBucket,
DocumentSpan documentSpan, DocumentSpan documentSpan,
HighlightSpanKind spanKind, HighlightSpanKind spanKind,
string documentName,
Guid projectGuid, Guid projectGuid,
SourceText sourceText, SourceText sourceText,
ClassifiedSpansAndHighlightSpan classifiedSpans) ClassifiedSpansAndHighlightSpan classifiedSpans)
: base(context, definitionBucket, documentSpan, projectGuid, sourceText) : base(context, definitionBucket, documentSpan, documentName, projectGuid, sourceText)
{ {
_spanKind = spanKind; _spanKind = spanKind;
_classifiedSpansAndHighlights = classifiedSpans; _classifiedSpansAndHighlights = classifiedSpans;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册