public void patchPluginXml(XmlFile pluginXml, PsiClass klass) throws IncorrectOperationException {
    final XmlTag rootTag = pluginXml.getDocument().getRootTag();
    if (rootTag != null && IdeaPlugin.TAG_NAME.equals(rootTag.getName())) {
      XmlTag components = rootTag.findFirstSubTag(myName);
      if (components == null || !components.isPhysical()) {
        components = (XmlTag)rootTag.add(rootTag.createChildTag(myName, rootTag.getNamespace(), null, false));
      }

      XmlTag cmp = (XmlTag)components.add(components.createChildTag("component", components.getNamespace(), null, false));
      cmp.add(cmp.createChildTag("implementation-class", cmp.getNamespace(), klass.getQualifiedName(), false));

      // some magic to figure out interface-class
      final PsiMethod[] methods = klass.findMethodsByName("getInstance", true);
      for (PsiMethod method : methods) {
        final PsiParameter[] parameters = method.getParameterList().getParameters();
        if (parameters.length <= 1) {
          final PsiType returnType = method.getReturnType();
          if (returnType instanceof PsiClassType) {
            final String intf = returnType.getCanonicalText();
            cmp.add(cmp.createChildTag("interface-class", cmp.getNamespace(), intf, false));
            break;
          }
        }
      }

      PsiNavigateUtil.navigate(cmp);
    }
  }
public void patchPluginXml(XmlFile pluginXml, PsiClass klass)