提交 462f50c5 编写于 作者: H Heejae Chang

fixed where project name gets disappeared if a project is unloaded in "BuildOnly" error list mode.

now we will show <Unknown> for such project.
上级 522e1e0d
......@@ -47,6 +47,29 @@ public AbstractTableDataSource(Workspace workspace)
public abstract string Identifier { get; }
public void RefreshAllFactories()
{
ImmutableArray<SubscriptionWithoutLock> snapshot;
List<TableEntriesFactory<TData>> factories;
lock (_gate)
{
snapshot = _subscriptions;
factories = _map.Values.ToList();
}
// let table manager know that we want to refresh factories.
for (var i = 0; i < snapshot.Length; i++)
{
foreach (var factory in factories)
{
factory.OnRefreshed();
snapshot[i].AddOrUpdate(factory, newFactory: false);
}
}
}
public void Refresh(TableEntriesFactory<TData> factory)
{
var snapshot = _subscriptions;
......@@ -59,6 +82,11 @@ public void Refresh(TableEntriesFactory<TData> factory)
public void Shutdown()
{
// editor team wants us to update snapshot versions before
// removing factories on shutdown.
RefreshAllFactories();
// and then remove all factories.
ImmutableArray<SubscriptionWithoutLock> snapshot;
lock (_gate)
......@@ -214,29 +242,6 @@ protected void ChangeStableState(bool stable)
}
}
protected void RefreshAllFactories()
{
ImmutableArray<SubscriptionWithoutLock> snapshot;
List<TableEntriesFactory<TData>> factories;
lock (_gate)
{
snapshot = _subscriptions;
factories = _map.Values.ToList();
}
// let table manager know that we want to refresh factories.
for (var i = 0; i < snapshot.Length; i++)
{
foreach (var factory in factories)
{
factory.OnRefreshed();
snapshot[i].AddOrUpdate(factory, newFactory: false);
}
}
}
protected void AddAggregateKey(object data, object aggregateKey)
{
_aggregateKeyMap.Add(GetItemKey(data), aggregateKey);
......
......@@ -94,17 +94,17 @@ public string ProjectName
var projectId = Extensions.GetProjectId(Primary);
if (projectId == null)
{
return null;
return ServicesVSResources.Unknown;
}
if (_cache == null)
{
// return single project name
return Workspace.GetProjectName(projectId);
return Workspace.GetProjectName(projectId) ?? ServicesVSResources.Unknown;
}
// return joined project names
return _cache.GetProjectName(Workspace);
return _cache.GetProjectName(Workspace) ?? ServicesVSResources.Unknown;
}
}
......
......@@ -257,10 +257,40 @@ public override bool TryNavigateTo(int index, bool previewTab)
return false;
}
return TryNavigateTo(item.Workspace, item.DocumentId,
return TryNavigateTo(item.Workspace, GetProperDocumentId(item),
item.DataLocation?.OriginalStartLine ?? 0, item.DataLocation?.OriginalStartColumn ?? 0, previewTab);
}
private DocumentId GetProperDocumentId(DiagnosticData data)
{
// check whether documentId still exist. it might have changed if project it belong to has reloaded.
var solution = data.Workspace.CurrentSolution;
if (solution.GetDocument(data.DocumentId) != null)
{
return data.DocumentId;
}
// okay, documentId no longer exist in current solution, find it by file path.
if (string.IsNullOrWhiteSpace(data.DataLocation?.OriginalFilePath))
{
// we don't have filepath
return null;
}
var documentIds = solution.GetDocumentIdsWithFilePath(data.DataLocation.OriginalFilePath);
foreach (var id in documentIds)
{
// found right documentId;
if (id.ProjectId == data.ProjectId)
{
return id;
}
}
// okay, there is no right one, take the first one if there is any
return documentIds.FirstOrDefault();
}
protected override bool IsEquivalent(DiagnosticData item1, DiagnosticData item2)
{
// everything same except location
......
......@@ -78,6 +78,9 @@ protected override void AddTableSourceIfNecessary(Solution solution)
{
if (solution.ProjectIds.Count == 0)
{
// whenever there is a change in solution, make sure we refresh static info
// of build errors so that things like project name correctly refreshed
_buildTableSource.RefreshAllFactories();
return;
}
......@@ -89,6 +92,9 @@ protected override void RemoveTableSourceIfNecessary(Solution solution)
{
if (solution.ProjectIds.Count > 0)
{
// whenever there is a change in solution, make sure we refresh static info
// of build errors so that things like project name correctly refreshed
_buildTableSource.RefreshAllFactories();
return;
}
......
......@@ -1146,6 +1146,15 @@ internal class ServicesVSResources {
}
}
/// <summary>
/// Looks up a localized string similar to &lt;Unknown&gt;.
/// </summary>
internal static string Unknown {
get {
return ResourceManager.GetString("Unknown", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unknown rename type.
/// </summary>
......
......@@ -516,4 +516,7 @@ Use the dropdown to view and switch to other projects this file may belong to.</
<data name="FullSolutionAnalysisOff" xml:space="preserve">
<value>Low memory detected. Full solution analysis disabled for this solution.</value>
</data>
<data name="Unknown" xml:space="preserve">
<value>&lt;Unknown&gt;</value>
</data>
</root>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册