public void perform(final boolean generateFinal, final String modifier, final GrVariable variable) {
    final Document document = myEditor.getDocument();
    LOG.assertTrue(variable != null);
    final GrModifierList modifierList = variable.getModifierList();
    LOG.assertTrue(modifierList != null);
    final int textOffset = modifierList.getTextOffset();

    final Runnable runnable = () -> {
      if (generateFinal) {
        final GrTypeElement typeElement = variable.getTypeElementGroovy();
        final int typeOffset = typeElement != null ? typeElement.getTextOffset() : textOffset;
        document.insertString(typeOffset, modifier + " ");
      }
      else {
        final int idx = modifierList.getText().indexOf(modifier);
        document.deleteString(textOffset + idx, textOffset + idx + modifier.length() + 1);
      }
    };
    final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor);
    if (lookup != null) {
      lookup.performGuardedChange(runnable);
    } else {
      runnable.run();
    }
    PsiDocumentManager.getInstance(variable.getProject()).commitDocument(document);
  }
public void perform(final boolean generateFinal, final String modifier, final GrVariable variable)