Skip to content

Commit 5a8d208

Browse files
Rename
1 parent ed7591e commit 5a8d208

File tree

12 files changed

+45
-39
lines changed

12 files changed

+45
-39
lines changed

packages/cursorless-engine/src/processTargets/modifiers/ContainingScopeStage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class ContainingScopeStage implements ModifierStage {
3434
run(target: Target): Target[] {
3535
const { scopeType, ancestorIndex = 0 } = this.modifier;
3636

37-
const scopeHandler = this.scopeHandlerFactory.create(
37+
const scopeHandler = this.scopeHandlerFactory.tryCreate(
3838
scopeType,
3939
target.editor.document.languageId,
4040
);

packages/cursorless-engine/src/processTargets/modifiers/EveryScopeStage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class EveryScopeStage implements ModifierStage {
3939
const { scopeType } = this.modifier;
4040
const { editor, isReversed } = target;
4141

42-
const scopeHandler = this.scopeHandlerFactory.create(
42+
const scopeHandler = this.scopeHandlerFactory.tryCreate(
4343
scopeType,
4444
editor.document.languageId,
4545
);
@@ -108,7 +108,7 @@ export class EveryScopeStage implements ModifierStage {
108108
scopeHandlerFactory: ScopeHandlerFactory,
109109
target: Target,
110110
): Range[] {
111-
const iterationScopeHandler = scopeHandlerFactory.create(
111+
const iterationScopeHandler = scopeHandlerFactory.tryCreate(
112112
scopeHandler.iterationScopeType,
113113
target.editor.document.languageId,
114114
);

packages/cursorless-engine/src/processTargets/modifiers/PreferredScopeStage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class PreferredScopeStage implements ModifierStage {
4141
}
4242
}
4343

44-
const scopeHandler = this.scopeHandlerFactory.createWithAssert(
44+
const scopeHandler = this.scopeHandlerFactory.create(
4545
this.modifier.scopeType,
4646
target.editor.document.languageId,
4747
);

packages/cursorless-engine/src/processTargets/modifiers/RelativeScopeStage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class RelativeScopeStage implements ModifierStage {
3131
) {}
3232

3333
run(target: Target): Target[] {
34-
const scopeHandler = this.scopeHandlerFactory.create(
34+
const scopeHandler = this.scopeHandlerFactory.tryCreate(
3535
this.modifier.scopeType,
3636
target.editor.document.languageId,
3737
);

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/BoundedScopeHandler.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,17 @@ abstract class BoundedBaseScopeHandler extends BaseScopeHandler {
3232
) {
3333
super();
3434

35-
this.targetScopeHandler = this.scopeHandlerFactory.createWithAssert(
35+
this.targetScopeHandler = this.scopeHandlerFactory.create(
3636
this.targetScopeType,
3737
this.languageId,
3838
);
39-
this.surroundingPairInteriorScopeHandler =
40-
this.scopeHandlerFactory.createWithAssert(
41-
{
42-
type: "surroundingPairInterior",
43-
delimiter: "any",
44-
},
45-
this.languageId,
46-
);
39+
this.surroundingPairInteriorScopeHandler = this.scopeHandlerFactory.create(
40+
{
41+
type: "surroundingPairInterior",
42+
delimiter: "any",
43+
},
44+
this.languageId,
45+
);
4746
}
4847

4948
get iterationScopeType(): ScopeType {

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/NestedScopeHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export abstract class NestedScopeHandler extends BaseScopeHandler {
6060

6161
private get searchScopeHandler(): ScopeHandler {
6262
if (this._searchScopeHandler == null) {
63-
this._searchScopeHandler = this.scopeHandlerFactory.createWithAssert(
63+
this._searchScopeHandler = this.scopeHandlerFactory.create(
6464
this.searchScopeType,
6565
this.languageId,
6666
);

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/OneOfScopeHandler.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@ export class OneOfScopeHandler extends BaseScopeHandler {
2424
languageId: string,
2525
): ScopeHandler {
2626
const scopeHandlers: ScopeHandler[] = scopeType.scopeTypes.map(
27-
(scopeType) =>
28-
scopeHandlerFactory.createWithAssert(scopeType, languageId),
27+
(scopeType) => scopeHandlerFactory.create(scopeType, languageId),
2928
);
3029

3130
const iterationScopeType = (): CustomScopeType => ({
3231
type: "custom",
3332
scopeHandler: new OneOfScopeHandler(
3433
undefined,
3534
scopeHandlers.map((scopeHandler) =>
36-
scopeHandlerFactory.createWithAssert(
35+
scopeHandlerFactory.create(
3736
scopeHandler.iterationScopeType,
3837
languageId,
3938
),

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import type { ScopeType } from "@cursorless/common";
22
import type { CustomScopeType, ScopeHandler } from "./scopeHandler.types";
33

44
export interface ScopeHandlerFactory {
5-
create(
5+
tryCreate(
66
scopeType: ScopeType | CustomScopeType,
77
languageId: string,
88
): ScopeHandler | undefined;
99

10-
createWithAssert(
10+
create(
1111
scopeType: ScopeType | CustomScopeType,
1212
languageId: string,
1313
): ScopeHandler;

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ import type { CustomScopeType, ScopeHandler } from "./scopeHandler.types";
4545
*/
4646
export class ScopeHandlerFactoryImpl implements ScopeHandlerFactory {
4747
constructor(private languageDefinitions: LanguageDefinitions) {
48-
this.create = this.create.bind(this);
48+
this.tryCreate = this.tryCreate.bind(this);
4949
}
5050

51-
create(
51+
tryCreate(
5252
scopeType: ScopeType | CustomScopeType,
5353
languageId: string,
5454
): ScopeHandler | undefined {
@@ -115,11 +115,11 @@ export class ScopeHandlerFactoryImpl implements ScopeHandlerFactory {
115115
}
116116
}
117117

118-
createWithAssert(
118+
create(
119119
scopeType: ScopeType | CustomScopeType,
120120
languageId: string,
121121
): ScopeHandler {
122-
const handler = this.create(scopeType, languageId);
122+
const handler = this.tryCreate(scopeType, languageId);
123123
if (handler == null) {
124124
throw new Error(`Couldn't create scope handler for '${scopeType.type}'`);
125125
}

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/SurroundingPairInteriorScopeHandler.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ export class SurroundingPairInteriorScopeHandler extends BaseScopeHandler {
1717
) {
1818
super();
1919

20-
this.surroundingPairScopeHandler =
21-
this.scopeHandlerFactory.createWithAssert(
22-
{
23-
type: "surroundingPair",
24-
delimiter: this.scopeType.delimiter,
25-
requireStrongContainment: true,
26-
},
27-
this.languageId,
28-
);
20+
this.surroundingPairScopeHandler = this.scopeHandlerFactory.create(
21+
{
22+
type: "surroundingPair",
23+
delimiter: this.scopeType.delimiter,
24+
requireStrongContainment: true,
25+
},
26+
this.languageId,
27+
);
2928
}
3029

3130
get iterationScopeType() {

0 commit comments

Comments
 (0)