@Override
  public void handleInsert(@NotNull InsertionContext context) {
    final Document document = context.getEditor().getDocument();
    int offset = context.getTailOffset();
    String replacement = myCanonicalText + DOT_CLASS;
    if (document.getTextLength() > offset + DOT_CLASS.length() &&
        document.getText(TextRange.from(offset, DOT_CLASS.length())).equals(DOT_CLASS)) {
      replacement = myCanonicalText;
    }
    document.replaceString(context.getStartOffset(), offset, replacement);
    final Project project = context.getProject();
    PsiDocumentManager.getInstance(project).commitDocument(document);
    JavaCodeStyleManager.getInstance(project).shortenClassReferences(context.getFile(), context.getStartOffset(), offset);
  }
@Override
  public void handleInsert(@NotNull InsertionContext context)