Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/LanguageServer/Impl/Indexing/MostRecentDocumentSymbols.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.Python.Analysis.Documents;
using Microsoft.Python.Core;
using Microsoft.Python.Core.Diagnostics;
using Microsoft.Python.Parsing.Ast;

namespace Microsoft.Python.LanguageServer.Indexing {
class MostRecentDocumentSymbols : IMostRecentDocumentSymbols {
Expand Down Expand Up @@ -120,7 +121,20 @@ public void Dispose() {
}

private async Task<IReadOnlyList<HierarchicalSymbol>> IndexAsync(IDocument doc, CancellationToken indexCt) {
var ast = await doc.GetAstAsync(indexCt);
PythonAst ast = null;

for (var i = 0; i < 5; i++) {
ast = await doc.GetAstAsync(indexCt);
if (ast != null) {
break;
}
await Task.Delay(100);
}

if (ast == null) {
return Array.Empty<HierarchicalSymbol>();
}

indexCt.ThrowIfCancellationRequested();
var walker = new SymbolIndexWalker(ast);
ast.Walk(walker);
Expand Down