{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://cocotec.io/schemas/popili/coco-ast-v1.schema.json",
  "title": "Coco Abstract Syntax Tree",
  "$ref": "#/$defs/Root",
  "$defs": {
    "Attribute": {
      "type": "object",
      "description": "A single attribute in a Coco file, e.g. @runtime(.SingleThreaded).",
      "allOf": [
        {
          "$ref": "#/$defs/BaseNode"
        }
      ],
      "properties": {
        "arguments": {
          "description": "The arguments to the attribute (e.g. .SingleThreaded).",
          "type": "array",
          "items": {
            "$ref": "https://cocotec.io/schemas/popili/coco-values-v1.schema.json#/$defs/RenderedValue",
            "$$target": "coco_rendered_value.json#/$defs/RenderedValue"
          }
        },
        "decl": {
          "description": "The declaration of the attribute (e.g. Base.runtime).",
          "type": "object",
          "properties": {
            "fully_qualified_name": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          }
        },
        "kind": {
          "const": "Attribute"
        }
      },
      "required": ["decl"],
      "unevaluatedProperties": false,
      "title": "Attribute"
    },
    "BaseNode": {
      "type": "object",
      "properties": {
        "kind": {
          "description": "The kind of node.",
          "type": "string"
        },
        "position": {
          "$ref": "#/$defs/SourceRange"
        },
        "attributes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Attribute"
          }
        }
      },
      "required": ["kind"],
      "title": "BaseNode"
    },
    "Decl": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/BaseNode"
        }
      ],
      "properties": {
        "fully_qualified_name": {
          "type": "string"
        },
        "metadata": {
          "$ref": "#/$defs/Metadata"
        },
        "name": {
          "type": "string"
        },
        "decls": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Decl"
          }
        }
      },
      "unevaluatedProperties": false,
      "title": "Decl"
    },
    "Metadata": {
      "type": "object",
      "properties": {
        "cognitive_complexity": {
          "type": "integer"
        }
      },
      "additionalProperties": false,
      "title": "Metadata"
    },
    "Package": {
      "type": "object",
      "properties": {
        "name": {
          "description": "The name of the package.",
          "type": "string"
        },
        "modules": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Decl"
          }
        },
        "root_directory": {
          "type": "string"
        }
      },
      "required": ["name", "modules", "root_directory"],
      "additionalProperties": false,
      "title": "Package"
    },
    "Root": {
      "type": "object",
      "properties": {
        "$schema": {
          "type": "string",
          "description": "The schema that this document conforms to."
        },
        "packages": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Package"
          }
        }
      },
      "required": ["packages"],
      "additionalProperties": false,
      "title": "Root"
    },
    "SourceLocation": {
      "type": "object",
      "properties": {
        "column": {
          "type": "integer",
          "description": "The 1-based column"
        },
        "line": {
          "type": "integer",
          "description": "The 1-based line"
        }
      },
      "required": ["column", "line"],
      "additionalProperties": false,
      "description": "A single location",
      "title": "SourceLocation"
    },
    "SourceRange": {
      "type": "object",
      "properties": {
        "start": {
          "$ref": "#/$defs/SourceLocation"
        },
        "file": {
          "type": "string",
          "description": "The file that this range is in, relative to the Coco.toml file. If this property is not present, the file can be inferred by going to the parent of this node and looking at its file, continuing until a file is found."
        },
        "end": {
          "$ref": "#/$defs/SourceLocation"
        }
      },
      "required": ["start", "end"],
      "additionalProperties": false,
      "description": "A range in a document. The range is half-open: it includes the start but excludes the end.",
      "title": "SourceRange"
    }
  }
}
