@@ -214,8 +214,9 @@ ProjectEntry DoParse(ITextSource fileContent, IProject parentProject, bool fullP
214214 return new ProjectEntry ( parentProject , parseInfo . UnresolvedFile , parseInfo ) ;
215215 } else {
216216 if ( versionComparison == 0 && index >= 0 ) {
217+ // Ensure we have parse info for the specified project (entry.UnresolvedFile is null for newly registered projects)
217218 // If full parse info is requested, ensure we have full parse info.
218- if ( ! ( fullParseInformationRequested && entries [ index ] . CachedParseInformation == null ) ) {
219+ if ( entries [ index ] . UnresolvedFile != null && ! ( fullParseInformationRequested && entries [ index ] . CachedParseInformation == null ) ) {
219220 // We already have the requested version parsed, just return it:
220221 return entries [ index ] ;
221222 }
@@ -271,6 +272,7 @@ ParseInformation ParseWithExceptionHandling(ITextSource fileContent, bool fullPa
271272 #region ParseAsync
272273 Task < ProjectEntry > runningAsyncParseTask ;
273274 ITextSourceVersion runningAsyncParseFileContentVersion ;
275+ IProject runningAsyncParseProject ;
274276 bool runningAsyncParseFullInfoRequested ;
275277
276278 public async Task < ParseInformation > ParseAsync ( ITextSource fileContent , IProject parentProject , CancellationToken cancellationToken )
@@ -312,15 +314,17 @@ Task<ProjectEntry> DoParseAsync(ITextSource fileContent, IProject parentProject,
312314 int index = FindIndexForProject ( parentProject ) ;
313315 int versionComparison = CompareVersions ( fileContent . Version ) ;
314316 if ( versionComparison == 0 && index >= 0 ) {
317+ // Ensure we have parse info for the specified project (entry.UnresolvedFile is null for newly registered projects)
315318 // If full parse info is requested, ensure we have full parse info.
316- if ( ! ( requestFullParseInformation && entries [ index ] . CachedParseInformation == null ) ) {
319+ if ( entries [ index ] . UnresolvedFile != null && ! ( requestFullParseInformation && entries [ index ] . CachedParseInformation == null ) ) {
317320 // We already have the requested version parsed, just return it:
318321 return Task . FromResult ( entries [ index ] ) ;
319322 }
320323 }
321324 // Optimization:
322325 // if an equivalent task is already running, return that one instead
323326 if ( runningAsyncParseTask != null && ( ! requestFullParseInformation || runningAsyncParseFullInfoRequested )
327+ && runningAsyncParseProject == parentProject
324328 && runningAsyncParseFileContentVersion . BelongsToSameDocumentAs ( fileContent . Version )
325329 && runningAsyncParseFileContentVersion . CompareAge ( fileContent . Version ) == 0 )
326330 {
@@ -338,12 +342,14 @@ Task<ProjectEntry> DoParseAsync(ITextSource fileContent, IProject parentProject,
338342 lock ( this ) {
339343 runningAsyncParseTask = null ;
340344 runningAsyncParseFileContentVersion = null ;
345+ runningAsyncParseProject = null ;
341346 }
342347 }
343348 } , cancellationToken ) ;
344349 if ( fileContent != null && fileContent . Version != null && ! cancellationToken . CanBeCanceled ) {
345350 runningAsyncParseTask = task ;
346351 runningAsyncParseFileContentVersion = fileContent . Version ;
352+ runningAsyncParseProject = parentProject ;
347353 runningAsyncParseFullInfoRequested = requestFullParseInformation ;
348354 }
349355 }
0 commit comments