private void AnalyzeEntry(PythonAnalyzerEntry entry, IPythonModule module, PythonAst ast, int version)
        {
            // Now run the analysis.
            var analyzable = module as IAnalyzable;

            analyzable?.NotifyAnalysisBegins();

            var walker = new ModuleWalker(_services, module, ast);

            ast.Walk(walker);

            _analyzerCancellationToken.ThrowIfCancellationRequested();

            walker.Complete();
            _analyzerCancellationToken.ThrowIfCancellationRequested();
            var analysis = new DocumentAnalysis((IDocument)module, version, walker.GlobalScope, walker.Eval, walker.StarImportMemberNames);

            analyzable?.NotifyAnalysisComplete(analysis);
            entry.TrySetAnalysis(analysis, version);

            if (module.ModuleType == ModuleType.User)
            {
                var linterDiagnostics = _analyzer.LintModule(module);
                _diagnosticsService?.Replace(entry.Module.Uri, linterDiagnostics, DiagnosticSource.Linter);
            }
        }
        private void AnalyzeEntry(PythonAnalyzerEntry entry, IPythonModule module, int version, bool isFinalPass)
        {
            if (entry.PreviousAnalysis is LibraryAnalysis)
            {
                _log?.Log(TraceEventType.Verbose, $"Request to re-analyze finalized {module.Name}.");
            }

            // Now run the analysis.
            var analyzable = module as IAnalyzable;

            analyzable?.NotifyAnalysisBegins();

            var ast    = module.GetAst();
            var walker = new ModuleWalker(_services, module);

            ast.Walk(walker);

            _analyzerCancellationToken.ThrowIfCancellationRequested();

            walker.Complete();
            _analyzerCancellationToken.ThrowIfCancellationRequested();

            analyzable?.NotifyAnalysisComplete(version, walker, isFinalPass);
            entry.TrySetAnalysis(module.Analysis, version);

            if (module.ModuleType == ModuleType.User)
            {
                var linterDiagnostics = _analyzer.LintModule(module);
                _diagnosticsService?.Replace(entry.Module.Uri, linterDiagnostics, DiagnosticSource.Linter);
            }
        }
Exemplo n.º 3
0
        private void AnalyzeEntry(IDependencyChainNode <PythonAnalyzerEntry> node, PythonAnalyzerEntry entry, IPythonModule module, PythonAst ast, int version)
        {
            // Now run the analysis.
            var analyzable = module as IAnalyzable;

            analyzable?.NotifyAnalysisBegins();

            var walker = new ModuleWalker(_services, module, ast);

            ast.Walk(walker);

            _analyzerCancellationToken.ThrowIfCancellationRequested();

            walker.Complete();
            _analyzerCancellationToken.ThrowIfCancellationRequested();

            bool isCanceled;

            lock (_syncObj) {
                isCanceled = _isCanceled;
            }

            if (!isCanceled)
            {
                node?.MarkWalked();
            }

            var analysis = CreateAnalysis(node, (IDocument)module, ast, version, walker, isCanceled);

            analyzable?.NotifyAnalysisComplete(analysis);
            entry.TrySetAnalysis(module.Analysis, version);

            if (module.ModuleType == ModuleType.User)
            {
                var linterDiagnostics = _analyzer.LintModule(module);
                _diagnosticsService?.Replace(entry.Module.Uri, linterDiagnostics, DiagnosticSource.Linter);
            }
        }
        private void AnalyzeEntry(IDependencyChainNode <PythonAnalyzerEntry> node, PythonAnalyzerEntry entry, IPythonModule module, PythonAst ast, int version)
        {
            // Now run the analysis.
            var analyzable = module as IAnalyzable;

            analyzable?.NotifyAnalysisBegins();

            Debug.Assert(ast != null);
            var analysis = DoAnalyzeEntry(node, module, ast, version);

            _analyzerCancellationToken.ThrowIfCancellationRequested();

            if (analysis != null)
            {
                analyzable?.NotifyAnalysisComplete(analysis);
                entry.TrySetAnalysis(analysis, version);

                if (module.ModuleType == ModuleType.User)
                {
                    var linterDiagnostics = _analyzer.LintModule(module);
                    _diagnosticsService?.Replace(entry.Module.Uri, linterDiagnostics, DiagnosticSource.Linter);
                }
            }
        }