Skip to main content

Class: DocumentScopeHandler

processTargets/modifiers/scopeHandlers/DocumentScopeHandler.DocumentScopeHandler

Hierarchy

Constructors

constructor

new DocumentScopeHandler(_scopeType, _languageId)

Parameters

NameType
_scopeTypeScopeType
_languageIdstring

Overrides

BaseScopeHandler.constructor

Defined in

processTargets/modifiers/scopeHandlers/DocumentScopeHandler.ts:12

Properties

isHierarchical

Protected Readonly isHierarchical: false

Indicates whether scopes are allowed to contain one another. If false, we can optimise the algorithm by making certain assumptions.

Overrides

BaseScopeHandler.isHierarchical

Defined in

processTargets/modifiers/scopeHandlers/DocumentScopeHandler.ts:10


iterationScopeType

Readonly iterationScopeType: Object

The scope type of the default iteration scope of this scope type. This scope type will be used when the input target has no explicit range (ie Target.hasExplicitRange is false).

Type declaration

NameType
type"document"

Overrides

BaseScopeHandler.iterationScopeType

Defined in

processTargets/modifiers/scopeHandlers/DocumentScopeHandler.ts:9


scopeType

Readonly scopeType: Object

The scope type handled by this scope handler

Type declaration

NameType
type"document"

Overrides

BaseScopeHandler.scopeType

Defined in

processTargets/modifiers/scopeHandlers/DocumentScopeHandler.ts:8

Methods

generateScopeCandidates

Protected generateScopeCandidates(editor, _position, _direction): Iterable<TargetScope>

Returns an iterable that yields scopes.

If your scope type is not hierarchical, and {@link direction} is "forward", yield all scopes whose domain's end is equal to or after position in document order.

If your scope type is not hierarchical, and {@link direction} is "backward", yield all scopes whose domain's start is equal to or before position, in reverse document order.

If your scope type is hierarchical, and {@link direction} is "forward", walk forward starting at position (including position). Any time a scope's domain ends or starts, yield that scope. If multiple domains start or end at a particular point, break ties as follows:

  1. First yield any scopes with empty domain.
  2. Then yield any scopes whose domains are ending, in reverse order of where they start.
  3. Then yield the scope with minimal domain that is starting. Any time you yield a scope, advance your position to the end of the scope, but when considering this new position, don't return this scope again.

If your scope type is hierarchical, and {@link direction} is "backward", walk backward starting at position (including position). Any time a scope's domain ends or starts, yield that scope. If multiple domains start or end at a particular point, break ties as follows:

  1. First yield any scopes with empty domain.
  2. Then yield any scopes whose domains are starting, in order of where they end.
  3. Then yield the scope with minimal domain that is ending. Any time you yield a scope, advance your position to the start of the scope, but when considering this new position, don't return this scope again.

Note that the {@link hints} argument can be ignored, but you are welcome to use it to improve performance. For example, knowing the ScopeIteratorRequirements.distalPosition can be useful if you need to query a list of scopes in bulk.

Some notes:

  • Once you have yielded a scope, you do not need to yield any scopes contained by that scope.
  • You can yield the same scope more than once if it makes your life easier

The only strict requirements are that

  • you yield every scope that might meet the requirements
  • you yield scopes in the correct order

Parameters

NameType
editorTextEditor
_positionPosition
_directionDirection

Returns

Iterable<TargetScope>

Overrides

BaseScopeHandler.generateScopeCandidates

Defined in

processTargets/modifiers/scopeHandlers/DocumentScopeHandler.ts:16


generateScopes

generateScopes(editor, position, direction, requirements?): Iterable<TargetScope>

Returns an iterable of scopes meeting the requirements in {@link requirements}, yielded in a specific order. See generateScopeCandidates and compareTargetScopes for more on the order.

Parameters

NameType
editorTextEditor
positionPosition
directionDirection
requirementsundefined | ScopeIteratorRequirements

Returns

Iterable<TargetScope>

Inherited from

BaseScopeHandler.generateScopes

Defined in

processTargets/modifiers/scopeHandlers/BaseScopeHandler.ts:94