{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "IBM zCodeFormatSettings",
  "description": "JSON schema for zcodeformat.yaml or zcodeformat.json code formatter preferences files. Version 0.0.1 -- Licensed Materials - Property of IBM - (c) Copyright IBM Corporation 2022. All Rights Reserved.",
  "type": "object",
  "properties": {
    "additionalProperties": false,
    "cobol": {
      "$ref": "#/definitions/cobol"
    },
    "copybook": {
      "$ref": "#/definitions/copybook"
    }
  },
  "definitions": {
    "copybookCapitalizationOptions": { "enum": ["upper", "lower"] },
    "cobolCapitalizationOptions": { "enum": ["none", "upper", "lower", "mixed"] },
    "cobol": {
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "dataDivision": {
          "additionalProperties": false,
          "type": "object",
          "properties": {
            "enableIndentation": {
              "type": "boolean",
              "description": "Enable indentation of record descriptions\nIf false, startOfAreaA and indentLength are not allowed",
              "default": true
            },
            "indentation": {
              "type": "object",
              "description": "Indentation objects based on enableIndentation",
              "$ref": "#/definitions/dataDivIndent"
            },
            "alignPictureClauses": {
              "type": "boolean",
              "description": "Align PICTURE Clauses",
              "default": true
            },
            "alignValueClauses": {
              "type": "boolean",
              "description": "Align VALUE Clauses",
              "default": true
            }
          },
          "anyOf": [
            {
              "properties": {
                "enableIndentation": { "const": false },
                "indentation": { "type": "object", "additionalProperties": false }
              }
            },
            {
              "properties": {
                "enableIndentation": { "const": true },
                "indentation": {
                  "$ref": "#/definitions/dataDivIndent"
                }
              }
            }
          ]
        },
        "procedureDivision": {
          "additionalProperties": false,
          "type": "object",
          "properties": {
            "enableIndentation": {
              "type": "boolean",
              "description": "Enable indentation of procedure divisions",
              "default": true
            },
            "indentation": {
              "type": "object",
              "description": "Indentation objects based on enableIndentation",
              "$ref": "#/definitions/procDivIndent"
            }
          },
          "anyOf": [
            {
              "properties": {
                "enableIndentation": { "const": false },
                "indentation": { "type": "object", "additionalProperties": false }
              }
            },
            {
              "properties": {
                "enableIndentation": { "const": true },
                "indentation": {
                  "$ref": "#/definitions/procDivIndent"
                }
              }
            }
          ]
        },
        "reservedWordCase": {
          "type": "string",
          "description": "Reserved words",
          "default": "upper",
          "$ref": "#/definitions/cobolCapitalizationOptions"
        },
        "userDefinedWordCase": {
          "type": "string",
          "description": "User-defined words",
          "default": "upper",
          "$ref": "#/definitions/cobolCapitalizationOptions"
        },
        "commentCase": {
          "type": "string",
          "description": "Comment",
          "default": "none",
          "$ref": "#/definitions/cobolCapitalizationOptions"
        },
        "functionCase": {
          "type": "string",
          "description": "Function",
          "default": "upper",
          "$ref": "#/definitions/cobolCapitalizationOptions"
        },
        "dateFormatCase": {
          "type": "string",
          "description": "Date format",
          "default": "upper",
          "$ref": "#/definitions/cobolCapitalizationOptions"
        },
        "compilerDirectiveCase": {
          "type": "string",
          "description": "Compiler directive",
          "default": "upper",
          "$ref": "#/definitions/cobolCapitalizationOptions"
        },
        "endOfAreaB": {
          "type": "integer",
          "description": "End of Area B\n\nIf -1, will use Margin R as the end of Area B",
          "default": -1,
          "oneOf": [
            { "minimum": -1, "maximum": -1 },
            { "minimum": 50, "maximum": 100 }
          ]
        },
        "lineWrappingStyle": {
          "type": "string",
          "description": "If indentation moves code beyond Area B",
          "default": "wrapToNextLine",
          "enum": ["wrapToNextLine", "noIndent", "indentToAreaB", "indentPastAreaB"]
        }
      }
    },
    "copybook": {
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "codeCase": {
          "type": "string",
          "description": "Format copybook code in uppercase",
          "default": "upper",
          "$ref": "#/definitions/copybookCapitalizationOptions"
        },
        "commentCase": {
          "type": "string",
          "description": "Format copybook comments in uppercase",
          "default": "upper",
          "$ref": "#/definitions/copybookCapitalizationOptions"
        }
      }
    },
    "dataDivIndent": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "startOfAreaA": {
          "type": "integer",
          "description": "Start of Area A\nCannot be used if enableIndentation is false",
          "default": 8,
          "minimum": 8,
          "maximum": 11
        },
        "indentLength": {
          "type": "integer",
          "description": "Indent Length\nCannot be used if enableIndentation is false",
          "default": 3,
          "minimum": 0,
          "maximum": 10
        }
      }
    },
    "procDivIndent": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "startOfAreaA": {
          "type": "integer",
          "description": "Start of Area A\nCannot be used if enableIndentation is false",
          "default": 8,
          "minimum": 8,
          "maximum": 11
        },
        "startOfAreaB": {
          "type": "integer",
          "description": "Start of Area B\nCannot be used if enableIndentation is false",
          "default": 12,
          "minimum": 12,
          "maximum": 16
        },
        "indentMultipleLineStatements": {
          "type": "integer",
          "description": "Multiple line statement indent length\nCannot be used if enableIndentation is false\nuse -1 to disable",
          "default": 3,
          "minimum": 0,
          "maximum": 10
        },
        "alignLists": {
          "type": "boolean",
          "description": "Align lists\nCannot be used if enableIndentation is false",
          "default": true
        },
        "indentForAllBlocks": {
          "type": "integer",
          "description": "Fixed indent length to use for all blocks\nCannot be used if enableIndentation is false\nCannot be used with other individual block indent values",
          "default": 3,
          "minimum": 0,
          "maximum": 10
        },
        "blocks": {
          "type": "object",
          "description": "Individual block indent values",
          "$ref": "#/definitions/blockIndent"
        }
      },
      "anyOf": [
        {
          "properties": {
            "indentForAllBlocks": { "type": "number" },
            "blocks": { "type": "object", "additionalProperties": false }
          }
        },
        {
          "properties": {
            "indentForAllBlocks": false,
            "blocks": {
              "$ref": "#/definitions/blockIndent"
            }
          }
        }
      ]
    },
    "blockIndent": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "indentAtEndBlock": {
          "type": "integer",
          "description": "Indent length of AT END block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 3,
          "minimum": 0,
          "maximum": 10
        },
        "indentAtEndOfPageBlock": {
          "type": "integer",
          "description": "Indent length of AT END OF PAGE block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 3,
          "minimum": 0,
          "maximum": 10
        },
        "indentExecBlock": {
          "type": "integer",
          "description": "Indent length of EXEC block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 5,
          "minimum": 0,
          "maximum": 10
        },
        "indentEndExecPhrase": {
          "type": "boolean",
          "description": "Indent END-EXEC phrase\nCannot be used if enableIndentation is false\nEND-EXEC phrase will be indented with Exec Block",
          "default": true
        },
        "indentIfBlock": {
          "type": "integer",
          "description": "Indent length of IF block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 3,
          "minimum": 0,
          "maximum": 10
        },
        "indentInvalidKeyBlock": {
          "type": "integer",
          "description": "Indent length of INVALID KEY block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 8,
          "minimum": 0,
          "maximum": 10
        },
        "indentNotAtEndBlock": {
          "type": "integer",
          "description": "Indent length of NOT AT END block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 4,
          "minimum": 0,
          "maximum": 10
        },
        "indentNotAtEndOfPageBlock": {
          "type": "integer",
          "description": "Indent length of NOT AT END OF PAGE block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 4,
          "minimum": 0,
          "maximum": 10
        },
        "indentNotInvalidKeyBlock": {
          "type": "integer",
          "description": "Indent length of INVALID KEY\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 4,
          "minimum": 0,
          "maximum": 10
        },
        "indentNotOnExceptionBlock": {
          "type": "integer",
          "description": "Indent length of NOT ON EXCEPTION block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 4,
          "minimum": 0,
          "maximum": 10
        },
        "indentNotOnOverflowBlock": {
          "type": "integer",
          "description": "Indent length of NOT ON OVERFLOW block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 4,
          "minimum": 0,
          "maximum": 10
        },
        "indentNotOnSizeErrorBlock": {
          "type": "integer",
          "description": "Indent length of NOT ON SIZE ERROR block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 4,
          "minimum": 0,
          "maximum": 10
        },
        "indentOnExceptionBlock": {
          "type": "integer",
          "description": "Indent length of ON EXCEPTION block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 3,
          "minimum": 0,
          "maximum": 10
        },
        "indentOnOverflowBlock": {
          "type": "integer",
          "description": "Indent length of ON OVERFLOW block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 3,
          "minimum": 0,
          "maximum": 10
        },
        "indentOnSizeErrorBlock": {
          "type": "integer",
          "description": "Indent length of ON SIZE ERROR block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 3,
          "minimum": 0,
          "maximum": 10
        },
        "indentPerformBlock": {
          "type": "integer",
          "description": "Indent length of PERFORM block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 8,
          "minimum": 0,
          "maximum": 10
        },
        "indentWhenBlock": {
          "type": "integer",
          "description": "Indent length of WHEN block\nCannot be used if enableIndentation is false\nCannot be used if indentForAllBlocks is used",
          "default": 5,
          "minimum": 0,
          "maximum": 10
        }
      }
    }
  }
}