Advanced CRPL Syntax for VSCode

Started by stellatedHexahedron, November 04, 2018, 12:47:32 PM

Previous topic - Next topic

stellatedHexahedron

I'm writing a VSCode extension which does the following for CRPL files

  • Syntax Highlighting
  • Looking stuff up on the wiki
  • Syntactical diagnostics  (making sure block delimiters match, $ parameters are at the start of the file, etc)
  • Implements several VSCode features for named entities (variables/functions): go-to-definition, rename, and find references
  • Checks to make sure variables are used (written to at least once and read from at least once)
I'm planning to add other, more semantic stuff as well -- eg, command signature checking, variable scoping, proofing against some more obscure bugs (mostly as pointed out by Cornucanis so far), etc. If anyone has any ideas of what else I could add, feel free to suggest it.

Most Recent Download Link (To use this file, open VSCode and use the "Extensions: Install from VSIX..." command.)

Releases Page


cornucanis

Looks like a very helpful extension! You may want to add a warning against using Delay within a loop, in order to prevent this bug.

GoodMorning

On the same note, it may be helpful to let user-defined functions tooltips specify the arguments as follows:

:FunctionName # [ In In - Out Out] Some helpful words of description
    "DoSomething" Trace
A narrative is a lightly-marked path to another reality.

kajacx

Nice, I have something simillar for N++ ()link, but not as sophisticated. What I'm missing and would like to see is:
1) a warning if a variable is nevver written to, or never read from. This will greatly reduce typos in varaible names
2) an option to jump to user function definition from a call statement
3) the hints for user function, as was said by GM
You may convince me to use Visual Studio, which is no easy task I assure you.
Why do work yourself, when you can write a program that will do the work for you.

stellatedHexahedron

Quote from: cornucanis on November 05, 2018, 02:28:20 AM
Looks like a very helpful extension! You may want to add a warning against using Delay within a loop, in order to prevent this bug.

Noted!

Quote from: GoodMorning on November 05, 2018, 03:48:44 PM
On the same note, it may be helpful to let user-defined functions tooltips specify the arguments as follows:

:FunctionName # [ In In - Out Out] Some helpful words of description
    "DoSomething" Trace


Yes, that's planned. Any comment(s) immediately following a function definition will be integrated into a tooltip for that function, and if one of the lines follows a certain format, it will also be used for type checking.

Quote from: kajacx on November 10, 2018, 07:00:04 AM
Nice, I have something simillar for N++ ()link, but not as sophisticated. What I'm missing and would like to see is:
1) a warning if a variable is nevver written to, or never read from. This will greatly reduce typos in varaible names
2) an option to jump to user function definition from a call statement
3) the hints for user function, as was said by GM

All planned. For some reason I've been working on type checking as the next thing, but it's taking forever, so I might just switch to doing these things.

Quote from: kajacx on November 10, 2018, 07:00:04 AM
You may convince me to use Visual Studio, which is no easy task I assure you.

Hah, it's always a pain to transfer text editors, but you won't regret it, I assure you :)

cornucanis

#5
Hey, another issue you may want to warn against in your extension recently came to light. The short version is that using SetTerrain within the Awake function will cause the map to become unable to load. As a consequence of this, destroying an object which leaves behind a PZ within the Awake function also causes the issue as explained in the post. So basically the warning should trigger when SetTerrain or Destroy are placed within the Awake function.

stellatedHexahedron

I just released version 0.3 of the extension. The major addition is the ability to rename/jump to definition/find references for variables and functions.

Quote from: cornucanis on November 16, 2018, 06:15:23 AM
Hey, another issue you may want to warn against in your extension recently came to light.

Thanks, cornucanis. I'll include that in the next release.

stellatedHexahedron

Hey, obviously I kinda dropped this project, but for some reason today the stars aligned, and I added a "syntax only on save" option, which should eliminate the dreadful lag on larger files.

Builder17

Quote from: stellatedHexahedron on September 28, 2019, 05:50:19 PM
Hey, obviously I kinda dropped this project, but for some reason today the stars aligned, and I added a "syntax only on save" option, which should eliminate the dreadful lag on larger files.


Grabz

Hey, thanks a bunch.

Don't worry about the project, it's well written and has been an invaluable tool for me. Besides, the hype around writing extravagant CW3 content has mostly died down, so we probably will not see much interest in CRPL, less and less as time goes on.

Grabz

For the 4RPL coders out there, I made a tiny modification to the original vsix file to make the extension work on .4rpl files. It won't highlight new functions and for all intents and purposes will still act like its CRPL, but the useful highlighting will remain, so it is better than nothing.

The file attached has .zip extension, simply change it to .vsix and it will work. I did it this way because the forum whitelist doesn't let me post a vsix, and vsix files are just zip files.

Karsten75

Quote from: Grabz on June 24, 2021, 09:09:11 AM
It won't highlight new functions and for all intents and purposes will still act like its CRPL

Do you know what needs to be done to bring it up to equivalence for 4RPL?

Grabz

Quote from: Karsten75 on June 24, 2021, 05:41:13 PM
Do you know what needs to be done to bring it up to equivalence for 4RPL?
It seems that it is mainly a lot of tedious work copy pasting function names into a config file, and a script will likely need to be adjusted for new features such as $$.

Seeing as the extension is written in NodeJS I'm sure I could do it, but I'm not certain if it is worth the time given the apparent lack of popularity given to this extension.