/// <summary> /// Getting not analyzed enterprise group filtered by user query /// </summary> /// <param name="analysisQueue">Analysis queue item</param> /// <returns>Enterprise group</returns> public EnterpriseGroup GetEnterpriseGroupForAnalysis(AnalysisQueue analysisQueue) { return(_ctx.EnterpriseGroups.Include(x => x.PersonsUnits).Include(x => x.Address).FirstOrDefault(su => !_ctx.AnalysisLogs.Any(al => al.AnalysisQueueId == analysisQueue.Id && al.AnalyzedUnitId == su.RegId) && su.StartPeriod >= analysisQueue.UserStartPeriod && su.StartPeriod <= analysisQueue.UserEndPeriod)); }
private async Task DoInitializeAsync(InitializeParams @params, CancellationToken token) { _disposableBag.ThrowIfDisposed(); Analyzer = await AnalysisQueue.ExecuteInQueueAsync(ct => CreateAnalyzer(@params.initializationOptions.interpreter, token), AnalysisPriority.High); _disposableBag.ThrowIfDisposed(); _clientCaps = @params.capabilities; _traceLogging = @params.initializationOptions.traceLogging; _analysisUpdates = @params.initializationOptions.analysisUpdates; Analyzer.EnableDiagnostics = _clientCaps?.python?.liveLinting ?? false; _reloadModulesQueueItem = new ReloadModulesQueueItem(Analyzer); if (@params.initializationOptions.displayOptions != null) { DisplayOptions = @params.initializationOptions.displayOptions; } _displayTextBuilder = DocumentationBuilder.Create(DisplayOptions); DisplayStartupInfo(); if (@params.rootUri != null) { _rootDir = @params.rootUri.ToAbsolutePath(); } else if (!string.IsNullOrEmpty(@params.rootPath)) { _rootDir = PathUtils.NormalizePath(@params.rootPath); } SetSearchPaths(@params.initializationOptions.searchPaths); SetTypeStubSearchPaths(@params.initializationOptions.typeStubSearchPaths); Analyzer.Interpreter.ModuleNamesChanged += Interpreter_ModuleNamesChanged; }
public Server() { AnalysisQueue = new AnalysisQueue(); AnalysisQueue.UnhandledException += Analysis_UnhandledException; ParseQueue = new ParseQueue(); _editorFiles = new EditorFiles(this); _disposableBag .Add(() => { foreach (var ext in _extensions.Values) { ext?.Dispose(); } foreach (var ext in _oldExtensions.Values) { (ext as IDisposable)?.Dispose(); } }) .Add(ProjectFiles) .Add(() => Analyzer?.Dispose()) .Add(AnalysisQueue) .Add(_editorFiles) .Add(() => _shutdownCts.Cancel()); }
/// <summary> /// Getting not analyzed statistical unit filtered by user query /// </summary> /// <param name="analysisQueue">Analysis queue item</param> /// <returns>Statistical unit</returns> public StatisticalUnit GetStatisticalUnitForAnalysis(AnalysisQueue analysisQueue) { return(_ctx.StatisticalUnits.Include(x => x.PersonsUnits).Include(x => x.Address).FirstOrDefault(su => !_ctx.AnalysisLogs.Any(al => al.AnalysisQueueId == analysisQueue.Id && al.AnalyzedUnitId == su.RegId) && su.StartPeriod >= analysisQueue.UserStartPeriod && su.StartPeriod <= analysisQueue.UserEndPeriod)); }
private void Interpreter_ModuleNamesChanged(object sender, EventArgs e) { Analyzer.Modules.Reload(); foreach (var entry in Analyzer.ModulesByFilename) { AnalysisQueue.Enqueue(entry.Value.ProjectEntry, AnalysisPriority.Normal); } }
public RubyAnalyzer(IComponentModel /*!*/ componentModel) { _engine = componentModel.GetService <IRubyRuntimeHost>().RubyScriptEngine; _squiggleProvider = componentModel.GetService <IErrorProviderFactory>(); _queue = new ParseQueue(this); _analysisQueue = new AnalysisQueue <AnalysisItem>(this); _projectFiles = new Dictionary <string, AnalysisItem>(StringComparer.OrdinalIgnoreCase); }
public Server() { _queue = new AnalysisQueue(); _queue.UnhandledException += Analysis_UnhandledException; _pendingAnalysisEnqueue = new VolatileCounter(); _parseQueue = new ParseQueue(); _pendingParse = new Dictionary <IDocument, VolatileCounter>(); _openFiles = new OpenFiles(_projectFiles, this); }
public async Task ReloadModulesAsync(CancellationToken token) { #if false foreach (var entry in Analyzer.ModulesByFilename) { AnalysisQueue.Enqueue(entry.Value.ProjectEntry, AnalysisPriority.Normal); } #endif }
public PythonAnalyzer(IPythonRuntimeHost runtimeHost, IErrorProviderFactory errorProvider) { _engine = runtimeHost.ScriptEngine; _squiggleProvider = errorProvider; _queue = new ParseQueue(this); _analysisQueue = new AnalysisQueue <IProjectEntry>(this); _analysisState = new ProjectState(_engine); _projectFiles = new Dictionary <string, IProjectEntry>(StringComparer.OrdinalIgnoreCase); }
public Server() { _queue = new AnalysisQueue(); _pendingAnalysisEnqueue = new VolatileCounter(); _parseQueue = new ParseQueue(); _pendingParse = new Dictionary <IDocument, VolatileCounter>(); _projectFiles = new ConcurrentDictionary <Uri, IProjectEntry>(); _pendingChanges = new ConcurrentDictionary <Uri, List <DidChangeTextDocumentParams> >(UriEqualityComparer.IncludeFragment); _lastReportedDiagnostics = new ConcurrentDictionary <Uri, Dictionary <int, int> >(); }
public Server() { _queue = new AnalysisQueue(); _queue.UnhandledException += Analysis_UnhandledException; _pendingAnalysisEnqueue = new VolatileCounter(); _parseQueue = new ParseQueue(); _pendingParse = new Dictionary <IDocument, VolatileCounter>(); _openFiles = new OpenFiles(_projectFiles, this); _extensions = new ConcurrentDictionary <string, ILanguageServerExtension>(); }
public SentinelModule(string name, bool importing) : base(name) { _scope = AnalysisQueue.Current; if (importing) { _semaphore = new SemaphoreSlim(0, 1000); } else { _realModule = this; } }
/// <summary> /// Statistical units analysis /// </summary> /// <param name="analysisQueue">Queue item</param> /// <param name="analyzer">Stat unit analyzer</param> private void AnalyzeStatisticalUnits(AnalysisQueue analysisQueue, IStatUnitAnalyzer analyzer) { while (true) { var unitForAnalysis = _helper.GetStatisticalUnitForAnalysis(analysisQueue); if (unitForAnalysis == null) { break; } AddAnalysisLogs(analysisQueue.Id, unitForAnalysis, analyzer); } }
/// <summary> /// Enterprise groups analysis /// </summary> /// <param name="analysisQueue">Queue item</param> /// <param name="analyzer">Stat unit analyzer</param> private void AnalyzeEnterpriseGroups(AnalysisQueue analysisQueue, IStatUnitAnalyzer analyzer) { while (true) { var unitForAnalysis = _helper.GetEnterpriseGroupForAnalysis(analysisQueue); if (unitForAnalysis == null) { break; } AddAnalysisLogs(analysisQueue.Id, unitForAnalysis, analyzer); } }
public static void AddAnalysisLogs(NSCRegDbContext context) { var queueEntry = new AnalysisQueue { UserStartPeriod = DateTime.Now, UserEndPeriod = DateTime.Now, ServerStartPeriod = DateTime.Now, User = context.Users.First(), }; var log = new[] { new AnalysisLog { AnalyzedUnitId = 1, AnalyzedUnitType = StatUnitTypes.LocalUnit, SummaryMessages = "ConnectionRulesWarnings;MandatoryFieldsRulesWarnings", IssuedAt = DateTime.Parse("2017-12-22 19:09:25.7736777"), ResolvedAt = null, ErrorValues = "{'LegalUnitId':['AnalysisRelatedLegalUnit'],'Activities':['AnalysisRelatedActivity'],'Address':['AnalysisRelatedAddress'],'DataSourceClassificationId':['AnalysisMandatoryDataSource'],'ShortName':['AnalysisMandatoryShortName'],'TelephoneNo':['AnalysisMandatoryTelephoneNo'],'RegistrationReasonId':['AnalysisMandatoryRegistrationReason'],'ContactPerson':['AnalysisMandatoryContactPerson'],'Status':['AnalysisMandatoryStatusActive']}" }, new AnalysisLog { AnalyzedUnitId = 2, AnalyzedUnitType = StatUnitTypes.LocalUnit, SummaryMessages = "ConnectionRulesWarnings;MandatoryFieldsRulesWarnings", IssuedAt = DateTime.Parse("2017-12-22 19:09:28.4686079"), ResolvedAt = null, ErrorValues = "{'LegalUnitId':['AnalysisRelatedLegalUnit'],'Activities':['AnalysisRelatedActivity'],'Address':['AnalysisRelatedAddress'],'DataSourceClassificationId':['AnalysisMandatoryDataSource'],'ShortName':['AnalysisMandatoryShortName'],'TelephoneNo':['AnalysisMandatoryTelephoneNo'],'RegistrationReasonId':['AnalysisMandatoryRegistrationReason'],'ContactPerson':['AnalysisMandatoryContactPerson'],'Status':['AnalysisMandatoryStatusActive']}" }, new AnalysisLog { AnalyzedUnitId = 3, AnalyzedUnitType = StatUnitTypes.LegalUnit, SummaryMessages = "ConnectionRulesWarnings;MandatoryFieldsRulesWarnings", IssuedAt = DateTime.Parse("2017-12-22 19:09:30.3878882"), ResolvedAt = null, ErrorValues = "{'Address':['AnalysisRelatedAddress'],'DataSourceClassificationId':['AnalysisMandatoryDataSource'],'ShortName':['AnalysisMandatoryShortName'],'TelephoneNo':['AnalysisMandatoryTelephoneNo'],'RegistrationReasonId':['AnalysisMandatoryRegistrationReason'],'ContactPerson':['AnalysisMandatoryContactPerson'],'Status':['AnalysisMandatoryStatusActive'],'Persons':['AnalysisMandatoryPersonOwner']}" }, new AnalysisLog { AnalyzedUnitId = 4, AnalyzedUnitType = StatUnitTypes.EnterpriseUnit, SummaryMessages = "ConnectionRulesWarnings;MandatoryFieldsRulesWarnings;OrphanUnitsRulesWarnings", IssuedAt = DateTime.Parse("2017-12-22 19:09:32.1186972"), ResolvedAt = null, ErrorValues = "{'LegalUnits':['AnalysisRelatedLegalUnit'],'Activities':['AnalysisRelatedActivity'],'Address':['AnalysisRelatedAddress'],'DataSourceClassificationId':['AnalysisMandatoryDataSource'],'ShortName':['AnalysisMandatoryShortName'],'TelephoneNo':['AnalysisMandatoryTelephoneNo'],'RegistrationReasonId':['AnalysisMandatoryRegistrationReason'],'ContactPerson':['AnalysisMandatoryContactPerson'],'Status':['AnalysisMandatoryStatusActive'],'EntGroupId':['AnalysisOrphanEnterprise']}" }, new AnalysisLog { AnalyzedUnitId = 5, AnalyzedUnitType = StatUnitTypes.EnterpriseUnit, SummaryMessages = "ConnectionRulesWarnings;MandatoryFieldsRulesWarnings;OrphanUnitsRulesWarnings", IssuedAt = DateTime.Parse("2017-12-22 19:09:33.8364446"), ResolvedAt = null, ErrorValues = "{'LegalUnits':['AnalysisRelatedLegalUnit'],'Activities':['AnalysisRelatedActivity'],'Address':['AnalysisRelatedAddress'],'DataSourceClassificationId':['AnalysisMandatoryDataSource'],'ShortName':['AnalysisMandatoryShortName'],'TelephoneNo':['AnalysisMandatoryTelephoneNo'],'RegistrationReasonId':['AnalysisMandatoryRegistrationReason'],'ContactPerson':['AnalysisMandatoryContactPerson'],'Status':['AnalysisMandatoryStatusActive'],'EntGroupId':['AnalysisOrphanEnterprise']}" }, new AnalysisLog { AnalyzedUnitId = 6, AnalyzedUnitType = StatUnitTypes.EnterpriseUnit, SummaryMessages = "ConnectionRulesWarnings;MandatoryFieldsRulesWarnings;OrphanUnitsRulesWarnings", IssuedAt = DateTime.Parse("2017-12-22 19:09:35.5120566"), ResolvedAt = null, ErrorValues = "{'LegalUnits':['AnalysisRelatedLegalUnit'],'Activities':['AnalysisRelatedActivity'],'Address':['AnalysisRelatedAddress'],'DataSourceClassificationId':['AnalysisMandatoryDataSource'],'ShortName':['AnalysisMandatoryShortName'],'TelephoneNo':['AnalysisMandatoryTelephoneNo'],'RegistrationReasonId':['AnalysisMandatoryRegistrationReason'],'ContactPerson':['AnalysisMandatoryContactPerson'],'Status':['AnalysisMandatoryStatusActive'],'EntGroupId':['AnalysisOrphanEnterprise']}" }, new AnalysisLog { AnalyzedUnitId = 7, AnalyzedUnitType = StatUnitTypes.EnterpriseUnit, SummaryMessages = "ConnectionRulesWarnings;MandatoryFieldsRulesWarnings;OrphanUnitsRulesWarnings", IssuedAt = DateTime.Parse("2017-12-22 19:09:37.2072083"), ResolvedAt = null, ErrorValues = "{'LegalUnits':['AnalysisRelatedLegalUnit'],'Activities':['AnalysisRelatedActivity'],'Address':['AnalysisRelatedAddress'],'DataSourceClassificationId':['AnalysisMandatoryDataSource'],'ShortName':['AnalysisMandatoryShortName'],'TelephoneNo':['AnalysisMandatoryTelephoneNo'],'RegistrationReasonId':['AnalysisMandatoryRegistrationReason'],'ContactPerson':['AnalysisMandatoryContactPerson'],'Status':['AnalysisMandatoryStatusActive'],'EntGroupId':['AnalysisOrphanEnterprise']}" }, new AnalysisLog { AnalyzedUnitId = 8, AnalyzedUnitType = StatUnitTypes.EnterpriseUnit, SummaryMessages = "ConnectionRulesWarnings;MandatoryFieldsRulesWarnings;OrphanUnitsRulesWarnings", IssuedAt = DateTime.Parse("2017-12-22 19:09:39.0724324"), ResolvedAt = null, ErrorValues = "{'LegalUnits':['AnalysisRelatedLegalUnit'],'Activities':['AnalysisRelatedActivity'],'Address':['AnalysisRelatedAddress'],'DataSourceClassificationId':['AnalysisMandatoryDataSource'],'ShortName':['AnalysisMandatoryShortName'],'TelephoneNo':['AnalysisMandatoryTelephoneNo'],'RegistrationReasonId':['AnalysisMandatoryRegistrationReason'],'ContactPerson':['AnalysisMandatoryContactPerson'],'Status':['AnalysisMandatoryStatusActive'],'EntGroupId':['AnalysisOrphanEnterprise']}" }, new AnalysisLog { AnalyzedUnitId = 9, AnalyzedUnitType = StatUnitTypes.EnterpriseUnit, SummaryMessages = "ConnectionRulesWarnings;MandatoryFieldsRulesWarnings", IssuedAt = DateTime.Parse("2017-12-22 19:09:40.7310654"), ResolvedAt = null, ErrorValues = "{'Activities':['AnalysisRelatedActivity'],'Address':['AnalysisRelatedAddress'],'DataSourceClassificationId':['AnalysisMandatoryDataSource'],'ShortName':['AnalysisMandatoryShortName'],'TelephoneNo':['AnalysisMandatoryTelephoneNo'],'RegistrationReasonId':['AnalysisMandatoryRegistrationReason'],'ContactPerson':['AnalysisMandatoryContactPerson'],'Status':['AnalysisMandatoryStatusActive']}" }, new AnalysisLog { AnalyzedUnitId = 10, AnalyzedUnitType = StatUnitTypes.LegalUnit, SummaryMessages = "ConnectionRulesWarnings;MandatoryFieldsRulesWarnings", IssuedAt = DateTime.Parse("2017-12-22 19:09:42.3663417"), ResolvedAt = null, ErrorValues = "{'Address':['AnalysisRelatedAddress'],'DataSourceClassificationId':['AnalysisMandatoryDataSource'],'ShortName':['AnalysisMandatoryShortName'],'TelephoneNo':['AnalysisMandatoryTelephoneNo'],'RegistrationReasonId':['AnalysisMandatoryRegistrationReason'],'ContactPerson':['AnalysisMandatoryContactPerson'],'Status':['AnalysisMandatoryStatusActive'],'Persons':['AnalysisMandatoryPersonOwner']}" }, }; foreach (var entry in log) { entry.AnalysisQueue = queueEntry; } context.AnalysisLogs.AddRange(log); context.SaveChanges(); }
public void AnalyzeStatUnits(AnalysisQueue analysisQueue) { if (!analysisQueue.ServerStartPeriod.HasValue) { analysisQueue.ServerStartPeriod = DateTime.Now; _context.SaveChanges(); } var analyzer = new StatUnitAnalyzer(_analysisRules, _mandatoryFields, _context, _validationSettings); AnalyzeStatisticalUnits(analysisQueue, analyzer); AnalyzeEnterpriseGroups(analysisQueue, analyzer); analysisQueue.ServerEndPeriod = DateTime.Now; _context.SaveChanges(); }
public async Task ReloadModulesAsync(CancellationToken token) { LogMessage(MessageType._General, "Reloading modules..."); // Make sure reload modules is executed on the analyzer thread. var task = _reloadModulesQueueItem.Task; AnalysisQueue.Enqueue(_reloadModulesQueueItem, AnalysisPriority.Normal); await task; // re-analyze all of the modules when we get a new set of modules loaded... foreach (var entry in Analyzer.ModulesByFilename) { AnalysisQueue.Enqueue(entry.Value.ProjectEntry, AnalysisPriority.Normal); } }
public Server(IServiceContainer services = null) : base(services) { AnalysisQueue = new AnalysisQueue(); AnalysisQueue.UnhandledException += Analysis_UnhandledException; ParseQueue = new ParseQueue(); _editorFiles = new EditorFiles(this); _disposableBag .Add(() => { foreach (var ext in _extensions.Values) { ext.Dispose(); } }) .Add(ProjectFiles) .Add(() => Analyzer?.Dispose()) .Add(AnalysisQueue) .Add(_editorFiles) .Add(() => _shutdownCts.Cancel()); }
// ./Analysis/Engine/Impl/Infrastructure/Extensions/EnumerableExtensions.cs:26 -- think this is where MaybeEnumerate is defined private async Task DoInitializeAsync(/* InitializeParams @params, CancellationToken ct */) { // _disposableBag.ThrowIfDisposed(); Analyzer = await AnalysisQueue.ExecuteInQueueAsync(ct => CreateAnalyzer(), AnalysisPriority.High); }
private void CreateNewAnalyzer(AnalysisLimits limits) { _jsAnalyzer = new JsAnalyzer(limits); if (ShouldEnqueue()) { _analysisQueue = new AnalysisQueue(this); } _fullyLoaded = true; }
private void CreateNewAnalyzer(AnalysisLimits limits) { _jsAnalyzer = new JsAnalyzer(limits); if (_analysisLevel != AnalysisLevel.None) { _analysisQueue = new AnalysisQueue(this); } _fullyLoaded = true; }
public GroupAnalysis(IGroupableAnalysisProject project, AnalysisQueue queue) { _project = project; _queue = queue; }
private void CreateNewAnalyzer(AnalysisLimits limits) { if (_analysisLevel == AnalysisLevel.NodeLsNone || _analysisLevel == AnalysisLevel.Preview) { return; } _jsAnalyzer = new JsAnalyzer(limits); if (ShouldEnqueue()) { _analysisQueue = new AnalysisQueue(this); } _fullyLoaded = true; }
private bool LoadCachedAnalysis(AnalysisLimits limits) { if (_analysisLevel == AnalysisLevel.NodeLsNone || _analysisLevel == AnalysisLevel.Preview) { return false; } string analysisDb = GetAnalysisPath(); if (File.Exists(analysisDb) && ShouldEnqueue()) { FileStream stream = null; bool disposeStream = true; try { stream = new FileStream(analysisDb, FileMode.Open); byte[] header = new byte[DbHeader.Length]; stream.Read(header, 0, header.Length); if (DbHeader.SequenceEqual(header)) { var statusbar = (IVsStatusbar)NodejsPackage.GetGlobalService(typeof(SVsStatusbar)); if (statusbar != null) { statusbar.SetText(SR.GetString(SR.StatusAnalysisLoading)); } Task.Run(() => { try { using (new DebugTimer("LoadAnalysis")) { var serializer = new AnalysisSerializer(); var analyzer = (JsAnalyzer)serializer.Deserialize(stream); AnalysisQueue queue; if (analyzer.Limits.Equals(limits)) { queue = new AnalysisQueue(this); foreach (var entry in analyzer.AllModules) { _projectFiles[entry.FilePath] = new ProjectItem(entry); } _reparseDateTime = new FileInfo(analysisDb).LastWriteTime; _analysisQueue = queue; _jsAnalyzer = analyzer; if (statusbar != null) { statusbar.SetText(SR.GetString(SR.StatusAnalysisLoaded)); } } } } catch (InvalidOperationException) { // corrupt or invalid DB if (statusbar != null) { statusbar.SetText(SR.GetString(SR.StatusAnalysisLoadFailed)); } } catch (Exception e) { Debug.Fail(String.Format("Unexpected exception while loading analysis: {0}", e)); // bug in deserialization if (statusbar != null) { statusbar.SetText(SR.GetString(SR.StatusAnalysisLoadFailed)); } } finally { stream.Dispose(); // apply any changes lock (_loadingDeltas) { if (_jsAnalyzer == null) { // we failed to load the cached analysis, create a new // analyzer now... CreateNewAnalyzer(LoadLimits()); } _fullyLoaded = true; foreach (var delta in _loadingDeltas) { delta(); } } } }).HandleAllExceptions(SR.GetString(SR.NodejsToolsForVisualStudio)).DoNotWait(); disposeStream = false; return true; } } catch (IOException) { } finally { if (stream != null && disposeStream) { stream.Dispose(); } } } return false; }