Skip to content

Commit

Permalink
Enable code sync when Live Share is requesting analyzer info
Browse files Browse the repository at this point in the history
  • Loading branch information
zooba committed Nov 28, 2018
1 parent d383817 commit 5da1d66
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions Python/Product/LiveShare/LiveShare.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.LiveShare" />
<Reference Include="Microsoft.VisualStudio.LiveShare.LanguageServices" />
<Reference Include="Microsoft.VisualStudio.Text.Data" />
<Reference Include="Microsoft.VisualStudio.Threading" />
<Reference Include="Microsoft.VisualStudio.Shell.Framework" />
<!-- <Reference Include="Microsoft.VisualStudio.Text.UI" /> -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ public async Task<TOut> RequestAsync<TIn, TOut>(LspRequest<TIn, TOut> method, TI
method.Name == Methods.TextDocumentReferences.Name ||
method.Name == Methods.TextDocumentSignatureHelp.Name
) {
var analyzer = await FindAnalyzer((param as TextDocumentPositionParams)?.TextDocument);
var doc = (param as TextDocumentPositionParams)?.TextDocument;
if (doc == null) {
return default(TOut);
}

var analyzer = await FindAnalyzer(doc);
if (analyzer == null) {
return default(TOut);
}
Expand All @@ -106,6 +111,16 @@ public async Task<TOut> RequestAsync<TIn, TOut>(LspRequest<TIn, TOut> method, TI
return (TOut)(object)await analyzer.SendLanguageServerRequestAsync<TIn, Location[]>(method.Name, param);
}

var entry = analyzer.GetAnalysisEntryFromUri(doc.Uri);
if (entry != null) {
var buffers = entry.TryGetBufferParser()?.AllBuffers;
if (buffers != null) {
foreach (var b in buffers) {
await entry.EnsureCodeSyncedAsync(b);
}
}
}

return await analyzer.SendLanguageServerRequestAsync<TIn, TOut>(method.Name, param);
}

Expand Down

0 comments on commit 5da1d66

Please sign in to comment.