Esempio n. 1
0
        public void OnTelemetryEvent(JToken arg)
        {
            if (!(arg is JObject telemetry))
            {
                return;
            }

            Trace.WriteLine(telemetry.ToString());
            try {
                var te = telemetry.ToObject <PylanceTelemetryEvent>();
                if (te == null)
                {
                    return;
                }

                if (te.Exception == null)
                {
                    _logger.LogEvent(te.EventName, te.Properties, te.Measurements);
                }
                else
                {
                    _logger.LogFault(new PylanceException(te.EventName, te.Exception.stack), te.EventName, false);
                }

                // Special case language_server/analysis_complete. We need this for testing so we
                // know when it's okay to try to bring up intellisense
                if (te.EventName == "language_server/analysis_complete")
                {
                    AnalysisComplete.Invoke(this, EventArgs.Empty);
                }
            } catch {
            }
        }
Esempio n. 2
0
        internal async void OnAnalysisComplete()
        {
            IsAnalyzed = true;
            AnalysisComplete?.Invoke(this, EventArgs.Empty);

            BufferParser bufferParser;

            try {
                bufferParser = await GetBufferParserAsync();
            } catch (OperationCanceledException) {
                return;
            }

            foreach (var notify in bufferParser.Buffers.SelectMany(b => b.GetNewAnalysisRegistrations()))
            {
                notify(this);
            }
        }
Esempio n. 3
0
        internal void OnAnalysisComplete()
        {
            IsAnalyzed = true;
            AnalysisComplete?.Invoke(this, EventArgs.Empty);

            var bufferParser = BufferParser;

            if (bufferParser != null)
            {
                foreach (var buffer in bufferParser.Buffers)
                {
                    var events = buffer.GetNewAnalysisRegistrations();
                    foreach (var notify in events)
                    {
                        notify(this);
                    }
                }
            }
        }
Esempio n. 4
0
 internal void OnAnalysisComplete()
 {
     IsAnalyzed = true;
     AnalysisComplete?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 5
0
        private void Worker(object threadStarted)
        {
            try {
                SynchronizationContext.SetSynchronizationContext(new AnalysisSynchronizationContext(this));
                _scheduler = TaskScheduler.FromCurrentSynchronizationContext();
            } finally {
                ((AutoResetEvent)threadStarted).Set();
            }

            while (!_cancel.IsCancellationRequested)
            {
                IAnalyzable workItem;

                AnalysisPriority pri;
                lock (_queueLock) {
                    workItem     = GetNextItem(out pri);
                    _isAnalyzing = true;
                }
                var evt = AnalysisStarted;
                if (evt != null)
                {
                    evt(this, EventArgs.Empty);
                }

                if (workItem != null)
                {
                    try {
                        var groupable = workItem as IGroupableAnalysisProjectEntry;
                        if (groupable != null)
                        {
                            bool added = _enqueuedGroups.Add(groupable.AnalysisGroup);
                            if (added)
                            {
                                Enqueue(new GroupAnalysis(groupable.AnalysisGroup, this), pri);
                            }

                            groupable.Analyze(_cancel.Token, true);
                        }
                        else
                        {
                            workItem.Analyze(_cancel.Token);
                        }
                    } catch (Exception ex) {
                        if (ex.IsCriticalException() || System.Diagnostics.Debugger.IsAttached)
                        {
                            throw;
                        }

                        //ex.ReportUnhandledException(null, GetType());
                        _cancel.Cancel();
                    }
                }
                else
                {
                    _isAnalyzing = false;
                    AnalysisComplete?.Invoke(this, EventArgs.Empty);
                    WaitHandle.SignalAndWait(
                        _analyzer.QueueActivityEvent,
                        _workEvent
                        );
                }
            }
            _isAnalyzing = false;
        }