BlitzMax VSCode extension worklog

Started by Hezkore, June 29, 2019, 20:11:31

Previous topic - Next topic

Hezkore

You can find more info and the release over at:
https://www.syntaxbomb.com/index.php/topic,5771.0.html

So I've been working on a VSCode extension that adds BlitzMax and BlitzMax NG support to VSCode.
And instead of posting about every single feature I'm adding in that thread; I figured I'd open a worklog.

Recently, I've managed to parse the `commands.txt` file and add everything to the VSCode auto-complete system:


Next; somehow displaying help files associated with each command when the user presses `F1`.
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

Hezkore

#1
VSCode has this thing called a "webview", which should be perfect for displaying the BlitzMax docs (seeing as how they're all HTML anyways).
But it turns out that the webview really only displays things from inside the extensions own workfolder.
That means that it won't display any images or CSS from the BlitzMax documents.

Basically, it ends up like this:


It also doesn't allow for things like '#Print' at the end of the URL for jumping to sections in the HTML.
And I haven't quite figured out how to work around this...
Two hacky solutions come to mind though.

One: I just copy the docs folder into the extension folder at start and only reference those.
I could check the dates on the files and only copy the files that's been changed.
This doesn't solve the "URL jump to section ('#Print')"-problem though.

Two: I scrape the information from the HTML and display it myself.
This does fix the "URL jump to section ('#Print')"-problem, but it means that you can't navigate the documents like you're used to.

I'll update the extension later today with the new auto-complete stuff anyways, and keep working on the webview some more.
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

Hezkore

#2
I've pushed the auto-complete update.
It features some much better indentation rules as well, making it less of a hassle to actually write code, heh.
VSCode will automatically update the extension for you at startup. (unless disabled)
And I made the auto-complete dialog a little nicer:
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

Hezkore

#3
I noticed some architecture and platform oddities with the extension recently.
So I sat down and updated the build options to include architecture and platform.
The extension will automatically select the ones matching your system though, so you shouldn't have to even think about this.
And I believe these options are specific to BlitzMax NG, but feel free to correct me if I'm wrong.
Oh, and there's a new "Build Docs" command which lets you rebuild the BlitzMax module documentations from inside VSCode.



Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

Hezkore

#4
I've pushed a small update which will make the extension less annoying if the BlitzMax path isn't correctly set.
It'll also ask the user to set the path if it's incorrect, instead of only when it's not set at all.



And I've gotten some requests about "folding".
The funny thing is that it's already supported!
It's just that VSCode doesn't show it unless you hover over it.



So I've now also set the `editor.showFoldingControls` to `always` for the extension.
You can still change it per workspace and user if you prefer the old style.
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

Hezkore

#5
Sadly I've made no progress with the integrated documentations.
Though I've added some "hover information".
Basically if you hover over anything the extension will try to find an explanation for it:


This exposed a very minor bug that I've since fixed.
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

Hezkore

#6
Been a busy day at work, so I've not managed to work a whole lot on the extension.
Did some polishing on the hover tips though.
They now include additional information (if it's been provided by the docs).


I'm still not sure how to provide the full documentations.
Thinking about just providing the scraped information with any attached example in a custom view.
At least until I can figure out a way to get the webview to work.
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

Hezkore

#7
So I've been working on re-tooling some parts of the extension.
I'm also abandoning the standard BlitzMax documentations.
One thing I didn't like was that the commands.txt file didn't specifically tell me where the functions and all that was specified.
So I'm instead generating my own documentations, but I'm still using the standard bbdocs tags that 'makedocs' uses.
My system will however automatically updated itself if it detects any changes to the modules.
It'll also tell you exactly where each module function, variable, type etc. is defined.
But it's taking a lot longer than expected...



I feel like it'll be worth it in the end though.
And this will of course work for both Legacy and BmxNG.
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

Hezkore

#8
Slow but steady progress!

Dragon Quest Builders 2 has kept me rather busy.
But the module scanner can now go through all modules, plus all the imports and document every 'bbdoc'.
I'm pretty happy with the speed of it.
And it should automatically detect changes to the modules and update itself next start or by forcing a check.
It'll cache everything as well, so if no changes has been made; it'll just load the previous data.

Here's a video of it going through 266 modules.
Then next startup it uses the cached data and goes through 0 modules.
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

Hezkore

#9
So the way the extension detects module changes and updates the docs is by checking each modules folder "last modified" date.
Basically what that means is that if any file is removed, renamed or created inside that directory; the extension will detect it and update the docs.
One problem, and a NTFS file system limitation really, is that modified files inside the folder does NOT update the "last modified" date for the folder.
So if you were to add a new function to your module; the extension would not detect it.
What I've done to fix this is make the extension also look at the "last modified" date on the main .bmx file for that module as well.
One problem however is that imports will not be picked up on by the extension.
That's why something like 'ModuleInfo "Version: 1.00"' is a good idea to have in your modules main .bmx file.
The extension would detect the version changes and update the entire module.

So basically:
Added/removed/renamed any source file - detected
Module main file modified - detected
Imported file modified - not detected

You can also force rebuild the docs yourself by calling a VSCode command!
(which is the only way to do it in MaxIDE)
So if there's anything that doesn't seem right, you can just call that command.
It takes less than 3 seconds to generate docs for all 266 modules on my computer anyways.

It will also, of course, detect any removed modules:


Here's some of what the extension generates for the docs and saves as a Json:
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

iWasAdam

very impressive stuff and FAST. Great work doing this :)

Derron

that last-modified-thing is what BMK has to fight too - if you want to do "quick" builds (only compile changed or never-compiled stuff) then it has to scan through folders too. Especially with wrappers of big libraries and updates of these libraries you might run into stuff not being catched properly.

I think you should have an option which also scans "deeply" for modules without "last modified" changes (for the "last modified" ones we can skip traversing through all the subfolders).
This works well as:
- threaded (you can edit code meanwhile)
- not needed immediately (syntax highlighting can "update" while coding)
- is still done pretty fast (especially with "framework" limiting available modules/files)

BMK cannot do that as for compilation it _needs_ current code compilates right in that moment.



Keep up the work - never thought you will put so much efforts in (I just got my Geany plugin working and ... work pretty much done. Barebone ;-)).


bye
Ron

Hezkore

Thanks everyone!

And yeah, I do have some plans on how to better detect module changes.
But that will have to wait until later. :)

And grats on your Geany plugin!
Maybe Brucey needs to update this list then: https://blitzmax.org/docs/en/community/ides/
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

Hezkore

#13
One funny thing about making this module scanner is that I get to see all the bbdoc tag typos.



I'll eventually fix the typos and make a pull request... unless Brucey sees this.
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

Derron