feat(al): add AL (Business Central / Dynamics 365) language support - #1649
feat(al): add AL (Business Central / Dynamics 365) language support#1649Capitaller wants to merge 8 commits into
Conversation
…into feature/al-language-support
…extensions, and namespace-aware symbol resolution
…th case-insensitive matching support
… support, additional extension types, and case-insensitive matching logic
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c05fe9eeb2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const AL_CLASS_TYPES = [ | ||
| 'codeunit_declaration', 'table_declaration', 'page_declaration', | ||
| 'report_declaration', 'xmlport_declaration', 'query_declaration', | ||
| ...AL_EXTENSION_TYPES, | ||
| ]; |
There was a problem hiding this comment.
Add missing AL object declarations
When an AL project declares standard objects such as permissionset, profile, controladdin, entitlement, or pagecustomization, this extractor never emits a node for them because only the types in AL_CLASS_TYPES plus enum/interface are routed to createNode. This also makes the new permissionsetextension/profileextension extends refs unable to resolve to in-repo base objects, so search/impact miss those AL objects. Please include the missing declaration node types in the object set.
Useful? React with 👍 / 👎.
| resolvedBy: 'exact-match', | ||
| }; | ||
| } | ||
| if (chosen.length > 1) return null; |
There was a problem hiding this comment.
Prefer local AL calls before declaring ambiguity
For a bare AL call like ValidateName();, if another object anywhere in the project defines a method with the same name while the caller file also has its own ValidateName, preferCallSiteFile only reorders the candidates; chosen.length is still greater than one, so this returns null and suppresses the normal exact-name fallback. This leaves common local helper calls unresolved as soon as the name is duplicated elsewhere; filter to the unique same-file/local candidate or let the generic scorer run before treating it as ambiguous.
Useful? React with 👍 / 👎.
Summary
Adds full AL (Microsoft Dynamics 365 Business Central) language support to CodeGraph, enabling semantic code intelligence across large ERP codebases.
What's included:
alExtractorinsrc/extraction/languages/al.tswith aresolveNamehook that correctly resolves AL object names from theobject_namefield (Codeunit, Table, Page, Report, XMLport, Query, and all extension types).alextension registered insrc/extraction/grammars.ts'al'language type added tosrc/types.tssrc/resolution/name-matcher.ts(AL is case-insensitive by language spec)__tests__/al-extraction.test.tstree-sitter-alWASM grammar (bundled undersrc/extraction/wasm/)Motivation
AL is the primary language for Microsoft Dynamics 365 Business Central, one of the most widely deployed ERP platforms globally. A typical BC codebase (e.g. the official W1 BaseApp) contains 7,800+ files, 115,000+ symbols and 264,000+ dependency edges.
Without CodeGraph, AI agents are forced to rely on grep/find, which fails to understand the graph of Codeunit dependencies and produces shallow, keyword-matched answers.
With CodeGraph, an AI agent answers this in 47s using 2 tool calls:
The agent correctly traces the full call chain:
GetSalesLines→InsertInvoiceRounding→InitInvoiceRoundingLine, identifies the responsible Codeunit (Sales-Post Prepayments, Codeunit 442), and names the correct temporary tables (TempPrepmtInvLineBuf,TempSalesLine,TempVATAmountLine). Without CodeGraph, the same agent runs 10+ grep commands and produces a shallow answer that misses the core architecture.Test plan
npm run build— passes with zero TypeScript errorsnpm run test __tests__/al-extraction.test.ts— AL extraction parity test passes (Codeunit name, procedure nodes, and call reference edges all verified)npm run test— full suite passes: 175 test files, 3,010 tests, 0 failurescodegraph_exploreMCP tool calls exclusively — no grep/find fallback — on real Business Central architecture queries