提交 fa8f20c7 编写于 作者: H Heejae Chang

PR. Feedback

some code clean up - rename and such
上级 12a83529
......@@ -114,7 +114,7 @@ private void ClearAnalyzerDiagnostics(DiagnosticAnalyzer analyzer, ProjectId pro
private DiagnosticsUpdatedArgs MakeArgs(DiagnosticAnalyzer analyzer, ImmutableHashSet<DiagnosticData> items, Project project)
{
var id = analyzer.GetUniqueIdForAnalyzer();
var id = analyzer.GetUniqueId();
return new DiagnosticsUpdatedArgs(
id: Tuple.Create(this, id, project?.Id),
......
......@@ -36,12 +36,12 @@ public static bool IsCompilerAnalyzer(this DiagnosticAnalyzer analyzer)
return false;
}
public static ValueTuple<string, VersionStamp> GetUniqueIdForAnalyzer(this DiagnosticAnalyzer analyzer)
public static ValueTuple<string, VersionStamp> GetUniqueId(this DiagnosticAnalyzer analyzer)
{
// Get the unique ID for given diagnostic analyzer.
// note that we also put version stamp so that we can detect changed analyzer.
var type = analyzer.GetType();
return ValueTuple.Create(type.AssemblyQualifiedName, GetProviderVersion(type.Assembly.Location));
return ValueTuple.Create(type.AssemblyQualifiedName, GetAnalyzerVersion(type.Assembly.Location));
}
public static Action<Diagnostic> GetAddExceptionDiagnosticDelegate(this DiagnosticAnalyzer analyzer, AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource, Project project)
......@@ -83,7 +83,7 @@ public static Action<Diagnostic> GetAddExceptionDiagnosticDelegate(this Diagnost
return AnalyzerExecutor.Create(compilation, analyzerOptions, addDiagnostic, addExceptionDiagnostic, continueOnAnalyzerException, cancellationToken);
}
private static VersionStamp GetProviderVersion(string path)
private static VersionStamp GetAnalyzerVersion(string path)
{
if (path == null || !File.Exists(path))
{
......
......@@ -218,9 +218,9 @@ private static DiagnosticState[] CreateDiagnosticStates(string language, Diagnos
}
/// <summary>
/// Get the unique state name for the given {type, provider} tuple.
/// Get the unique state name for the given {type, analyzer} tuple.
/// Note that this name is used by the underlying persistence stream of the corresponding <see cref="DiagnosticState"/> to Read/Write diagnostic data into the stream.
/// If any two distinct {type, provider} tuples have the same diagnostic state name, we will end up sharing the persistence stream between them, leading to duplicate/missing/incorrect diagnostic data.
/// If any two distinct {type, analyzer} tuples have the same diagnostic state name, we will end up sharing the persistence stream between them, leading to duplicate/missing/incorrect diagnostic data.
/// </summary>
private static ValueTuple<string, VersionStamp> GetNameAndVersion(DiagnosticAnalyzer analyzer, StateType type)
{
......@@ -228,7 +228,7 @@ private static DiagnosticState[] CreateDiagnosticStates(string language, Diagnos
// Get the unique ID for given diagnostic analyzer.
// note that we also put version stamp so that we can detect changed analyzer.
var tuple = analyzer.GetUniqueIdForAnalyzer();
var tuple = analyzer.GetUniqueId();
return ValueTuple.Create(UserDiagnosticsPrefixTableName + "_" + type.ToString() + "_" + tuple.Item1, tuple.Item2);
}
}
......
......@@ -72,7 +72,7 @@ public override Task DocumentOpenAsync(Document document, CancellationToken canc
using (Logger.LogBlock(FunctionId.Diagnostics_DocumentOpen, GetOpenLogMessage, document, cancellationToken))
{
// we remove whatever information we used to have on document open/close and re-calcuate diagnostics
// we had to do this since some diagnostic provider change its behavior based on whether the document is opend or not.
// we had to do this since some diagnostic analyzer change its behavior based on whether the document is opend or not.
// so we can't use cached information.
return ClearDocumentStatesAsync(document, _stateManger.GetStateSets(document.Project), cancellationToken);
}
......@@ -86,7 +86,7 @@ public override Task DocumentResetAsync(Document document, CancellationToken can
_memberRangeMap.Remove(document.Id);
// we remove whatever information we used to have on document open/close and re-calcuate diagnostics
// we had to do this since some diagnostic provider change its behavior based on whether the document is opend or not.
// we had to do this since some diagnostic analyzer change its behavior based on whether the document is opend or not.
// so we can't use cached information.
return ClearDocumentStatesAsync(document, _stateManger.GetStateSets(document.Project), cancellationToken);
}
......@@ -138,8 +138,8 @@ private async Task AnalyzeSyntaxAsync(Document document, ImmutableHashSet<string
{
await HandleSuppressedAnalyzerAsync(document, stateSet, StateType.Syntax, cancellationToken).ConfigureAwait(false);
}
else if (ShouldRunProviderForStateType(userDiagnosticDriver, stateSet.Analyzer, StateType.Syntax, diagnosticIds) &&
(skipClosedFileChecks || ShouldRunProviderForClosedFile(openedDocument, stateSet.Analyzer)))
else if (ShouldRunAnalyzerForStateType(userDiagnosticDriver, stateSet.Analyzer, StateType.Syntax, diagnosticIds) &&
(skipClosedFileChecks || ShouldRunAnalyzerForClosedFile(openedDocument, stateSet.Analyzer)))
{
var data = await _executor.GetSyntaxAnalysisDataAsync(userDiagnosticDriver, stateSet, versions).ConfigureAwait(false);
if (data.FromCache)
......@@ -215,7 +215,7 @@ private async Task AnalyzeBodyDocumentAsync(Document document, SyntaxNode member
{
await HandleSuppressedAnalyzerAsync(document, stateSet, StateType.Document, cancellationToken).ConfigureAwait(false);
}
else if (ShouldRunProviderForStateType(spanBasedDriver, stateSet.Analyzer, StateType.Document, out supportsSemanticInSpan))
else if (ShouldRunAnalyzerForStateType(spanBasedDriver, stateSet.Analyzer, StateType.Document, out supportsSemanticInSpan))
{
var userDiagnosticDriver = supportsSemanticInSpan ? spanBasedDriver : documentBasedDriver;
......@@ -260,8 +260,8 @@ private async Task AnalyzeDocumentAsync(Document document, VersionArgument versi
{
await HandleSuppressedAnalyzerAsync(document, stateSet, StateType.Document, cancellationToken).ConfigureAwait(false);
}
else if (ShouldRunProviderForStateType(userDiagnosticDriver, stateSet.Analyzer, StateType.Document, diagnosticIds) &&
(skipClosedFileChecks || ShouldRunProviderForClosedFile(openedDocument, stateSet.Analyzer)))
else if (ShouldRunAnalyzerForStateType(userDiagnosticDriver, stateSet.Analyzer, StateType.Document, diagnosticIds) &&
(skipClosedFileChecks || ShouldRunAnalyzerForClosedFile(openedDocument, stateSet.Analyzer)))
{
var data = await _executor.GetDocumentAnalysisDataAsync(userDiagnosticDriver, stateSet, versions).ConfigureAwait(false);
if (data.FromCache)
......@@ -313,8 +313,8 @@ private async Task AnalyzeProjectAsync(Project project, ImmutableHashSet<string>
{
await HandleSuppressedAnalyzerAsync(project, stateSet, cancellationToken).ConfigureAwait(false);
}
else if (ShouldRunProviderForStateType(userDiagnosticDriver, stateSet.Analyzer, StateType.Project, diagnosticIds) &&
(skipClosedFileChecks || ShouldRunProviderForClosedFile(openedDocument: false, analyzer: stateSet.Analyzer)))
else if (ShouldRunAnalyzerForStateType(userDiagnosticDriver, stateSet.Analyzer, StateType.Project, diagnosticIds) &&
(skipClosedFileChecks || ShouldRunAnalyzerForClosedFile(openedDocument: false, analyzer: stateSet.Analyzer)))
{
var data = await _executor.GetProjectAnalysisDataAsync(userDiagnosticDriver, stateSet, versions).ConfigureAwait(false);
if (data.FromCache)
......@@ -459,7 +459,7 @@ public override async Task<IEnumerable<DiagnosticData>> GetDiagnosticsForSpanAsy
{
bool supportsSemanticInSpan;
if (!spanBasedDriver.IsAnalyzerSuppressed(stateSet.Analyzer) &&
ShouldRunProviderForStateType(spanBasedDriver, stateSet.Analyzer, stateType, out supportsSemanticInSpan))
ShouldRunAnalyzerForStateType(spanBasedDriver, stateSet.Analyzer, stateType, out supportsSemanticInSpan))
{
var userDiagnosticDriver = supportsSemanticInSpan ? spanBasedDriver : documentBasedDriver;
......@@ -528,7 +528,7 @@ public override async Task<IEnumerable<DiagnosticData>> GetDiagnosticsForSpanAsy
}
}
private bool ShouldRunProviderForClosedFile(bool openedDocument, DiagnosticAnalyzer analyzer)
private bool ShouldRunAnalyzerForClosedFile(bool openedDocument, DiagnosticAnalyzer analyzer)
{
// we have opened document, doesnt matter
if (openedDocument)
......@@ -539,20 +539,20 @@ private bool ShouldRunProviderForClosedFile(bool openedDocument, DiagnosticAnaly
return _owner.GetDiagnosticDescriptors(analyzer).Any(d => d.DefaultSeverity != DiagnosticSeverity.Hidden);
}
private bool ShouldRunProviderForStateType(DiagnosticAnalyzerDriver driver, DiagnosticAnalyzer provider,
private bool ShouldRunAnalyzerForStateType(DiagnosticAnalyzerDriver driver, DiagnosticAnalyzer analyzer,
StateType stateTypeId, ImmutableHashSet<string> diagnosticIds)
{
bool discarded;
return ShouldRunProviderForStateType(driver, provider, stateTypeId, out discarded, diagnosticIds, _owner.GetDiagnosticDescriptors);
return ShouldRunAnalyzerForStateType(driver, analyzer, stateTypeId, out discarded, diagnosticIds, _owner.GetDiagnosticDescriptors);
}
private static bool ShouldRunProviderForStateType(DiagnosticAnalyzerDriver driver, DiagnosticAnalyzer provider, StateType stateTypeId,
private static bool ShouldRunAnalyzerForStateType(DiagnosticAnalyzerDriver driver, DiagnosticAnalyzer analyzer, StateType stateTypeId,
out bool supportsSemanticInSpan, ImmutableHashSet<string> diagnosticIds = null, Func<DiagnosticAnalyzer, ImmutableArray<DiagnosticDescriptor>> getDescriptor = null)
{
Debug.Assert(!driver.IsAnalyzerSuppressed(provider));
Debug.Assert(!driver.IsAnalyzerSuppressed(analyzer));
supportsSemanticInSpan = false;
if (diagnosticIds != null && getDescriptor(provider).All(d => !diagnosticIds.Contains(d.Id)))
if (diagnosticIds != null && getDescriptor(analyzer).All(d => !diagnosticIds.Contains(d.Id)))
{
return false;
}
......@@ -560,13 +560,13 @@ private bool ShouldRunProviderForClosedFile(bool openedDocument, DiagnosticAnaly
switch (stateTypeId)
{
case StateType.Syntax:
return provider.SupportsSyntaxDiagnosticAnalysis(driver);
return analyzer.SupportsSyntaxDiagnosticAnalysis(driver);
case StateType.Document:
return provider.SupportsSemanticDiagnosticAnalysis(driver, out supportsSemanticInSpan);
return analyzer.SupportsSemanticDiagnosticAnalysis(driver, out supportsSemanticInSpan);
case StateType.Project:
return provider.SupportsProjectDiagnosticAnalysis(driver);
return analyzer.SupportsProjectDiagnosticAnalysis(driver);
default:
throw ExceptionUtilities.Unreachable;
......
......@@ -318,7 +318,7 @@ protected override async Task AppendDiagnosticsFromKeyAsync(Project project, Sta
cancellationToken.ThrowIfCancellationRequested();
if (driver.IsAnalyzerSuppressed(stateSet.Analyzer) ||
!this.Owner.ShouldRunProviderForStateType(driver, stateSet.Analyzer, stateType, this.DiagnosticIds))
!this.Owner.ShouldRunAnalyzerForStateType(driver, stateSet.Analyzer, stateType, this.DiagnosticIds))
{
continue;
}
......
......@@ -53,7 +53,7 @@ public void Touch(DiagnosticAnalyzer analyzer, Document document, VersionStamp v
// now update member range map
UpdateMemberRange_NoLock(data, document, newVersion, memberId, span, oldRanges.TextVersion);
// save provider version information
// save analyzer version information
Touch_NoLock(data, analyzer, document, newVersion);
ValidateMemberRangeMap(document, newVersion);
......@@ -188,7 +188,7 @@ private MemberRanges GetSavedMemberRange_NoLock(DictionaryData data, DiagnosticA
ImmutableArray<TextSpan> range;
if (!data.VersionMap.TryGetValue(analyzer, out version))
{
// it is first time for this provider
// it is first time for this analyzer
Contract.ThrowIfFalse(document.TryGetSyntaxRoot(out root));
Contract.ThrowIfFalse(document.TryGetTextVersion(out version));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册