* 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
()
| 906 | * directories, so a module there serves only its own files (#2322). |
| 907 | */ |
| 908 | private getGoModules(): GoModule[] { |
| 909 | if (this.goModules) return this.goModules; |
| 910 | const dirs = new Set<string>(['']); |
| 911 | for (const file of this.knownFiles ?? this.queries.getAllFilePaths()) { |
| 912 | if (file.endsWith('.go')) dirs.add(goDirOf(file)); |
| 913 | } |
| 914 | const modules = new Set<GoModule>(); |
| 915 | for (const dir of dirs) { |
| 916 | const mod = this.nearestGoModule(dir); |
| 917 | const modDir = mod ? path.relative(this.projectRoot, mod.rootDir).split(path.sep).join('/') : ''; |
| 918 | if (mod && !/(?:^|\/)(?:testdata|[_.][^/]*)(?:\/|$)/.test(modDir)) modules.add(mod); |
| 919 | } |
| 920 | this.goModules = [...modules]; |
| 921 | return this.goModules; |
| 922 | } |
| 923 | |
| 924 | /** `readFile` through the LRU content cache (null = read failed, also cached). */ |
| 925 | private readFileCached(filePath: string): string | null { |
no test coverage detected