-
Notifications
You must be signed in to change notification settings - Fork 1
Add abstract classes and inheritance to NeoJoin #174
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
base: main
Are you sure you want to change the base?
Conversation
| * @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 {} |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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).
| { | ||
| "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" | ||
| }, |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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)*)? |
There was a problem hiding this comment.
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.
| for (String superClassName : mainQuery.getSuperClasses()) { | ||
| var superClassCandidates = targetClasses.stream().filter(targetClass -> targetClass.name().equals(superClassName)).toList(); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
Work in progress:
closes #29