public static void expand(@NotNull String key, @NotNull CustomTemplateCallback callback,
                            @NotNull ZenCodingGenerator defaultGenerator,
                            @NotNull Collection<? extends ZenCodingFilter> extraFilters,
                            boolean expandPrimitiveAbbreviations, int segmentsLimit) throws EmmetException {
    ApplicationManager.getApplication().assertIsNonDispatchThread();

    final ZenCodingNode node = parse(key, callback, defaultGenerator, null);
    if (node == null) return;

    if (node instanceof TemplateNode) {
      if (key.equals(((TemplateNode)node).getTemplateToken().getKey()) && callback.findApplicableTemplates(key).size() > 1) {
        TemplateManagerImpl templateManager = (TemplateManagerImpl)callback.getTemplateManager();
        Map<TemplateImpl, String> template2Argument =
          templateManager.findMatchingTemplates(callback.getFile(), callback.getEditor(), null, TemplateSettings.getInstance());
        Runnable runnable = templateManager.startNonCustomTemplates(template2Argument, callback.getEditor(), null);
        if (runnable != null) {
          ApplicationManager.getApplication().invokeLater(runnable);
        }
        return;
      }
    }

    PsiElement context = callback.getContext();
    ZenCodingGenerator generator = ObjectUtils.notNull(findApplicableGenerator(node, callback, false), defaultGenerator);
    List<ZenCodingFilter> filters = getFilters(node, context);
    filters.addAll(extraFilters);

    checkTemplateOutputLength(node, callback);

    callback.deleteTemplateKey(key);
    expand(node, generator, filters, null, callback, expandPrimitiveAbbreviations, segmentsLimit);
  }
public static void expand(@NotNull String key, @NotNull CustomTemplateCallback callback,
                            @NotNull ZenCodingGenerator defaultGenerator,
                            @NotNull Collection<? extends ZenCodingFilter> extraFilters,
                            boolean expandPrimitiveAbbreviations, int segmentsLimit)