Complete item when full stop is pressed, after document has been bound
This commit is contained in:
parent
f75b7fc223
commit
55c5f58b47
|
@ -35,7 +35,7 @@ namespace UpsilonLanguageServer.Services
|
|||
{
|
||||
HoverProvider = true,
|
||||
SignatureHelpProvider = new SignatureHelpOptions( new[]{'(', ','}),
|
||||
CompletionProvider = new CompletionOptions(true, ""),
|
||||
CompletionProvider = new CompletionOptions(true, "."),
|
||||
TextDocumentSync = new TextDocumentSyncOptions
|
||||
{
|
||||
OpenClose = true,
|
||||
|
|
|
@ -157,8 +157,13 @@ namespace UpsilonLanguageServer.Services
|
|||
[JsonRpcMethod]
|
||||
public async Task<CompletionList> Completion(TextDocumentIdentifier textDocument, Position position, CompletionContext context)
|
||||
{
|
||||
if (Session.Documents.TryGetValue(textDocument.Uri, out var doc) && doc.Bound != null)
|
||||
{
|
||||
if (!Session.Documents.TryGetValue(textDocument.Uri, out var doc))
|
||||
return new CompletionList(new CompletionItem[0], false);
|
||||
|
||||
await doc.WaitForDocumentBound();
|
||||
if (doc.Bound == null)
|
||||
return new CompletionList(new CompletionItem[0], false);
|
||||
|
||||
var linePos = doc.SourceText.GetLineStartPos(position.Line);
|
||||
var characterPosition = linePos + position.Character;
|
||||
using (var nodeIterator = doc.Bound.GetNodeAtPosition(characterPosition).GetEnumerator())
|
||||
|
@ -191,7 +196,7 @@ namespace UpsilonLanguageServer.Services
|
|||
return new CompletionList(
|
||||
variables.Select(x =>
|
||||
{
|
||||
var (key, value) = x;
|
||||
var (_, value) = x;
|
||||
return new CompletionItem(value.Name,
|
||||
CompletionItemKind.Variable, value.Type.ToString(),
|
||||
x.Value.CommentValue == null
|
||||
|
@ -199,7 +204,7 @@ namespace UpsilonLanguageServer.Services
|
|||
: $"\n\n{string.Join(" \n", value.CommentValue)}");
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
return new CompletionList(new CompletionItem[0], false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue