Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apex Server Language Error #388

Closed
marcalbaladejo opened this issue Apr 19, 2018 · 13 comments
Closed

Apex Server Language Error #388

marcalbaladejo opened this issue Apr 19, 2018 · 13 comments

Comments

@marcalbaladejo
Copy link

Summary

Hi,
We are getting these errors in the output console. Any idea about how to fix them?

09:15:12.381 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Scanning built-in and system Apex types.
Apr 19, 2018 9:15:12 AM org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint notify
WARNING: Unsupported notification method: initialized
Apr 19, 2018 9:15:12 AM apex.jorje.parser.impl.BaseApexLexer dedupe
INFO: Deduped array ApexLexer.DFA22_transition. Found 7403062 shorts which is 14MB not including array overhead. Removed 6746470 shorts which is 12MB not counting array overhead. Took 9 ms.
09:15:15.002 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Patching standard library for System.Database.* methods
09:15:15.008 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Done patching standard library for System.Database.* methods
09:15:15.608 [ApexIndexer STARTING] INFO a.jorje.lsp.impl.index.ApexIndexer - Scanning user-defined types.
09:15:15.607 [Apex Prelude Service STARTING] INFO a.j.l.i.s.ApexPreludeManagedService - Scanning built-in and system Apex types took 3227 ms.
09:15:31.238 [ApexIndexer STARTING] ERROR a.jorje.lsp.impl.index.ApexIndexer - exception thrown in traversing codeunit for references
java.lang.NullPointerException: null
at apex.jorje.lsp.impl.utils.TypeUsageSiteUtil.processTypeUsageSite(TypeUsageSiteUtil.java:46)
at apex.jorje.lsp.impl.index.ApexIndexer$1.visitEnd(ApexIndexer.java:543)
at apex.jorje.lsp.impl.index.ApexIndexer$1.visitEnd(ApexIndexer.java:254)
at apex.jorje.semantic.ast.expression.NewListInitExpression.traverse(NewListInitExpression.java:112)
at apex.jorje.semantic.ast.statement.VariableDeclaration.traverse(VariableDeclaration.java:81)
at apex.jorje.semantic.ast.statement.VariableDeclarationStatements.traverse(VariableDeclarationStatements.java:87)
at apex.jorje.semantic.ast.statement.BlockStatement.traverse(BlockStatement.java:140)
at apex.jorje.semantic.ast.statement.MethodBlockStatement.traverse(MethodBlockStatement.java:75)
at apex.jorje.semantic.ast.member.Method.traverse(Method.java:103)
at apex.jorje.semantic.ast.compilation.UserClass.traverse(UserClass.java:126)
at apex.jorje.lsp.impl.index.ApexIndexer.insertCodeUnit(ApexIndexer.java:254)
at apex.jorje.lsp.impl.index.ApexIndexer.buildCacheInternal(ApexIndexer.java:186)
at apex.jorje.lsp.impl.index.ApexIndexer.buildCache(ApexIndexer.java:196)
at apex.jorje.lsp.impl.index.ApexIndexer.lambda$startUp$1(ApexIndexer.java:895)
at java.util.Optional.ifPresent(Optional.java:159)
at apex.jorje.lsp.impl.index.ApexIndexer.startUp(ApexIndexer.java:893)
at com.google.common.util.concurrent.AbstractScheduledService$ServiceDelegate$2.run(AbstractScheduledService.java:217)
at com.google.common.util.concurrent.Callables$3.run(Callables.java:100)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Thanks!

@vazexqi
Copy link
Contributor

vazexqi commented Apr 19, 2018

@marcalbaladejo

  1. What version of the extensions are you using? I believe we have fixed something similar (NullPointerException in the Indexer) to this.
  2. Also, while there can be errors in there, it is possible for the Apex Language Server to recover. Is code completion, goto-definition, and find-all-references not working for you?

If the above don't solve it, it would be nice if we could take a look at the code. Is this an open project? Or are you able to open up a support case and grant us permission to look into your org?

@GaryFNC - Would be good to give more info on the error so that the user can at least pinpoint what was the last thing that was processed before the NPE.

@marcalbaladejo
Copy link
Author

Hi @vazexqi,

  1. It is version 42.11.0
  2. Indeed it works, but not for all classes/methods. Some methods allow goto-definition, but for others it is not working. Code formatting is not working at all, but not sure if it should.

Sorry, it is not an open project, but happy to provide any debug information you may need.

Thanks!

@vazexqi
Copy link
Contributor

vazexqi commented Apr 19, 2018

The fact that it works for some but not others is an indication that it choke on some classes/triggers. This could be because of bad syntax or because of some other missing information (like managed packages or sobjects not being pulled down). We try to be as tolerant as possible even when we don't have all the information, but there are limits to not having the information available.

@marcalbaladejo - Are you able to open a support issue with the org id and user id so that we can take a closer look at the code?

Without seeing the code, here's what I can think of:

  1. Are you trying to do goto-definition on types from the Apex Standard Library? Those won't work since we don't surface the source for that.
  2. Are you trying to do goto-definition on a managed type?
  3. Are you trying to do goto-definition on an sobject type? Have you invoked SFDX: Refresh SObject Definitions?

@marcalbaladejo
Copy link
Author

Hi,
Case created: 18840869
The org id is 00D5E000000CuW5, access granted.

  1. No, it is our own methods, for example a method of the same class, or another class. I provided concrete examples in the case.
  2. No
  3. No

Thanks!!

@marcalbaladejo
Copy link
Author

Hi Nick,
I've updated the case, i think the problem happens when we use sObjects references in APEX without the namespace (which we always do), so, this is causing the error:
List<MyObject__c> objects = new List<MyObject__c>();

but not this:
List<mynamespace__MyObject__c> objects = new List<mynamespace__MyObject__c>();

@vazexqi
Copy link
Contributor

vazexqi commented Apr 20, 2018

@marcalbaladejo - Thanks for the update. That helps us narrow it down.

CC: @GaryFNC , @lcampos

@vazexqi
Copy link
Contributor

vazexqi commented May 1, 2018

@marcalbaladejo - Just wanted to let you know that we finally got the case routed to the team and we are taking a look at this.

@marcalbaladejo
Copy link
Author

thanks @vazexqi

@GaryFNC
Copy link
Contributor

GaryFNC commented May 1, 2018

@marcalbaladejo The actual exception that you encountered (and its effects on other lines in the class) is fixed in release 42.14.0 of the extension - to be released late this week.

However, there is still an underlying issue where we don't yet properly handle the short form of the SObject without the namespace prefix. The problem is understood and will be fixed in an upcoming version.

The effect is that the lines that use the short from of the SObject name will not properly do Go To or Find All due to a perceived semantic error, but with the exception fixed, the other lines in the class will work properly.

@marcalbaladejo
Copy link
Author

@GaryFNC This is a great step forward, thank you very much!

@GaryFNC
Copy link
Contributor

GaryFNC commented May 1, 2018

@marcalbaladejo Thanks for chasing down the problem for us - made it much simpler to find the underlying issue.... I'll leave this open until I get the full fix done.

@vazexqi
Copy link
Contributor

vazexqi commented May 17, 2018

This should be fixed by #413

@marcalbaladejo - Please reopen this issue if you have any other questions.

@vazexqi vazexqi closed this as completed May 17, 2018
@marcalbaladejo
Copy link
Author

Thanks @vazexqi , yes, it is not failing now, thanks!!
Would be good to enable completion when not using the long name (with namespace), the same for classes, as by default it always includes the namespace. (which we don't use).
But at least no errors now! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants