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
Make the code generator emit proper line numbers and positions from .vugu files #38
Comments
@erinpentecost I'm going to try adding in parse.go and the related files so that Parse() works in htmlx. Wish me luck! :) (And let me know if you have any feedback or comments on this.) |
I split out some of the requirements into other files, so you'll probably spot some duplicates if you add in everything I removed. I'm slowly working on an io.Reader wrapper that should let us use the normal module. |
Okay awesome, thanks for the info! |
Ok, I finally finished a writer/reader middleware that can convert between byte offsets and lines/columns. Columns won't be accurate if you use runes that encode to more than one byte. Here's the thing: byteline I'm working on an edit to vugufmt that uses it. Hopefully it works out. |
Awesome! Yeah looks like that could work well. I guess golang/go#31312 never got any further response, bummer. I'm using your fork of x/net/html for line numbers in some new code I'm writing. If this byteline thing ends up working well, I could switch over to doing that instead. |
Note to self on this:
I actually tried this and it was a disaster for this use case. Trouble is generated Go code has lots of code generated stuff in it that doesn't correspond directly to anything in the vugu file (and it's not uncommon for the error to be at this part). And the //line directive does not provide a way "unset" the line back to the original value. Possibly just the <script> part could be done - if it's place at the bottom of the output .go file and has a line directive, that could, should be tried. |
Maybe the best solution is the easy one and just remove the code from inside html and put in a file with a name. mymodule.html So when compiled the errors are in place. |
@morpheus747 You can achieve something close to this right now by having // myfile.vugu:100
if x { That would probably be better than nothing. |
two thinks came to mi mind. Let me understad this more by checking the code so i can add to this problem, because i face this. And can't found the error in the code and was so frustrating. Can you give me some orientation about where is the code generator or where start to read the code ? |
The generated code (from running You should be able to see the emitted |
Looks like the Go compiler supports line directives, allowing us to explicitly indicate an alternate file name and line number of where to look for an error. The code generator should be changed to use the htmlx package now available after #9 to extract and report these line numbers. When #17 is being done, we should make sure you can click on an error in the console and it opens to the correct .vugu file line and col.
Also might be useful: https://dave.cheney.net/2018/01/08/gos-hidden-pragmas
The text was updated successfully, but these errors were encountered: