sancarn / stdVBA

VBA Standard Library - A Collection of libraries to form a common standard layer for modern VBA applications.
MIT License
294 stars 58 forks source link

stdProcess does not parse, property closed with End Function #91

Closed Beakerboy closed 8 months ago

Beakerboy commented 8 months ago

Two method signatures are incorrect. They begin with ‘Public Property’ but close with ‘End Function’.

Returns whether the process is still running or not
'@returns - `true` if the process is still running, `false` otherwise
Public Property Get isRunning() As Boolean
  isRunning = GetProcessVersion(pProcessId) > 0
End Function

'Returns whether the process is critical or not
'@returns - `true` if the process is critical, `false` otherwise
Public Property Get isCritical() As Boolean
  'Note: IsProcessCritical can return a weird boolean where `bool` and `Not bool` both result in `True`, which is nonsense...
  'for this reason we explicitely cast to a long here...
  If CLng(IsProcessCritical(pQueryInfoHandle, isCritical)) = 0 Then
    Err.Raise 1, "stdProcess.isCritical", "Cannot get critical status of process. Error code 0x" & Hex(Err.LastDllError)
  End If
End Function
sancarn commented 8 months ago

Very true, thanks a bunch for the report!

Beakerboy commented 8 months ago

I also see in stdArray that every line continuation symbol has a space after it. Did you manually type those? The VBA IDE will automatically strip them off, and according to Microsoft, a "Line continuation element" must be a space and an underscore that is immediately followed by a line-break.

sancarn commented 8 months ago

Did you manually type those?

I did, I think in the VBE it used to not recognise the line break unless there was a leading space? Either that or something to do with VSCode highlighter perhaps... Can't totally remember it now, because I kinda just do it automatically... 😅


Ahh! Tell you what, I was probably using notepad++ back then and maybe it was auto-correcting stuff so had to press space to press enter so it didn't auto-fill something 😅


Edit: Looks like the VBE automatically removes trailing whitespaces on import/edit

Beakerboy commented 8 months ago

BTW, here's the script I'm using to test my ANTLR grammar: https://github.com/Beakerboy/stdVBA/blob/dev/.github/workflows/lint_vba.yml

Your libraries do enough complicated stuff that I'm finding a ton of bugs in the written VBA language specification document. Currently, I have a strict interpretation of the grammar, but the next step will be to identify those things that the IDE recognizes as errors and corrects automatically, so my linting tool can follow suit. It will notify what was identified and offer to automatically correct them as well.

sancarn commented 8 months ago

Amazing! Interesting that you can't do a PR with that...

sancarn commented 8 months ago

@Beakerboy Do you know if there is a way of finding the issues you have logged and tracking progress?

Beakerboy commented 8 months ago

Yeah, the open specifications team has been great about letting me know that what I’m saying is actually correct, and that the document will have the appropriate changes in the next release.

I have a list of the issues: https://github.com/Beakerboy/grammars-v4/tree/coverage/vba/vba7_1

Beakerboy commented 8 months ago

StdPerformance line 208 has the same problem.

sancarn commented 8 months ago

So it does! Thanks!

Beakerboy commented 8 months ago

The precompiler, grammar, and linter are all very much alpha-beta. I’m using your repo to find and fix bugs so no need to file issue unless you wanted to supply a pull request. However, I’ll run through the few errors your projects are showing so you know what’s what.

first off, I delete all your code in WIP. Several files have comments before the CLASS or Attribute header, which immediately causes parsing errors. Feel free to clean some of it up if you want me to test it.

the VBAL document does not address member attributes in Redim statements, so

‘ Full member addressing does not work
Redim this.foo(1 To 2)

‘ Also in a with block
With Foo
    Redim .bar(1 To 2)
End With

~The precompiler is doing something weird in stdClipboard. It’s failing to comment out a line that should be commented. It’s either a grammar issue in vba_cc.g4 or something in vba_precompiler. I see some commented lines in the code are not getting another single-quote added to them, so I suspect comment lines are affecting the calculation of the line number.~ fixed in grammar

The weird string In string builder tests is not paring correctly. I need to use lab.antlr.org to work through that.

I need to add VB_VarHelpId to the list of available statements at the module level.

sancarn commented 8 months ago

first off, I delete all your code in WIP

Tbh I would suggest that anyway. That whole folder is a mess of incomplete ideas. I really should clean it up fully...

Beakerboy commented 8 months ago

My rule of thumb is my main or master branch is all ready for prime-time. My dev branch is all valid, but not documented or does not 100% coverage, and then a have feature branches for works in progress.

Beakerboy commented 8 months ago

All the outstanding issues with the parsing stage of the Linting tool have been resolved, and it didn’t find any more issues with your code. If you want to mess around with the linter, change parse-only to dev to see the list of recommended whitespace, capitalization and documentation changes…and please let me know if there are any you would like added.

sancarn commented 8 months ago

Not sure I gully agree with some of the linter's whitespace complaints e.g.

image

My assumption is these will only be warnings, but still most linters that I know of are whitespace agnostic and case insensitive... Maybe this makes sense for an IDE addin though... I'm not fully sure. I've seen no errors about comments/docs at the moment which I think is fair. certainly something that would be a nice warning though - e.g. undocumented parameters of a function etc. But I realise that documentation isn't consistent across repos either.

Beakerboy commented 8 months ago

The plan is to allow the whitespace settings to be configurable, or make it easy enough for someone to drop in their own rule. The big one I see in your code is inconsistent capitalization of keywords, like “as” and “end”

Parsing is a “must”, while the Linting side is very much style, like, do I use the Call keyword or not; do I force the use of Public before the function name. In your case, you want to align comments which is a different style then I have code for, and the reason I’m interested in looking at your code is to see what style differences I should develop checks for.

I’m planning on just checking that there is at least one line of comments before each function, sub, and property. Analyzing the content of the comment would be a different project.

sancarn commented 8 months ago

Totally agree with everything you're saying. And yeah makes sense to check your style against someone else's. There are a few other projects out there like vbcordlib which you might want to check against too ☺️

Your plan to check for a leading comment sounds good enough to me ☺️

Beakerboy commented 8 months ago

The plan is to have the “severity” of each rule configurable. Parsing problems would be a “Failure”, anything that the Excel VBA IDE would not allow would be an “error”. Stuff like indentation would be a “warning” and then other stuff like documentation would be a “Notice”. Planning on allowing “Deprecation” as well.

sancarn commented 8 months ago

I think most things like keywords not being capitalised would be something i'd be happy to automate away. Expect this is a long term goal?