boolean (char c, PsiElement element) { // comma can be after the element, but only the comma if (PsiUtilCore.getElementType(element) == JsonElementTypes.R_CURLY) { return c == ',' && element.getPrevSibling() instanceof JsonProperty; } if (PsiUtilCore.getElementType(element) == JsonElementTypes.R_BRACKET) { return c == ',' && element.getPrevSibling() instanceof JsonStringLiteral; } // we can have a whitespace in the position, but again - only for the comma PsiElement parent = element.getParent(); if (element instanceof PsiWhiteSpace && c == ',') { PsiElement sibling = element.getPrevSibling(); return sibling instanceof JsonProperty || sibling instanceof JsonStringLiteral; } // the most ordinary case - literal property key or value PsiElement grandParent = parent instanceof JsonStringLiteral ? parent.getParent() : null; return grandParent instanceof JsonProperty && (c != ':' || ((JsonProperty)grandParent).getNameElement() == parent) && (c != ',' || ((JsonProperty)grandParent).getValue() == parent); }