Skip to content

Commit 2d41425

Browse files
akoclaude
andcommitted
feat: add @excluded annotation for documents and microflow activities
Support @excluded at two levels: - Document-level: marks microflows/pages as excluded from the project (Mendix Excluded field), matching Studio Pro's "Exclude from project" - Activity-level: disables individual microflow activities (Disabled field), matching Studio Pro's grey-out behavior Syntax: @excluded CREATE MICROFLOW Mod.Old () BEGIN @excluded LOG INFO 'deprecated'; END; DESCRIBE emits @excluded for excluded documents and disabled activities. Also restructures RENAME grammar rule to use renameTarget subrule for ANTLR compatibility (separate keyword accessors weren't generated for alternatives using different tokens). Closes #150 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f6adb72 commit 2d41425

20 files changed

Lines changed: 9373 additions & 9618 deletions

mdl/ast/ast_microflow.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ type CreateMicroflowStmt struct {
5353
Comment string
5454
Folder string // Folder path within module (e.g., "Resources/Images")
5555
CreateOrModify bool
56+
Excluded bool // @excluded — document excluded from project
5657
}
5758

5859
func (s *CreateMicroflowStmt) isStatement() {}
@@ -105,12 +106,13 @@ type RaiseErrorStmt struct {
105106
func (s *RaiseErrorStmt) isMicroflowStatement() {}
106107

107108
// ActivityAnnotations holds metadata annotations for microflow activities.
108-
// These are emitted as @position, @caption, @color, @annotation lines in MDL.
109+
// These are emitted as @position, @caption, @color, @annotation, @excluded lines in MDL.
109110
type ActivityAnnotations struct {
110111
Position *Position // @position(x, y)
111112
Caption string // @caption 'text'
112113
Color string // @color Green
113114
AnnotationText string // @annotation 'text'
115+
Excluded bool // @excluded
114116
}
115117

116118
// ChangeItem represents a single assignment in CREATE/CHANGE: Attr = expr

mdl/ast/ast_page_v3.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type CreatePageStmtV3 struct {
3030
Documentation string
3131
IsReplace bool // CREATE OR REPLACE
3232
IsModify bool // CREATE OR MODIFY
33+
Excluded bool // @excluded — document excluded from project
3334
}
3435

3536
func (s *CreatePageStmtV3) isStatement() {}

mdl/executor/cmd_microflows_builder_annotations.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ func (fb *flowBuilder) applyAnnotations(activityID model.ID, ann *ast.ActivityAn
109109
return
110110
}
111111

112-
// Find the object by ID for @caption and @color
113-
if ann.Caption != "" || ann.Color != "" {
112+
// Find the object by ID for @caption, @color, and @excluded
113+
if ann.Caption != "" || ann.Color != "" || ann.Excluded {
114114
for _, obj := range fb.objects {
115115
if obj.GetID() != activityID {
116116
continue
117117
}
118118

119-
// @caption and @color — only applicable to ActionActivity
119+
// @caption, @color, and @excluded — only applicable to ActionActivity
120120
if activity, ok := obj.(*microflows.ActionActivity); ok {
121121
if ann.Caption != "" {
122122
activity.Caption = ann.Caption
@@ -125,6 +125,9 @@ func (fb *flowBuilder) applyAnnotations(activityID model.ID, ann *ast.ActivityAn
125125
if ann.Color != "" {
126126
activity.BackgroundColor = ann.Color
127127
}
128+
if ann.Excluded {
129+
activity.Disabled = true
130+
}
128131
}
129132

130133
break

mdl/executor/cmd_microflows_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (e *Executor) execCreateMicroflow(s *ast.CreateMicroflowStmt) error {
8181
Documentation: s.Documentation,
8282
AllowConcurrentExecution: true, // Default: allow concurrent execution
8383
MarkAsUsed: false,
84-
Excluded: false,
84+
Excluded: s.Excluded,
8585
}
8686

8787
// Build entity resolver function for parameter/return types

mdl/executor/cmd_microflows_show.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ func (e *Executor) describeMicroflow(name ast.QualifiedName) error {
310310
lines = append(lines, " */")
311311
}
312312

313+
// @excluded annotation
314+
if targetMf.Excluded {
315+
lines = append(lines, "@excluded")
316+
}
317+
313318
// CREATE MICROFLOW header
314319
qualifiedName := name.Module + "." + name.Name
315320
if len(targetMf.Parameters) > 0 {

mdl/executor/cmd_microflows_show_helpers.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ func emitObjectAnnotations(obj microflows.MicroflowObject, lines *[]string, inde
6969
pos := obj.GetPosition()
7070
*lines = append(*lines, indentStr+fmt.Sprintf("@position(%d, %d)", pos.X, pos.Y))
7171

72-
// @caption and @color (only for ActionActivity)
72+
// @excluded, @caption, and @color (only for ActionActivity)
7373
if activity, ok := obj.(*microflows.ActionActivity); ok {
74+
if activity.Disabled {
75+
*lines = append(*lines, indentStr+"@excluded")
76+
}
7477
if !activity.AutoGenerateCaption && activity.Caption != "" {
7578
escapedCaption := strings.ReplaceAll(activity.Caption, "'", "''")
7679
*lines = append(*lines, indentStr+fmt.Sprintf("@caption '%s'", escapedCaption))

mdl/executor/cmd_pages_builder_v3.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (pb *pageBuilder) buildPageV3(s *ast.CreatePageStmtV3) (*pages.Page, error)
3939
Documentation: s.Documentation,
4040
URL: s.URL,
4141
MarkAsUsed: false,
42-
Excluded: false,
42+
Excluded: s.Excluded,
4343
}
4444

4545
// Set title

mdl/executor/cmd_pages_describe.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ func (e *Executor) describePage(name ast.QualifiedName) error {
8585
}
8686
}
8787

88+
// @excluded annotation
89+
if foundPage.Excluded {
90+
fmt.Fprintln(e.output, "@excluded")
91+
}
92+
8893
// V3 syntax: CREATE PAGE Module.Page (Title: '...', Layout: ..., Params: { })
8994
header := fmt.Sprintf("CREATE OR MODIFY PAGE %s.%s", modName, foundPage.Name)
9095
props := []string{}

mdl/grammar/MDLParser.g4

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,16 +277,14 @@ dropStatement
277277
;
278278

279279
renameStatement
280-
: RENAME ENTITY qualifiedName TO identifierOrKeyword (DRY RUN)?
281-
| RENAME MICROFLOW qualifiedName TO identifierOrKeyword (DRY RUN)?
282-
| RENAME NANOFLOW qualifiedName TO identifierOrKeyword (DRY RUN)?
283-
| RENAME PAGE qualifiedName TO identifierOrKeyword (DRY RUN)?
284-
| RENAME ENUMERATION qualifiedName TO identifierOrKeyword (DRY RUN)?
285-
| RENAME ASSOCIATION qualifiedName TO identifierOrKeyword (DRY RUN)?
286-
| RENAME CONSTANT qualifiedName TO identifierOrKeyword (DRY RUN)?
280+
: RENAME renameTarget qualifiedName TO identifierOrKeyword (DRY RUN)?
287281
| RENAME MODULE identifierOrKeyword TO identifierOrKeyword (DRY RUN)?
288282
;
289283

284+
renameTarget
285+
: ENTITY | MICROFLOW | NANOFLOW | PAGE | ENUMERATION | ASSOCIATION | CONSTANT
286+
;
287+
290288
/**
291289
* Moves a document to a different folder or module.
292290
*

mdl/grammar/parser/MDLParser.interp

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

0 commit comments

Comments
 (0)