Overview
The Scope component checks the state and category of the token at the current position.
Properties
lines
Returns the latest Lines instance.
This is an alias of Code#Lines
.
i18n
Returns the i18n collection.
This is an alias of this.options.i18n
.
Methods
isIn()
isIn( names: string | string[], position?: Position ): boolean
Checks if the current or specified position is in the specified state or category.
With the !
negating notation, this returns true
if the position is NOT inside the scope.
Note that the Lexer (RyuseiLight) determines states and categories.
// Returns `true` if the caret is inside a comment. Scope.isIn( [ 'comment' ] ); // Returns `true` if the caret is inside a "attr" state. Scope.isIn( [ '#attr' ] ); // Returns `true` if the caret is not inside a comment and a string. Scope.isIn( [ '!comment', '!string' ] );
Params
names | A name or an array with names of states and/or categories. |
---|---|
position | Optional. Specifies the position to check. |
Return
true
if the start position is inside the scope.
inState()
inState( states: string | string[], position?: Position ): boolean
Checks if the current or specified position is in the specified state or not.
The !
negating notation is acceptable.
Params
states | A name or an array with names of states. |
---|---|
position | Optional. Specifies the position to check. |
inCategory()
inCategory( categories: string | string[], position?: Position ): boolean
Checks if the current or specified position is in the specified category or not.
The !
negating notation is acceptable.
Params
categories | A name or an array with names of categories. |
---|---|
position | Optional. Specifies the position to check. |