Skip to content

Commit 30bfaca

Browse files
akoclaude
andcommitted
refactor: use identifiers instead of strings for image names
Mendix requires image names to be valid identifiers (CE7247). Change IMAGE 'name' FROM FILE to IMAGE Name FROM FILE so invalid names are caught at parse time. The imageName rule allows plain identifiers, quoted identifiers, and common keywords. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fb6279c commit 30bfaca

File tree

11 files changed

+7789
-7617
lines changed

11 files changed

+7789
-7617
lines changed

docs-site/src/language/image-collections.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ CREATE IMAGE COLLECTION <Module>.<Name>
2424
[EXPORT LEVEL 'Hidden'|'Public']
2525
[COMMENT '<description>']
2626
[(
27-
IMAGE '<name>' FROM FILE '<path>',
27+
IMAGE <Name> FROM FILE '<path>',
2828
...
2929
)];
3030
```
@@ -33,7 +33,7 @@ CREATE IMAGE COLLECTION <Module>.<Name>
3333
|--------|-------------|---------|
3434
| `EXPORT LEVEL` | `'Hidden'` (internal to module) or `'Public'` (accessible from other modules) | `'Hidden'` |
3535
| `COMMENT` | Documentation for the collection | (none) |
36-
| `IMAGE ... FROM FILE` | Load an image from the filesystem into the collection | (none) |
36+
| `IMAGE Name FROM FILE` | Load an image from the filesystem into the collection | (none) |
3737

3838
The image format is detected automatically from the file extension. Relative paths are resolved from the current working directory. Supported formats: PNG, SVG, GIF, JPEG, BMP, WebP.
3939

@@ -52,16 +52,16 @@ CREATE IMAGE COLLECTION MyModule.StatusIcons
5252

5353
-- With images from files
5454
CREATE IMAGE COLLECTION MyModule.NavigationIcons (
55-
IMAGE 'home' FROM FILE 'assets/home.png',
56-
IMAGE 'settings' FROM FILE 'assets/settings.svg'
55+
IMAGE home FROM FILE 'assets/home.png',
56+
IMAGE settings FROM FILE 'assets/settings.svg'
5757
);
5858

5959
-- All options combined
6060
CREATE IMAGE COLLECTION MyModule.BrandAssets
6161
EXPORT LEVEL 'Public'
6262
COMMENT 'Company branding assets' (
63-
IMAGE 'logo-dark' FROM FILE 'assets/logo-dark.png',
64-
IMAGE 'logo-light' FROM FILE 'assets/logo-light.png'
63+
IMAGE logo_dark FROM FILE 'assets/logo-dark.png',
64+
IMAGE logo_light FROM FILE 'assets/logo-light.png'
6565
);
6666
```
6767

docs/01-project/MDL_QUICK_REFERENCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ CREATE OR REPLACE NAVIGATION Responsive
309309
|-----------|--------|-------|
310310
| Show collections | `SHOW IMAGE COLLECTION [IN Module];` | List all or filter by module |
311311
| Describe collection | `DESCRIBE IMAGE COLLECTION Module.Name;` | Full MDL output with embedded images |
312-
| Create collection | `CREATE IMAGE COLLECTION Module.Name [EXPORT LEVEL 'Hidden'\|'Public'] [COMMENT 'text'] [(IMAGE 'name' FROM FILE 'path', ...)];` | With or without images |
312+
| Create collection | `CREATE IMAGE COLLECTION Module.Name [EXPORT LEVEL 'Hidden'\|'Public'] [COMMENT 'text'] [(IMAGE Name FROM FILE 'path', ...)];` | With or without images |
313313
| Drop collection | `DROP IMAGE COLLECTION Module.Name;` | Removes collection and all embedded images |
314314

315315
**Export levels:** `'Hidden'` (default, internal to module), `'Public'` (accessible from other modules).

mdl-examples/doctype-tests/17-image-collection-examples.mdl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ CREATE IMAGE COLLECTION ImgTest.BrandAssets
7373
* Supported formats: PNG, SVG, GIF, JPEG, BMP, WebP
7474
*/
7575
CREATE IMAGE COLLECTION ImgTest.NavigationIcons (
76-
IMAGE 'cli_screenshot' FROM FILE '../../docs/images/mxcli-cli.png',
77-
IMAGE 'repl_screenshot' FROM FILE '../../docs/images/mxcli-repl.png'
76+
IMAGE cli_screenshot FROM FILE '../../docs/images/mxcli-cli.png',
77+
IMAGE repl_screenshot FROM FILE '../../docs/images/mxcli-repl.png'
7878
);
7979
/
8080

@@ -84,8 +84,8 @@ CREATE IMAGE COLLECTION ImgTest.NavigationIcons (
8484
CREATE IMAGE COLLECTION ImgTest.AppLogos
8585
EXPORT LEVEL 'Public'
8686
COMMENT 'Application logos for branding' (
87-
IMAGE 'vscode_ext' FROM FILE '../../docs/images/mxcli-vscode-ext.png',
88-
IMAGE 'catalog' FROM FILE '../../docs/images/mxcli-catalog.png'
87+
IMAGE vscode_ext FROM FILE '../../docs/images/mxcli-vscode-ext.png',
88+
IMAGE catalog_view FROM FILE '../../docs/images/mxcli-catalog.png'
8989
);
9090
/
9191

mdl/executor/cmd_imagecollections.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (e *Executor) describeImageCollection(name ast.QualifiedName) error {
151151
if i == len(ic.Images)-1 {
152152
comma = ""
153153
}
154-
fmt.Fprintf(e.output, " IMAGE '%s' FROM FILE '%s'%s\n", img.Name, filePath, comma)
154+
fmt.Fprintf(e.output, " IMAGE %s FROM FILE '%s'%s\n", img.Name, filePath, comma)
155155
}
156156

157157
fmt.Fprintln(e.output, ");")

mdl/executor/cmd_misc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ Image Collections:
303303
CREATE IMAGE COLLECTION Module.Name
304304
[EXPORT LEVEL 'Hidden'|'Public']
305305
[COMMENT 'description']
306-
[(IMAGE 'name' FROM FILE 'path', ...)];
306+
[(IMAGE Name FROM FILE 'path', ...)];
307307
/
308308
309309
DROP IMAGE COLLECTION Module.Name;

mdl/grammar/MDLParser.g4

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,13 @@ imageCollectionBody
792792
;
793793

794794
imageCollectionItem
795-
: IMAGE name=STRING_LITERAL FROM FILE_KW path=STRING_LITERAL // IMAGE 'name' FROM FILE '/path/to/file.png'
795+
: IMAGE imageName FROM FILE_KW path=STRING_LITERAL // IMAGE MyIcon FROM FILE '/path/to/file.png'
796+
;
797+
798+
imageName
799+
: IDENTIFIER
800+
| QUOTED_IDENTIFIER
801+
| commonNameKeyword
796802
;
797803

798804
// =============================================================================

mdl/grammar/parser/MDLParser.interp

Lines changed: 2 additions & 1 deletion
Large diffs are not rendered by default.

mdl/grammar/parser/mdl_parser.go

Lines changed: 7749 additions & 7601 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mdl/grammar/parser/mdlparser_base_listener.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mdl/grammar/parser/mdlparser_listener.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)