Skip to main content

Class: BaseTarget

processTargets/targets/BaseTarget.BaseTarget

Hierarchy

Implements

Constructors

constructor

new BaseTarget(parameters)

Parameters

NameType
parametersCommonTargetParameters

Defined in

processTargets/targets/BaseTarget.ts:35

Properties

hasExplicitRange

hasExplicitRange: boolean = true

If true, then this target has an explicit range. This attribute is used by "every" to determine whether to return all scopes in the iteration scope or just the ones that overlap with the given target's contentRange.

Most targets have explicit ranges. As of writing this comment, the only targets that don't are as follows:

  • a decorated mark ("air"), or
  • an empty cursor mark ("this" with an empty selection), or
  • an empty "that" mark (eg after saying "chuck air").

For example, when the user says "change every state air", we clear every statement in the function, but "change every state this" with a non-empty selection will only target statements overlapping the cursor.

Implementation of

Target.hasExplicitRange

Defined in

processTargets/targets/BaseTarget.ts:31


hasExplicitScopeType

hasExplicitScopeType: boolean = true

If true, then this target has an explicit scope type, and so should never be automatically expanded to a containing scope.

Examples of targets that have explicit scopes are ScopeTypeTarget (eg "funk"), TokenTarget (eg "token"), etc.

As of writing this comment, the only target type that doesn't have an explicit scope type is UntypedTarget, which can be constructed by

  • using a decorated mark ("air"), or
  • using any cursor mark ("this"), or
  • using a range between decorated marks or cursor marks (eg "past air" or "air past bat"), or
  • using any "that" mark (eg after saying "copy air"), though this final behaviour will change with #466.

The primary consumer of this attribute is ModifyIfUntypedStage, which is used in the following situations to automatically expand to a particular scope type when hasExplicitScopeType is false:

  • To expand to "line" for "pour", "clone", and "breakpoint"
  • To expand to "token" for "leading" and "trailing"
  • To expand to nearest containing pair for "inside", "bounds", and "rewrap"
  • To expand to SnippetVariable.wrapperScopeType for snippet wrapping
  • To expand to Snippet.insertionScopeTypes for snippet insertion

For example, when the user says "pour air", the {@link DecoratedSymbolStage} will return an UntypedTarget, which has hasExplicitScopeType=false, so "pour" will expand to the line containining the air token and insert a newline after it.

Implementation of

Target.hasExplicitScopeType

Defined in

processTargets/targets/BaseTarget.ts:30


isLine

isLine: boolean = false

If true this target should be treated as a line

Implementation of

Target.isLine

Defined in

processTargets/targets/BaseTarget.ts:29


isNotebookCell

isNotebookCell: boolean = false

If true this target is a notebook cell

Implementation of

Target.isNotebookCell

Defined in

processTargets/targets/BaseTarget.ts:33


isRaw

isRaw: boolean = false

If true this target is a raw selection and its insertion delimiter should not be used on bring action

Implementation of

Target.isRaw

Defined in

processTargets/targets/BaseTarget.ts:32


state

Protected Readonly state: CommonTargetParameters

Defined in

processTargets/targets/BaseTarget.ts:28

Accessors

contentRange

get contentRange(): Range

The range of the content

Returns

Range

Implementation of

Target.contentRange

Defined in

processTargets/targets/BaseTarget.ts:65


contentSelection

get contentSelection(): Selection

The content range and is reversed turned into a selection

Returns

Selection

Implementation of

Target.contentSelection

Defined in

processTargets/targets/BaseTarget.ts:61


contentText

get contentText(): string

The text contained in the content range

Returns

string

Implementation of

Target.contentText

Defined in

processTargets/targets/BaseTarget.ts:57


editor

get editor(): TextEditor

The text editor used for all ranges

Returns

TextEditor

Implementation of

Target.editor

Defined in

processTargets/targets/BaseTarget.ts:44


insertionDelimiter

Abstract get insertionDelimiter(): string

If this selection has a delimiter use it for inserting before or after the target. For example, new line for a line or paragraph and comma for a list or argument

Returns

string

Implementation of

Target.insertionDelimiter

Defined in

processTargets/targets/BaseTarget.ts:181


isReversed

get isReversed(): boolean

If true active is before anchor

Returns

boolean

Implementation of

Target.isReversed

Defined in

processTargets/targets/BaseTarget.ts:47


thatTarget

get thatTarget(): Target

Internal target that should be used for the that mark

Returns

Target

Implementation of

Target.thatTarget

Defined in

processTargets/targets/BaseTarget.ts:51

Methods

cloneWith

Readonly cloneWith(parameters): any

Parameters

NameType
parametersCloneWithParameters

Returns

any

Defined in

processTargets/targets/BaseTarget.ts:110


constructChangeEdit

constructChangeEdit(text): EditWithRangeUpdater

Constructs change/insertion edit. Adds delimiter before/after if needed

Parameters

NameType
textstring

Returns

EditWithRangeUpdater

Implementation of

Target.constructChangeEdit

Defined in

processTargets/targets/BaseTarget.ts:69


constructRemovalEdit

constructRemovalEdit(): EditWithRangeUpdater

Constructs removal edit

Returns

EditWithRangeUpdater

Implementation of

Target.constructRemovalEdit

Defined in

processTargets/targets/BaseTarget.ts:77


createContinuousRangeTarget

createContinuousRangeTarget(isReversed, endTarget, includeStart, includeEnd): Target

Parameters

NameType
isReversedboolean
endTargetTarget
includeStartboolean
includeEndboolean

Returns

Target

Implementation of

Target.createContinuousRangeTarget

Defined in

processTargets/targets/BaseTarget.ts:121


getBoundaryStrict

getBoundaryStrict(): Target[]

Returns

Target[]

Implementation of

Target.getBoundaryStrict

Defined in

processTargets/targets/BaseTarget.ts:106


getCloneParameters

Protected Abstract getCloneParameters(): object

Returns

object

Defined in

processTargets/targets/BaseTarget.ts:119


getEditNewContext

getEditNewContext(): EditNewContext

Returns

EditNewContext

Implementation of

Target.getEditNewContext

Defined in

processTargets/targets/BaseTarget.ts:85


getEqualityParameters

Protected getEqualityParameters(): object

Constructs an object that can be used for determining equality between two BaseTarget objects. We proceed by just getting the objects clone parameters and removing the thatTarget.

We would prefer to instead merge the thatTargets into a list. See #780 for more details.

Returns

object

The object to be used for determining equality

Defined in

processTargets/targets/BaseTarget.ts:168


getInteriorStrict

getInteriorStrict(): Target[]

Returns

Target[]

Implementation of

Target.getInteriorStrict

Defined in

processTargets/targets/BaseTarget.ts:103


getLeadingDelimiterTarget

Abstract getLeadingDelimiterTarget(): undefined | Target

The range of the delimiter before the content selection

Returns

undefined | Target

Implementation of

Target.getLeadingDelimiterTarget

Defined in

processTargets/targets/BaseTarget.ts:182


getRemovalHighlightRange

getRemovalHighlightRange(): undefined | Range

Returns

undefined | Range

Implementation of

Target.getRemovalHighlightRange

Defined in

processTargets/targets/BaseTarget.ts:91


getRemovalRange

Abstract getRemovalRange(): Range

Returns

Range

Implementation of

Target.getRemovalRange

Defined in

processTargets/targets/BaseTarget.ts:184


getTrailingDelimiterTarget

Abstract getTrailingDelimiterTarget(): undefined | Target

The range of the delimiter after the content selection

Returns

undefined | Target

Implementation of

Target.getTrailingDelimiterTarget

Defined in

processTargets/targets/BaseTarget.ts:183


isEqual

isEqual(otherTarget): boolean

Parameters

NameType
otherTargetTarget

Returns

boolean

Implementation of

Target.isEqual

Defined in

processTargets/targets/BaseTarget.ts:151


toPositionTarget

toPositionTarget(position): Target

Construct a position target with the given position.

Parameters

NameType
positionPosition

Returns

Target

Implementation of

Target.toPositionTarget

Defined in

processTargets/targets/BaseTarget.ts:177


withContentRange

withContentRange(contentRange): Target

Parameters

NameType
contentRangeRange

Returns

Target

Implementation of

Target.withContentRange

Defined in

processTargets/targets/BaseTarget.ts:99


withThatTarget

withThatTarget(thatTarget): Target

Parameters

NameType
thatTargetTarget

Returns

Target

Implementation of

Target.withThatTarget

Defined in

processTargets/targets/BaseTarget.ts:95