* 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
()
| 808 | * directories, so a module there serves only its own files (#2322). |
| 809 | */ |
| 810 | private getGoModules(): GoModule[] { |
| 811 | if (this.goModules) return this.goModules; |
| 812 | const dirs = new Set<string>(['']); |
| 813 | for (const file of this.knownFiles ?? this.queries.getAllFilePaths()) { |
| 814 | if (file.endsWith('.go')) dirs.add(goDirOf(file)); |
| 815 | } |
| 816 | const modules = new Set<GoModule>(); |
| 817 | for (const dir of dirs) { |
| 818 | const mod = this.nearestGoModule(dir); |
| 819 | const modDir = mod ? path.relative(this.projectRoot, mod.rootDir).split(path.sep).join('/') : ''; |
| 820 | if (mod && !/(?:^|\/)(?:testdata|[_.][^/]*)(?:\/|$)/.test(modDir)) modules.add(mod); |
| 821 | } |
| 822 | this.goModules = [...modules]; |
| 823 | return this.goModules; |
| 824 | } |
| 825 | |
| 826 | /** `readFile` through the LRU content cache (null = read failed, also cached). */ |
| 827 | private readFileCached(filePath: string): string | null { |
no test coverage detected