-
Notifications
You must be signed in to change notification settings - Fork 426
Description
Summary
I've noticed a couple places where semantic errors are highlighted in VSCode incorrectly.
For example, methods on the CustomSetting apex class (such as getOrgDefaults()
)always show with the error: Method does not exist or incorrect signature
.
Another example is referencing a private method annotated with @TestVisible
from a test class shows the error: Method is not visible
.
Steps To Reproduce:
Private Methods
- In a Salesforce project, ensure
Salesforcedx-vscode-apex: Enable-semantic-errors
is checked in VS Code settings - Create an Apex Class with a private method and annotated with
@TestVisible
public with sharing class ExampleClass {
@TestVisible
private static Integer addTwoNumbers(Integer a, Integer b) {
return a+b;
}
}
- Create another Apex Class to test the first one
@isTest
public with sharing class ExampleClassTest {
@isTest
static void testAddTwoNumbers() {
Integer result = ExampleClass.addTwoNumbers(2, 3);
Assert.areEqual(5, result);
}
}
addTwoNumbers
is underlined with the following error:Method is not visible: Integer ExampleClass.addTwoNumbers(Integer, Integer)
Custom Settings
- In a Salesforce project, ensure
Salesforcedx-vscode-apex: Enable-semantic-errors
is checked in VS Code settings - Create a CustomSetting in your Salesforce org called
Trigger_Settings
- Create an Apex Class that references the CustomSetting and attempts to get the org defaults.
public with sharing class ExampleClassTwo {
public static void main() {
Trigger_Settings__c ts = Trigger_Settings__c.getOrgDefaults();
}
}
getOrgDefaults
is underlined with the following error:Method does not exist or incorrect signature: getOrgDefaults from the type Trigger_Settings__c
Expected result
Neither scenario should show a semantic error, as the classes will successfully deploy and execute.
Actual result
VS Code shows semantic errors.
Additional information
Salesforce Extension Version in VS Code: 62.14.1
Salesforce CLI Version: @salesforce/cli/2.76.7 darwin-arm64 node-v20.18.0
OS and version: macOS 15.3 (24D60)
VS Code version: 1.97.1 (Universal)
Most recent version of the extensions where this was working: N/A