Skip to content

Commit f89f299

Browse files
Remove legacy code and comments (#3037)
1 parent ee3b057 commit f89f299

File tree

7 files changed

+9
-254
lines changed

7 files changed

+9
-254
lines changed

packages/cursorless-engine/src/disabledComponents/DisabledLanguageDefinitions.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { TextDocument, Range, Listener } from "@cursorless/common";
2-
import type { Node } from "web-tree-sitter";
1+
import type { Listener } from "@cursorless/common";
32
import type { LanguageDefinition } from "../languages/LanguageDefinition";
43
import type { LanguageDefinitions } from "../languages/LanguageDefinitions";
54

@@ -16,10 +15,6 @@ export class DisabledLanguageDefinitions implements LanguageDefinitions {
1615
return undefined;
1716
}
1817

19-
getNodeAtLocation(_document: TextDocument, _range: Range): Node | undefined {
20-
return undefined;
21-
}
22-
2318
dispose(): void {
2419
// Do nothing
2520
}

packages/cursorless-engine/src/languages/LanguageDefinition.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ export class LanguageDefinition {
7575
/**
7676
* @param scopeType The scope type for which to get a scope handler
7777
* @returns A scope handler for the given scope type and language id, or
78-
* undefined if the given scope type / language id combination is still using
79-
* legacy pathways
78+
* undefined if the given scope type is not supported by this language.
8079
*/
8180
getScopeHandler(scopeType: ScopeType) {
8281
if (!this.query.hasCapture(scopeType.type)) {

packages/cursorless-engine/src/languages/LanguageDefinitions.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Disposable, Range, TextDocument } from "@cursorless/common";
1+
import type { Disposable } from "@cursorless/common";
22
import {
33
Notifier,
44
showError,
@@ -8,7 +8,6 @@ import {
88
type TreeSitter,
99
} from "@cursorless/common";
1010
import { toString } from "lodash-es";
11-
import type { Node } from "web-tree-sitter";
1211
import { LanguageDefinition } from "./LanguageDefinition";
1312
import { treeSitterQueryCache } from "./TreeSitterQuery/treeSitterQueryCache";
1413

@@ -32,11 +31,6 @@ export interface LanguageDefinitions {
3231
* the given language id doesn't have a new-style query definition
3332
*/
3433
get(languageId: string): LanguageDefinition | undefined;
35-
36-
/**
37-
* @deprecated Only for use in legacy containing scope stage
38-
*/
39-
getNodeAtLocation(document: TextDocument, range: Range): Node | undefined;
4034
}
4135

4236
/**
@@ -160,10 +154,6 @@ export class LanguageDefinitionsImpl
160154
return definition === LANGUAGE_UNDEFINED ? undefined : definition;
161155
}
162156

163-
public getNodeAtLocation(document: TextDocument, range: Range): Node {
164-
return this.treeSitter.getNodeAtLocation(document, range);
165-
}
166-
167157
onDidChangeDefinition = this.notifier.registerListener;
168158

169159
dispose() {

packages/cursorless-engine/src/processTargets/ModifierStageFactoryImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class ModifierStageFactoryImpl implements ModifierStageFactory {
8383
if (modifier.scopeType.type === "instance") {
8484
return new InstanceStage(this, this.storedTargets, modifier);
8585
}
86-
return new RelativeScopeStage(this, this.scopeHandlerFactory, modifier);
86+
return new RelativeScopeStage(this.scopeHandlerFactory, modifier);
8787
case "keepContentFilter":
8888
return new KeepContentFilterStage(modifier);
8989
case "keepEmptyFilter":

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

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@ import {
44
} from "@cursorless/common";
55
import { islice, itake } from "itertools";
66
import type { Target } from "../../typings/target.types";
7-
import type { ModifierStageFactory } from "../ModifierStageFactory";
8-
import type {
9-
ModifierStage,
10-
ModifierStateOptions,
11-
} from "../PipelineStages.types";
7+
import type { ModifierStage } from "../PipelineStages.types";
128
import { constructScopeRangeTarget } from "./constructScopeRangeTarget";
139
import { getPreferredScopeTouchingPosition } from "./getPreferredScopeTouchingPosition";
1410
import { OutOfRangeError } from "./listUtils";
15-
import { runLegacy } from "./relativeScopeLegacy";
1611
import type { ScopeHandlerFactory } from "./scopeHandlers/ScopeHandlerFactory";
1712
import type { TargetScope } from "./scopeHandlers/scope.types";
1813
import type {
@@ -28,26 +23,16 @@ import type {
2823
*/
2924
export class RelativeScopeStage implements ModifierStage {
3025
constructor(
31-
private modifierStageFactory: ModifierStageFactory,
3226
private scopeHandlerFactory: ScopeHandlerFactory,
3327
private modifier: RelativeScopeModifier,
3428
) {}
3529

36-
run(target: Target, options: ModifierStateOptions): Target[] {
37-
const scopeHandler = this.scopeHandlerFactory.maybeCreate(
30+
run(target: Target): Target[] {
31+
const scopeHandler = this.scopeHandlerFactory.create(
3832
this.modifier.scopeType,
3933
target.editor.document.languageId,
4034
);
4135

42-
if (scopeHandler == null) {
43-
return runLegacy(
44-
this.modifierStageFactory,
45-
this.modifier,
46-
target,
47-
options,
48-
);
49-
}
50-
5136
const scopes = Array.from(
5237
this.modifier.offset === 0
5338
? generateScopesInclusive(scopeHandler, target, this.modifier)

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

Lines changed: 0 additions & 207 deletions
This file was deleted.

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,13 @@ import { WordScopeHandler } from "./WordScopeHandler/WordScopeHandler";
3333

3434
/**
3535
* Returns a scope handler for the given scope type and language id, or
36-
* undefined if the given scope type / language id combination is still using
37-
* legacy pathways.
38-
*
39-
* Note that once all our scope types are migrated to the new scope handler
40-
* setup for all languages, we can stop returning `undefined`, change the return
41-
* type of this function, and remove the legacy checks in the clients of this
42-
* function.
36+
* undefined if the given scope type / language id combination is not supported.
4337
*
4438
* @param scopeType The scope type for which to get a scope handler
4539
* @param languageId The language id of the document where the scope handler
4640
* will be used
4741
* @returns A scope handler for the given scope type and language id, or
48-
* undefined if the given scope type / language id combination is still using
49-
* legacy pathways
42+
* undefined if the given scope type / language id combination is not supported.
5043
*/
5144
export class ScopeHandlerFactoryImpl implements ScopeHandlerFactory {
5245
constructor(private languageDefinitions: LanguageDefinitions) {

0 commit comments

Comments
 (0)