提交 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
ContentTypeRegistryService = componentModel.GetService<IContentTypeRegistryService>();
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;
ProjectSystemName = projectSystemName;
......@@ -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.
LastDesignTimeBuildSucceeded = true;
UpdateProjectDisplayNameAndFilePath(projectSystemName, projectFilePath);
UpdateProjectDisplayNameAndFilePath(displayName, projectFilePath);
if (ProjectFilePath != null)
{
......
......@@ -22,6 +22,21 @@ internal interface IVisualStudioHostProject
Guid Guid { 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; }
IVisualStudioHostDocument GetDocumentOrAdditionalDocument(DocumentId id);
......
......@@ -77,7 +77,8 @@ public ProjectInfo CreateProjectInfoForCurrentState()
public Workspace Workspace => _workspace;
public string ProjectSystemName => "MiscellaneousFiles";
public string DisplayName => "MiscellaneousFiles";
public string ProjectSystemName => DisplayName;
public IVisualStudioHostDocument GetDocumentOrAdditionalDocument(DocumentId id)
{
......
......@@ -245,7 +245,7 @@ public sealed override Task OnDefinitionFoundAsync(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
// from (to support features like filtering). Normally that would mean we could
......@@ -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
// 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 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);
return (guid, sourceText);
return (guid, projectName, sourceText);
}
protected async Task<Entry> CreateDocumentSpanEntryAsync(
......@@ -266,7 +269,7 @@ protected async Task<(Guid, SourceText)> GetGuidAndSourceTextAsync(Document docu
HighlightSpanKind spanKind)
{
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 lineSpan = GetLineSpanForReference(sourceText, narrowSpan);
......@@ -275,7 +278,7 @@ protected async Task<(Guid, SourceText)> GetGuidAndSourceTextAsync(Document docu
return new DocumentSpanEntry(
this, definitionBucket, documentSpan, spanKind,
guid, sourceText, taggedLineParts);
projectName, guid, sourceText, taggedLineParts);
}
private TextSpan GetLineSpanForReference(SourceText sourceText, TextSpan referenceSpan)
......
......@@ -81,9 +81,9 @@ protected override async Task OnDefinitionFoundWorkerAsync(DefinitionItem defini
RoslynDefinitionBucket definitionBucket, DefinitionItem definition)
{
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
private readonly AbstractTableDataSourceFindUsagesContext _context;
private readonly DocumentSpan _documentSpan;
private readonly string _projectName;
private readonly object _boxedProjectGuid;
protected readonly SourceText _sourceText;
......@@ -31,13 +32,14 @@ private abstract class AbstractDocumentSpanEntry : Entry
AbstractTableDataSourceFindUsagesContext context,
RoslynDefinitionBucket definitionBucket,
DocumentSpan documentSpan,
string projectName,
Guid projectGuid,
SourceText sourceText)
: base(definitionBucket)
{
_context = context;
_documentSpan = documentSpan;
_projectName = projectName;
_boxedProjectGuid = projectGuid;
_sourceText = sourceText;
}
......@@ -58,7 +60,7 @@ protected override object GetValueWorker(string keyName)
case StandardTableKeyNames.Column:
return _sourceText.Lines.GetLinePosition(SourceSpan.Start).Character;
case StandardTableKeyNames.ProjectName:
return Document.Project.Name;
return _projectName;
case StandardTableKeyNames.ProjectGuid:
return _boxedProjectGuid;
case StandardTableKeyNames.Text:
......
......@@ -22,9 +22,10 @@ private class DefinitionItemEntry : AbstractDocumentSpanEntry
AbstractTableDataSourceFindUsagesContext context,
RoslynDefinitionBucket definitionBucket,
DocumentSpan documentSpan,
string documentName,
Guid projectGuid,
SourceText sourceText)
: base(context, definitionBucket, documentSpan, projectGuid, sourceText)
: base(context, definitionBucket, documentSpan, documentName, projectGuid, sourceText)
{
}
......
......@@ -39,10 +39,11 @@ private class DocumentSpanEntry : AbstractDocumentSpanEntry
RoslynDefinitionBucket definitionBucket,
DocumentSpan documentSpan,
HighlightSpanKind spanKind,
string documentName,
Guid projectGuid,
SourceText sourceText,
ClassifiedSpansAndHighlightSpan classifiedSpans)
: base(context, definitionBucket, documentSpan, projectGuid, sourceText)
: base(context, definitionBucket, documentSpan, documentName, projectGuid, sourceText)
{
_spanKind = spanKind;
_classifiedSpansAndHighlights = classifiedSpans;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册