[SourceKit] Add "Active Regions" request

`source.request.activeregions` is a new request that reports all
`#if`, `#else` and `#elseif` decls in the response with an `is_active` flag.
This is mainly useful for a client to know which branches are active,
but for completeness sake, the active decls are also reported.

Note: it only reports the positions of the decls, not the entire ranges.
It's up to clients to map this to the syntactic structure of a tree.
Reporting the ranges of the decls could be confusing in the case
of nested `#if`s, where the ranges can overlap.
This commit is contained in:
Louis D'hauwe
2023-02-21 15:53:29 -08:00
parent 45edfc359b
commit 876682fb12
11 changed files with 279 additions and 0 deletions

View File

@@ -83,6 +83,7 @@ UID_KEYS = [
KEY('BodyLength', 'key.bodylength'),
KEY('DocOffset', 'key.docoffset'),
KEY('DocLength', 'key.doclength'),
KEY('IsActive', 'key.is_active'),
KEY('IsLocal', 'key.is_local'),
KEY('InheritedTypes', 'key.inheritedtypes'),
KEY('Attributes', 'key.attributes'),
@@ -224,6 +225,7 @@ UID_REQUESTS = [
REQUEST('CodeCompleteSetCustom', 'source.request.codecomplete.setcustom'),
REQUEST('TypeContextInfo', 'source.request.typecontextinfo'),
REQUEST('ConformingMethodList', 'source.request.conformingmethods'),
REQUEST('ActiveRegions', 'source.request.activeregions'),
REQUEST('CursorInfo', 'source.request.cursorinfo'),
REQUEST('RangeInfo', 'source.request.rangeinfo'),
REQUEST('RelatedIdents', 'source.request.relatedidents'),