public @Nullable DomExtensionsRegistrarImpl extend(@NotNull Project project,
                                                     @NotNull DomInvocationHandler handler,
                                                     @Nullable DomExtensionsRegistrarImpl registrar) {
    if (myDomClass == null) {
      try {
        myDomClass = Class.forName(domClassName, true, pluginDescriptor.getPluginClassLoader());
      }
      catch (Throwable e) {
        LOG.error(new PluginException(e, pluginDescriptor.getPluginId()));
        return registrar;
      }
    }

    if (!myDomClass.isAssignableFrom(handler.getRawType())) {
      return registrar;
    }

    if (myExtender == null) {
      try {
        myExtender = project.instantiateClass(extenderClassName, pluginDescriptor);
      }
      catch (ProcessCanceledException e) {
        throw e;
      }
      catch (Throwable e) {
        LOG.error(e);
        return registrar;
      }
    }

    if (!myExtender.supportsStubs() && XmlUtil.isStubBuilding()) {
      return registrar;
    }

    if (registrar == null) {
      registrar = new DomExtensionsRegistrarImpl();
    }
    //noinspection unchecked
    ((DomExtender<DomElement>)myExtender).registerExtensions(handler.getProxy(), registrar);
    return registrar;
  }
public @Nullable DomExtensionsRegistrarImpl extend(@NotNull Project project,
                                                     @NotNull DomInvocationHandler handler,
                                                     @Nullable DomExtensionsRegistrarImpl registrar)