Skip to content

Commit

Permalink
Renamed to maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Dec 1, 2024
1 parent 39710bd commit 4b8ced9
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down Expand Up @@ -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,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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}'`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand All @@ -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,
);
Expand All @@ -59,7 +59,7 @@ export class ScopeRangeProvider {
return [];
}

const iterationScopeHandler = this.scopeHandlerFactory.tryCreate(
const iterationScopeHandler = this.scopeHandlerFactory.maybeCreate(
scopeHandler.iterationScopeType,
languageId,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand All @@ -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,
);
Expand All @@ -65,7 +65,7 @@ export class ScopeSupportChecker {
return getLegacyScopeSupport(languageId, scopeType);
}

const iterationScopeHandler = this.scopeHandlerFactory.tryCreate(
const iterationScopeHandler = this.scopeHandlerFactory.maybeCreate(
scopeHandler.iterationScopeType,
languageId,
);
Expand Down

0 comments on commit 4b8ced9

Please sign in to comment.