Fix text spans being too long (using end pos as length)

This commit is contained in:
Deukhoofd 2018-11-17 14:37:41 +01:00
parent 0f45660a43
commit 16d50b3311
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
4 changed files with 8 additions and 3 deletions

View File

@ -10,7 +10,7 @@ namespace Upsilon.Parser
Left = left;
Operator = @operator;
Right = right;
Span = new TextSpan(left.Span.Start, right.Span.End);
Span = new TextSpan(left.Span.Start, right.Span.End - left.Span.Start);
}
public override SyntaxKind Kind => SyntaxKind.BinaryExpression;

View File

@ -13,7 +13,7 @@ namespace Upsilon.Parser
EqualsToken = equalsToken;
Expression = expression;
var start = LocalToken?.Span.Start ?? Identifier.Span.Start;
Span = new TextSpan(start, Expression.Span.End);
Span = new TextSpan(start, Expression.Span.End - start);
}
public override SyntaxKind Kind => SyntaxKind.AssignmentStatement;

View File

@ -13,7 +13,7 @@ namespace Upsilon.Parser
var first = statements.FirstOrDefault();
var last = statements.LastOrDefault();
if (first != null && last != null)
Span = new TextSpan(first.Span.Start, last.Span.End);
Span = new TextSpan(first.Span.Start, last.Span.End - first.Span.Start);
}
public ImmutableArray<StatementSyntax> Statements { get; }

View File

@ -11,5 +11,10 @@ namespace Upsilon.Text
public int Start { get; }
public int Length { get; }
public int End => Start + Length;
public override string ToString()
{
return $"{Start} - {End}";
}
}
}