salesforcedx-vscode icon indicating copy to clipboard operation
salesforcedx-vscode copied to clipboard

Syntax highlight on Code Initializer is incorrect

Open jefersonchaves opened this issue 1 year ago • 0 comments

Summary

The code inside of an initializer (more info at "Using Initialization Code") does not match method code blocks.

Steps To Reproduce:

  1. Create a class like this:
public with sharing class TestDataBuilder {

    public class NoneDAGException extends Exception {
        // Initializer
        {
            this.setMessage('Object graph should be a Directed Acyclic Graph.');
        }

        // Sample method for comparison
        public void anotherMethod() {
            this.setMessage('Object graph should be a Directed Acyclic Graph.');
        }
    }

}
  1. Save the cls file.

Expected result

The same result of anotherMethod. image

Actual result

The string inside this.setMessage is not highlighted as the other code. image

Additional information

Interestingly enough that changing it to auto-detect on a new file (it detects Anonymous Apex), does highlight correctly: image

However, picking Anonymous Apex provides the incorrect highlight again.

Salesforce Extension Version in VS Code:

SFDX CLI Version: @salesforce/cli/2.0.0-beta.51 darwin-arm64 node-v18.15.0 (Salesforce CLI Beta v2 - https://github.com/forcedotcom/cli/issues/2132).

OS and version: macOS Ventura 13.4 (22F66)

jefersonchaves avatar Jun 14 '23 13:06 jefersonchaves