Skip to content

Conversation

@larsk21
Copy link
Member

@larsk21 larsk21 commented Dec 12, 2025

Work in progress:

  • change grammar and scoping rules
  • support abstract classes in AQR and meta-model generation
  • support super classes and overwritten features in AQR and meta-model generation
  • show validation results in IDE
  • transform instances correctly
  • tests

closes #29

@larsk21 larsk21 self-assigned this Dec 12, 2025
@larsk21 larsk21 added the language Changes to the language (grammar or semantics) label Dec 12, 2025
* @param overwritten overwritten feature in a super class
* @param expression expression calculating the value of the feature (not inherited)
*/
record Overwrite(AQRFeature overwritten, XExpression expression) implements Kind {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the common terminology is Override instead of Overwrite here.

return "Attribute[name='%s', type=%s, kind=%s, options=%s]".formatted(name, type.getName(), kind, options);
}

Attribute setFeatureKind(Kind kind) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably call this method withFeatureKind(..) in order to prevent confusions whether the attribute itself is modified or a new instance is created.

Comment on lines +69 to +71
name=ID
':' type=[ecore::EObject|QualifiedName] // type refers either to an EDataType or a Query
(hasModifiers?='[' (modifiers+=Modifier (',' modifiers+=Modifier)*)? ']')?; // allow empty modifier list in grammar and forbid it using a validator for improved error messages
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This order of operands differs from your example in #29 (comment).

Comment on lines -28 to -31
{
"match": "(!|!\u003d|!\u003d\u003d|#|%|%\u003d|\u0026|\u0026\u0026|\\(|\\)|\\*|\\*\\*|\\*\u003d|\\+|\\+\\+|\\+\u003d|,|-|--|-\u003d|-\u003e|\\.|\\.\\.|\\.\\.\\*|\\.\\.\u003c|/|/\u003d|:|::|:\u003d|;|\u003c|\u003c\u003e|\u003d|\u003d\u003d|\u003d\u003d\u003d|\u003d\u003e|\u003e|\u003e\u003d|\\?|\\?\\.|\\?:|\\[|\\]|\\{|\\||\\|\\||\\})",
"name": "punctuation.neojoin"
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this section is missing from the new grammar below and will lead to the problem described here: eclipse-xtext/xtext#3337
You can either copy the rule manually or use the implementation in my PR to resolve the issue .. or accept that punctuation is highlighted in red :D

case AQRFeature.Kind.Copy copy -> copy.source().getName();
case AQRFeature.Kind.Calculate ignored ->
invariantFailed("Calculated feature must have a name: " + feature.getExpression());
case AQRFeature.Kind.Overwrite overwriding -> overwriding.overwritten().name();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
case AQRFeature.Kind.Overwrite overwriding -> overwriding.overwritten().name();
case AQRFeature.Kind.Overwrite overriding -> overriding.overwritten().name();

body=Body?;
(
'create' root?='root'? name=ID?
('extends' superClasses+=QualifiedName (',' superClasses+=QualifiedName)*)?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably use a cross-reference here.

Comment on lines +209 to +210
for (String superClassName : mainQuery.getSuperClasses()) {
var superClassCandidates = targetClasses.stream().filter(targetClass -> targetClass.name().equals(superClassName)).toList();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use a cross-reference in the grammar, you will get the query object or source class directly and can use the tracing info to resolve the target class.

selectedClasses.stream()
.sorted(Comparator.comparing(EClassifier::getName))
.forEach(this::targetClazz);
// class might have already been generated as super class of another class
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, actually not, because that part is not implemented yet :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

language Changes to the language (grammar or semantics)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for inheritance to the syntax

3 participants