Class: TokenScopeHandler
processTargets/modifiers/scopeHandlers/ParagraphScopeHandler.TokenScopeHandler
Hierarchy
↳
TokenScopeHandler
Constructors
constructor
• new TokenScopeHandler(_scopeType
, _languageId
)
Parameters
Name | Type |
---|---|
_scopeType | ScopeType |
_languageId | string |
Overrides
Defined in
processTargets/modifiers/scopeHandlers/ParagraphScopeHandler.ts:19
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/ParagraphScopeHandler.ts:17
iterationScopeType
• Readonly
iterationScopeType: ScopeType
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
).
Overrides
BaseScopeHandler.iterationScopeType
Defined in
processTargets/modifiers/scopeHandlers/ParagraphScopeHandler.ts:16
scopeType
• Readonly
scopeType: ScopeType
The scope type handled by this scope handler
Overrides
Defined in
processTargets/modifiers/scopeHandlers/ParagraphScopeHandler.ts:15
Methods
generateScopeCandidates
▸ 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:
- First yield any scopes with empty domain.
- Then yield any scopes whose domains are ending, in reverse order of where they start.
- 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:
- First yield any scopes with empty domain.
- Then yield any scopes whose domains are starting, in order of where they end.
- 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
Name | Type |
---|---|
editor | TextEditor |
position | Position |
direction | Direction |
Returns
Iterable
<TargetScope
>
Overrides
BaseScopeHandler.generateScopeCandidates
Defined in
processTargets/modifiers/scopeHandlers/ParagraphScopeHandler.ts:23
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
Name | Type |
---|---|
editor | TextEditor |
position | Position |
direction | Direction |
requirements | undefined | ScopeIteratorRequirements |
Returns
Iterable
<TargetScope
>
Inherited from
BaseScopeHandler.generateScopes
Defined in
processTargets/modifiers/scopeHandlers/BaseScopeHandler.ts:94