int (PsiExpression expression) { expression = PsiUtil.skipParenthesizedExprDown(expression); if (!(expression instanceof PsiLiteralExpression || expression instanceof PsiPolyadicExpression) || !ExpressionUtils.hasStringType(expression)) { return -1; } final Object value = ExpressionUtils.computeConstantExpression(expression); if (!(value instanceof String string)) { return -1; } int index = string.indexOf('%'); final int length = string.length(); int count = 0; while (index >= 0 && length > index + 1) { final char c = string.charAt(index + 1); if (c == 's') { count++; } else if (c != '%') { return -1; } index = string.indexOf('%', index + 1); } if (count == 0) { return -1; } return count; }