JsonLikeSyntaxAdapter (Project project) { return new JsonLikeSyntaxAdapter() { private final JsonElementGenerator myGenerator = new JsonElementGenerator(project); @Override public @Nullable PsiElement getPropertyValue(PsiElement property) { assert property instanceof JsonProperty; return ((JsonProperty)property).getValue(); } @Override public @NotNull String getPropertyName(PsiElement property) { assert property instanceof JsonProperty; return ((JsonProperty)property).getName(); } @Override public @NotNull PsiElement createProperty(@NotNull String name, @NotNull String value, PsiElement element) { return myGenerator.createProperty(name, value); } @Override public boolean ensureComma(PsiElement self, PsiElement newElement) { if (newElement instanceof JsonProperty && self instanceof JsonProperty) { self.getParent().addAfter(myGenerator.createComma(), self); return true; } return false; } @Override public void removeIfComma(PsiElement forward) { if (forward instanceof LeafPsiElement && ((LeafPsiElement)forward).getElementType() == JsonElementTypes.COMMA) { forward.delete(); } } @Override public boolean fixWhitespaceBefore(PsiElement initialElement, PsiElement element) { return true; } @Override public @NotNull String getDefaultValueFromType(@Nullable JsonSchemaType type) { return type == null ? "" : type.getDefaultValue(); } @Override public PsiElement adjustNewProperty(PsiElement element) { return element; } @Override public PsiElement adjustPropertyAnchor(LeafPsiElement element) { throw new IncorrectOperationException("Shouldn't use leafs for insertion in pure JSON!"); } }; }