Jump to content

Recommended Posts

Posted

I think I have two bugs to report. I'm currently using VS Code 1.101.0 and v1.8.4 of your extension.

  1. The extension gives an error about the With syntax found in Excel.au3 in _Excel_BookNew. The error is: Syntax error: Expected "_", [\t ], or end of line but "I" found.
  2. The extension will silently stop displaying suggestions and won't load any function documentation if you reference a file that contains function documentation that is incorrectly formatted. In my case, I was referencing my Acro.au3 file which has a split Syntax line and an empty remarks line. It requires both to stop functioning, but I haven't been able to figure out exactly what the conditions are. It looks like this:
Spoiler
; #FUNCTION# ====================================================================================================================
; Name ..........: _Acro_DocBookmarkProperties
; Description ...: Sets the various properties of a bookmark and returns an array of properties
; Syntax ........: _Acro_DocBookmarkProperties($oBookmark[, $sName = Default[, $aColor = Default[, $bOpen = Default[,
;                  $iStyle = Default[, $sExecutableJavaScript = Default]]]]])
; Parameters ....: $oBookmark           - an object.
;                  $sName               - [optional] a string value. Default is Default.
;                  $aColor              - [optional] an array, see remarks. Default is Default.
;                  $bOpen               - [optional] True - expended, False - collapsed. Default is Default.
;                  $iStyle              - [optional] an integer, see remarks. Default is Default.
;                  $sExecutableJavaScript- [optional] a string value. Default is Default.
; Return values .: Success - a 0-based 1D array of properties, see remarks for details
;                  Failure - False and sets @error:
;                  |1 - $oBookmark isn't an object
;                  |2 - Error setting name, sets @extended to COM error
;                  |3 - Error setting color, sets @extended to COM error
;                  |4 - Error setting open, sets @extended to COM error
;                  |5 - Error setting style, sets @extended to COM error
;                  |6 - Error setting action (JavaScript), sets @extended to COM error
; Author ........: Seadoggie01
; Modified ......: November 23, 2020
; Remarks .......: Use like: _Acro_DocBookmarkProperties($oBookmark) to get an array of values
;
;                  Default means values won't be changed.
;                  $aColor is ["T"] for transparent, ["G", x] for grayscale,
;                  +["RGB", x, x, x] for a RGB value, or ["CMYK", x, x, x, x] for a CMYK value.
;                  +N.B. The JavaScript color object isn't available through the COM.
;                  $iStyle: 0 is normal, 1 is italic, 2 is bold, and 3 is bold-italic
;                  $sExecutableJavaScript is NOT checked for valid JavaScript
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _Acro_DocBookmarkProperties($oBookmark, $sName = Default, $aColor = Default, $bOpen = Default, $iStyle = Default, $sExecutableJavaScript = Default)
    ; [function internals]
EndFunc

I don't always follow the "proper" documentation (due to laziness about learning it), but I don't think the extension should crash because of it :D It'd be fantastic if it reported an error, great if it displayed just the information it understood, and perfectly acceptable if it displayed nothing and waited for me to update the documentation to something valid (hahahahaha!)

Also, if anyone knows how to quickly restart extensions, I'd love to know. I spent a while testing by deleting some code, closing, and then reopening VS Code to find this bug. The "Extensions: Refresh" does nothing in the case of this not-quite-an-error. Disabling and enabling the extension via the menu is slow, but works -- as I found out later.

As always, thank you so much for your work on this extension!

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Posted (edited)

Hi @seadoggie01! :D

Thanks for the heads up! :D

6 hours ago, seadoggie01 said:

The extension gives an error about the With syntax found in Excel.au3 in _Excel_BookNew. The error is: Syntax error: Expected "_", [\t ], or end of line but "I" found.

This is due to the incomplete parser. Currently With...EndWith blocks are not supported. Anything inside the block will fail, since i haven't added any rules to it yet. The reason is that EVERY rule needs to be copied with the small change, that ".property" is a valid syntax within that or child code blocks.
It is low priority, since With...EndWith is rarely seen used, but will be supported in the future at some point (depending on how urgent it is).

6 hours ago, seadoggie01 said:

The extension will silently stop displaying suggestions and won't load any function documentation if you reference a file that contains function documentation that is incorrectly formatted. In my case, I was referencing my Acro.au3 file which has a split Syntax line and an empty remarks line. It requires both to stop functioning, but I haven't been able to figure out exactly what the conditions are. It looks like this

That's an interesting bug! ;) From quick testing, the issue seems to be caused by the empty line in the remarks:

; Remarks .......: Use like: _Acro_DocBookmarkProperties($oBookmark) to get an array of values
;
;                  Default means values won't be changed.

My guess is some of my code is stuck in an infinite loop... I will look into it and fix it soon, since it can deadlock the extension.
"Legacy" documentation blocks was implemented quick, since I'm trying to move towards the more cross language familiar docBlock syntax, but that still does not mean the code should fail this spectacularly😅

 

6 hours ago, seadoggie01 said:

Also, if anyone knows how to quickly restart extensions, I'd love to know. I spent a while testing by deleting some code, closing, and then reopening VS Code to find this bug. The "Extensions: Refresh" does nothing in the case of this not-quite-an-error. Disabling and enabling the extension via the menu is slow, but works -- as I found out later.

>Developer: Reload Window
Should be your solution. It's not great, but faster than restarting the entire application 😉

 

Thank you for the kind words and the bug reporting! 😄

 

Edit:

found the line causing problems with the function documentation: https://github.com/genius257/vscode-autoit/blob/0f1bb89f8af77ee7a005d1d5a9da429e5f344700/server/src/autoit/docBlock/DocBlockFactory.ts#L84

It's my regular expression to test if the content matches the UDF documentation format. It causes catastrophic backtracking, never getting past that regex check. Prevention in JS seems to time a new worker, child-process or a regex library, from a quick google search...
I don't want to do any of that currently, so I've updated the regex, so it no longer has issues with your example, and if my test parses, I will push the change, and hope this issue does not come back 😜

Edited by genius257
Posted
On 6/17/2025 at 5:38 PM, genius257 said:

This is due to the incomplete parser. Currently With...EndWith blocks are not supported. Anything inside the block will fail, since i haven't added any rules to it yet. The reason is that EVERY rule needs to be copied with the small change, that ".property" is a valid syntax within that or child code blocks.
It is low priority, since With...EndWith is rarely seen used, but will be supported in the future at some point (depending on how urgent it is).

Would it instead be possible to have some sort of state such that you enable or disable the possibility of having ".Property" as valid? It seems like nested rules would be much more difficult/annoying to implement. Then again, I know very little of parsers having only ever made ~1/2 to 3/4 of one myself :)

After skimming your parser: :blink: I might look up PegJS later tonight, but I don't think that my idea will work there.

On 6/17/2025 at 5:38 PM, genius257 said:

>Developer: Reload Window

This. Is. Fantastic! :D

1.8.5 does fix my issue, thank you!

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Posted
5 hours ago, seadoggie01 said:

Would it instead be possible to have some sort of state such that you enable or disable the possibility of having ".Property" as valid? It seems like nested rules would be much more difficult/annoying to implement. Then again, I know very little of parsers having only ever made ~1/2 to 3/4 of one myself :)

Sadly it does not seem like i can. A limitation of the simplicity of the parser grammar. Maybe a script could generate the grammar like that, but that would ruin the point of trying to keep a (relatively) "simple" parser solution.
And yes it will be annoying not only to implement, but also to update.

 

5 hours ago, seadoggie01 said:

After skimming your parser: :blink: I might look up PegJS later tonight, but I don't think that my idea will work there.

The original Peg.js project is abandoned. PeggyJS is the version that is still being worked on ;)

 

Good to hear my extension is working again ;)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...