diff --git a/packages/cursorless-engine/src/processTargets/modifiers/ContainingScopeStage.ts b/packages/cursorless-engine/src/processTargets/modifiers/ContainingScopeStage.ts index 1cfa2b39be..2c3f34108b 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/ContainingScopeStage.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/ContainingScopeStage.ts @@ -34,7 +34,7 @@ export class ContainingScopeStage implements ModifierStage { run(target: Target): Target[] { const { scopeType, ancestorIndex = 0 } = this.modifier; - const scopeHandler = this.scopeHandlerFactory.tryCreate( + const scopeHandler = this.scopeHandlerFactory.maybeCreate( scopeType, target.editor.document.languageId, ); diff --git a/packages/cursorless-engine/src/processTargets/modifiers/EveryScopeStage.ts b/packages/cursorless-engine/src/processTargets/modifiers/EveryScopeStage.ts index 32252be996..cde16de7dd 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/EveryScopeStage.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/EveryScopeStage.ts @@ -39,7 +39,7 @@ export class EveryScopeStage implements ModifierStage { const { scopeType } = this.modifier; const { editor, isReversed } = target; - const scopeHandler = this.scopeHandlerFactory.tryCreate( + const scopeHandler = this.scopeHandlerFactory.maybeCreate( scopeType, editor.document.languageId, ); @@ -108,7 +108,7 @@ export class EveryScopeStage implements ModifierStage { scopeHandlerFactory: ScopeHandlerFactory, target: Target, ): Range[] { - const iterationScopeHandler = scopeHandlerFactory.tryCreate( + const iterationScopeHandler = scopeHandlerFactory.maybeCreate( scopeHandler.iterationScopeType, target.editor.document.languageId, ); diff --git a/packages/cursorless-engine/src/processTargets/modifiers/RelativeScopeStage.ts b/packages/cursorless-engine/src/processTargets/modifiers/RelativeScopeStage.ts index 2ad109e072..3d91160e12 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/RelativeScopeStage.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/RelativeScopeStage.ts @@ -31,7 +31,7 @@ export class RelativeScopeStage implements ModifierStage { ) {} run(target: Target): Target[] { - const scopeHandler = this.scopeHandlerFactory.tryCreate( + const scopeHandler = this.scopeHandlerFactory.maybeCreate( this.modifier.scopeType, target.editor.document.languageId, ); diff --git a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactory.ts b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactory.ts index 977332839a..b50cfac4f3 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactory.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactory.ts @@ -2,7 +2,7 @@ import type { ScopeType } from "@cursorless/common"; import type { CustomScopeType, ScopeHandler } from "./scopeHandler.types"; export interface ScopeHandlerFactory { - tryCreate( + maybeCreate( scopeType: ScopeType | CustomScopeType, languageId: string, ): ScopeHandler | undefined; diff --git a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts index ac121d4cd6..17b7f9c129 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/ScopeHandlerFactoryImpl.ts @@ -45,11 +45,11 @@ import type { CustomScopeType, ScopeHandler } from "./scopeHandler.types"; */ export class ScopeHandlerFactoryImpl implements ScopeHandlerFactory { constructor(private languageDefinitions: LanguageDefinitions) { - this.tryCreate = this.tryCreate.bind(this); + this.maybeCreate = this.maybeCreate.bind(this); this.create = this.create.bind(this); } - tryCreate( + maybeCreate( scopeType: ScopeType | CustomScopeType, languageId: string, ): ScopeHandler | undefined { @@ -120,7 +120,7 @@ export class ScopeHandlerFactoryImpl implements ScopeHandlerFactory { scopeType: ScopeType | CustomScopeType, languageId: string, ): ScopeHandler { - const handler = this.tryCreate(scopeType, languageId); + const handler = this.maybeCreate(scopeType, languageId); if (handler == null) { throw new Error(`Couldn't create scope handler for '${scopeType.type}'`); } diff --git a/packages/cursorless-engine/src/scopeProviders/ScopeRangeProvider.ts b/packages/cursorless-engine/src/scopeProviders/ScopeRangeProvider.ts index 15002defc3..5ae8efc6b0 100644 --- a/packages/cursorless-engine/src/scopeProviders/ScopeRangeProvider.ts +++ b/packages/cursorless-engine/src/scopeProviders/ScopeRangeProvider.ts @@ -29,7 +29,7 @@ export class ScopeRangeProvider { editor: TextEditor, { scopeType, visibleOnly }: ScopeRangeConfig, ): ScopeRanges[] { - const scopeHandler = this.scopeHandlerFactory.tryCreate( + const scopeHandler = this.scopeHandlerFactory.maybeCreate( scopeType, editor.document.languageId, ); @@ -50,7 +50,7 @@ export class ScopeRangeProvider { { scopeType, visibleOnly, includeNestedTargets }: IterationScopeRangeConfig, ): IterationScopeRanges[] { const { languageId } = editor.document; - const scopeHandler = this.scopeHandlerFactory.tryCreate( + const scopeHandler = this.scopeHandlerFactory.maybeCreate( scopeType, languageId, ); @@ -59,7 +59,7 @@ export class ScopeRangeProvider { return []; } - const iterationScopeHandler = this.scopeHandlerFactory.tryCreate( + const iterationScopeHandler = this.scopeHandlerFactory.maybeCreate( scopeHandler.iterationScopeType, languageId, ); diff --git a/packages/cursorless-engine/src/scopeProviders/ScopeSupportChecker.ts b/packages/cursorless-engine/src/scopeProviders/ScopeSupportChecker.ts index c1d812948d..d2b9e8345f 100644 --- a/packages/cursorless-engine/src/scopeProviders/ScopeSupportChecker.ts +++ b/packages/cursorless-engine/src/scopeProviders/ScopeSupportChecker.ts @@ -29,7 +29,7 @@ export class ScopeSupportChecker { */ getScopeSupport(editor: TextEditor, scopeType: ScopeType): ScopeSupport { const { languageId } = editor.document; - const scopeHandler = this.scopeHandlerFactory.tryCreate( + const scopeHandler = this.scopeHandlerFactory.maybeCreate( scopeType, languageId, ); @@ -56,7 +56,7 @@ export class ScopeSupportChecker { scopeType: ScopeType, ): ScopeSupport { const { languageId } = editor.document; - const scopeHandler = this.scopeHandlerFactory.tryCreate( + const scopeHandler = this.scopeHandlerFactory.maybeCreate( scopeType, languageId, ); @@ -65,7 +65,7 @@ export class ScopeSupportChecker { return getLegacyScopeSupport(languageId, scopeType); } - const iterationScopeHandler = this.scopeHandlerFactory.tryCreate( + const iterationScopeHandler = this.scopeHandlerFactory.maybeCreate( scopeHandler.iterationScopeType, languageId, );