-
Notifications
You must be signed in to change notification settings - Fork 8
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
fix: parse out word for errors and clear them #1163
Conversation
buildengine/engine.go
Outdated
@@ -29,6 +29,10 @@ type schemaChange struct { | |||
*schema.Module | |||
} | |||
|
|||
type Listener struct { |
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 should be an interface, it's very rare that you would need to use a struct for something like this.
func (s *Server) BuildStarted(dir string) { | ||
dirURI := "file://" + dir | ||
|
||
s.diagnostics.Range(func(uri protocol.DocumentUri, diagnostics []protocol.Diagnostic) bool { |
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.
Aha!
// getLineOrWordLength returns the length of the line or the length of the word starting at the given column. | ||
// If wholeLine is true, it returns the length of the entire line. | ||
// If wholeLine is false, it returns the length of the word starting at the column. | ||
func getLineOrWordLength(filePath string, lineNum, column int, wholeLine bool) (int, error) { |
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.
While this is probably okay as a stop-gap, we should really be extending the error type to include range information so we can include it when the errors are created, as this is incredibly inefficient.
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.
I started down this path and got pretty hung up on parser stuff (I think that was the source of the issue). It was a bit of a time suck so I just put this in for now to keep moving forward.
I suspect it had something to do with how our schema.Position
doesn't exactly match participle.Position
but I'm fully just guessing. Once I added EndColumn
to schema.Position
I lost all position information. I do have a branch with that work though we can pick up when you have a sec :)
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.
Your assumption is correct: the Position type is a mirror of participles so you'll need to either add the end location to the error rather than the position, or include it in our position type and write a function to do the mapping.
78d3a56
to
8a58a71
Compare
Screen.Recording.2024-04-03.at.2.16.13.PM.mov