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
4 changes: 2 additions & 2 deletions packages/app-vscode/src/createScopeVisualizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
ScopeProvider,
ScopeType,
} from "@cursorless/lib-common";
import { isPseudoScope } from "@cursorless/lib-common";
import { isPseudoScopeType } from "@cursorless/lib-common";
import type { VscodeScopeVisualizer } from "./ide/vscode/VSCodeScopeVisualizer";
import { createVscodeScopeVisualizer } from "./ide/vscode/VSCodeScopeVisualizer";
import type {
Expand All @@ -25,7 +25,7 @@ export function createScopeVisualizer(

return {
start(scopeType: ScopeType, visualizationType: VisualizationType) {
if (isPseudoScope(scopeType)) {
if (isPseudoScopeType(scopeType)) {
throw new Error(
`Can't visualize pseudo scopes like '${scopeType.type}'`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,8 @@ const simpleScopeTypeTypesSet = new Set(simpleScopeTypeTypes);

export type SimpleScopeTypeType = (typeof simpleScopeTypeTypes)[number];

export const pseudoScopes = new Set<SimpleScopeTypeType>([
export const pseudoScopeTypeTypes = new Set<SimpleScopeTypeType>([
"instance",
"interior",
"className",
"functionName",
]);
Expand All @@ -228,8 +227,10 @@ export function isSimpleScopeType(
return (simpleScopeTypeTypesSet as Set<string>).has(scopeType.type);
}

export function isPseudoScope(scopeType: ScopeType): boolean {
return isSimpleScopeType(scopeType) && pseudoScopes.has(scopeType.type);
export function isPseudoScopeType(scopeType: ScopeType): boolean {
return (
isSimpleScopeType(scopeType) && pseudoScopeTypeTypes.has(scopeType.type)
);
}

export interface SimpleScopeType {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { pseudoScopes, simpleScopeTypeTypes } from "@cursorless/lib-common";

const scopeCaptureNames = [
...simpleScopeTypeTypes.filter((s) => !pseudoScopes.has(s)),
// Interior is a pseudo scope, but it's implemented with an actual internal scope
"interior",
] as const;
import {
pseudoScopeTypeTypes,
simpleScopeTypeTypes,
} from "@cursorless/lib-common";

const scopeCaptureNames = simpleScopeTypeTypes.filter(
(s) => !pseudoScopeTypeTypes.has(s),
);

export type ScopeCaptureName = (typeof scopeCaptureNames)[number];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { IDE, ScopeType } from "@cursorless/lib-common";
import { isPseudoScope, UnsupportedScopeError } from "@cursorless/lib-common";
import {
isPseudoScopeType,
UnsupportedScopeError,
} from "@cursorless/lib-common";
import type { LanguageDefinitions } from "../../../languages/LanguageDefinitions";
import {
BoundedNonWhitespaceSequenceScopeHandler,
Expand Down Expand Up @@ -139,7 +142,7 @@ export class ScopeHandlerFactoryImpl implements ScopeHandlerFactory {
return ConditionalScopeHandler.maybeCreate(this, scopeType, languageId);
default:
// Pseudoscopes are handled separately in their own modifiers.
if (isPseudoScope(scopeType)) {
if (isPseudoScopeType(scopeType)) {
throw new Error(`Unexpected pseudo scope type '${scopeType.type}'`);
}
return this.languageDefinitions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
import type {
Direction,
Position,
ScopeType,
TextEditor,
} from "@cursorless/lib-common";
import { NoContainingScopeError } from "@cursorless/lib-common";
import type { Direction, Position, TextEditor } from "@cursorless/lib-common";
import type { LanguageDefinitions } from "../../../../languages/LanguageDefinitions";
import type { Target } from "../../../../typings/target.types";
import { InteriorTarget } from "../../../targets";
import { BaseScopeHandler } from "../BaseScopeHandler";
import type { TargetScope } from "../scope.types";
import type {
ComplexScopeType,
ScopeIteratorRequirements,
} from "../scopeHandler.types";
import type { ScopeIteratorRequirements } from "../scopeHandler.types";
import type { TreeSitterScopeHandler } from "../TreeSitterScopeHandler";

export class InteriorScopeHandler extends BaseScopeHandler {
public readonly scopeType = { type: "interior" } as const;
public readonly iterationScopeType = { type: "document" } as const;
protected isHierarchical = true;

static maybeCreate(
Expand All @@ -39,12 +31,6 @@ export class InteriorScopeHandler extends BaseScopeHandler {
super();
}

get iterationScopeType(): ScopeType | ComplexScopeType {
throw new NoContainingScopeError(
"Iteration scope for InteriorScopeHandler",
);
}

*generateScopeCandidates(
editor: TextEditor,
position: Position,
Expand Down
4 changes: 2 additions & 2 deletions packages/lib-engine/src/scopeProviders/ScopeInfoProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
SurroundingPairScopeType,
} from "@cursorless/lib-common";
import {
isPseudoScope,
isPseudoScopeType,
simpleScopeTypeTypes,
surroundingPairNames,
} from "@cursorless/lib-common";
Expand Down Expand Up @@ -70,7 +70,7 @@ export class ScopeInfoProvider {
// Create simple scope types from simple scope type types
.map((scopeTypeType) => ({ type: scopeTypeType }))
// Ignore pseudo-scope because it's not really a scope
.filter((scopeType) => !isPseudoScope(scopeType)),
.filter((scopeType) => !isPseudoScopeType(scopeType)),

...surroundingPairNames.map(
(surroundingPairName): SurroundingPairScopeType => ({
Expand Down
Loading