@Override
  public @Nullable TextRange surroundElements(@NotNull Project project,
                                              @NotNull Editor editor,
                                              PsiElement @NotNull [] elements) {

    if (!isApplicable(elements)) {
      return null;
    }

    final JsonElementGenerator generator = new JsonElementGenerator(project);

    final PsiElement firstElement = elements[0];
    final JsonElement newNameElement;
    if (firstElement instanceof JsonValue) {
      assert elements.length == 1 : "Only single JSON value can be wrapped in object literal";
      JsonObject replacement = generator.createValue(createReplacementText(firstElement.getText()));
      replacement = (JsonObject)firstElement.replace(replacement);
      newNameElement = replacement.getPropertyList().get(0).getNameElement();
    }
    else {
      assert firstElement instanceof JsonProperty;
      final String propertiesText = getTextAndRemoveMisc(firstElement, elements[elements.length - 1]);
      final JsonObject tempJsonObject = generator.createValue(createReplacementText("{\n" + propertiesText) + "\n}");
      JsonProperty replacement = tempJsonObject.getPropertyList().get(0);
      replacement = (JsonProperty)firstElement.replace(replacement);
      newNameElement = replacement.getNameElement();
    }
    final TextRange rangeWithQuotes = newNameElement.getTextRange();
    return new TextRange(rangeWithQuotes.getStartOffset() + 1, rangeWithQuotes.getEndOffset() - 1);
  }
@Override
  public @Nullable TextRange surroundElements(@NotNull Project project,
                                              @NotNull Editor editor,
                                              PsiElement @NotNull [] elements)