Skip to content

Commit

Permalink
xpr as anno value: add on name resolution and add example
Browse files Browse the repository at this point in the history
  • Loading branch information
stewsk committed Sep 13, 2024
1 parent 0f80e6f commit 978659b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cds/cdl.md
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,8 @@ Each path in the expression is checked:
* If the annotation is assigned to a subelement of a structured element, the top level
elements of the entity can be accessed via `$self`.
* A parameter `par` can be accessed via `:par`, just like parameters of a parametrized entity in queries.
* For an annotation assigned to a bound action or function, elements of the respective entity
can be accessed via `$self`.
* The draft specific element `IsActiveEntity` can be referred to with the magic variable `$draft.IsActiveEntity`.
During draft augmentation `$draft.IsActiveEntity` is rewritten to `$self.IsActiveEntity` for all draft enabled
entities (root and sub nodes but not for named types or entity parameters).
Expand All @@ -1112,6 +1114,27 @@ Each path in the expression is checked:
In contrast to `@aReference: foo.bar`, a single reference written as expression `@aRefExpr: ( foo.bar )`
is checked by the compiler.

```cds
@MyAnno: (a) // reference to element
entity Foo (par: Integer) {
key ID : Integer;
@MyAnno: (:par) // reference to entity parameter
a : Integer;
@MyAnno: (a) // reference to sibling element
b : Integer;
s {
@MyAnno: (y) // reference to sibling element
x : Integer;
@MyAnno: ($self.a) // reference to top level element
y : Integer;
}
}
actions {
@MyAnno: ($self.a)
action A ()
}
```

#### CSN Representation

In CSN, the expression is represented as a record with two properties:
Expand Down

0 comments on commit 978659b

Please sign in to comment.