Interface Proxiable<T>

  • Type Parameters:
    T - the type of the proxy object, it should be the same as of proxied object
    All Known Implementing Classes:
    CssCustomFunctionNode, CssCustomFunctionNode.CssCustomFunctionNodeProxy

    public interface Proxiable<T>
    The idea behind the Proxiable interface is to improve performance of compiler passes by eliminating unnecessary copying of AST subtrees. Passes which perform a lot of copying should use this copy-on-write proxy creation mechanism instead.

    CssNode classes which implement the Proxiable interface create copy-on-write proxy objects. Created proxies reflect the state of the proxied object until a mutation method is called on the proxy. When this happens the proxy copies the original object's data, breaks the link to the original and updates itself with the mutation.

    Proxy nodes will usually reflect any changes performed on the original node. If this behavior is not desired -- say proxies should act as copies of the original node -- there is a simple solution. Just replace the original node with a proxy and use the original node as the backing node for all proxies. This way the original node is hidden and all modifications go through proxies. The example implementation: CssCustomFunctionNode.CssCustomFunctionNodeProxy.createProxy(). q

    • Method Detail

      • createProxy

        T createProxy()
        Creates the proxy object. If the original object is immutable and does not have any children, it can return itself.
        Returns:
        the proxy object