Skip to content

Commit

Permalink
Merge pull request #12074 from drognanar/revertreasons
Browse files Browse the repository at this point in the history
Revert change to IIncrementalAnalyzer interface
  • Loading branch information
KevinH-MS committed Jun 17, 2016
2 parents 62b4751 + 50c22bc commit cf87973
Show file tree
Hide file tree
Showing 31 changed files with 91 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private static async Task TestAsync(string codeWithMarker)
var document = workspace.Documents.First();
var documentId = document.Id;
var reasons = new InvocationReasons(PredefinedInvocationReasons.DocumentAdded);
await worker.AnalyzeSyntaxAsync(workspace.CurrentSolution.GetDocument(documentId), InvocationReasons.Empty, CancellationToken.None);
await worker.AnalyzeSyntaxAsync(workspace.CurrentSolution.GetDocument(documentId), CancellationToken.None);

var todoLists = worker.GetItems_TestingOnly(documentId);
var expectedLists = document.SelectedSpans;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Task DocumentResetAsync(Document document, CancellationToken cancellation
return _state.PersistAsync(document, new Data(VersionStamp.Default, VersionStamp.Default, ImmutableArray<TodoItem>.Empty), cancellationToken);
}

public async Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
public async Task AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken)
{
// it has an assumption that this will not be called concurrently for same document.
// in fact, in current design, it won't be even called concurrently for different documents.
Expand Down Expand Up @@ -220,12 +220,12 @@ public Task DocumentCloseAsync(Document document, CancellationToken cancellation
return SpecializedTasks.EmptyTask;
}

public Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, InvocationReasons reasons, CancellationToken cancellationToken)
public Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, CancellationToken cancellationToken)
{
return SpecializedTasks.EmptyTask;
}

public Task AnalyzeProjectAsync(Project project, bool semanticsChanged, InvocationReasons reasons, CancellationToken cancellationToken)
public Task AnalyzeProjectAsync(Project project, bool semanticsChanged, CancellationToken cancellationToken)
{
return SpecializedTasks.EmptyTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public async void Register(Workspace workspace)
await Task.Delay(workerBackOffTimeSpanInMS).ConfigureAwait(false);

// do actual analysis
await analyzer.AnalyzeSyntaxAsync(document, InvocationReasons.Empty, source.Token).ConfigureAwait(false);
await analyzer.AnalyzeDocumentAsync(document, bodyOpt: null, reasons: InvocationReasons.Empty, cancellationToken: source.Token).ConfigureAwait(false);
await analyzer.AnalyzeSyntaxAsync(document, source.Token).ConfigureAwait(false);
await analyzer.AnalyzeDocumentAsync(document, bodyOpt: null, cancellationToken: source.Token).ConfigureAwait(false);

// don't call project one.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.SolutionCrawler;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
Expand All @@ -32,9 +31,9 @@ public async Task TestHasSuccessfullyLoadedBeingFalse()
service.DiagnosticsUpdated += (s, a) => Assert.Empty(a.Diagnostics);

// now call each analyze method. none of them should run.
await analyzer.AnalyzeSyntaxAsync(document, InvocationReasons.Empty, CancellationToken.None).ConfigureAwait(false);
await analyzer.AnalyzeDocumentAsync(document, bodyOpt: null, reasons: InvocationReasons.Empty, cancellationToken: CancellationToken.None).ConfigureAwait(false);
await analyzer.AnalyzeProjectAsync(document.Project, semanticsChanged: true, reasons: InvocationReasons.Empty, cancellationToken: CancellationToken.None).ConfigureAwait(false);
await analyzer.AnalyzeSyntaxAsync(document, CancellationToken.None).ConfigureAwait(false);
await analyzer.AnalyzeDocumentAsync(document, bodyOpt: null, cancellationToken: CancellationToken.None).ConfigureAwait(false);
await analyzer.AnalyzeProjectAsync(document.Project, semanticsChanged: true, cancellationToken: CancellationToken.None).ConfigureAwait(false);

// wait for all events to raised
await listener.CreateWaitTask().ConfigureAwait(false);
Expand Down Expand Up @@ -75,9 +74,9 @@ public async Task TestHasSuccessfullyLoadedBeingFalseWhenFileOpened()
};

// now call each analyze method. none of them should run.
await analyzer.AnalyzeSyntaxAsync(document, InvocationReasons.Empty, CancellationToken.None).ConfigureAwait(false);
await analyzer.AnalyzeDocumentAsync(document, bodyOpt: null, reasons: InvocationReasons.Empty, cancellationToken: CancellationToken.None).ConfigureAwait(false);
await analyzer.AnalyzeProjectAsync(document.Project, semanticsChanged: true, reasons: InvocationReasons.Empty, cancellationToken: CancellationToken.None).ConfigureAwait(false);
await analyzer.AnalyzeSyntaxAsync(document, CancellationToken.None).ConfigureAwait(false);
await analyzer.AnalyzeDocumentAsync(document, bodyOpt: null, cancellationToken: CancellationToken.None).ConfigureAwait(false);
await analyzer.AnalyzeProjectAsync(document.Project, semanticsChanged: true, cancellationToken: CancellationToken.None).ConfigureAwait(false);

// wait for all events to raised
await listener.CreateWaitTask().ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1039,13 +1039,13 @@ public Analyzer(bool waitForCancellation = false, bool blockedRun = false)
this.RunningEvent = new ManualResetEventSlim(initialState: false);
}

public Task AnalyzeProjectAsync(Project project, bool semanticsChanged, InvocationReasons reasons, CancellationToken cancellationToken)
public Task AnalyzeProjectAsync(Project project, bool semanticsChanged, CancellationToken cancellationToken)
{
this.ProjectIds.Add(project.Id);
return SpecializedTasks.EmptyTask;
}

public Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, InvocationReasons reasons, CancellationToken cancellationToken)
public Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, CancellationToken cancellationToken)
{
if (bodyOpt == null)
{
Expand All @@ -1055,7 +1055,7 @@ public Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, Invocati
return SpecializedTasks.EmptyTask;
}

public Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
public Task AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken)
{
this.SyntaxDocumentIds.Add(document.Id);
Process(document.Id, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Imports Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Options
Imports Microsoft.CodeAnalysis.Shared.Options
Imports Microsoft.CodeAnalysis.SolutionCrawler
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.UnitTests.Diagnostics
Expand Down Expand Up @@ -1935,7 +1934,7 @@ class MyClass
Assert.Equal(HiddenDiagnosticsCompilationAnalyzer.Descriptor.Id, descriptors.Single().Id)

' Force project analysis
incrementalAnalyzer.AnalyzeProjectAsync(project, semanticsChanged:=True, reasons:=InvocationReasons.Empty, cancellationToken:=CancellationToken.None).Wait()
incrementalAnalyzer.AnalyzeProjectAsync(project, semanticsChanged:=True, cancellationToken:=CancellationToken.None).Wait()

' Get cached project diagnostics.
Dim diagnostics = diagnosticService.GetCachedDiagnosticsAsync(workspace, project.Id).WaitAndGetResult(CancellationToken.None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.TodoComment

Dim document = workspace.Documents.First()
Dim documentId = document.Id
Await worker.AnalyzeSyntaxAsync(workspace.CurrentSolution.GetDocument(documentId), InvocationReasons.Empty, CancellationToken.None)
Await worker.AnalyzeSyntaxAsync(workspace.CurrentSolution.GetDocument(documentId), CancellationToken.None)

Dim todoLists = worker.GetItems_TestingOnly(documentId)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,28 @@ protected BaseDiagnosticIncrementalAnalyzer(DiagnosticAnalyzerService owner, Wor
/// </summary>
/// <param name="document">The document to analyze.</param>
/// <param name="bodyOpt">If present, indicates a portion (e.g. a method body) of the document to analyze.</param>
/// <param name="reasons">The reason(s) this analysis was triggered.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public abstract Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, InvocationReasons reasons, CancellationToken cancellationToken);
public abstract Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, CancellationToken cancellationToken);
/// <summary>
/// Analyze a single project such that diagnostics for the entire project become available.
/// Calls <see cref="DiagnosticAnalyzerService.RaiseDiagnosticsUpdated(DiagnosticsUpdatedArgs)"/> for each
/// unique group of diagnostics, where a group is identified by analysis classification (project), project, and analyzer.
/// </summary>
/// <param name="project">The project to analyze.</param>
/// <param name="semanticsChanged">Indicates a change to the declarative semantics of the project.</param>
/// <param name="reasons">The reason(s) this analysis was triggered.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public abstract Task AnalyzeProjectAsync(Project project, bool semanticsChanged, InvocationReasons reasons, CancellationToken cancellationToken);
public abstract Task AnalyzeProjectAsync(Project project, bool semanticsChanged, CancellationToken cancellationToken);
/// <summary>
/// Apply syntax tree actions (that have not already been applied) to a document.
/// Calls <see cref="DiagnosticAnalyzerService.RaiseDiagnosticsUpdated(DiagnosticsUpdatedArgs)"/> for each
/// unique group of diagnostics, where a group is identified by analysis classification (syntax), document, and analyzer.
/// </summary>
/// <param name="document">The document to analyze.</param>
/// <param name="reasons">The reason(s) this analysis was triggered.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public abstract Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken);
public abstract Task AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken);
/// <summary>
/// Respond to a document being opened for editing in the host.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public bool NeedsReanalysisOnOptionChanged(object sender, OptionChangedEventArgs
return false;
}

public async Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
public async Task AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken)
{
// right now, there is no way to observe diagnostics for closed file.
if (!_workspace.IsDocumentOpen(document.Id) ||
Expand All @@ -103,7 +103,7 @@ public async Task AnalyzeSyntaxAsync(Document document, InvocationReasons reason
_workspace, document.Project.Solution, document.Project.Id, document.Id, diagnosticData));
}

public async Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, InvocationReasons reasons, CancellationToken cancellationToken)
public async Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, CancellationToken cancellationToken)
{
// right now, there is no way to observe diagnostics for closed file.
if (!_workspace.IsDocumentOpen(document.Id) ||
Expand Down Expand Up @@ -150,7 +150,7 @@ private void RaiseEmptyDiagnosticUpdated(int kind, DocumentId documentId)
new DefaultUpdateArgsId(_workspace.Kind, kind, documentId), _workspace, null, documentId.ProjectId, documentId));
}

public Task AnalyzeProjectAsync(Project project, bool semanticsChanged, InvocationReasons reasons, CancellationToken cancellationToken)
public Task AnalyzeProjectAsync(Project project, bool semanticsChanged, CancellationToken cancellationToken)
{
return SpecializedTasks.EmptyTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@ public IncrementalAnalyzerDelegatee(DiagnosticAnalyzerService owner, Workspace w
}

#region IIncrementalAnalyzer
public override Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
public override Task AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken)
{
return Analyzer.AnalyzeSyntaxAsync(document, reasons, cancellationToken);
return Analyzer.AnalyzeSyntaxAsync(document, cancellationToken);
}

public override Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, InvocationReasons reasons, CancellationToken cancellationToken)
public override Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, CancellationToken cancellationToken)
{
return Analyzer.AnalyzeDocumentAsync(document, bodyOpt, reasons, cancellationToken);
return Analyzer.AnalyzeDocumentAsync(document, bodyOpt, cancellationToken);
}

public override Task AnalyzeProjectAsync(Project project, bool semanticsChanged, InvocationReasons reasons, CancellationToken cancellationToken)
public override Task AnalyzeProjectAsync(Project project, bool semanticsChanged, CancellationToken cancellationToken)
{
return Analyzer.AnalyzeProjectAsync(project, semanticsChanged, reasons, cancellationToken);
return Analyzer.AnalyzeProjectAsync(project, semanticsChanged, cancellationToken);
}

public override Task DocumentOpenAsync(Document document, CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Options;
using Microsoft.CodeAnalysis.SolutionCrawler;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.Diagnostics.EngineV2
{
// TODO: make it to use cache
internal partial class DiagnosticIncrementalAnalyzer : BaseDiagnosticIncrementalAnalyzer
{
public override Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
public override Task AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken)
{
return AnalyzeDocumentForKindAsync(document, AnalysisKind.Syntax, cancellationToken);
}

public override Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, InvocationReasons reasons, CancellationToken cancellationToken)
public override Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, CancellationToken cancellationToken)
{
return AnalyzeDocumentForKindAsync(document, AnalysisKind.Semantic, cancellationToken);
}
Expand Down Expand Up @@ -66,7 +65,7 @@ private async Task AnalyzeDocumentForKindAsync(Document document, AnalysisKind k
}
}

public override async Task AnalyzeProjectAsync(Project project, bool semanticsChanged, InvocationReasons reasons, CancellationToken cancellationToken)
public override async Task AnalyzeProjectAsync(Project project, bool semanticsChanged, CancellationToken cancellationToken)
{
try
{
Expand Down
3 changes: 3 additions & 0 deletions src/Features/Core/Portable/Features.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,12 @@
<Compile Include="SolutionCrawler\IncrementalAnalyzerBase.cs" />
<Compile Include="SolutionCrawler\IncrementalAnalyzerProviderBase.cs" />
<Compile Include="SolutionCrawler\InternalSolutionCrawlerOptionsProvider.cs" />
<Compile Include="SolutionCrawler\InvocationReasons.cs" />
<Compile Include="SolutionCrawler\InvocationReasons_Constants.cs" />
<Compile Include="SolutionCrawler\ISolutionCrawlerProgressReporter.cs" />
<Compile Include="SolutionCrawler\ISolutionCrawlerService.cs" />
<Compile Include="SolutionCrawler\IWorkCoordinatorPriorityService.cs" />
<Compile Include="SolutionCrawler\PredefinedInvocationReasons.cs" />
<Compile Include="SolutionCrawler\SolutionCrawlerLogger.cs" />
<Compile Include="SolutionCrawler\InternalSolutionCrawlerOptions.cs" />
<Compile Include="SolutionCrawler\SolutionCrawlerProgressReporter.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public IncrementalAnalyzer(
_metadataPathToInfo = metadataPathToInfo;
}

public override Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, InvocationReasons reasons, CancellationToken cancellationToken)
public override Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt, CancellationToken cancellationToken)
{
if (!document.SupportsSyntaxTree)
{
Expand All @@ -208,7 +208,7 @@ public override Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt,
return UpdateSymbolTreeInfoAsync(document.Project, cancellationToken);
}

public override Task AnalyzeProjectAsync(Project project, bool semanticsChanged, InvocationReasons reasons, CancellationToken cancellationToken)
public override Task AnalyzeProjectAsync(Project project, bool semanticsChanged, CancellationToken cancellationToken)
{
return UpdateSymbolTreeInfoAsync(project, cancellationToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public IIncrementalAnalyzer CreateIncrementalAnalyzer(Workspace workspace)

private class IncrementalAnalyzer : IncrementalAnalyzerBase
{
public override Task AnalyzeSyntaxAsync(Document document, InvocationReasons reasons, CancellationToken cancellationToken)
public override Task AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken)
{
return SyntaxTreeInfo.PrecalculateAsync(document, cancellationToken);
}
Expand Down
Loading

0 comments on commit cf87973

Please sign in to comment.