Fix issues with identifier spans

This commit is contained in:
Deukhoofd 2019-01-17 17:33:53 +01:00
parent 1e7fc7629e
commit d341318989
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
3 changed files with 2 additions and 16 deletions

View File

@ -250,7 +250,7 @@ namespace Upsilon.Parser
var str = stringBuilder.ToString(); var str = stringBuilder.ToString();
if (kind == SyntaxKind.Identifier) if (kind == SyntaxKind.Identifier)
{ {
return new IdentifierToken(str, new TextSpan(startLine, start, _linePosition, _position)); return new IdentifierToken(str, new TextSpan(startLine, start, _linePosition, _position + 1));
} }
if (kind == SyntaxKind.ReturnKeyword) if (kind == SyntaxKind.ReturnKeyword)

View File

@ -17,6 +17,7 @@ namespace Upsilon.Text
if (startPosition < 0) startPosition = 0; if (startPosition < 0) startPosition = 0;
if (startLine == endLine) if (startLine == endLine)
{ {
if (endPosition > _text[startLine].Length) endPosition = _text[startLine].Length;
return _text[startLine].Substring(startPosition, endPosition - startPosition); return _text[startLine].Substring(startPosition, endPosition - startPosition);
} }
var sb = new StringBuilder(); var sb = new StringBuilder();

View File

@ -1,15 +0,0 @@
namespace Upsilon.Text
{
public struct SourceTextLine
{
public SourceTextLine(int start, int lineLength)
{
Start = start;
LineLength = lineLength;
}
public int Start { get; }
public int LineLength { get; }
public int End => Start + LineLength;
}
}