Handling of displaying comment data on functions

This commit is contained in:
Deukhoofd 2018-11-26 15:14:14 +01:00
parent 4efc452dd2
commit 6aeb95c289
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
3 changed files with 13 additions and 3 deletions

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using JsonRpc.Standard.Contracts;
@ -6,6 +7,7 @@ using LanguageServer.VsCode;
using LanguageServer.VsCode.Contracts;
using LanguageServer.VsCode.Server;
using Upsilon.Binder;
using Upsilon.Parser;
namespace UpsilonLanguageServer.Services
{
@ -25,15 +27,23 @@ namespace UpsilonLanguageServer.Services
var findNode = doc.Bound.GetNodeAtPosition(linePos + position.Character);
if (findNode != null)
{
var contents = $"Kind: {findNode.Kind}";
var contents = new StringBuilder($"Kind: {findNode.Kind}");
if (findNode is BoundExpression expression)
{
contents += $"\n\nType: {expression.Type}";
contents.Append($"\n\nType: {expression.Type}");
}
if (findNode is BoundVariableSymbol varSymbol)
{
if (varSymbol.VariableSymbol.CommentValue != null)
{
contents.Append($"\n\n{string.Join(" \n", varSymbol.VariableSymbol.CommentValue)}");
}
}
return new Hover()
{
Contents = contents
Contents = contents.ToString()
};
}
}