int (@NotNull Document document, @NotNull Project project, int offset) { PsiDocumentManager manager = PsiDocumentManager.getInstance(project); if (manager.isUncommited(document)) manager.commitDocument(document); PsiFile psiFile = manager.getPsiFile(document); if (psiFile != null) { PsiElement currElement = psiFile.findElementAt(offset); final IElementType elementType = PsiUtilCore.getElementType(currElement); if (elementType == JsonElementTypes.DOUBLE_QUOTED_STRING || elementType == JsonElementTypes.SINGLE_QUOTED_STRING || elementType == JsonElementTypes.LITERAL || elementType == JsonElementTypes.BOOLEAN_LITERAL || elementType == JsonElementTypes.TRUE || elementType == JsonElementTypes.FALSE || elementType == JsonElementTypes.IDENTIFIER || elementType == JsonElementTypes.NULL_LITERAL || elementType == JsonElementTypes.NUMBER_LITERAL) { return currElement.getTextRange().getEndOffset(); } if (elementType == JsonElementTypes.COLON) { return SKIP_WRAPPING; } if (currElement != null) { if (currElement instanceof PsiComment || PsiUtilCore.getElementType(PsiTreeUtil.skipWhitespacesForward(currElement)) == JsonElementTypes.COMMA) { return SKIP_WRAPPING; } } } return -1; }