A lot more auto complete support
This commit is contained in:
parent
fdd97fa9b3
commit
34751d9edc
Binary file not shown.
Binary file not shown.
|
@ -9,6 +9,7 @@ using LanguageServer.VsCode.Contracts;
|
|||
using LanguageServer.VsCode.Server;
|
||||
using Upsilon.Binder;
|
||||
using Upsilon.Parser;
|
||||
using Upsilon.Utilities;
|
||||
|
||||
namespace UpsilonLanguageServer.Services
|
||||
{
|
||||
|
@ -25,7 +26,7 @@ namespace UpsilonLanguageServer.Services
|
|||
if (doc.Bound != null && doc.SourceText != null)
|
||||
{
|
||||
var linePos = doc.SourceText.GetLineStartPos(position.Line);
|
||||
var findNode = doc.Bound.GetNodeAtPosition(linePos + position.Character);
|
||||
var findNode = doc.Bound.GetBottomNodeAtPosition(linePos + position.Character);
|
||||
if (findNode != null)
|
||||
{
|
||||
var contents = new StringBuilder($"Kind: {findNode.Kind}");
|
||||
|
@ -117,7 +118,7 @@ namespace UpsilonLanguageServer.Services
|
|||
if (context.TriggerCharacter == '.')
|
||||
{
|
||||
var linePos = doc.SourceText.GetLineStartPos(position.Line);
|
||||
var findNode = doc.Bound.GetNodeAtPosition(linePos + position.Character - 2);
|
||||
var findNode = doc.Bound.GetBottomNodeAtPosition(linePos + position.Character - 2);
|
||||
if (findNode is BoundVariableSymbol variableSymbol)
|
||||
{
|
||||
if (variableSymbol.VariableSymbol is TableVariableSymbol tableSymbol)
|
||||
|
@ -133,13 +134,25 @@ namespace UpsilonLanguageServer.Services
|
|||
: $"\n\n{string.Join(" \n", value.CommentValue)}");
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var linePos = doc.SourceText.GetLineStartPos(position.Line);
|
||||
var scope = doc.Bound.GetScopeAt(linePos + position.Character);
|
||||
var variables = scope.GetBoundScopeVisibleVariables();
|
||||
if (scope != null)
|
||||
{
|
||||
return new CompletionList(
|
||||
new[]
|
||||
variables.Select(x =>
|
||||
{
|
||||
new CompletionItem(findNode.Kind.ToString(), CompletionItemKind.Variable,
|
||||
variableSymbol.VariableSymbol.Name, ""),
|
||||
},
|
||||
false);
|
||||
var (key, value) = x;
|
||||
return new CompletionItem(key,
|
||||
CompletionItemKind.Variable, value.Type.ToString(),
|
||||
x.Value.CommentValue == null
|
||||
? ""
|
||||
: $"\n\n{string.Join(" \n", value.CommentValue)}");
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue