A way to replace aspects

Issue #174 new
Jesper Öqvist created an issue

In some situations it's useful to be able to replace an entire aspect. Say we have written an aspect named A that looks like this:

aspect A {
    class X { ... }
}

Since there is no simple way to change that class declaration we might want to replace it entirely. It would be useful if we can do this without excluding the original aspect file from the compilation. I propose a new feature in JastAdd to replace aspects using a new syntax:

aspect B replaces A {
}

The above aspect would replace aspect A when compiled together with aspect A. If no aspect A exists JastAdd should produce a warning. The entire contents of aspect A would be replaced by the entirety of aspect B. JastAdd would still need to parse both aspect A and B, but could then discard aspect A if the replacements are processed before anything else.

Using the above example it should be possible to continue and replace aspect B aswell:

aspect C replaces B {
}

JastAdd should report an error if two aspects attempt to replace the same aspect.

Comments (1)

  1. Log in to comment