Add abstract classes and inheritance to NeoJoin#174
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.
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.
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.
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.
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.
| 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)*)? |
| for (String superClassName : mainQuery.getSuperClasses()) { | ||
| var superClassCandidates = targetClasses.stream().filter(targetClass -> targetClass.name().equals(superClassName)).toList(); |
There was a problem hiding this comment.
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.
Well, actually not, because that part is not implemented yet :p
Work in progress:
closes #29