private bool CanUpdateAnalysis( PythonAnalyzerEntry entry, IDependencyChainNode <PythonAnalyzerEntry> node, int version, out IPythonModule module, out PythonAst ast, out IDocumentAnalysis currentAnalysis) { if (!entry.CanUpdateAnalysis(version, out module, out ast, out currentAnalysis)) { if (IsAnalyzedLibraryInLoop(node, currentAnalysis)) { // Library analysis exists, don't analyze again return(false); } if (ast == null) { if (currentAnalysis == null) { // Entry doesn't have ast yet. There should be at least one more session. Cancel(); _log?.Log(TraceEventType.Verbose, $"Analysis of {module.Name}({module.ModuleType}) canceled (no AST yet)."); return(false); } //Debug.Fail($"Library module {module.Name} of type {module.ModuleType} has been analyzed already!"); return(false); } _log?.Log(TraceEventType.Verbose, $"Analysis of {module.Name}({module.ModuleType}) canceled. Version: {version}, current: {module.Analysis.Version}."); return(false); } return(true); }
private void AnalyzeEntry() { var stopWatch = _log != null?Stopwatch.StartNew() : null; try { if (!_entry.CanUpdateAnalysis(Version, out var module, out var ast, out var currentAnalysis)) { if (currentAnalysis is LibraryAnalysis) { return; } else if (ast == default) { if (currentAnalysis == default) { // Entry doesn't have ast yet. There should be at least one more session. Cancel(); } else { Debug.Fail($"Library module {module.Name} of type {module.ModuleType} has been analyzed already!"); } } _log?.Log(TraceEventType.Verbose, $"Analysis of {module.Name}({module.ModuleType}) canceled."); return; } var startTime = stopWatch?.Elapsed ?? TimeSpan.Zero; AnalyzeEntry(null, _entry, module, ast, Version); LogCompleted(null, module, stopWatch, startTime); } catch (OperationCanceledException oce) { _entry.TryCancel(oce, Version); LogCanceled(_entry.Module); } catch (Exception exception) { _entry.TrySetException(exception, Version); LogException(_entry.Module, exception); } finally { stopWatch?.Stop(); } }