private void CreateNewInterval(IDEEvent e, FileInteractionType classification)
 {
     _intervals.Add(_cur = _context.CreateIntervalFromEvent <FileInteractionInterval>(e));
     _cur.FileName       = e.ActiveDocument.FileName;
     _cur.Type           = classification;
     TransformerUtils.SetDocumentTypeIfNecessary(_cur, e); // initial
 }
        public void ProcessEvent(IDEEvent e)
        {
            Asserts.That(e.TriggeredAt.HasValue);
            Asserts.That(e.TerminatedAt.HasValue);

            /*if (e.TriggeredAt.Value > new DateTime(2016, 08, 19, 19, 17, 38))
             * {
             *  Console.WriteLine();
             * }*/

            if (e.ActiveDocument == null || e.TerminatedAt < _referenceTime)
            {
                // TODO include case: doc.Type != "CSharp"
                return;
            }

            if (IsTimedOut(e))
            {
                _cur = null;
            }

            // untested (
            if (_cur != null && (e is TestRunEvent || HasDocumentChanged(e)))
            {
                _context.UpdateDurationForIntervalToThis(_cur, e.TriggeredAt.Value);
                _cur = null;
            }
            // )

            var classification = ClassifyEventType(e);

            if (classification.HasValue)
            {
                if (_cur == null)
                {
                    CreateNewInterval(e, classification.Value);
                }
                else
                {
                    TransformerUtils.SetDocumentTypeIfNecessary(_cur, e); // updates
                    _cur.Project = _context.CurrentProject;               // might not be available from the beginning

                    if (_cur.Type == classification.Value)
                    {
                        // extend to max duration
                        _context.UpdateDurationForIntervalToMaximum(_cur, e.TerminatedAt.Value);
                    }
                    else
                    {
                        // cut duration to current trigger point
                        _context.UpdateDurationForIntervalToThis(_cur, e.TriggeredAt.Value);
                        CreateNewInterval(e, classification.Value);
                    }
                }
            }
        }