Syntax highlighting, code completion, auto indentation fail when method named void.

Issue #549 resolved
Craig Ceremuga created an issue

Let me preface this by saying I know that one's best practices should never involve naming a method "void" given its status as a return type, but sometimes things happen. Despite that, Salesforce does technically allow you to name your method that, and it deploys fine.

When these things happen, syntax highlighting, code completion and auto indentation get thrown off for the entire file containing a method named "void". See the screenshot below for a bit more info regarding the highlighting aspect of it.

Screen Shot 2017-02-22 at 2.11.09 PM.png

Comments (6)

  1. Scott Wells repo owner

    Thanks for the report, Craig. This is one of the things about Apex that perplexes me...why language keywords/reserved words are allowed as identifiers. Anyway, sounds like void is intended to be a valid identifier name, though, so I'll add it to the list of keywords that can be used as identifiers in an upcoming release.

  2. Scott Wells repo owner

    Thanks for letting me know, Felipe. While Salesforce does publish a list of reserved words that can also be used as identifiers, as evidenced by this and other reported issues, it's quite incomplete. As a result I've tried to be conservative when it comes to adding reserved words/keywords as valid identifiers in Apex because of the potential for breaking the parser on valid code accidentally. For the most part I've been doing it reactively. I'll add export to the list and would certainly be interested to know if others are found that need to be added.

  3. Log in to comment