{"id":38814660,"url":"https://github.com/apex-dev-tools/apex-parser","last_synced_at":"2026-04-21T23:01:26.529Z","repository":{"id":223702083,"uuid":"490408511","full_name":"apex-dev-tools/apex-parser","owner":"apex-dev-tools","description":"Salesforce Apex/SOQL/SOSL language parser","archived":false,"fork":false,"pushed_at":"2025-08-14T15:10:19.000Z","size":1649,"stargazers_count":26,"open_issues_count":3,"forks_count":9,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-09-22T06:57:40.201Z","etag":null,"topics":["apex","parser","salesforce"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apex-dev-tools.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-09T18:55:37.000Z","updated_at":"2025-09-03T14:01:41.000Z","dependencies_parsed_at":"2024-05-12T16:45:18.161Z","dependency_job_id":"5fb98b57-7604-4f4f-a0be-b4440d31108e","html_url":"https://github.com/apex-dev-tools/apex-parser","commit_stats":null,"previous_names":["apex-dev-tools/apex-parser"],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/apex-dev-tools/apex-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apex-dev-tools%2Fapex-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apex-dev-tools%2Fapex-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apex-dev-tools%2Fapex-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apex-dev-tools%2Fapex-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apex-dev-tools","download_url":"https://codeload.github.com/apex-dev-tools/apex-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apex-dev-tools%2Fapex-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28508906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T11:50:55.898Z","status":"ssl_error","status_checked_at":"2026-01-17T11:50:55.569Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apex","parser","salesforce"],"created_at":"2026-01-17T12:58:53.424Z","updated_at":"2026-01-17T12:58:54.031Z","avatar_url":"https://github.com/apex-dev-tools.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# apex-parser\n\nParser for Salesforce Apex (including Triggers \u0026 inline SOQL/SOQL). This is based on an [ANTLR4](https://www.antlr.org/) grammar, see [`antlr/BaseApexParser.g4`](./antlr/BaseApexParser.g4). Currently packaged for Java and JavaScript/TypeScript targets.\n\nThe packages include ANTLR4 generated types plus optional extras for convenience. The TypeScript package exports type aliases for ANTLR types, while both packages have abstractions like `ApexParserFactory` and `ApexErrorListener`. There are minimal examples below and in the test classes.\n\n## Installation\n\n### Maven\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.apex-dev-tools\u003c/groupId\u003e\n    \u003cartifactId\u003eapex-parser\u003c/artifactId\u003e\n    \u003cversion\u003e\u003c!-- version --\u003e\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### NPM\n\n```sh\n# Optionally install `antlr4` to use runtime types\nnpm i @apexdevtools/apex-parser\n```\n\n## Usage\n\n`ApexParser` entry points to access tree:\n\n- `compilationUnit()`, a class file.\n- `triggerUnit()`, a trigger file.\n- `anonymousUnit()`, an apex script file.\n- `query()`, a raw SOQL query.\n\n### Explore Parse Tree (TypeScript)\n\n```typescript\nimport { ApexParserFactory, ApexParserBaseVisitor } from \"@apexdevtools/apex-parser\";\n\nconst parser = ApexParserFactory.createParser(\"public class Hello {}\");\n\n/*\n * Use a visitor. Return value and manual control.\n */\nclass Visitor extends ApexParserBaseVisitor\u003cany\u003e {}\n\nconst visitor = new Visitor();\nvisitor.visit(parser.compilationUnit());\n\n\n/*\n * Or walk with listener. Enter/exit operations - for whole tree.\n */\nclass Listener extends ApexParserBaseListener {}\n\nconst listener = new Listener();\nApexParseTreeWalker.DEFAULT.walk(listener, parser.compilationUnit());\n```\n\n### SOSL FIND quoting\n\nSOSL FIND uses ' as a quoting character when embedded in Apex, in the API braces are used:\n\n```sosl\nFind {something} RETURNING Account\n```\n\nTo parse the API format there is an alternative parser rule, `soslLiteralAlt`, that you can use instead of `soslLiteral`. See `SOSLParserTest` for some examples of how these differ.\n\n## Development\n\n### Prerequisites\n\n- JDK 11+ (for ANTLR tool)\n- Maven\n- NodeJS LTS\n\n### Building\n\nThe outer package contains scripts to build both distributions:\n\n```shell\n# Run once - prepare for dev (installs deps, runs antlr gen)\nnpm run init\n\n# Run antlr gen, compile and test\nnpm run build\n```\n\nOr you can setup and later build each distribution separately:\n\n```shell\nnpm run init:npm\nnpm run build:npm\n\nnpm run init:jvm\nnpm run build:jvm\n```\n\n### Testing\n\n#### Unit Tests\n\nMore options for testing:\n\n```shell\n# From ./npm\nnpm run build\nnpm test\n# File and test name regex filtering\nnpm test -- ApexParserTest -t Expression\n\n# From ./jvm\nmvn test\n```\n\n#### System Tests\n\nThe system tests use a collection of sample projects located in the [`apex-samples`](https://github.com/apex-dev-tools/apex-samples) repository. Follow the README instructions in `apex-samples` to checkout the submodules at the version tag used by the [build workflow](.github/workflows/Build.yml). Both packages must be built beforehand, as the js system test spawns the jar as well.\n\nTo run the tests:\n\n```shell\n# Set SAMPLES env var to samples repo location\nexport SAMPLES=\u003cabs path to apex-samples\u003e\n\n# From root dir\nnpm run build\nnpm run systest\n```\n\nSystem test failures relating to the snapshots may highlight regressions. Though if an error is expected or the samples have changed, instead use `npm run systest:update` to update the snapshots, then commit the changes.\n\n## Source \u0026 Licenses\n\nAll the source code included uses a 3-clause BSD license. The only third-party component included is the Apex Antlr4 grammar originally from [Tooling-force.com](https://github.com/neowit/tooling-force.com), although this version used is now markedly different from the original.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapex-dev-tools%2Fapex-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapex-dev-tools%2Fapex-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapex-dev-tools%2Fapex-parser/lists"}