Closed JNiedle closed 5 years ago
@JNiedle In your VSCode project in the explorer window on the left, can you expand ".sfdx->tools->sobjects->customObjects" folder and see if class files exist for the SObject types references in your source. From the error messages that you have posted I would expect at least the files "Order_Confirmation_Requestc.cls", "Orderc.cls", "OrderReleasec.cls" and "OrderLinec.cls" to show up there.
If they do show up then can you try editing the files that have these errors and see if the error goes away. It is possible that the diagnostics that show up was not updated and this would help us find out if that was the case since an edit would force diagnostics to be refreshed for the file.
@praksb, the class file does exist:
I edited the file and I can see in the output window for the Apex Lanuage server that changes to the object's class file are triggering the language server to re-scan the user defined types:
However it's still not recognizing the custom SObject that I edited.
@JNiedle Can you edit the source file that was referencing this SObject type not the definition file(the source file that has the error)? Also, in your code where you are referencing this SObject, are you able to right-click on the type and invoke other features like Go-To-Definition and Find-All-References and verify if they work as expected?
I am trying to understand if you are observing this issue because the diagnostics is stale or is it because the compiler failed to bind to the SObject type for some reason.
@praksb Editing the file has no effect on the problems listed.
I am unable to peek, go to definition, and find all references are not working. I get "No definition found for Order_Confirmation_Request__C" for peek and go to definition. I get "No results" for find all references.
In my settings.json file I have salesforcedx-vscode-apex.enable-semantic-errors set to true. When setting to false, the problems go away, but I also don't get any of the feedback that I need for development.
One more note: peeking/go to definition/find all references works for sobjects declared as variables or in lists, but not within a query:
However, the other issues I'm seeing for "DML requires SObject or SObject list type" is still an issue. Same with "Method does not exist or incorrect signature: void get(String) from the type Order__c".
@JNiedle Unfortunately, our IDE support for SOQL/SOSL in Apex is not great. This is a feature limitation and we have an open issue in our backlog to be addressed sometime in the future:
https://github.com/forcedotcom/salesforcedx-vscode/issues/947
However, it doesn't explain the warnings you get in the problem box since I would expect the warnings to go away on an edit since that will trigger a recompilation which should bind the SObject types referenced outside of SOQL/SOSL successfully. The only other thing that I would ask you to try is check if the warnings window refresh at all when you remove the line or segment of code that was giving you the warning or if you add more code with syntax/semantic errors. There is a known issue with race condition that might sometimes not cause the diagnostics window to refresh. Our fix for this issue should be out next week.
If you did see the warnings refresh after the above edits, then it would be be helpful for me to further debug if you could share a zip file containing your project classes. You could share it to me via the email address on my profile: https://github.com/praksb
@praksb Thank you for linking the open issue.
I've been developing in this class all day and additions or deletions in that class did not effect the number of problems appearing in the problems window. I added "faketype asdf = new faketype()" and it did give me a new warning for an invalid type: faketype.
I will zip and send the project.
I spoke to @JNiedle about the issue he was observing. I could see that on his machine, the custom sobject type fails to bind and throw an error when used in SOQL. Unfortunately, I couldn't get it to repro on my machine. I am going to do some more investigation to see if there are any special codepaths that would cause the Custom type used in a SOQL statement to fail to bind and throw an error. We may have to add some logging to debug this in the future.
@JNiedle I have a repro of this issue. Like you suspected it occurs only on Windows. I have identified the problem and working on a fix.
@praksb Thanks for following up! Let me know when I can test it!
@JNiedle The fix is now part of the latest extension release: 45.12.0.
Hello , i would request for open of this issue as I'm still facing the same issue and the version I'm using is v53.0.0.
Hi, I am still facing this issue today.
I checked that the sObject_name__c.cls file exists under .sfdx/tools/sobjects/customObjects
(it does) and have tried closing and reopening VSCode several times, including deleting .sfdx/tools/apex.db
to force the server to rebuild its cache. Nothing works. It does not recognize certain custom sObjects.
I'd note that the sObjects causing this are vlocity managed objects which had to be manually added to manifest/package.xml
, (including all of their custom fields) to force sfdx to retrieve them, since just using the wildcard in the manifest was not doing the job. The object definition directories under force-app/main/default/objects/vlocity_cmt__<object_name>__c
are present but have red text in the explorer.
Summary
The Apex Language server does not recognize custom objects and displays "Invalid type" errors and other errors associated with it not recognizing that the custom object exists and inherits sObject methods.
Steps To Reproduce:
Expected result
I expect that the list of problems recognize that the SObject exists and has all the associated methods for an sobject like "get(string)" or "getSobject(string)". Along with this, it is throwing other errors because it does not recognize that the SObject exists like "DML requires SObject or SObject list type".
Actual result
I receive a list of warnings in the problems box in Visual Studio Code:
Even though the objects exist in SalesForce:
VS Code Version: 1.31.1
SFDX CLI Version: 6.56.0
OS and version: Windows x64 1809