Fix text spans being too long (using end pos as length)
This commit is contained in:
parent
0f45660a43
commit
16d50b3311
|
@ -10,7 +10,7 @@ namespace Upsilon.Parser
|
||||||
Left = left;
|
Left = left;
|
||||||
Operator = @operator;
|
Operator = @operator;
|
||||||
Right = right;
|
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;
|
public override SyntaxKind Kind => SyntaxKind.BinaryExpression;
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Upsilon.Parser
|
||||||
EqualsToken = equalsToken;
|
EqualsToken = equalsToken;
|
||||||
Expression = expression;
|
Expression = expression;
|
||||||
var start = LocalToken?.Span.Start ?? Identifier.Span.Start;
|
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;
|
public override SyntaxKind Kind => SyntaxKind.AssignmentStatement;
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Upsilon.Parser
|
||||||
var first = statements.FirstOrDefault();
|
var first = statements.FirstOrDefault();
|
||||||
var last = statements.LastOrDefault();
|
var last = statements.LastOrDefault();
|
||||||
if (first != null && last != null)
|
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; }
|
public ImmutableArray<StatementSyntax> Statements { get; }
|
||||||
|
|
|
@ -11,5 +11,10 @@ namespace Upsilon.Text
|
||||||
public int Start { get; }
|
public int Start { get; }
|
||||||
public int Length { get; }
|
public int Length { get; }
|
||||||
public int End => Start + Length;
|
public int End => Start + Length;
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{Start} - {End}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue