@@ -12,15 +12,15 @@ import {
12
12
} from "@cursorless/cursorless-engine" ;
13
13
import {
14
14
commandIds ,
15
+ createVscodeIde ,
15
16
KeyboardCommands ,
16
17
StatusBarItem ,
17
- VscodeHats ,
18
- VscodeIDE ,
19
18
} from "@cursorless/cursorless-vscode-core" ;
20
19
import {
21
20
CursorlessApi ,
22
21
getCommandServerApi ,
23
22
getParseTreeApi ,
23
+ ParseTreeApi ,
24
24
toVscodeRange ,
25
25
} from "@cursorless/vscode-common" ;
26
26
import * as vscode from "vscode" ;
@@ -40,23 +40,14 @@ export async function activate(
40
40
) : Promise < CursorlessApi > {
41
41
const parseTreeApi = await getParseTreeApi ( ) ;
42
42
43
- const vscodeIDE = new VscodeIDE ( context ) ;
44
-
45
- const hats = new VscodeHats ( vscodeIDE , context ) ;
46
- await hats . init ( ) ;
43
+ const { vscodeIDE, hats } = await createVscodeIde ( context ) ;
47
44
48
45
const commandServerApi =
49
46
vscodeIDE . runMode === "test"
50
47
? getFakeCommandServerApi ( )
51
48
: await getCommandServerApi ( ) ;
52
49
53
- const getNodeAtLocation = ( document : TextDocument , range : Range ) => {
54
- return parseTreeApi . getNodeAtLocation (
55
- new vscode . Location ( document . uri , toVscodeRange ( range ) ) ,
56
- ) ;
57
- } ;
58
-
59
- const treeSitter : TreeSitter = { getNodeAtLocation } ;
50
+ const treeSitter : TreeSitter = createTreeSitter ( parseTreeApi ) ;
60
51
61
52
const normalizedIde =
62
53
vscodeIDE . runMode === "production"
@@ -112,6 +103,16 @@ export async function activate(
112
103
} ;
113
104
}
114
105
106
+ function createTreeSitter ( parseTreeApi : ParseTreeApi ) : TreeSitter {
107
+ return {
108
+ getNodeAtLocation ( document : TextDocument , range : Range ) {
109
+ return parseTreeApi . getNodeAtLocation (
110
+ new vscode . Location ( document . uri , toVscodeRange ( range ) ) ,
111
+ ) ;
112
+ } ,
113
+ } ;
114
+ }
115
+
115
116
// this method is called when your extension is deactivated
116
117
export function deactivate ( ) {
117
118
// do nothing
0 commit comments