MCPcopy Create free account
hub / github.com/Snapchat/Valdi / validateImports

Method validateImports

compiler/companion/src/Workspace.ts:357–374  ·  view source on GitHub ↗
(openedFile: OpenedFile, output: Diagnostic[])

Source from the content-addressed store, hash-verified

355
356 return { start, end, text, category: 'error' };
357 }
358
359 private validateImports(openedFile: OpenedFile, output: Diagnostic[]): boolean {
360 const importPaths = getImportStringLiteralsFromSourceFile(openedFile.sourceFile);
361 let success = true;
362
363 for (const importPath of importPaths) {
364 const resolvedImportPath = this.resolveImportPath(openedFile.sourceFile.fileName, importPath.text);
365 const resolvedPath = this.project.resolvePath(resolvedImportPath);
366 const pathToCheck = this.importPathResolver.getAlias(resolvedPath) ?? resolvedPath;
367
368 if (!this.project.fileExists(pathToCheck.absolutePath)) {
369 const errorMessage = `File '${importPath.text}' does not exist`;
370 output.push(this.makeDiagnostic(openedFile.sourceFile, importPath, errorMessage));
371 success = false;
372 }
373 }
374
375 return success;
376 }
377

Callers 1

getDiagnosticsSyncMethod · 0.95

Calls 7

resolveImportPathMethod · 0.95
makeDiagnosticMethod · 0.95
getAliasMethod · 0.80
resolvePathMethod · 0.45
fileExistsMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected