Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xpr as anno value: add on name resolution and add example #1251

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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