File tree Expand file tree Collapse file tree 4 files changed +15
-21
lines changed
cursorless-engine/src/processTargets/modifiers Expand file tree Collapse file tree 4 files changed +15
-21
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,12 @@ export class UnsupportedLanguageError extends Error {
9
9
}
10
10
}
11
11
12
- export class UnsupportedError extends Error {
13
- constructor ( message : string ) {
14
- super ( message ) ;
15
- this . name = "UnsupportedError" ;
12
+ export class UnsupportedScopeError extends Error {
13
+ constructor ( scopeType : string ) {
14
+ super (
15
+ `Scope '${ scopeType } ' is not implemented yet; See ${ DOCS_URL } /contributing/adding-a-new-scope` ,
16
+ ) ;
17
+ this . name = "UnsupportedScopeError" ;
16
18
}
17
19
}
18
20
Original file line number Diff line number Diff line change @@ -34,15 +34,11 @@ export class ContainingScopeStage implements ModifierStage {
34
34
run ( target : Target ) : Target [ ] {
35
35
const { scopeType, ancestorIndex = 0 } = this . modifier ;
36
36
37
- const scopeHandler = this . scopeHandlerFactory . maybeCreate (
37
+ const scopeHandler = this . scopeHandlerFactory . create (
38
38
scopeType ,
39
39
target . editor . document . languageId ,
40
40
) ;
41
41
42
- if ( scopeHandler == null ) {
43
- throw new NoContainingScopeError ( scopeType . type ) ;
44
- }
45
-
46
42
const containingScopes = getContainingScopeTarget (
47
43
target ,
48
44
scopeHandler ,
Original file line number Diff line number Diff line change @@ -42,15 +42,11 @@ export class EveryScopeStage implements ModifierStage {
42
42
const { scopeType } = this . modifier ;
43
43
const { editor, isReversed } = target ;
44
44
45
- const scopeHandler = this . scopeHandlerFactory . maybeCreate (
45
+ const scopeHandler = this . scopeHandlerFactory . create (
46
46
scopeType ,
47
47
editor . document . languageId ,
48
48
) ;
49
49
50
- if ( scopeHandler == null ) {
51
- throw new NoContainingScopeError ( scopeType . type ) ;
52
- }
53
-
54
50
let scopes : TargetScope [ ] | undefined ;
55
51
56
52
if ( target . hasExplicitRange ) {
@@ -97,15 +93,11 @@ export class EveryScopeStage implements ModifierStage {
97
93
scopeHandlerFactory : ScopeHandlerFactory ,
98
94
target : Target ,
99
95
) : Range [ ] {
100
- const iterationScopeHandler = scopeHandlerFactory . maybeCreate (
96
+ const iterationScopeHandler = scopeHandlerFactory . create (
101
97
scopeHandler . iterationScopeType ,
102
98
target . editor . document . languageId ,
103
99
) ;
104
100
105
- if ( iterationScopeHandler == null ) {
106
- throw Error ( "Could not find iteration scope handler" ) ;
107
- }
108
-
109
101
const iterationScopeTarget = getContainingScopeTarget (
110
102
target ,
111
103
iterationScopeHandler ,
Original file line number Diff line number Diff line change 1
- import { pseudoScopes , type ScopeType } from "@cursorless/common" ;
1
+ import {
2
+ pseudoScopes ,
3
+ UnsupportedScopeError ,
4
+ type ScopeType ,
5
+ } from "@cursorless/common" ;
2
6
import type { LanguageDefinitions } from "../../../languages/LanguageDefinitions" ;
3
7
import {
4
8
BoundedNonWhitespaceSequenceScopeHandler ,
@@ -145,7 +149,7 @@ export class ScopeHandlerFactoryImpl implements ScopeHandlerFactory {
145
149
) : ScopeHandler {
146
150
const handler = this . maybeCreate ( scopeType , languageId ) ;
147
151
if ( handler == null ) {
148
- throw new Error ( `Couldn't create scope handler for ' ${ scopeType . type } '` ) ;
152
+ throw new UnsupportedScopeError ( scopeType . type ) ;
149
153
}
150
154
return handler ;
151
155
}
You can’t perform that action at this time.
0 commit comments