Giter VIP home page Giter VIP logo

Comments (22)

ebraun95 avatar ebraun95 commented on August 19, 2024 1

Hi @CristiCanizales, I just did this and it took care of most of the issues. However I am still showing the following warnings.

image

from salesforcedx-vscode.

CristiCanizales avatar CristiCanizales commented on August 19, 2024

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.

CristiCanizales avatar CristiCanizales commented on August 19, 2024

@ebraun95 if you reload vscode again, are all the warnings still there?

from salesforcedx-vscode.

ebraun95 avatar ebraun95 commented on August 19, 2024

@CristiCanizales I closed the project, quit vscode, relauched it, reopened the project and the warnings are still present.

from salesforcedx-vscode.

peternhale avatar peternhale commented on August 19, 2024

@ebraun95 Please run SFDX: Refresh SObject Definitions to see if that helps.

from salesforcedx-vscode.

ebraun95 avatar ebraun95 commented on August 19, 2024

@peternhale I have already done this several times. The warming from the last image are still there.

from salesforcedx-vscode.

peternhale avatar peternhale commented on August 19, 2024

@ebraun95 Just double checking, does dir .sfdx/tools/sobjects/customObjects have any contents?

from salesforcedx-vscode.

ebraun95 avatar ebraun95 commented on August 19, 2024

@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.

ebraun95 avatar ebraun95 commented on August 19, 2024

also the warnings from the last image are only from 1 class. I get these warnings whenever i open any class/trigger. For example
image

from salesforcedx-vscode.

peternhale avatar peternhale commented on August 19, 2024

@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.

ebraun95 avatar ebraun95 commented on August 19, 2024

@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.

image

image

from salesforcedx-vscode.

ebraun95 avatar ebraun95 commented on August 19, 2024

@peternhale sorry i refreshed the window after refreshing. I did it again but did not reload. Here is what I see.

image

from salesforcedx-vscode.

peternhale avatar peternhale commented on August 19, 2024

@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.

ebraun95 avatar ebraun95 commented on August 19, 2024

@peternhale That would be correct.

image

from salesforcedx-vscode.

peternhale avatar peternhale commented on August 19, 2024

@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.

ebraun95 avatar ebraun95 commented on August 19, 2024

@peternhale after going though a few classes, here are a few that I can share.

Getting error on all of these
image

Getting error on all of these
image

Getting error on all of these
image

Seems to be anytime have Database.Query. Normal loops with the object directly referenced seem to be okay
image

Same error with Attachment object and Parent as well
image
image

from salesforcedx-vscode.

peternhale avatar peternhale commented on August 19, 2024

Thanks @ebraun95 I'll have a look. Is it safe to assume that all your code deploys and runs as expected?

from salesforcedx-vscode.

peternhale avatar peternhale commented on August 19, 2024

@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.

git2gus avatar git2gus commented on August 19, 2024

This issue has been linked to a new work item: W-14828510

from salesforcedx-vscode.

ebraun95 avatar ebraun95 commented on August 19, 2024

@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.

peternhale avatar peternhale commented on August 19, 2024

Thanks for letting me know @ebraun95. Hopefully we will be able to improve the language server to provide more accurate information.

from salesforcedx-vscode.

diyer avatar diyer commented on August 19, 2024

Created a new work item for the warnings. Closing this as the original issue has been fixed

from salesforcedx-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.