Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { TextDocument, Range, Listener } from "@cursorless/common";
import type { Node } from "web-tree-sitter";
import type { Listener } from "@cursorless/common";
import type { LanguageDefinition } from "../languages/LanguageDefinition";
import type { LanguageDefinitions } from "../languages/LanguageDefinitions";

Expand All @@ -16,10 +15,6 @@ export class DisabledLanguageDefinitions implements LanguageDefinitions {
return undefined;
}

getNodeAtLocation(_document: TextDocument, _range: Range): Node | undefined {
return undefined;
}

dispose(): void {
// Do nothing
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ export class LanguageDefinition {
/**
* @param scopeType The scope type for which to get a scope handler
* @returns A scope handler for the given scope type and language id, or
* undefined if the given scope type / language id combination is still using
* legacy pathways
* undefined if the given scope type is not supported by this language.
*/
getScopeHandler(scopeType: ScopeType) {
if (!this.query.hasCapture(scopeType.type)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Disposable, Range, TextDocument } from "@cursorless/common";
import type { Disposable } from "@cursorless/common";
import {
Notifier,
showError,
Expand All @@ -8,7 +8,6 @@ import {
type TreeSitter,
} from "@cursorless/common";
import { toString } from "lodash-es";
import type { Node } from "web-tree-sitter";
import { LanguageDefinition } from "./LanguageDefinition";
import { treeSitterQueryCache } from "./TreeSitterQuery/treeSitterQueryCache";

Expand All @@ -32,11 +31,6 @@ export interface LanguageDefinitions {
* the given language id doesn't have a new-style query definition
*/
get(languageId: string): LanguageDefinition | undefined;

/**
* @deprecated Only for use in legacy containing scope stage
*/
getNodeAtLocation(document: TextDocument, range: Range): Node | undefined;
}

/**
Expand Down Expand Up @@ -160,10 +154,6 @@ export class LanguageDefinitionsImpl
return definition === LANGUAGE_UNDEFINED ? undefined : definition;
}

public getNodeAtLocation(document: TextDocument, range: Range): Node {
return this.treeSitter.getNodeAtLocation(document, range);
}

onDidChangeDefinition = this.notifier.registerListener;

dispose() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class ModifierStageFactoryImpl implements ModifierStageFactory {
if (modifier.scopeType.type === "instance") {
return new InstanceStage(this, this.storedTargets, modifier);
}
return new RelativeScopeStage(this, this.scopeHandlerFactory, modifier);
return new RelativeScopeStage(this.scopeHandlerFactory, modifier);
case "keepContentFilter":
return new KeepContentFilterStage(modifier);
case "keepEmptyFilter":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@ import {
} from "@cursorless/common";
import { islice, itake } from "itertools";
import type { Target } from "../../typings/target.types";
import type { ModifierStageFactory } from "../ModifierStageFactory";
import type {
ModifierStage,
ModifierStateOptions,
} from "../PipelineStages.types";
import type { ModifierStage } from "../PipelineStages.types";
import { constructScopeRangeTarget } from "./constructScopeRangeTarget";
import { getPreferredScopeTouchingPosition } from "./getPreferredScopeTouchingPosition";
import { OutOfRangeError } from "./listUtils";
import { runLegacy } from "./relativeScopeLegacy";
import type { ScopeHandlerFactory } from "./scopeHandlers/ScopeHandlerFactory";
import type { TargetScope } from "./scopeHandlers/scope.types";
import type {
Expand All @@ -28,26 +23,16 @@ import type {
*/
export class RelativeScopeStage implements ModifierStage {
constructor(
private modifierStageFactory: ModifierStageFactory,
private scopeHandlerFactory: ScopeHandlerFactory,
private modifier: RelativeScopeModifier,
) {}

run(target: Target, options: ModifierStateOptions): Target[] {
const scopeHandler = this.scopeHandlerFactory.maybeCreate(
run(target: Target): Target[] {
const scopeHandler = this.scopeHandlerFactory.create(
this.modifier.scopeType,
target.editor.document.languageId,
);

if (scopeHandler == null) {
return runLegacy(
this.modifierStageFactory,
this.modifier,
target,
options,
);
}

const scopes = Array.from(
this.modifier.offset === 0
? generateScopesInclusive(scopeHandler, target, this.modifier)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,13 @@ import { WordScopeHandler } from "./WordScopeHandler/WordScopeHandler";

/**
* Returns a scope handler for the given scope type and language id, or
* undefined if the given scope type / language id combination is still using
* legacy pathways.
*
* Note that once all our scope types are migrated to the new scope handler
* setup for all languages, we can stop returning `undefined`, change the return
* type of this function, and remove the legacy checks in the clients of this
* function.
* undefined if the given scope type / language id combination is not supported.
*
* @param scopeType The scope type for which to get a scope handler
* @param languageId The language id of the document where the scope handler
* will be used
* @returns A scope handler for the given scope type and language id, or
* undefined if the given scope type / language id combination is still using
* legacy pathways
* undefined if the given scope type / language id combination is not supported.
*/
export class ScopeHandlerFactoryImpl implements ScopeHandlerFactory {
constructor(private languageDefinitions: LanguageDefinitions) {
Expand Down
Loading