0.1.1 • Published 4 years ago

@salesforce/soql-tmlanguage v0.1.1

Weekly downloads
1
License
BSD-3-Clause
Repository
github
Last release
4 years ago

Introduction

This repository contains the language grammar for Salesforce's SOQL query language.

Development

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 .soql file (with the VS Code text editor) and then runnning command Developer: Inspect Editor Tokens and Scopes.

Grammar file

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 js-yaml.

Tests

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:source validates "manually created" queries.
  • yarn test:snapshots validates "snapshot-based" queries.
  • yarn test validates 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.