Skip to content

Removed legacy language machinery #2956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 16, 2025
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
Expand Up @@ -233,7 +233,6 @@ export interface ScopeSupportFacetInfo {

export enum ScopeSupportFacetLevel {
supported,
supportedLegacy,
unsupported,
notApplicable,
}
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/types/ScopeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,5 @@ export interface IterationScopeRanges {
export enum ScopeSupport {
supportedAndPresentInEditor,
supportedButNotPresentInEditor,
supportedLegacy,
unsupported,
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export interface CursorlessEngine {
storedTargets: StoredTargetMap;
hatTokenMap: HatTokenMap;
injectIde: (ide: IDE | undefined) => void;
runIntegrationTests: () => Promise<void>;
addCommandRunnerDecorator: (
commandRunnerDecorator: CommandRunnerDecorator,
) => void;
Expand Down
3 changes: 0 additions & 3 deletions packages/cursorless-engine/src/cursorlessEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
import { ModifierStageFactoryImpl } from "./processTargets/ModifierStageFactoryImpl";
import { ScopeHandlerFactoryImpl } from "./processTargets/modifiers/scopeHandlers";
import { runCommand } from "./runCommand";
import { runIntegrationTests } from "./runIntegrationTests";
import { ScopeInfoProvider } from "./scopeProviders/ScopeInfoProvider";
import { ScopeRangeProvider } from "./scopeProviders/ScopeRangeProvider";
import { ScopeRangeWatcher } from "./scopeProviders/ScopeRangeWatcher";
Expand Down Expand Up @@ -142,8 +141,6 @@ export async function createCursorlessEngine({
storedTargets,
hatTokenMap,
injectIde,
runIntegrationTests: () =>
runIntegrationTests(treeSitter, languageDefinitions),
addCommandRunnerDecorator: (decorator: CommandRunnerDecorator) => {
commandRunnerDecorators.push(decorator);
},
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Position, TextDocument } from "@cursorless/common";
import { type TreeSitter } from "@cursorless/common";
import type * as treeSitter from "web-tree-sitter";
import { ide } from "../../singletons/ide.singleton";
import { getNodeRange } from "../../util/nodeSelectors";
import { getNodeRange } from "./getNodeRange";
import type {
MutableQueryCapture,
MutableQueryMatch,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Range } from "@cursorless/common";
import type { Node } from "web-tree-sitter";

export function getNodeRange(node: Node) {
return new Range(
node.startPosition.row,
node.startPosition.column,
node.endPosition.row,
node.endPosition.column,
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Range } from "@cursorless/common";
import type { Point } from "web-tree-sitter";

export function makeRangeFromPositions(
startPosition: Point,
endPosition: Point,
) {
return new Range(
startPosition.row,
startPosition.column,
endPosition.row,
endPosition.column,
);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Position } from "@cursorless/common";
import { Range, adjustPosition } from "@cursorless/common";
import { z } from "zod";
import { makeRangeFromPositions } from "../../util/nodeSelectors";
import { makeRangeFromPositions } from "./makeRangeFromPositions";
import type { MutableQueryCapture } from "./QueryCapture";
import { QueryPredicateOperator } from "./QueryPredicateOperator";
import { isEven } from "./isEven";
Expand Down
95 changes: 0 additions & 95 deletions packages/cursorless-engine/src/languages/elseIfExtractor.ts

This file was deleted.

83 changes: 0 additions & 83 deletions packages/cursorless-engine/src/languages/getNodeMatcher.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import type {
ContainingScopeModifier,
EveryScopeModifier,
Modifier,
} from "@cursorless/common";
import type { Modifier } from "@cursorless/common";
import type { ModifierStage } from "./PipelineStages.types";

export interface ModifierStageFactory {
create(modifier: Modifier): ModifierStage;
getLegacyScopeStage(
modifier: ContainingScopeModifier | EveryScopeModifier,
): ModifierStage;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import type {
ContainingScopeModifier,
EveryScopeModifier,
Modifier,
} from "@cursorless/common";
import type { Modifier } from "@cursorless/common";
import type { StoredTargetMap } from "../core/StoredTargets";
import type { LanguageDefinitions } from "../languages/LanguageDefinitions";
import type { ModifierStageFactory } from "./ModifierStageFactory";
Expand Down Expand Up @@ -30,11 +26,6 @@ import { RawSelectionStage } from "./modifiers/RawSelectionStage";
import { RelativeScopeStage } from "./modifiers/RelativeScopeStage";
import { VisibleStage } from "./modifiers/VisibleStage";
import type { ScopeHandlerFactory } from "./modifiers/scopeHandlers/ScopeHandlerFactory";
import type {
SimpleContainingScopeModifier,
SimpleEveryScopeModifier,
} from "./modifiers/scopeTypeStages/LegacyContainingSyntaxScopeStage";
import { LegacyContainingSyntaxScopeStage } from "./modifiers/scopeTypeStages/LegacyContainingSyntaxScopeStage";

export class ModifierStageFactoryImpl implements ModifierStageFactory {
constructor(
Expand Down Expand Up @@ -116,30 +107,4 @@ export class ModifierStageFactoryImpl implements ModifierStageFactory {
}
}
}

/**
* Any scope type that has not been fully migrated to the new
* {@link ScopeHandler} setup should have a branch in this `switch` statement.
* Once the scope type is fully migrated, remove the branch and the legacy
* modifier stage.
*
* Note that it is possible for a scope type to be partially migrated. For
* example, we could support modern scope handlers for a certain scope type in
* Ruby, but not yet in Python.
*
* @param modifier The modifier for which to get the modifier stage
* @returns A scope stage implementing the modifier for the given scope type
*/
getLegacyScopeStage(
modifier: ContainingScopeModifier | EveryScopeModifier,
): ModifierStage {
switch (modifier.scopeType.type) {
default:
// Default to containing syntax scope using tree sitter
return new LegacyContainingSyntaxScopeStage(
this.languageDefinitions,
modifier as SimpleContainingScopeModifier | SimpleEveryScopeModifier,
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import type { ContainingScopeModifier } from "@cursorless/common";
import { NoContainingScopeError } from "@cursorless/common";
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 { getContainingScopeTarget } from "./getContainingScopeTarget";
import type { ScopeHandlerFactory } from "./scopeHandlers/ScopeHandlerFactory";

Expand Down Expand Up @@ -34,7 +31,7 @@ export class ContainingScopeStage implements ModifierStage {
private modifier: ContainingScopeModifier,
) {}

run(target: Target, options: ModifierStateOptions): Target[] {
run(target: Target): Target[] {
const { scopeType, ancestorIndex = 0 } = this.modifier;

const scopeHandler = this.scopeHandlerFactory.maybeCreate(
Expand All @@ -43,9 +40,7 @@ export class ContainingScopeStage implements ModifierStage {
);

if (scopeHandler == null) {
return this.modifierStageFactory
.getLegacyScopeStage(this.modifier)
.run(target, options);
throw new NoContainingScopeError(scopeType.type);
}

const containingScopes = getContainingScopeTarget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ export class EveryScopeStage implements ModifierStage {
);

if (scopeHandler == null) {
return this.modifierStageFactory
.getLegacyScopeStage(this.modifier)
.run(target, options);
throw new NoContainingScopeError(scopeType.type);
}

let scopes: TargetScope[] | undefined;
Expand Down
Loading
Loading