MSON AST Source Map

January 15, 2015 · View on GitHub

This document defines serialization formats for MSON AST Source Map.

Version

Refer to the MSON AST Definition – the version of the Source Map conforms to the version of MSON AST.

Source Map Definition

Following is the description of MSON Source map media types using the MSON syntax.

Source Map (array)

Set of indices to source code blocks. The blocks may be non-continuous.

Each block is defined by a zero-based index of its first character and the number of following characters.

Items

  • (array, fixed) - A tuple defining position of a block in the source code
    • 1219 (number) - Zero-based index of the first character
    • 30 (number) - Number of the characters in the block

Named Type Source Map (object)

Source map of the Named Type

Properties

Type Section Source Map (enum)

Source map of the Type Section

Members

  • (Source Map) - Source map of content for blockDescription or a literal value of sample and default classes
  • (array[Element Source Map]) - Ordered array of elements (memberType, sample or default classes only)

Element Source Map (enum)

Source map of the Element

Members

Elements Source Map (array[Element Source Map])

Source map of the Elements

Property Member Source Map (Value Member Source Map)

Source map of the Property Member

Properties

  • name (Source Map) - Source map of the property name

Value Member Source Map (object)

Source map of the Value Member

Properties

  • description (Source Map) - Source map of inline description
  • valueDefinition (Source Map) - Source map of member's value definition
  • sections (array[Type Section Source Map]) - List of member's type section source maps

Mixin Source Map (Source Map)

Source map of the Mixin

One Of Source Map (Elements Source Map)

Source map of the One Of

Media Types

The Base type media type is application/vnd.mson.sourcemap.

Serialization formats

Two supported, feature-equal, serialization formats are JSON and YAML:

  • application/vnd.mson.sourcemap+json
  • application/vnd.mson.sourcemap+yaml

Example: JSON Serialization

application/vnd.mson.sourcemap+json; version=2.0

{
  "name": [
    [0, 16]
  ],
  "typeDefinition": [
    [0, 16]
  ],
  "sections": [
    [
      {
        "name": [
          [18, 17]
        ],
        "description": [],
        "valueDefinition": [
          [18, 17]
        ],
        "sections": []
      },
      {
        "name": [
          [37, 19]
        ],
        "description": [],
        "valueDefinition": [
          [37, 19]
        ],
        "sections": []
      },
      {
        "name": [
          [58, 22]
        ],
        "description": [],
        "valueDefinition": [
          [58, 22]
        ],
        "sections": []
      },
      {
        "name": [
          [82, 18]
        ],
        "description": [],
        "valueDefinition": [
          [82, 18]
        ],
        "sections": []
      },
      {
        "name": [
          [102, 15]
        ],
        "description": [],
        "valueDefinition": [
          [102, 15]
        ],
        "sections": [
          [
            {
              "description": [],
              "valueDefinition": [
                [123, 2]
              ],
              "sections": []
            },
            {
              "description": [],
              "valueDefinition": [
                [131, 2]
              ],
              "sections": []
            },
            {
              "description": [],
              "valueDefinition": [
                [137, 4]
              ],
              "sections": []
            }
          ]
        ]
      }
    ]
  ]
}

NOTE: This example uses the same MSON AST as used in the MSON AST Definition example.