Comments (22)
Hi @CristiCanizales, I just did this and it took care of most of the issues. However I am still showing the following warnings.
from salesforcedx-vscode.
Hi @ebraun95, can you try deleting whole .sfdx
folder, reload vscode, reauth to your org, run SFDX: Refresh SObject Definitions
from the command palette (CMD + Shift + P) and check again?
from salesforcedx-vscode.
@ebraun95 if you reload vscode again, are all the warnings still there?
from salesforcedx-vscode.
@CristiCanizales I closed the project, quit vscode, relauched it, reopened the project and the warnings are still present.
from salesforcedx-vscode.
@ebraun95 Please run SFDX: Refresh SObject Definitions
to see if that helps.
from salesforcedx-vscode.
@peternhale I have already done this several times. The warming from the last image are still there.
from salesforcedx-vscode.
@ebraun95 Just double checking, does dir .sfdx/tools/sobjects/customObjects
have any contents?
from salesforcedx-vscode.
@peternhale yes, it was not there initially until i refreshed the sobject definitions which corrected a majority of the warnings I was seeing in regards to custom objects and fields. However, the last image provided was from after I did the refreshes which still shows those warnings.
from salesforcedx-vscode.
also the warnings from the last image are only from 1 class. I get these warnings whenever i open any class/trigger. For example
from salesforcedx-vscode.
@ebraun95 I am trying to reproduce what you are seeing, using dreamhouse-lwc from Salesforce trailhead. These are the steps I have done thus far.
- remove
.sfdx/tools/246
and.sfdx/tools/sobjects
- reload vscode window
This is the initial state for a workspace wrt Apex language server and sobjects and one should find a structure like this
tree -d .sfdx/tools
.sfdx/tools
├── 246
│ └── StandardApexLibrary
│ ├── ApexPages
│ ├── AppLauncher
│ ├── Approval
│ ├── Auth
│ ├── Cache
│ ├── Canvas
│ ├── ChatterAnswers
│ ├── ConnectApi
│ ├── DataSource
│ ├── Database
│ ├── Datacloud
│ ├── Dom
│ ├── EventBus
│ ├── Flow
│ ├── KbManagement
│ ├── Messaging
│ ├── Metadata
│ ├── Process
│ ├── QuickAction
│ ├── Reports
│ ├── Schema
│ ├── Search
│ ├── Site
│ ├── Slack
│ ├── Support
│ ├── System
│ ├── TerritoryMgmt
│ ├── TxnSecurity
│ ├── UserProvisioning
│ ├── VisualEditor
│ └── Wave
├── debug (optional)
│ └── logs
├── sobjects
│ └── standardObjects
├── soqlMetadata
│ ├── customObjects
│ └── standardObjects
The language server will create the apex.db and install the StandardApexLibrary (~1100 Apex classes). The Apex extension will also seed the sobject/standadObjects
with 19 sobjects, mostly related to CRM.
The output from the Apexlanguage server should look like this
08:35:56.668 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Scanning built-in and system Apex types.
08:35:56.744 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Scanning built-in Apex types.
08:35:56.746 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Collecting built-in standard types from jar
08:35:57.874 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Done collecting built-in standard types from jar
08:35:57.874 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Scanning Apex Standard Library.
08:35:58.101 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Done scanning Apex Standard Library.
08:35:58.103 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Starting ApexIndexer.
08:35:58.103 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Start indexer.
08:35:58.107 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Scanning user-defined types.
08:35:58.108 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Scanning workspace source.
08:35:58.127 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Loading existing resource files from apex.db.
08:35:58.144 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Building change list.
08:35:58.167 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Applying found changes
08:35:58.167 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Creating 32 Apex artifacts in Apex DB
Jan 16, 2024 8:35:58 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 6 ms.
08:35:59.724 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: StandardObjects: 19
08:35:59.725 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: CustomObjects: 0
08:35:59.725 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: ApexFiles: 13
08:35:59.725 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: ErrorFiles: 6
08:35:59.725 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Total Memory (MB): 384
08:35:59.725 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Used Memory (MB): 162
08:35:59.725 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Scanning user-defined types took 1592 ms.
08:35:59.726 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Scanning built-in and system Apex types took 3058 ms.
The language server, in the ApexIndexer section, scans the local workspace for changes between the apex index and apex artifacts. Given this is the initial scan after installing a new apex.db, one would expect to see your custom apex class and trigger files discovered and indexed, as noted by ApexIndexer: ApexFiles: 13
. This scan would also include entries found in .sfdx/tools/sobjects
, as noted by ApexIndexer: StandardObjects: 19
in the log.
This appears to be similar to your original share of the language server output.
In this state one "should" see warnings for custom object that are not present.
During sobject refresh, the org is queried for the requested sobject metadata sobjects (All, standard or custom), those results are written to the appropriate subfolder in sobjects and then the language server will reindex the workspace.
This is what I see after sobject refresh with dreamhouse-lwc repo
08:53:54.746 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - Processing changes to SObjects Created
08:53:54.749 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Start indexer.
08:53:54.750 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Scanning user-defined types.
08:53:54.750 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Scanning workspace source.
08:53:54.773 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Loading existing resource files from apex.db.
08:53:54.784 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Building change list.
08:53:54.815 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Applying found changes
08:53:54.815 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Updating 19 Apex artifacts in Apex DB
08:53:55.401 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Creating 1144 Apex artifacts in Apex DB
08:53:57.945 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: StandardObjects: 1161
08:53:57.945 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: CustomObjects: 2
08:53:57.945 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: ApexFiles: 13
08:53:57.945 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: ErrorFiles: 6
08:53:57.945 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Total Memory (MB): 624
08:53:57.945 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Used Memory (MB): 388
08:53:57.945 [ApexIndexer RUNNING] INFO a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Scanning user-defined types took 3179 ms.
These two entries show that the scanner found 19 existing sobjects in the DB that required updating because they changed on the files system and it is adding 1144 entries that are new in the file system.
Would you retrace these steps for you project and capture the language server results as I have done?
from salesforcedx-vscode.
@peternhale I retraced what you did, the first image is after removing the 246 and sobjects folders. The second image is after I refreshed the sobject definitions.
from salesforcedx-vscode.
@peternhale sorry i refreshed the window after refreshing. I did it again but did not reload. Here is what I see.
from salesforcedx-vscode.
@ebraun95 Thank you. The results show that the custom objects are being picked up by the language server during indexing. I assume you are still seeing the warnings?
from salesforcedx-vscode.
@peternhale That would be correct.
from salesforcedx-vscode.
@ebraun95 would it be possible for you to provide a snippet of your code around these warnings? I just want to see the syntax you are using.
from salesforcedx-vscode.
@peternhale after going though a few classes, here are a few that I can share.
Seems to be anytime have Database.Query. Normal loops with the object directly referenced seem to be okay
Same error with Attachment object and Parent as well
from salesforcedx-vscode.
Thanks @ebraun95 I'll have a look. Is it safe to assume that all your code deploys and runs as expected?
from salesforcedx-vscode.
@ebraun95 In general, its seems to be related to the notion of namespaces in the apex world, or at least the first example is.
I was able to reproduce the warning with this Schema.RecordTypeInfo mid = Schema.SObjectType.Account.getRecordTypeInfosByName().get('foo');
In this case Schema
is both a standard apex class in the System
namespace AND as a namespace itself.
I was able to deploy the snippet above w/o error. I know the warning are annoying (and appear to be incorrect), so I will log a bug to investigate.
from salesforcedx-vscode.
This issue has been linked to a new work item: W-14828510
from salesforcedx-vscode.
@peternhale thank you for looking into this. Since the custom objects and fields are mainly no longer throwing errors and its not hindering my ability to actually do anything it doesn't appear to be a major issue.
from salesforcedx-vscode.
Thanks for letting me know @ebraun95. Hopefully we will be able to improve the language server to provide more accurate information.
from salesforcedx-vscode.
Created a new work item for the warnings. Closing this as the original issue has been fixed
from salesforcedx-vscode.
Related Issues (20)
- unable to connect org HOT 2
- Run Query Option Above SOQL Queries with Results in SOQL Builder Table View HOT 2
- Salesforce Extension Pack (Expanded) has incorrect publisher for Apex PMD extension HOT 3
- Apex debugger not showin Variables HOT 3
- Added an extension setting item that allows you to show or hide the "sf.delete.source.current.file" command in "editor/context" in the salesforcedx-vscode-core package from the context menu. HOT 2
- Running SFDX: "Deploy Source to Org" in VS Code deploying takes too long (15-20 mins) to complete. HOT 2
- Running SFDX: "Deploy Source to Org" in VS Code deploying takes too long (15-20 mins) to complete HOT 5
- Support for newer Java version HOT 7
- Cannot deploy namespaced Apex classes in unlocked packages to org HOT 10
- Infinite Activation HOT 3
- Doesn't work on Macbook M2 chip. HOT 3
- Unable to Retrieve Name spaced metadata in OrgBrowser HOT 12
- sfdx authorize an org failed to run HOT 2
- Timeout or long time for retrieve and diff functions HOT 15
- Repeated IllegalStateException on Valid Apex Code Using Apex Language Server HOT 4
- 📣Important Notice: Errors Caused by Recent Upgrade of ESLint Extension HOT 1
- Quick Start LWC development article out of date HOT 3
- Cannot read properties of undefined (reading 'entries') HOT 7
- Latest (61.2) SOQL & APEX extension fail to activate with recent decomposed element features HOT 4
- Nothing works anymore after upgrading to 61.2.1 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from salesforcedx-vscode.