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 LanguageServer.VsCode.Server;
|
||||||
using Upsilon.Binder;
|
using Upsilon.Binder;
|
||||||
using Upsilon.Parser;
|
using Upsilon.Parser;
|
||||||
|
using Upsilon.Utilities;
|
||||||
|
|
||||||
namespace UpsilonLanguageServer.Services
|
namespace UpsilonLanguageServer.Services
|
||||||
{
|
{
|
||||||
|
@ -25,7 +26,7 @@ namespace UpsilonLanguageServer.Services
|
||||||
if (doc.Bound != null && doc.SourceText != null)
|
if (doc.Bound != null && doc.SourceText != null)
|
||||||
{
|
{
|
||||||
var linePos = doc.SourceText.GetLineStartPos(position.Line);
|
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)
|
if (findNode != null)
|
||||||
{
|
{
|
||||||
var contents = new StringBuilder($"Kind: {findNode.Kind}");
|
var contents = new StringBuilder($"Kind: {findNode.Kind}");
|
||||||
|
@ -117,7 +118,7 @@ namespace UpsilonLanguageServer.Services
|
||||||
if (context.TriggerCharacter == '.')
|
if (context.TriggerCharacter == '.')
|
||||||
{
|
{
|
||||||
var linePos = doc.SourceText.GetLineStartPos(position.Line);
|
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 (findNode is BoundVariableSymbol variableSymbol)
|
||||||
{
|
{
|
||||||
if (variableSymbol.VariableSymbol is TableVariableSymbol tableSymbol)
|
if (variableSymbol.VariableSymbol is TableVariableSymbol tableSymbol)
|
||||||
|
@ -133,13 +134,25 @@ namespace UpsilonLanguageServer.Services
|
||||||
: $"\n\n{string.Join(" \n", value.CommentValue)}");
|
: $"\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(
|
return new CompletionList(
|
||||||
new[]
|
variables.Select(x =>
|
||||||
{
|
{
|
||||||
new CompletionItem(findNode.Kind.ToString(), CompletionItemKind.Variable,
|
var (key, value) = x;
|
||||||
variableSymbol.VariableSymbol.Name, ""),
|
return new CompletionItem(key,
|
||||||
},
|
CompletionItemKind.Variable, value.Type.ToString(),
|
||||||
false);
|
x.Value.CommentValue == null
|
||||||
|
? ""
|
||||||
|
: $"\n\n{string.Join(" \n", value.CommentValue)}");
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue