@@ -14,9 +14,7 @@ import { telemetry } from '../../shared/telemetry'
1414import { isCloud9 } from '../../shared/extensionUtilities'
1515import globals , { isWeb } from '../../shared/extensionGlobals'
1616import { isAmazonInternalOs } from '../../shared/vscode/env'
17- import { fs } from '../../shared/fs/fs'
18- import { tryRemoveFolder } from '../../shared/filesystemUtilities'
19- import { LspInstaller , LspResult } from '../../shared/languageServer/types'
17+ import { WorkspaceLSPResolver } from './workspaceInstaller'
2018
2119export interface Chunk {
2220 readonly filePath : string
@@ -25,13 +23,6 @@ export interface Chunk {
2523 readonly relativePath ?: string
2624 readonly programmingLanguage ?: string
2725}
28-
29- // const manifestUrl = 'https://aws-toolkit-language-servers.amazonaws.com/q-context/manifest.json'
30- // // this LSP client in Q extension is only going to work with these LSP server versions
31- // const supportedLspServerVersions = ['0.1.32']
32-
33- const nodeBinName = process . platform === 'win32' ? 'node.exe' : 'node'
34-
3526export interface BuildIndexConfig {
3627 startUrl ?: string
3728 maxIndexSize : number
@@ -49,21 +40,14 @@ export interface BuildIndexConfig {
4940 * Pre-process the input to Index Files API
5041 * Post-process the output from Query API
5142 */
52- export class LspController implements LspInstaller {
43+ export class LspController {
5344 static #instance: LspController
5445 private _isIndexingInProgress = false
55- private serverPath : string
56- private nodePath : string
5746
5847 public static get instance ( ) {
5948 return ( this . #instance ??= new this ( ) )
6049 }
6150
62- constructor ( ) {
63- this . serverPath = globals . context . asAbsolutePath ( path . join ( 'resources' , 'qserver' ) )
64- this . nodePath = globals . context . asAbsolutePath ( path . join ( 'resources' , nodeBinName ) )
65- }
66-
6751 isIndexingInProgress ( ) {
6852 return this . _isIndexingInProgress
6953 }
@@ -169,40 +153,16 @@ export class LspController implements LspInstaller {
169153 }
170154 }
171155
172- async isLspInstalled ( ) : Promise < boolean > {
173- return ( await fs . exists ( this . serverPath ) ) && ( await fs . exists ( this . nodePath ) )
174- }
175-
176- async cleanup ( ) : Promise < boolean > {
177- if ( await fs . exists ( this . serverPath ) ) {
178- await tryRemoveFolder ( this . serverPath )
179- }
180-
181- if ( await fs . exists ( this . nodePath ) ) {
182- await fs . delete ( this . nodePath )
183- }
184-
185- return true
186- }
187-
188- install ( ) : Promise < LspResult > {
189- // TODO
190- throw new Error ( 'Method not implemented.' )
191- }
192-
193156 async trySetupLsp ( context : vscode . ExtensionContext , buildIndexConfig : BuildIndexConfig ) {
194157 if ( isCloud9 ( ) || isWeb ( ) || isAmazonInternalOs ( ) ) {
195158 getLogger ( ) . warn ( 'LspController: Skipping LSP setup. LSP is not compatible with the current environment. ' )
196159 // do not do anything if in Cloud9 or Web mode or in AL2 (AL2 does not support node v18+)
197160 return
198161 }
199162 setImmediate ( async ( ) => {
200- const ok = await LspController . instance . install ( )
201- if ( ! ok ) {
202- return
203- }
204163 try {
205- await activateLsp ( context )
164+ const installResult = await new WorkspaceLSPResolver ( ) . resolve ( )
165+ await activateLsp ( context , path . join ( installResult . assetDirectory , 'resources/qserver/lspServer.js' ) )
206166 getLogger ( ) . info ( 'LspController: LSP activated' )
207167 void LspController . instance . buildIndex ( buildIndexConfig )
208168 // log the LSP server CPU and Memory usage per 30 minutes.
0 commit comments