MCPcopy
hub / github.com/microsoft/pyright / doTypeAnalysis

Method doTypeAnalysis

server/src/analyzer/sourceFile.ts:386–417  ·  view source on GitHub ↗
(configOptions: ConfigOptions, importMap: ImportMap)

Source from the content-addressed store, hash-verified

384 }
385
386 doTypeAnalysis(configOptions: ConfigOptions, importMap: ImportMap) {
387 assert(!this.isParseRequired());
388 assert(!this.isSemanticAnalysisRequired());
389 assert(this.isTypeAnalysisRequired());
390 assert(this._analysisJob.parseResults);
391 assert(this._analysisJob.nextPhaseToRun === AnalysisPhase.TypeAnalysis);
392
393 const fileInfo = this._buildFileInfo(configOptions, importMap, undefined);
394
395 try {
396 // Perform static type analysis.
397 let typeAnalyzer = new TypeAnalyzer(this._analysisJob.parseResults!.parseTree,
398 fileInfo, this._analysisJob.typeAnalysisPassNumber);
399 this._analysisJob.typeAnalysisPassNumber++;
400
401 timingStats.typeAnalyzerTime.timeOperation(() => {
402 // Repeatedly call the analyzer until everything converges.
403 this._analysisJob.isTypeAnalysisPassNeeded = typeAnalyzer.analyze();
404 this._analysisJob.typeAnalysisLastPassDiagnostics = fileInfo.diagnosticSink.diagnostics;
405 });
406 } catch (e) {
407 let message: string;
408 if (e instanceof Error) {
409 message = e.message;
410 } else {
411 message = JSON.stringify(e);
412 }
413
414 this._console.log(
415 `An internal error occurred while analyzing ${ this.getFilePath() }: ` + message);
416 }
417 }
418
419 // This method should be called once type analysis has completed for
420 // this file and all of its dependent files.

Callers 1

_doFullAnalysisMethod · 0.80

Calls 8

isParseRequiredMethod · 0.95
_buildFileInfoMethod · 0.95
analyzeMethod · 0.95
getFilePathMethod · 0.95
timeOperationMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected