public void doUpdateTag(final @NotNull String abbreviation,
                          final @NotNull XmlTag tag,
                          @NotNull PsiFile file,
                          @NotNull Editor editor) throws EmmetException {
    if (!tag.isValid()) return;

    ReadAction
      .nonBlocking(() -> expandTemplate(abbreviation, file, editor))
      .finishOnUiThread(ModalityState.current(), templateText -> {
        final Collection<String> classNames = new LinkedHashSet<>();
        ContainerUtil.addAll(classNames, HtmlUtil.splitClassNames(tag.getAttributeValue(HtmlUtil.CLASS_ATTRIBUTE_NAME)));
        final Map<String, String> attributes = new LinkedHashMap<>();
        final Ref<String> newTagName = Ref.create();
        processTags(file.getProject(), templateText, (tag1, firstTag) -> {
          if (firstTag && !abbreviation.isEmpty() && StringUtil.isJavaIdentifierPart(abbreviation.charAt(0))) {
            newTagName.set(tag1.getName());
          }

          for (String clazz : HtmlUtil.splitClassNames(tag1.getAttributeValue(HtmlUtil.CLASS_ATTRIBUTE_NAME))) {
            if (StringUtil.startsWithChar(clazz, '+')) {
              classNames.add(clazz.substring(1));
            }
            else if (StringUtil.startsWithChar(clazz, '-')) {
              classNames.remove(clazz.substring(1));
            }
            else {
              classNames.clear();
              classNames.add(clazz);
            }
          }

          if (!firstTag) {
            classNames.add(tag1.getName());
          }

          for (XmlAttribute xmlAttribute : tag1.getAttributes()) {
            if (!HtmlUtil.CLASS_ATTRIBUTE_NAME.equalsIgnoreCase(xmlAttribute.getName())) {
              attributes.put(xmlAttribute.getName(), StringUtil.notNullize(xmlAttribute.getValue()));
            }
          }
          return true;
        });

        WriteCommandAction.writeCommandAction(file.getProject(), file)
          .run(doUpdateTagAttributes(tag, file, newTagName.get(), classNames, attributes));
      })
      .expireWhen(() -> editor.isDisposed() || !file.isValid())
      .submit(AppExecutorUtil.getAppExecutorService());
  }
public void doUpdateTag(final @NotNull String abbreviation,
                          final @NotNull XmlTag tag,
                          @NotNull PsiFile file,
                          @NotNull Editor editor)