Skip to content

[Query] Location Map

github-actions[bot] edited this page Jul 21, 2026 · 1 revision

This document was generated from 'src/documentation/wiki-query.ts' on 2026-07-20, 17:48:27 UTC presenting an overview of flowR's query API (v2.12.3). Please do not edit this file/wiki page directly.

Location Map Query [overview]

Returns a simple mapping of ids to their location in the source file
This query is requested with the type location-map.
Run in the REPL: :query @location-map [(<crit>;...)] <code | file://path>

A query like the Id-Map Query query can return a huge result, especially for larger scripts. If you are not interested in all of the information contained within the full map, you can use the location map query to get a simple mapping of ids to their location in the source file.

Consider you have the following code:

x + 1
x * 2

The following query then gives you the aforementioned mapping:

[ { "type": "location-map" } ]

(This can be shortened to @location-map when used with the REPL command :query).

Results (prettified and summarized):

Query: location-map (3 ms)
   ╰ File List:
      ╰ 0: @inline
   ╰ Id List: {0, 1, 2, 3, 4, 5, 2-arg, ... (see JSON)}
All queries together required ≈8 ms (1ms accuracy, total 9 ms)

Show Detailed Results as Json

The analysis required 8.6 ms (including parsing and normalization and the query) within the generation environment.

In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR. Please consult the Interface wiki page for more information on how to get those.

{
  "location-map": {
    ".meta": {
      "timing": 3
    },
    "map": {
      "files": {
        "0": "@inline"
      },
      "ids": {
        "0": [
          0,
          [
            1,
            1,
            1,
            1
          ]
        ],
        "1": [
          0,
          [
            1,
            5,
            1,
            5
          ]
        ],
        "2": [
          0,
          [
            1,
            3,
            1,
            3
          ]
        ],
        "3": [
          0,
          [
            2,
            1,
            2,
            1
          ]
        ],
        "4": [
          0,
          [
            2,
            5,
            2,
            5
          ]
        ],
        "5": [
          0,
          [
            2,
            3,
            2,
            3
          ]
        ],
        "2-arg": [
          0,
          [
            1,
            3,
            1,
            3
          ]
        ],
        "5-arg": [
          0,
          [
            2,
            3,
            2,
            3
          ]
        ],
        "0-arg": [
          0,
          [
            1,
            1,
            1,
            1
          ]
        ],
        "1-arg": [
          0,
          [
            1,
            5,
            1,
            5
          ]
        ],
        "3-arg": [
          0,
          [
            2,
            1,
            2,
            1
          ]
        ],
        "4-arg": [
          0,
          [
            2,
            5,
            2,
            5
          ]
        ]
      }
    }
  },
  ".meta": {
    "timing": 8
  }
}

The query also accepts a list of slice criteria to filter the results to only include the locations of specific nodes. For example:

[ { "type": "location-map",   "ids": [ "1@x",    "2@x" ] } ]

(This can be shortened to @location-map (1@x;2@x) "x + 1\nx * 2" when used with the REPL command :query).

Results (prettified and summarized):

Query: location-map (4 ms)
   ╰ File List:
      ╰ 0: @inline
   ╰ Id List: {0, 3}
All queries together required ≈8 ms (1ms accuracy, total 9 ms)

Show Detailed Results as Json

The analysis required 9.2 ms (including parsing and normalization and the query) within the generation environment.

In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR. Please consult the Interface wiki page for more information on how to get those.

{
  "location-map": {
    ".meta": {
      "timing": 4
    },
    "map": {
      "files": {
        "0": "@inline"
      },
      "ids": {
        "0": [
          0,
          [
            1,
            1,
            1,
            1
          ]
        ],
        "3": [
          0,
          [
            2,
            1,
            2,
            1
          ]
        ]
      }
    }
  },
  ".meta": {
    "timing": 8
  }
}

All locations are given as a SourceRange paired with the file id in the format [file-id, [start-line, start-column, end-line, end-column]].

Implementation Details

Responsible for the execution of the Location Map Query query is executeLocationMapQuery in ./src/queries/catalog/location-map-query/location-map-query-executor.ts.

Clone this wiki locally