Skip to main content

Class: RelativeInclusiveScopeStage

processTargets/modifiers/RelativeInclusiveScopeStage.RelativeInclusiveScopeStage

Handles relative modifiers that include targets intersecting with the input, eg "two funks", "token backward", etc. Proceeds as follows:

  1. Gets all scopes intersecting with input target. For empty range, that will be the scope touching the input, preferring the one in the direction of RelativeScopeModifier.direction if the input is adjacent to two. For non-empty range, just queries {@link ScopeHandler.getScopesOverlappingRange}. These are called the offset 0 scopes, as they correspond to "offset 0".
  2. Subtracts the number of scopes at offset 0 from RelativeScopeModifier.length to determine how many more are needed, throwing an error if offset zero already has more scopes than needed.
  3. Calls {@link ScopeHandler.getScopeRelativeToPosition} starting from the end of the last offset 0 scope if direction is forward (start of the first if direction is backward). Uses offset determined from subtraction above to get enough scopes to result in RelativeScopeModifier.length total scopes.
  4. Constructs a range target from the first offset 0 scope past the newly returned scope if direction is forward, or from last offset 0 scope if direction is backward.

Implements

Constructors

constructor

new RelativeInclusiveScopeStage(modifier)

Parameters

NameType
modifierRelativeScopeModifier

Defined in

processTargets/modifiers/RelativeInclusiveScopeStage.ts:44

Methods

run

run(context, target): Target[]

Parameters

NameType
contextProcessedTargetsContext
targetTarget

Returns

Target[]

Implementation of

ModifierStage.run

Defined in

processTargets/modifiers/RelativeInclusiveScopeStage.ts:46