@@ -0,0 +1,2154 @@
+package mb.nabl2.terms.stratego;%0A%0Aimport com.google.common.collect.ClassToInstanceMap;%0Aimport com.google.common.collect.ImmutableClassToInstanceMap;%0Aimport mb.nabl2.terms.ITerm;%0Aimport org.immutables.serial.Serial;%0Aimport org.immutables.value.Value;%0Aimport org.spoofax.interpreter.terms.IStrategoTerm;%0Aimport org.spoofax.jsglr.client.imploder.IToken;%0Aimport org.spoofax.jsglr.client.imploder.ImploderAttachment;%0Aimport org.spoofax.terms.attachments.OriginAttachment;%0A%0Aimport java.util.Optional;%0A%0A/**%0A * A term attachment for placeholders.%0A */%0A@Value.Immutable%0A@Serial.Version(value = 42L)%0Apublic abstract class ATermPlaceholder %7B%0A%0A    @Value.Parameter public abstract String getName();%0A%0A    @SuppressWarnings(%7B %22unchecked%22, %22rawtypes%22 %7D) public %3CT extends ITerm%3E T put(T term) %7B%0A        final ImmutableClassToInstanceMap.Builder%3CObject%3E attachments = ImmutableClassToInstanceMap.builder();%0A        // builder does not allow overwriting entries, so we need to filter out%0A        // the term placeholder, in case it is already there%0A        // @formatter:off%0A        term.getAttachments().entrySet().stream()%0A            .filter(e -%3E !TermPlaceholder.class.equals(e.getKey()))%0A            .forEach(e -%3E attachments.put((Class)e.getKey(), e.getValue()));%0A        // @formatter:on%0A        attachments.put(TermPlaceholder.class, (TermPlaceholder) this);%0A        return (T)term.withAttachments(attachments.build());%0A    %7D%0A%0A    @Override public String toString() %7B%0A        return getName();%0A    %7D%0A    // static%0A%0A    public static Optional%3CTermPlaceholder%3E get(ITerm term) %7B%0A        return get(term.getAttachments());%0A    %7D%0A%0A    public static Optional%3CTermPlaceholder%3E get(ClassToInstanceMap%3CObject%3E attachments) %7B%0A        return Optional.ofNullable(attachments.getInstance(TermPlaceholder.class));%0A    %7D%0A%0A    public static boolean has(ITerm term) %7B%0A        return get(term).isPresent();%0A    %7D%0A%0A    public static %3CT extends ITerm%3E T copy(ITerm src, T dst) %7B%0A        //noinspection unchecked%0A        return (T)get(src).map(o -%3E o.put(dst)).orElse(dst);%0A    %7D%0A%0A    public static TermPlaceholder of(String name) %7B%0A        return TermPlaceholder.of(name);%0A    %7D%0A%0A%0A%7D%0A

Add ATermPlaceholder