@@ -104,34 +104,40 @@ export class QueryDiscovery extends Discovery<QueryDiscoveryResults> {
104104 ) : Promise < FileTreeDirectory [ ] > {
105105 const rootDirectories = [ ] ;
106106 for ( const workspaceFolder of workspaceFolders ) {
107- rootDirectories . push (
108- await this . discoverQueriesInWorkspace ( workspaceFolder ) ,
107+ const rootDirectory = await this . discoverQueriesInWorkspace (
108+ workspaceFolder ,
109109 ) ;
110+ if ( rootDirectory !== undefined ) {
111+ rootDirectories . push ( rootDirectory ) ;
112+ }
110113 }
111114 return rootDirectories ;
112115 }
113116
114117 private async discoverQueriesInWorkspace (
115118 workspaceFolder : WorkspaceFolder ,
116- ) : Promise < FileTreeDirectory > {
119+ ) : Promise < FileTreeDirectory | undefined > {
117120 const fullPath = workspaceFolder . uri . fsPath ;
118121 const name = workspaceFolder . name ;
119- const rootDirectory = new FileTreeDirectory ( fullPath , name ) ;
120122
121123 // Don't try discovery on workspace folders that don't exist on the filesystem
122- if ( await pathExists ( fullPath ) ) {
123- const resolvedQueries = await this . cliServer . resolveQueries ( fullPath ) ;
124- for ( const queryPath of resolvedQueries ) {
125- const relativePath = normalize ( relative ( fullPath , queryPath ) ) ;
126- const dirName = dirname ( relativePath ) ;
127- const parentDirectory = rootDirectory . createDirectory ( dirName ) ;
128- parentDirectory . addChild (
129- new FileTreeLeaf ( queryPath , basename ( queryPath ) ) ,
130- ) ;
131- }
124+ if ( ! ( await pathExists ( fullPath ) ) ) {
125+ return undefined ;
126+ }
132127
133- rootDirectory . finish ( ) ;
128+ const rootDirectory = new FileTreeDirectory ( fullPath , name ) ;
129+
130+ const resolvedQueries = await this . cliServer . resolveQueries ( fullPath ) ;
131+ for ( const queryPath of resolvedQueries ) {
132+ const relativePath = normalize ( relative ( fullPath , queryPath ) ) ;
133+ const dirName = dirname ( relativePath ) ;
134+ const parentDirectory = rootDirectory . createDirectory ( dirName ) ;
135+ parentDirectory . addChild (
136+ new FileTreeLeaf ( queryPath , basename ( queryPath ) ) ,
137+ ) ;
134138 }
139+
140+ rootDirectory . finish ( ) ;
135141 return rootDirectory ;
136142 }
137143}
0 commit comments