Author Topic: Advanced CRPL Syntax for VSCode  (Read 413 times)

stellatedHexahedron

  • Jr. Member
  • **
  • Posts: 5
Advanced CRPL Syntax for VSCode
« on: November 04, 2018, 12:47:32 pm »
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

« Last Edit: November 17, 2018, 10:28:10 am by stellatedHexahedron »

cornucanis

  • Community Guild
  • *****
  • Posts: 174
Re: Advanced CRPL Syntax for VSCode
« Reply #1 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.

GoodMorning

  • Community Guild
  • *****
  • Posts: 3302
  • (Pusillanimous)
Re: Advanced CRPL Syntax for VSCode
« Reply #2 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:
Code: [Select]
:FunctionName # [ In In - Out Out] Some helpful words of description
    "DoSomething" Trace
A narrative is a lightly-marked path to another reality.

kajacx

  • Community Guild
  • *****
  • Posts: 147
  • PRPL custom tools creator
Re: Advanced CRPL Syntax for VSCode
« Reply #3 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
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

  • Jr. Member
  • **
  • Posts: 5
Re: Advanced CRPL Syntax for VSCode
« Reply #4 on: November 13, 2018, 03:22:37 pm »
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!

On the same note, it may be helpful to let user-defined functions tooltips specify the arguments as follows:
Code: [Select]
: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.

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.

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

  • Community Guild
  • *****
  • Posts: 174
Re: Advanced CRPL Syntax for VSCode
« Reply #5 on: November 16, 2018, 06:15:23 am »
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.
« Last Edit: November 16, 2018, 06:22:02 am by cornucanis »

stellatedHexahedron

  • Jr. Member
  • **
  • Posts: 5
Re: Advanced CRPL Syntax for VSCode
« Reply #6 on: November 17, 2018, 10:25:51 am »
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.

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.