Apex
Affects PMD Version:
7.4.0
Description:
Apex parser doesn't seem to support SOSL, or it thinks it's SOQL. The following is valid yet produces a parser error:
List<List<SObject>> searchResults = [ FIND :searchTerm IN ALL FIELDS RETURNING Account(Id, toLabel(Name)) LIMIT 10 ];
It complains about the toLabel(), although syntax is valid, see https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_tolabel.htm
Exception Stacktrace:
force-app/main/sfps/Selfreg/classes/ParseErrorTest.cls - ParseException: Parse exception: com.google.summit.SummitAST$ParseException: Failed to parse force-app/main/sfps/Selfreg/classes/ParseErrorTest.cls:
Syntax error at 9:43: mismatched input '(' expecting {'using', 'where', 'order', 'limit', 'offset', ')'}
Syntax error at 9:49: mismatched input ')' expecting {'instanceof', ')', '[', '.', '=', '>', '<', '?.', '?', '==', '===', '!=', '<>', '!==', '&&', '||', '??', '++', '--', '+', '-', '*', '/', '&', '|', '^', '+=', '-=', '*=', '/=', '&=', '|=', '^=', '<<=', '>>=', '>>>='}
Syntax error at 11:8: extraneous input ']' expecting ';'
Code Sample demonstrating the issue:
public with sharing class ParseErrorTest { public Object doSoslSearch() { List<List<SObject>> searchResults = [ FIND :searchTerm IN ALL FIELDS RETURNING Account(Id, toLabel(Name)) LIMIT 10 ]; return null; } }
Steps to reproduce:
Running checks using PMD
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
pmd check -d path/to/project -R custom-apex-rules.xml
You can use any Apex ruleset, like https://github.com/ChuckJonas/vscode-apex-pmd/blob/master/rulesets/apex_ruleset.xml
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4