This repository contains the language grammar for Salesforce's SOQL query language.
yarnto install dependencies.
yarn buildto generate the final (.json) grammar file for VS Code.
yarn testto run unit tests (based on https://github.com/PanAeon/vscode-tmgrammar-test)
This package is used from VS Code extension
salesforcedx-vscode-soql. With that extension installed, you can see the grammar in action and debug/inspect it by opening a
(with the VS Code text editor) and then runnning command
Developer: Inspect Editor Tokens and Scopes.
grammars/ |-- soql.tmLanguage.yaml ;; The source of the SOQL grammar `-- soql.tmLanguage.json ;; Generated .json version of the grammar (git ignored)
VSCode only reads grammars in json format.
yarn build generates the
.json version of the SOQL grammar using
Tests are executed with vscode-tmgrammar-tests.
test/ "Manually" created test case |-- simple_account.soql `-- snapshots/ "Snapshot-based" test cases |-- example-*.soql |-- example-*.soql.snap `-- ...
yarn test:sourcevalidates "manually created" queries.
yarn test:snapshotsvalidates "snapshot-based" queries.
yarn testvalidates both.
The difference between manual vs. snapshot tests is that the latter are auto-generated and can be updated with command
vscode-tmgrammar-snap -u. They are useful to quickly see the output of applying the grammar and catch regressions.
The example-* queries were taken from Example SELECT clauses.