-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add location pointing to the end of a source #30
Add location pointing to the end of a source #30
Conversation
trlc/lexer.py
Outdated
def get_end_location(self): | ||
"""Get location pointing to the end of a source.""" | ||
|
||
lines_in_between = self.lexer.content[self.start_pos : self.end_pos + 1].count("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is too long, the pylint check is failing. You can run this locally with
make lint
trlc/lexer.py
Outdated
lines_in_between = self.lexer.content[self.start_pos : self.end_pos + 1].count("\n") | ||
end_line = self.line_no + lines_in_between | ||
n = self.end_pos | ||
while n > self.start_pos: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this logic fully works. For this input file:
'''foo
bar'''
We would get an end location of line 2, column 7, but column should be 6.
trlc/lexer.py
Outdated
@@ -108,6 +108,20 @@ def context_lines(self): | |||
return [stripped_line, | |||
" " * stripped_offset + "^" * min(tlen, maxtrail)] | |||
|
|||
def get_end_location(self): | |||
"""Get location pointing to the end of a source.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This docstring should go into the initial declaration of the function, in Location
trlc/lexer.py
Outdated
end_line = self.line_no + lines_in_between | ||
|
||
end_col = self.end_pos + 1 | ||
for n in range(self.end_pos, 0, -1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That range is too big, you should stop where the token begins, not at 0.
4d65cf1
into
bmw-software-engineering:main
No description provided.