A Visual Studio Code extension that provides syntax highlighting and document formatting for SNOMED CT Expression Constraint Language (ECL).
- Syntax Highlighting: Full TextMate grammar for ECL syntax
- Document Formatting: Intelligent formatting with complexity-aware line breaking
- Range Formatting: Format selected text regions
- Idempotent: Formatting the same text multiple times produces identical results
Try the online ECL formatter: https://mattcordell.github.io/ecl-formatter/
Format ECL expressions directly in your browser without installing the extension. The web version uses the same formatting logic as the VS Code extension, ensuring consistent results.
Features:
- Format ECL expressions online
- Copy formatted output to clipboard
- Example expressions included
- Mobile-friendly responsive design
- Works in all modern browsers
- Download the
.vsixfile from releases - In VS Code: Extensions → ... → Install from VSIX
- Select the downloaded file
git clone https://github.com/MattCordell/ecl-formatter.git
cd ecl-formatter
npm install
npm run buildPress F5 to launch Extension Development Host for testing.
The extension activates for files with extensions:
.ecl.snomed-ecl
- Command: Format Document
- Keyboard: Shift+Alt+F (Windows/Linux) or Shift+Option+F (macOS)
- Command Palette: "Format Document"
- Select text
- Command: Format Selection
- Command Palette: "Format Selection"
{
"ecl.formatter.indentSize": 2 // Number of spaces per indent level
}SNOMED CT Expression Constraint Language (ECL) is a formal language for defining constraints on SNOMED CT concepts.
Examples:
// Simple concept reference
404684003 |Clinical finding|
// Descendant constraint
<< 404684003
// Refinement
<< 404684003: 363698007 = << 39057004
// Compound expression
<< 404684003 AND << 987654321
// With filters
<< 404684003 {{ term = "heart" }}
// Reverse attribute (brief syntax)
< 91723000 : R 363698007 = < 125605004
// Reverse attribute (long syntax)
< 91723000 : reverseOf 363698007 = < 125605004
// Dotted attribute
< 125605004 . 363698007
// Chained dotted attributes
<< 19829001 . < 47429007 . 363698007- src/extension.ts - VS Code extension entry point
- src/parser/ - Chevrotain-based lexer and parser
lexer.ts- Token definitionsparser.ts- Grammar rules (CST)ast.ts- AST node type definitionsvisitor.ts- CST to AST transformation
- src/formatter/ - Document formatting
format.ts- Pure formatting functionformatter.ts- VS Code providersprinter.ts- AST to formatted textrules.ts- Formatting logic and complexity detection
- syntaxes/ - TextMate grammar for syntax highlighting
- src/test/ - Test suite (vitest)
Please read CONTRIBUTING.md for details on our documentation standards, code style, and development process.
[License information to be added]
Built with Chevrotain parser framework.