Open lukethacoder opened 4 years ago
Is there a work-around for this issue? Barring that, is there a specific version set (VSCode, SFDX) that I can install to get fully-functional autocomplete for Apex classes? For what it's worth, I'm seeing the same logging output for the Apex Language Server.
autocomplete is not working on trigger files it works on certain variables but not work on other ones
(it shows no suggestions)
(no errors on apex language server) vscode: 1.51.1 java: 11.0.9
@gab95 I have the same issue on autocomplete not working for variables defined inside trigger files. No issue on class files.
Thanks for the additional info @kkevinreyes
@kkevinreyes @gab95 We are looking for an open source repository where we can reproduce this issue for testing. Do either of you happen to have an example project where completions from within the trigger files are not working?
Please also include:
"salesforcedx-vscode-apex.advanced.enable-completion-statistics": "true"
. This will output additional information into the Apex Language Server output channel. It will help us determine if this is a performance issue.Thank you again for your help!
This issue has been automatically closed because there has been no response to our request for more information from the original author. Currently, there is not enough information provided for us to take action. Please reply and reopen this issue if you need additional assistance.
Still no luck with autocomplete in either class files or triggers.
enabled "salesforcedx-vscode-apex.advanced.enable-completion-statistics": "true"
and got an extra 2 lines of logging (last 2 lines here).
09:52:47.454 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Scanning built-in and system Apex types.
Apr. 10, 2021 9:52:48 AM apex.jorje.parser.impl.BaseApexLexer dedupe
INFO: Deduped array ApexLexer.DFA22_transition. Found 7075528 shorts which is 13MB not including array overhead. Removed 6418975 shorts which is 12MB not counting array overhead. Took 10 ms.
09:52:50.104 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Patching standard library for System.Database.* methods
09:52:50.109 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Done patching standard library for System.Database.* methods
09:52:50.743 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Scanning user-defined types.
09:52:50.744 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Scanning built-in and system Apex types took 3290 ms.
09:53:03.619 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: StandardObjects: 731
09:53:03.619 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: CustomObjects: 6
09:53:03.619 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: ApexFiles: 157
09:53:03.619 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: ErrorFiles: 65
09:53:03.619 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Scanning user-defined types took 12860 ms.
Apr. 10, 2021 9:57:50 AM org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint notify
INFO: Unsupported notification method: $/setTraceNotification
VS Code Version: 1.55.1 Salesforce Extension Pack (VS Code): 51.8.0 SFDX CLI Version: 7.90.2 OS: Windows 10 Home, Version 10.0.19043 Java version: jdk-11.0.7
This issue has been linked to a new work item: W-9145638
@lukethacoder Have you tried opening a sample-app project like dreamhouse-lwc? I'd like to see if even just a basic demo works. If still no luck there, might try a more nuclear option of uninstalling the extension pack, closing vs code, reopen vs code, and reinstall the extension pack. Try to open dreamhouse-lwc again and see if that works.
If we can get it to work with dreamhouse, that at least tells us there's something about the project structure or Apex contents of the projects you're working with that the language server isn't handling properly. If we can't, that seems like a sign that maybe something with the machine's setup is causing a communication problem.
Do other language server features work? If you right click a method or Apex class reference and select "find all references" or "rename symbols", does it do so successfully? This also will help isolate the problem.
I reckon it might be something machine related. Have nuked vs code + the sf extension pack multiple times over the past few months, again today, and even setup on a new machine with similar issues.
Installed and setup the dreamhouse-lwc project to see if that would work, but it still isn't playing nice.
Right clicking on an apex method doesn't even give the option for "find all references" or "rename symbols".
Apex Language Server logs look the same as posted up further.
Was thinking maybe my Java install might have been the issue (still might be) but I still have intelliJ and Illuminated Cloud 2 working just fine. This issue is one of the only reason I havn't fully moved over to VS Code.
VS Code Version: 1.55.2 Salesforce Extension Pack (VS Code): 51.11.0 SFDX CLI Version: 7.99.0 OS: Windows 10 Home, Version 10.0.19043 Java version: jdk-11.0.7
@lukethacoder did you ever get to the bottom of your issue? I'm seeing exactly the same behaviour.
My personal Windows PC
My work mac
I'm in the process of completely removing AdoptOpenJK and reinstalling from fresh to see if that makes any difference.
I'll also try cloning the dreamhouse-lwc and see if it's potentially a machine or project based issue.
I've wiped and reinstalled AdoptOpenJDK,
New triggers are autocompleting, but existing triggers in my project are not.
Was about to comment that new triggers are working for me as well! That is really strange that old ones are not.
Yup, exactly what i'm seeing. Nothing obvious in the Apex Language Server log either
This is my existing trigger
10:40:27.160 [ForkJoinPool.commonPool-worker-23] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Completions for file:///c:/Users/ben/apexacademy/force-app/main/default/triggers/WarrantySummary.trigger took 6 ms.
10:40:27.160 [ForkJoinPool.commonPool-worker-23] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: LocalVariableNamesCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 0
10:40:27.160 [ForkJoinPool.commonPool-worker-23] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: FieldNamesCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 0
10:40:27.160 [ForkJoinPool.commonPool-worker-23] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: MethodNamesCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 0
10:40:27.160 [ForkJoinPool.commonPool-worker-23] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: MembersCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 0
10:40:27.160 [ForkJoinPool.commonPool-worker-23] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: TypesCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 0
10:40:27.160 [ForkJoinPool.commonPool-worker-23] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: SystemNamespaceCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 0
10:40:27.160 [ForkJoinPool.commonPool-worker-23] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: TriggerKeywordCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 1
10:40:27.160 [ForkJoinPool.commonPool-worker-23] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: TriggerContextVariablesCompletionStrategy; Time Taken [ms]: 2; Number of Items Added: 0
10:40:27.160 [ForkJoinPool.commonPool-worker-23] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: EmbeddedSoqlCompletionStrategy; Time Taken [ms]: 1; Number of Items Added: 0
10:40:27.160 [ForkJoinPool.commonPool-worker-23] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: SObjectFieldNamesCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 0
This is my new trigger
10:42:48.140 [ForkJoinPool.commonPool-worker-9] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Completions for file:///c:/Users/ben/apexacademy/force-app/main/default/triggers/testTrigger.trigger took 3 ms.
10:42:48.140 [ForkJoinPool.commonPool-worker-9] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: LocalVariableNamesCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 0
10:42:48.140 [ForkJoinPool.commonPool-worker-9] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: FieldNamesCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 1
10:42:48.140 [ForkJoinPool.commonPool-worker-9] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: MethodNamesCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 0
10:42:48.140 [ForkJoinPool.commonPool-worker-9] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: MembersCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 0
10:42:48.140 [ForkJoinPool.commonPool-worker-9] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: TypesCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 35
10:42:48.140 [ForkJoinPool.commonPool-worker-9] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: SystemNamespaceCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 2
10:42:48.140 [ForkJoinPool.commonPool-worker-9] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: TriggerKeywordCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 1
10:42:48.140 [ForkJoinPool.commonPool-worker-9] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: TriggerContextVariablesCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 0
10:42:48.140 [ForkJoinPool.commonPool-worker-9] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: EmbeddedSoqlCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 0
10:42:48.140 [ForkJoinPool.commonPool-worker-9] INFO a.j.l.i.c.ApexCompletionStrategyAggregator - Strategy: SObjectFieldNamesCompletionStrategy; Time Taken [ms]: 0; Number of Items Added: 0
Is the content of the triggers identical? Are they both using the same API version?
Does the ‘refresh object definitions’ sfdx command somehow solve your issue? Its been deemed to solve some autocomplete issues in the past, but I have no idea if it will help in your case with the trigger/apex. Thought I’d ask because i dont see mention of that factor here.
-- Sent from Gmail Mobile
Is the content of the triggers identical?
Nope. I'll try this.
Are they both using the same API version?
Both in the same project - so yes?
Did some testing from the suggestion from @randi274
It looks like a scoping problem (forgive me if i use the wrong terminology, i'm still learning some of this! 😄 )
trigger testTrigger on Case (before insert) {
Boolean thisIsFalse;
for( Case c : Trigger.new) {
Boolean thisIsTrue;
}
}
If I try to complete this
then I get thisIsFalse
, but not thisIsTrue
Summary
Autocomplete / IntelliSense not working for Apex code. On both SObjects and built in Apex functions.
Steps To Reproduce:
sfdx sobject definitions refresh -u ORG_NAME
Expected result
Should show autocomplete/IntelliSense or snippet suggestion
Actual result
No autocomplete suggestions.
Additional information
SObject definitions pull in nicely.
Autocomplete doesnt work so nicely.
Additional information VS Code Version: 1.44.2 SFDX CLI Version: 7.56.1-2773b53bf5 OS and version: Windows 10 Home, Version 1909 JAVA Version: jdk-11.0.7
Have tried using various environments, both sandboxes and scratch orgs. Projects have very few apex classes, or any other components.
Test Classes do work very nicely, and I have double checked my JAVA_HOME/JDK_HOME paths (in addition to adding
"salesforcedx-vscode-apex.java.home": "C:\\Program Files\\Java\\jdk-11.0.7",
to preferences.Apex Language Server output log
Other related issues https://github.com/forcedotcom/salesforcedx-vscode/issues/2095 https://github.com/forcedotcom/salesforcedx-vscode/issues/920 https://github.com/forcedotcom/salesforcedx-vscode/issues/935