1
1
import { dirname , basename , normalize , relative } from "path" ;
2
2
import { Discovery } from "../common/discovery" ;
3
3
import { CodeQLCliServer } from "../codeql-cli/cli" ;
4
- import { pathExists } from "fs-extra" ;
5
4
import {
6
5
Event ,
7
6
EventEmitter ,
@@ -12,7 +11,7 @@ import {
12
11
import { MultiFileSystemWatcher } from "../common/vscode/multi-file-system-watcher" ;
13
12
import { App } from "../common/app" ;
14
13
import { FileTreeDirectory , FileTreeLeaf } from "../common/file-tree-nodes" ;
15
- import { getOnDiskWorkspaceFolders } from "../helpers" ;
14
+ import { getOnDiskWorkspaceFoldersObjects } from "../helpers" ;
16
15
17
16
/**
18
17
* The results of discovering queries.
@@ -44,10 +43,7 @@ export class QueryDiscovery extends Discovery<QueryDiscoveryResults> {
44
43
new MultiFileSystemWatcher ( ) ,
45
44
) ;
46
45
47
- constructor (
48
- private readonly app : App ,
49
- private readonly cliServer : CodeQLCliServer ,
50
- ) {
46
+ constructor ( app : App , private readonly cliServer : CodeQLCliServer ) {
51
47
super ( "Query Discovery" ) ;
52
48
53
49
this . push ( app . onDidChangeWorkspaceFolders ( this . refresh . bind ( this ) ) ) ;
@@ -66,8 +62,8 @@ export class QueryDiscovery extends Discovery<QueryDiscoveryResults> {
66
62
}
67
63
68
64
protected async discover ( ) : Promise < QueryDiscoveryResults > {
69
- const workspaceFolders = this . app . workspaceFolders ;
70
- if ( workspaceFolders === undefined || workspaceFolders . length === 0 ) {
65
+ const workspaceFolders = getOnDiskWorkspaceFoldersObjects ( ) ;
66
+ if ( workspaceFolders . length === 0 ) {
71
67
return {
72
68
queries : [ ] ,
73
69
watchPaths : [ ] ,
@@ -105,30 +101,19 @@ export class QueryDiscovery extends Discovery<QueryDiscoveryResults> {
105
101
) : Promise < FileTreeDirectory [ ] > {
106
102
const rootDirectories = [ ] ;
107
103
for ( const workspaceFolder of workspaceFolders ) {
108
- const rootDirectory = await this . discoverQueriesInWorkspace (
109
- workspaceFolder ,
104
+ rootDirectories . push (
105
+ await this . discoverQueriesInWorkspace ( workspaceFolder ) ,
110
106
) ;
111
- if ( rootDirectory !== undefined ) {
112
- rootDirectories . push ( rootDirectory ) ;
113
- }
114
107
}
115
108
return rootDirectories ;
116
109
}
117
110
118
111
private async discoverQueriesInWorkspace (
119
112
workspaceFolder : WorkspaceFolder ,
120
- ) : Promise < FileTreeDirectory | undefined > {
113
+ ) : Promise < FileTreeDirectory > {
121
114
const fullPath = workspaceFolder . uri . fsPath ;
122
115
const name = workspaceFolder . name ;
123
116
124
- // Don't try discovery on workspace folders that don't exist on the filesystem
125
- if (
126
- ! ( await pathExists ( fullPath ) ) ||
127
- ! getOnDiskWorkspaceFolders ( ) . includes ( fullPath )
128
- ) {
129
- return undefined ;
130
- }
131
-
132
117
const rootDirectory = new FileTreeDirectory ( fullPath , name ) ;
133
118
134
119
const resolvedQueries = await this . cliServer . resolveQueries ( fullPath ) ;
0 commit comments