use of com.intellij.json.psi.JsonElementGenerator in project intellij-community by JetBrains.
the class JsonPsiUtilTest method checkAddProperty.
private void checkAddProperty(@NotNull String before, @NotNull String after, final boolean first) {
getCustomCodeStyleSettings().OBJECT_WRAPPING = CommonCodeStyleSettings.DO_NOT_WRAP;
myFixture.configureByText(JsonFileType.INSTANCE, before);
final PsiElement atCaret = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
final JsonObject jsonObject = PsiTreeUtil.getParentOfType(atCaret, JsonObject.class);
assertNotNull(jsonObject);
WriteCommandAction.runWriteCommandAction(getProject(), () -> {
JsonPsiUtil.addProperty(jsonObject, new JsonElementGenerator(getProject()).createProperty("foo", "null"), first);
});
myFixture.checkResult(after);
}
use of com.intellij.json.psi.JsonElementGenerator in project intellij-community by JetBrains.
the class JsonPropertyMixin method setName.
@Override
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
final JsonElementGenerator generator = new JsonElementGenerator(getProject());
// Strip only both quotes in case user wants some exotic name like key'
getNameElement().replace(generator.createStringLiteral(StringUtil.unquoteString(name)));
return this;
}
Aggregations