本文整理汇总了C#中Workspace.GetOpenDocumentIds方法的典型用法代码示例。如果您正苦于以下问题:C# Workspace.GetOpenDocumentIds方法的具体用法?C# Workspace.GetOpenDocumentIds怎么用?C# Workspace.GetOpenDocumentIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workspace
的用法示例。
在下文中一共展示了Workspace.GetOpenDocumentIds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
public async void Register(Workspace workspace)
{
try
{
var workerBackOffTimeSpanInMS = workspace.Options.GetOption(InternalSolutionCrawlerOptions.PreviewBackOffTimeSpanInMS);
var analyzer = _provider.CreateIncrementalAnalyzer(workspace);
var source = s_cancellationTokens.GetValue(workspace, _ => new CancellationTokenSource());
var solution = workspace.CurrentSolution;
foreach (var documentId in workspace.GetOpenDocumentIds())
{
var document = solution.GetDocument(documentId);
if (document == null)
{
continue;
}
// delay analyzing
await Task.Delay(workerBackOffTimeSpanInMS).ConfigureAwait(false);
// do actual analysis
await analyzer.AnalyzeSyntaxAsync(document, source.Token).ConfigureAwait(false);
await analyzer.AnalyzeDocumentAsync(document, bodyOpt: null, cancellationToken: source.Token).ConfigureAwait(false);
// don't call project one.
}
}
catch (OperationCanceledException)
{
// do nothing
}
}
示例2: ReadOnlyDocumentTracker
public ReadOnlyDocumentTracker(IEditAndContinueWorkspaceService encService, Action<DocumentId, SessionReadOnlyReason, ProjectReadOnlyReason> onReadOnlyDocumentEditAttempt)
: base(assertIsForeground: true)
{
Debug.Assert(encService.DebuggingSession != null);
_encService = encService;
_readOnlyRegions = new Dictionary<DocumentId, IReadOnlyRegion>();
_workspace = encService.DebuggingSession.InitialSolution.Workspace;
_onReadOnlyDocumentEditAttempt = onReadOnlyDocumentEditAttempt;
_workspace.DocumentClosed += OnDocumentClosed;
_workspace.DocumentOpened += OnDocumentOpened;
foreach (var documentId in _workspace.GetOpenDocumentIds())
{
TrackDocument(documentId);
}
}
示例3: SynchronizeWithBuildAsync
public override async Task SynchronizeWithBuildAsync(Workspace workspace, ImmutableDictionary<ProjectId, ImmutableArray<DiagnosticData>> map)
{
if (!PreferBuildErrors(workspace))
{
// prefer live errors over build errors
return;
}
var solution = workspace.CurrentSolution;
foreach (var projectEntry in map)
{
var project = solution.GetProject(projectEntry.Key);
if (project == null)
{
continue;
}
// REVIEW: is build diagnostic contains suppressed diagnostics?
var stateSets = _stateManager.CreateBuildOnlyProjectStateSet(project);
var result = await CreateProjectAnalysisDataAsync(project, stateSets, projectEntry.Value).ConfigureAwait(false);
foreach (var stateSet in stateSets)
{
var state = stateSet.GetProjectState(project.Id);
await state.SaveAsync(project, result.GetResult(stateSet.Analyzer)).ConfigureAwait(false);
}
// REVIEW: this won't handle active files. might need to tweak it later.
RaiseProjectDiagnosticsIfNeeded(project, stateSets, result.OldResult, result.Result);
}
if (PreferLiveErrorsOnOpenedFiles(workspace))
{
// enqueue re-analysis of open documents.
this.Owner.Reanalyze(workspace, documentIds: workspace.GetOpenDocumentIds(), highPriority: true);
}
}
示例4: ClearVersionMap
private void ClearVersionMap(Workspace workspace, DocumentId documentId)
{
if (workspace.GetOpenDocumentIds(documentId.ProjectId).Any())
{
return;
}
var versionMap = GetVersionMapFromBranch(workspace, workspace.PrimaryBranchId);
using (this.gate.DisposableWrite())
{
versionMap.Remove(documentId.ProjectId);
}
}