Skip to content

Commit

Permalink
Remove entirely unused type in diagnostic subsystem (#77054)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi authored Feb 5, 2025
2 parents 0ba72bd + 7f68865 commit 4a7eab4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Workspaces.Diagnostics;
Expand All @@ -14,77 +12,28 @@ namespace Microsoft.CodeAnalysis.Diagnostics.EngineV2;

internal partial class DiagnosticIncrementalAnalyzer
{
/// <summary>
/// Simple data holder for local diagnostics for an analyzer
/// </summary>
private readonly struct DocumentAnalysisData
{
public static readonly DocumentAnalysisData Empty = new(VersionStamp.Default, lineCount: 0, []);

/// <summary>
/// Version of the diagnostic data.
/// </summary>
public readonly VersionStamp Version;

/// <summary>
/// Number of lines in the document.
/// </summary>
public readonly int LineCount;

/// <summary>
/// Current data that matches the version.
/// </summary>
public readonly ImmutableArray<DiagnosticData> Items;

/// <summary>
/// Last set of data we broadcasted to outer world, or <see langword="default"/>.
/// </summary>
public readonly ImmutableArray<DiagnosticData> OldItems;

public DocumentAnalysisData(VersionStamp version, int lineCount, ImmutableArray<DiagnosticData> items)
{
Debug.Assert(!items.IsDefault);

Version = version;
LineCount = lineCount;
Items = items;
OldItems = default;
}

public DocumentAnalysisData(VersionStamp version, int lineCount, ImmutableArray<DiagnosticData> oldItems, ImmutableArray<DiagnosticData> newItems)
: this(version, lineCount, newItems)
{
Debug.Assert(!oldItems.IsDefault);
OldItems = oldItems;
}
}

/// <summary>
/// Data holder for all diagnostics for a project for an analyzer
/// </summary>
private readonly struct ProjectAnalysisData
private readonly struct ProjectAnalysisData(
ProjectId projectId,
VersionStamp version,
ImmutableDictionary<DiagnosticAnalyzer, DiagnosticAnalysisResult> result)
{
/// <summary>
/// ProjectId of this data
/// </summary>
public readonly ProjectId ProjectId;
public readonly ProjectId ProjectId = projectId;

/// <summary>
/// Version of the Items
/// </summary>
public readonly VersionStamp Version;
public readonly VersionStamp Version = version;

/// <summary>
/// Current data that matches the version
/// </summary>
public readonly ImmutableDictionary<DiagnosticAnalyzer, DiagnosticAnalysisResult> Result;

public ProjectAnalysisData(ProjectId projectId, VersionStamp version, ImmutableDictionary<DiagnosticAnalyzer, DiagnosticAnalysisResult> result)
{
ProjectId = projectId;
Version = version;
Result = result;
}
public readonly ImmutableDictionary<DiagnosticAnalyzer, DiagnosticAnalysisResult> Result = result;

public DiagnosticAnalysisResult GetResult(DiagnosticAnalyzer analyzer)
=> GetResultOrEmpty(Result, analyzer, ProjectId, Version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ public ProjectState(StateSet owner, ProjectId projectId)
_lastResult = DiagnosticAnalysisResult.CreateInitialResult(projectId);
}

public ImmutableHashSet<DocumentId> GetDocumentsWithDiagnostics()
=> _lastResult.DocumentIdsOrEmpty;

public bool IsEmpty()
=> _lastResult.IsEmpty;

public bool IsEmpty(DocumentId documentId)
=> IsEmpty(_lastResult, documentId);

/// <summary>
/// Return all diagnostics for the given project stored in this state
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,6 @@ public ImmutableArray<DiagnosticData> GetOtherDiagnostics()
public DiagnosticAnalysisResult ToAggregatedForm()
=> new(ProjectId, Version, DocumentIds, IsEmpty);

public DiagnosticAnalysisResult UpdateAggregatedResult(VersionStamp version, DocumentId documentId)
=> new(ProjectId, version, DocumentIdsOrEmpty.Add(documentId), isEmpty: false);

public DiagnosticAnalysisResult DropExceptSyntax()
{
// quick bail out
Expand Down

0 comments on commit 4a7eab4

Please sign in to comment.