😰 Mood: Frantically refreshing the live race results every hour on the hour for Big’s Backyard Ultra. Currently 2 people left who have run 341 miles.

đŸŽ” Soundtrack: “wfh but make it jazz” playlist

📚 Reading Github Issues

Nothing exciting.

đŸ©ș Making My Own Diagnostic

After some other work stuff (boooooo), I got back to looking at gopls.

I was able to build gopls locally. (It was justgo install, idk why I thought it would be more complicated.) Then everything “just worked”. VSCode pointed to my version and I added some fun “meows” to the code to make sure.

I also learned that gopls has a CLI to test with so I don’t need to reload VSCode every time. Plus I was able to use the CLI to figure out that I am looking to group diagnostics together. Knowing that term will come in handy when searching the code.

$ gopls check --help
show diagnostic results for the specified file

Usage: check [flags] <filename>

Example: show the diagnostic results of this file:

  $ gopls check internal/lsp/cmd/check.go
$ gopls check main.go
main.go:62:3-4: MEOW redundant type from array, slice, or map composite literal
main.go:63:3-4: MEOW redundant type from array, slice, or map composite literal
main.go:64:3-4: MEOW redundant type from array, slice, or map composite literal
main.go:65:3-4: MEOW redundant type from array, slice, or map composite literal

Can you can tell it’s my dev version đŸ±??

I was poking through the code trying to figure out where to even start and I decided to learn how the code works by writing my own diagnostic. Initially my goal was to create a diagnostic that searched for the word “amelia” (my name) in a comment and suggested replacing it with “ameowlia” (my screen name).

Of course all parsing is done via ASTs. I never had to use ASTs before this sabbatical. They have really come up a lot in all of the areas I have explored. I had trouble finding the comments in the AST and eventually I determined that it was because the code was parsed excluding comments. Ah.

I made a new goal to create a diagnostic that finds string variables with the word “amelia” in them and replace “amelia” with “ameowlia”.

I looked at this diagnostic for “no new vars” and this one for simplifying composite literals for inspiration. And I was able to get something (very basic) working.

What is missing:

  • I’m struggling to get the quotes right when I replace it.
  • Right now it replaces the whole string (including quotes) not just the part that says “amelia”.
  • All of the text descriptions are sloppy and are kinda bogus.

But it is progress!