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

Method doSemanticAnalysis

server/src/analyzer/sourceFile.ts:347–384  ·  view source on GitHub ↗
(configOptions: ConfigOptions, builtinsScope?: Scope)

Source from the content-addressed store, hash-verified

345 }
346
347 doSemanticAnalysis(configOptions: ConfigOptions, builtinsScope?: Scope) {
348 assert(!this.isParseRequired());
349 assert(this.isSemanticAnalysisRequired());
350 assert(this._analysisJob.parseResults);
351 assert(this._analysisJob.nextPhaseToRun === AnalysisPhase.SemanticAnalysis);
352
353 const fileInfo = this._buildFileInfo(configOptions, undefined, builtinsScope);
354
355 try {
356 this._cleanParseTreeIfRequired();
357
358 // Perform semantic analysis.
359 let scopeAnalyzer = new ModuleScopeAnalyzer(
360 this._analysisJob.parseResults!.parseTree, fileInfo);
361 timingStats.semanticAnalyzerTime.timeOperation(() => {
362 scopeAnalyzer.analyze();
363 this._analysisJob.semanticAnalysisDiagnostics = fileInfo.diagnosticSink.diagnostics;
364 this._analysisJob.nextPhaseToRun = AnalysisPhase.TypeAnalysis;
365 this._diagnosticVersion++;
366 });
367
368 // Prepare for the next stage of the analysis.
369 this._analysisJob.typeAnalysisPassNumber = 1;
370 this._analysisJob.isTypeAnalysisPassNeeded = true;
371 this._analysisJob.isTypeAnalysisFinalized = false;
372 this._analysisJob.nextPhaseToRun = AnalysisPhase.TypeAnalysis;
373 } catch (e) {
374 let message: string;
375 if (e instanceof Error) {
376 message = e.message;
377 } else {
378 message = JSON.stringify(e);
379 }
380
381 this._console.log(
382 `An internal error occurred while analyzing ${ this.getFilePath() }: ` + message);
383 }
384 }
385
386 doTypeAnalysis(configOptions: ConfigOptions, importMap: ImportMap) {
387 assert(!this.isParseRequired());

Callers 1

_doSemanticAnalysisMethod · 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