* The project's Go modules: the root `go.mod`'s, and the nearest `go.mod` * of every directory holding an indexed `.go` file — so an ignored or * vendored tree, which holds no indexed file, adds none, and nothing walks * the disk. The go tool ignores `testdata/` and `_`/`.`-prefixed * di
()
| 920 | * directories, so a module there serves only its own files (#2322). |
| 921 | */ |
| 922 | private getGoModules(): GoModule[] { |
| 923 | if (this.goModules) return this.goModules; |
| 924 | const dirs = new Set<string>(['']); |
| 925 | for (const file of this.knownFiles ?? this.queries.getAllFilePaths()) { |
| 926 | if (file.endsWith('.go')) dirs.add(goDirOf(file)); |
| 927 | } |
| 928 | const modules = new Set<GoModule>(); |
| 929 | for (const dir of dirs) { |
| 930 | const mod = this.nearestGoModule(dir); |
| 931 | const modDir = mod ? path.relative(this.projectRoot, mod.rootDir).split(path.sep).join('/') : ''; |
| 932 | if (mod && !/(?:^|\/)(?:testdata|[_.][^/]*)(?:\/|$)/.test(modDir)) modules.add(mod); |
| 933 | } |
| 934 | this.goModules = [...modules]; |
| 935 | return this.goModules; |
| 936 | } |
| 937 | |
| 938 | /** `readFile` through the LRU content cache (null = read failed, also cached). */ |
| 939 | private readFileCached(filePath: string): string | null { |
no test coverage detected