Combing defines non-unique with refers to
In WebDSL are extended entities just partial classes in C#.
entity Issue { ... } extend entity Issue { ... }
They are however asymmetric, there is a single entity definition and zero or more extended entity definitions.
The current NaBL solution for this would be to
defines non-unique Entity e
but this has a big drawback: one does not get an error if there is a typo in the extended entity name.To solve this the extended entities need to be uses of a name rather than a non-unique definition. This gives errors on non existing entity names and provides support for ctrl-click to the entity definition site. However, then the extended entity cannot define new fields and functions.
So, I tried combining both (in a very similar use case in the relations language), making it both a
defines non-unique
and arefers to
at the same time. I couldn’t get this to work.Any suggestions on solving this?
Submitted by Daco Harkes on 20 November 2014 at 11:27
defines non-unique
combined withrefers to
is the preferred solution?- or an asymmetric
defines unique
anddefines non-unique
NaBL solution?- or
defines in a
wherea
can be any resolved NaBL uri (conditional definitions, which wont work with the current task engine)?
Issue Log
You can try to duplicate the names in a preprocessing step:
normalise: Entity(x, m*) -> Entity(x, Base(x), m*) normalise: ExtEntity(x, m*) -> Entity(x, Ext(x), m*)
And use two different namespaces:
Entity(x, _, _): defines non-unique Entity x scopes ... Base(x): defines BaseEntity x Ext(x): refers to BaseEntity x
Also defining two
entity Issue{ ... }
will not trigger duplicate definition errors whendefines non-unqiue
is used.workaround
Define the entities both uniquely and non uniquely on the ‘non extended’ sites.
Entity(e-ty, ...) defines Entity2 e-ty defines non-unique Entity e-ty
The workaround I described should trigger duplicate errors. Your workaround might not work well with scoping. If it does, its kind of fragile.
Duplicating names works for unresolved reference errors.
Adding extra constructorsBase
andExt
is not required.It does however not provide resolving references in the editor. (Not even if the use annotation is on the first name.)
Any other suggestions?
Resolve relation member to entity [[ entity [[User]]{} entity Book{} relation Owns{ [[User]] * Book 1 } ]] resolve #2 to #1
Funky, the testcases for resolving works while cmd/ctrl+click in the editor doesn’t work.
cmd/ctrl+click can be fixed by tweaking editor resolve:
editor-resolve: (node, position, ast, path, project-path) -> definition where node' := <try(resolve-child)>node; definition := <analysis-resolve(|<language>, project-path)> node' resolve-child: NaBLHelp(name, _) -> name
@Guido do you want to keep this issue open as a reminder to make a future NaBL support this use case?
Log in to post comments