Update to new Upsilon diagnostics system

This commit is contained in:
Deukhoofd 2019-01-17 12:28:40 +01:00
parent 7c57e8363b
commit 19c3efb6c2
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
5 changed files with 6 additions and 15 deletions

View File

@ -77,14 +77,9 @@ namespace UpsilonLanguageServer
private static Diagnostic ConvertToVsCodeDiagnostic(DiagnosticsMessage message)
{
var (startPosition, startPositionOnLine) = message.GetStartLine();
var (endPosition, endPositionOnLine) = message.GetEndLine();
var sourceString = message.Diagnostics.ScriptString;
if (endPosition >= sourceString.GetLineCount())
endPosition = sourceString.GetLineCount();
var range = new Range(startPosition, startPositionOnLine, endPosition,
endPositionOnLine);
var range = new Range(message.Span.StartLine, message.Span.StartPosition, message.Span.EndLine,
message.Span.EndPosition);
DiagnosticSeverity severity;
switch (message.DiagnosticLevel)

View File

@ -27,8 +27,7 @@ namespace UpsilonLanguageServer.Services
{
if (doc.Bound != null && doc.SourceText != null)
{
var linePos = doc.SourceText.GetLineStartPos(position.Line);
var findNode = doc.Bound.GetBottomNodeAtPosition(linePos + position.Character);
var findNode = doc.Bound.GetBottomNodeAtPosition(position.Line, position.Character);
if (findNode != null)
{
var contents = new StringBuilder($"Kind: {findNode.Kind}");
@ -79,8 +78,7 @@ namespace UpsilonLanguageServer.Services
await doc.WaitForDocumentBound();
if (doc.Bound != null && doc.SourceText != null)
{
var linePos = doc.SourceText.GetLineStartPos(position.Line);
var findNode = doc.Bound.GetBottomNodeAtPosition(linePos + position.Character);
var findNode = doc.Bound.GetBottomNodeAtPosition(position.Line, position.Character);
if (findNode != null)
{
if (findNode.Kind == BoundKind.BoundFunctionCallExpression)
@ -172,9 +170,7 @@ namespace UpsilonLanguageServer.Services
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())
using (var nodeIterator = doc.Bound.GetNodeAtPosition(position.Line, position.Character).GetEnumerator())
{
if (nodeIterator.MoveNext())
{
@ -197,7 +193,7 @@ namespace UpsilonLanguageServer.Services
}
}
var scope = doc.Bound.GetScopeAt(characterPosition);
var scope = doc.Bound.GetScopeAt(position.Line, position.Character);
var variables = scope.GetBoundScopeVisibleVariables();
if (scope != null)
{