Skip to content

[Query] Location Map

github-actions[bot] edited this page Nov 8, 2026 · 1 revision

Generated from 'wiki-query.ts' on 2026-11-08, 15:21:58 UTC (v2.17.4), do not edit 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>;...)] [token|full|statement] <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 (1 ms)
   ╰ File List:
      ╰ 0: @inline
   ╰ Id List: {0, 1, 2, 3, 4, 5, 2-arg, ... (see JSON)}

Show Detailed Results as Json

The analysis ran (including parsing and normalization and the query) within the generation environment.

The JSON contains the ids of the nodes in question (see the Interface wiki page).

{"location-map":{".meta":{},"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":{}}

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 (1 ms)
   ╰ File List:
      ╰ 0: @inline
   ╰ Id List: {0, 3}

Show Detailed Results as Json

The analysis ran (including parsing and normalization and the query) within the generation environment.

The JSON contains the ids of the nodes in question (see the Interface wiki page).

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

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

The Location Map Query is executed by executeLocationMapQuery.

Clone this wiki locally

⌂ 换网址