{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$ref": "#/definitions/RecordedUses",
  "definitions": {
    "Call": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "anyOf": [
            {
              "enum": [
                "tearoff",
                "with_arguments"
              ]
            },
            {
              "type": "string"
            }
          ]
        },
        "loading_unit_index": {
          "type": "integer"
        },
        "receiver": {
          "type": [
            "integer",
            "null"
          ]
        }
      },
      "required": [
        "loading_unit_index",
        "type"
      ],
      "if": {
        "properties": {
          "type": {
            "const": "with_arguments"
          }
        }
      },
      "then": {
        "properties": {
          "named": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "positional": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          }
        }
      }
    },
    "CallRecording": {
      "type": "object",
      "properties": {
        "definition_index": {
          "type": "integer"
        },
        "uses": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Call"
          },
          "minItems": 1
        }
      },
      "required": [
        "definition_index",
        "uses"
      ],
      "additionalProperties": false
    },
    "Constant": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "anyOf": [
            {
              "enum": [
                "bool",
                "double",
                "enum",
                "instance",
                "int",
                "list",
                "map",
                "non_constant",
                "null",
                "record",
                "set",
                "string",
                "symbol",
                "unsupported"
              ]
            },
            {
              "type": "string"
            }
          ]
        }
      },
      "required": [
        "type"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "const": "bool"
              }
            }
          },
          "then": {
            "properties": {
              "value": {
                "type": "boolean"
              }
            },
            "required": [
              "value"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "double"
              }
            }
          },
          "then": {
            "properties": {
              "value": {
                "$ref": "#/definitions/DoubleConstantValue"
              }
            },
            "required": [
              "value"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "enum"
              }
            }
          },
          "then": {
            "properties": {
              "definition_index": {
                "type": "integer"
              },
              "index": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "value": {
                "type": "object",
                "additionalProperties": {
                  "type": "integer"
                }
              }
            },
            "required": [
              "definition_index",
              "index",
              "name"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "instance"
              }
            }
          },
          "then": {
            "properties": {
              "definition_index": {
                "type": "integer"
              },
              "value": {
                "type": "object",
                "additionalProperties": true
              }
            },
            "required": [
              "definition_index"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "int"
              }
            }
          },
          "then": {
            "properties": {
              "value": {
                "type": "integer"
              }
            },
            "required": [
              "value"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "list"
              }
            }
          },
          "then": {
            "properties": {
              "value": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              }
            },
            "required": [
              "value"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "map"
              }
            }
          },
          "then": {
            "properties": {
              "value": {
                "type": "array",
                "items": {
                  "$ref": "#/definitions/MapEntry"
                }
              }
            },
            "required": [
              "value"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "non_constant"
              }
            }
          },
          "then": {
            "not": {
              "required": [
                "value"
              ]
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "null"
              }
            }
          },
          "then": {
            "not": {
              "required": [
                "value"
              ]
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "record"
              }
            }
          },
          "then": {
            "properties": {
              "named": {
                "type": "object",
                "additionalProperties": {
                  "type": "integer"
                }
              },
              "positional": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "set"
              }
            }
          },
          "then": {
            "properties": {
              "value": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              }
            },
            "required": [
              "value"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "string"
              }
            }
          },
          "then": {
            "properties": {
              "value": {
                "type": "string"
              }
            },
            "required": [
              "value"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "symbol"
              }
            }
          },
          "then": {
            "properties": {
              "libraryUri": {
                "type": [
                  "null",
                  "string"
                ],
                "pattern": "^package:"
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "name"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "unsupported"
              }
            }
          },
          "then": {
            "properties": {
              "message": {
                "type": "string"
              }
            },
            "required": [
              "message"
            ]
          }
        }
      ]
    },
    "Definition": {
      "type": "object",
      "properties": {
        "path": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Name"
          },
          "minItems": 1
        },
        "uri": {
          "type": "string",
          "pattern": "^package:"
        }
      },
      "required": [
        "path",
        "uri"
      ]
    },
    "DoubleConstantValue": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "anyOf": [
            {
              "enum": [
                "negative_infinity",
                "not_a_number",
                "number",
                "positive_infinity"
              ]
            },
            {
              "type": "string"
            }
          ]
        },
        "value": {
          "type": "number"
        }
      },
      "required": [
        "type"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "const": "number"
              }
            }
          },
          "then": {
            "required": [
              "value"
            ]
          }
        }
      ]
    },
    "Instance": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "anyOf": [
            {
              "enum": [
                "constant",
                "creation",
                "tearoff"
              ]
            },
            {
              "type": "string"
            }
          ]
        },
        "loading_unit_index": {
          "type": "integer"
        }
      },
      "required": [
        "loading_unit_index",
        "type"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "const": "constant"
              }
            }
          },
          "then": {
            "properties": {
              "constant_index": {
                "type": "integer"
              }
            },
            "required": [
              "constant_index"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "creation"
              }
            }
          },
          "then": {
            "properties": {
              "definition_index": {
                "type": "integer"
              },
              "named": {
                "type": "object",
                "additionalProperties": {
                  "type": "integer"
                }
              },
              "positional": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              }
            },
            "required": [
              "definition_index"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "tearoff"
              }
            }
          },
          "then": {
            "properties": {
              "definition_index": {
                "type": "integer"
              }
            },
            "required": [
              "definition_index"
            ]
          }
        }
      ]
    },
    "InstanceRecording": {
      "type": "object",
      "properties": {
        "definition_index": {
          "type": "integer"
        },
        "uses": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Instance"
          },
          "minItems": 1
        }
      },
      "required": [
        "definition_index",
        "uses"
      ],
      "additionalProperties": false
    },
    "LoadingUnit": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        }
      },
      "required": [
        "name"
      ]
    },
    "MapEntry": {
      "type": "object",
      "properties": {
        "key": {
          "type": "integer"
        },
        "value": {
          "type": "integer"
        }
      },
      "required": [
        "key",
        "value"
      ]
    },
    "Name": {
      "type": "object",
      "properties": {
        "disambiguators": {
          "type": "array",
          "items": {
            "type": "string",
            "anyOf": [
              {
                "enum": [
                  "instance",
                  "static"
                ]
              },
              {
                "type": "string"
              }
            ]
          }
        },
        "kind": {
          "type": "string",
          "anyOf": [
            {
              "enum": [
                "class",
                "constructor",
                "enum",
                "extension",
                "extension_type",
                "getter",
                "method",
                "mixin",
                "operator",
                "setter"
              ]
            },
            {
              "type": "string"
            }
          ]
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "kind",
        "name"
      ]
    },
    "RecordedUses": {
      "type": "object",
      "properties": {
        "definitions": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Definition"
          }
        },
        "constants": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Constant"
          }
        },
        "loading_units": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/LoadingUnit"
          }
        },
        "uses": {
          "$ref": "#/definitions/Uses"
        }
      }
    },
    "Uses": {
      "type": "object",
      "properties": {
        "instances": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/InstanceRecording"
          }
        },
        "static_calls": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/CallRecording"
          }
        }
      },
      "additionalProperties": false
    }
  }
}
