-
Notifications
You must be signed in to change notification settings - Fork 53
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
ast.DefinitionInfo should include the location of the source code #349
Comments
Hey, it's not quite clear what you're asking. Did you want column numbers as The first would be possible by doing some extra book keeping in the lexer and The latter is possible but significantly more difficult because it requires a If you expand on the use case a bit, we can maybe figure out a work around. |
I answer on our chat, but for other readers, we need to store the start, and end position of the |
@abhinav would you prefer to see this added as distinct type DefinitionInfo struct {
Name string
Line int
Column int
} ... or by moving to an embedded type DefinitionInfo struct {
Position
Name string
} The first is the most backwards-compatible (and easier on the existing test literals). The latter simplifies construction and still allows |
We now have enough information to record full positions (line+column) for constant values. Refs #349
Hey, sorry for the delay. I would lean with the first option, but an alternative is a new Pos field, with Line deprecated in favor of it. We'd still fill Line for backwards compatibility, but Pos is what should be used going forward. Something like this? type DefintiionInfo struct {
Name string
// Deprecated: Use Pos.
Line int
// Position of the definition in the source file.
Pos Position
} |
I think it will probably end up being more trouble maintaining both We can always produce a At a future point when we can break some backwards compatibility, we could drop |
Oh, that's reasonable. So to get a |
The nodeWithLine interface has been retired in favor of nodeWithPosition. ast.Pos() is the generic way to retrieve a node's position, and ast.LineNumber() has been revised to work in terms of the nodeWithPosition interface. Closes #349
Hi!
Now each
ast.Definition
hasfunc Info() DefinitionInfo()
which returns a struct withName
andLine
of theDefinition
, however, would be amazing if instead of the line we have aLocation[int, int]
(i.e token.Position) this would allow me to select back the text range in the source file and do extra parsing.The text was updated successfully, but these errors were encountered: