eirikpre / VSCode-SystemVerilog

SystemVerilog support in VS Code
MIT License
124 stars 46 forks source link

Declaring an extern function or task in a class is marked as error #205

Closed amey-kulkarni closed 5 months ago

amey-kulkarni commented 9 months ago

When declaring an extern function or task, the function or task keyword is highlighted as an error because there is no endfunction or endtask keyword associated with it. For example:

class MyClass:
    extern function void MyFunction();
endclass : MyClass

function void MyClass::MyFunction();
    foo;
endfunction : MyFunction

In the above example, the extern function declaration is highlighted as an error.

joecrop commented 9 months ago

@amey-kulkarni, you are referring to the word function being assigned red text, right? The ANTLR parser as well as other compilers don't seem to have an issue with this syntax, from what I can tell. As a matter of fact, the syntax highliter itself is fine with this too.

The issue is coming from language-configuration.json. This list tells vscode about other symbols that should also be treated as begin/end brackets. Putting function/endfunction on this list allows vscode to collapse functions, jump the cursor, etc. It also makes it hand to remind users that they may have forgotten an endfunction. It is also what makes the word function purple instead of the default blue. The downside is that we can't make this bracket mode syntax-aware/smart.

Long story short, it seems to me that the convince/power of listing function/endfunction as a 'bracket' outweighs the red text in cases where endfunction is not needed.