Skip to content

Commit 6fc18f2

Browse files
OpenDocumentGenerator: Move logging message to ProcessBatchAsync
Move a logging message from the point that a document is enqueued to the point that is dequeued and processed. This also avoids instantiating a DocumentSnapshot to get its Version until later.
1 parent 6503956 commit 6fc18f2

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/OpenDocumentGenerator.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ private async ValueTask ProcessBatchAsync(ImmutableArray<DocumentKey> items, Can
8585
continue;
8686
}
8787

88+
_logger.LogDebug($"Generating {key} at version {document.Version}");
89+
8890
var codeDocument = await document.GetGeneratedOutputAsync(token).ConfigureAwait(false);
8991

9092
foreach (var listener in _listeners)
@@ -117,10 +119,7 @@ private void ProjectManager_Changed(object? sender, ProjectChangeEventArgs args)
117119

118120
foreach (var documentFilePath in newProject.DocumentFilePaths)
119121
{
120-
if (newProject.TryGetDocument(documentFilePath, out var document))
121-
{
122-
EnqueueIfNecessary(document.Key, document.Version);
123-
}
122+
EnqueueIfNecessary(new(newProject.Key, documentFilePath));
124123
}
125124

126125
break;
@@ -135,13 +134,13 @@ private void ProjectManager_Changed(object? sender, ProjectChangeEventArgs args)
135134
var newProject = args.Newer.AssumeNotNull();
136135
var documentFilePath = args.DocumentFilePath.AssumeNotNull();
137136

137+
EnqueueIfNecessary(new(newProject.Key, documentFilePath));
138+
138139
if (newProject.TryGetDocument(documentFilePath, out var document))
139140
{
140-
EnqueueIfNecessary(document.Key, document.Version);
141-
142141
foreach (var relatedDocument in newProject.GetRelatedDocuments(document))
143142
{
144-
EnqueueIfNecessary(relatedDocument.Key, relatedDocument.Version);
143+
EnqueueIfNecessary(relatedDocument.Key);
145144
}
146145
}
147146

@@ -162,7 +161,7 @@ private void ProjectManager_Changed(object? sender, ProjectChangeEventArgs args)
162161

163162
if (newProject.TryGetDocument(relatedDocumentFilePath, out var newRelatedDocument))
164163
{
165-
EnqueueIfNecessary(newRelatedDocument.Key, newRelatedDocument.Version);
164+
EnqueueIfNecessary(newRelatedDocument.Key);
166165
}
167166
}
168167
}
@@ -177,16 +176,14 @@ private void ProjectManager_Changed(object? sender, ProjectChangeEventArgs args)
177176
}
178177
}
179178

180-
void EnqueueIfNecessary(DocumentKey documentKey, int documentVersion)
179+
void EnqueueIfNecessary(DocumentKey documentKey)
181180
{
182181
if (!_options.UpdateBuffersForClosedDocuments &&
183182
!_projectManager.IsDocumentOpen(documentKey.FilePath))
184183
{
185184
return;
186185
}
187186

188-
_logger.LogDebug($"Enqueuing generation of {documentKey.FilePath} in {documentKey.ProjectKey.Id} at version {documentVersion}");
189-
190187
_workQueue.AddWork(documentKey);
191188
}
192189
}

0 commit comments

Comments
 (0)