(
file: string,
workspaceDirs: string[],
)
| 239 | } |
| 240 | |
| 241 | public async refreshFile( |
| 242 | file: string, |
| 243 | workspaceDirs: string[], |
| 244 | ): Promise<void> { |
| 245 | if (this.pauseToken.paused) { |
| 246 | // FIXME: by returning here, there is a chance that while paused a file is modified and |
| 247 | // then after unpausing the file is not reindexed |
| 248 | return; |
| 249 | } |
| 250 | const { foundInDir } = findUriInDirs(file, workspaceDirs); |
| 251 | if (!foundInDir) { |
| 252 | return; |
| 253 | } |
| 254 | const branch = await this.ide.getBranch(foundInDir); |
| 255 | const repoName = await this.ide.getRepoName(foundInDir); |
| 256 | const indexesToBuild = await this.getIndexesToBuild(); |
| 257 | const stats = await this.ide.getFileStats([file]); |
| 258 | const filePath = Object.keys(stats)[0]; |
| 259 | for (const index of indexesToBuild) { |
| 260 | const tag = { |
| 261 | directory: foundInDir, |
| 262 | branch, |
| 263 | artifactId: index.artifactId, |
| 264 | }; |
| 265 | const [fullResults, fullLastUpdated, markComplete] = |
| 266 | await getComputeDeleteAddRemove( |
| 267 | tag, |
| 268 | { ...stats }, |
| 269 | (filepath) => this.ide.readFile(filepath), |
| 270 | repoName, |
| 271 | ); |
| 272 | |
| 273 | const [results, lastUpdated] = this.singleFileIndexOps( |
| 274 | fullResults, |
| 275 | fullLastUpdated, |
| 276 | filePath, |
| 277 | ); |
| 278 | // Don't update if nothing to update. Some of the indices might do unnecessary setup work |
| 279 | if (this.totalIndexOps(results) + lastUpdated.length === 0) { |
| 280 | continue; |
| 281 | } |
| 282 | |
| 283 | for await (const _ of index.update( |
| 284 | tag, |
| 285 | results, |
| 286 | markComplete, |
| 287 | repoName, |
| 288 | )) { |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | private async *refreshFiles( |
| 294 | files: string[], |
no test coverage detected