private void LogIsolatedEventBlocks(IDEEvent currentEvent)
        {
            if (WeWereAnIsolatedBlockAndLeftItWith(currentEvent))
            {
                LogFilteredBlock(_loggedEvents);
                _loggedEvents.Clear();
                _weMightBeInAnIsolatedBlock = false;
            }

            if (ALargeBreakOccured(currentEvent))
            {
                _weMightBeInAnIsolatedBlock = true;
            }

            if (_weMightBeInAnIsolatedBlock)
            {
                _loggedEvents.Add(currentEvent);

                if (TheBlockIsNotIsolated(currentEvent))
                {
                    _loggedEvents.Clear();
                    _weMightBeInAnIsolatedBlock = false;
                }
            }

            _lastEvent = currentEvent;
        }
        public void ProcessEvent(IDEEvent @event)
        {
            if (@event.ActiveDocument != null && _currentIntervals.ContainsKey(@event.ActiveDocument))
            {
                _context.AdaptIntervalTimeData(_currentIntervals[@event.ActiveDocument], @event);
            }

            var documentEvent = @event as DocumentEvent;

            if (documentEvent != null && documentEvent.Document != null)
            {
                if (_currentIntervals.ContainsKey(documentEvent.Document))
                {
                    _context.AdaptIntervalTimeData(_currentIntervals[documentEvent.Document], @event);

                    if (documentEvent.Action == DocumentAction.Closing)
                    {
                        _intervals.Add(_currentIntervals[documentEvent.Document]);
                        _currentIntervals.Remove(documentEvent.Document);
                    }
                }
                else
                {
                    if (documentEvent.Action == DocumentAction.Opened)
                    {
                        _currentIntervals[documentEvent.Document] =
                            _context.CreateIntervalFromEvent <FileOpenInterval>(@event);
                        _currentIntervals[documentEvent.Document].FileName = documentEvent.Document.FileName;
                    }
                }
            }
        }
示例#3
0
        public override void AnonymizeDurations(IDEEvent ideEvent)
        {
            var completionEvent = (CompletionEvent)ideEvent;

            completionEvent.Selections.ForEach(selection => selection.SelectedAfter = null);
            base.AnonymizeDurations(ideEvent);
        }
        public bool Func2(IDEEvent e)
        {
            if (string.IsNullOrEmpty(e.KaVEVersion))
            {
                return(false);
            }


            var ms = _regex.Matches(e.KaVEVersion);

            if (ms.Count != 1)
            {
                return(false);
            }
            var gs = ms[0].Groups;

            Asserts.That(gs.Count == 2);

            try
            {
                var num = int.Parse(gs[1].Value);
                return(num >= _firstVersionIncluded);
            }
            catch
            {
                return(false);
            }
        }
        public void FiltersEventsWithoutTriggeredAt()
        {
            var actuals   = _sut.FixAndFilter(new[] { new CommandEvent() });
            var expecteds = new IDEEvent[0];

            CollectionAssert.AreEqual(expecteds, actuals);
        }
        private static UseCase Categorize(IDEEvent e)
        {
            var ce = e as CompletionEvent;

            if (ce == null)
            {
                return(UseCase.OtherEvent);
            }
            ce.ProposalCollection = new ProposalCollection();
            if (!e.ActiveDocument.FileName.EndsWith(".cs"))
            {
                return(UseCase.Invalid);
            }
            if (e.IDESessionUUID == null || e.IDESessionUUID.IsEmpty())
            {
                return(UseCase.Invalid);
            }
            if (!e.TriggeredAt.HasValue)
            {
                return(UseCase.Invalid);
            }
            var sst = ce.Context2.SST;

            if (sst.Methods.Count == 0)
            {
                return(UseCase.Empty);
            }
            if (!HasTriggerPoint(sst))
            {
                return(UseCase.NoTrigger);
            }
            return(UseCase.Ok);
        }
示例#7
0
        public override void AnonymizeDurations(IDEEvent ideEvent)
        {
            var buildEvent = (BuildEvent)ideEvent;

            ForEachTargetDo(buildEvent, target => target.Duration = null);
            base.AnonymizeDurations(ideEvent);
        }
示例#8
0
        private void FilterIsolatedEventBlocks(IDEEvent currentEvent)
        {
            if (WeWereAnIsolatedBlockAndLeftItWith(currentEvent))
            {
                LogFilteredBlock(_droppedEvents);
                _droppedEvents.Clear();
                _weMightBeInAnIsolatedBlock = false;
            }

            if (ALargeBreakOccured(currentEvent))
            {
                _weMightBeInAnIsolatedBlock = true;
            }

            if (_weMightBeInAnIsolatedBlock)
            {
                DropCurrentEvent();
                _droppedEvents.Add(currentEvent);

                if (TheBlockIsNotIsolated(currentEvent))
                {
                    Insert(_droppedEvents.ToArray());
                    _droppedEvents.Clear();
                    _weMightBeInAnIsolatedBlock = false;
                }
            }

            _lastEvent = currentEvent;
        }
        /// <summary>
        ///     Assumes that TriggeredAt is set.
        /// </summary>
        public static DateTimeOffset GetTriggeredAt(this IDEEvent ideEvent)
        {
            var triggeredAt = ideEvent.TriggeredAt;

            Asserts.That(triggeredAt.HasValue, "all events should have a trigger date");
            return(triggeredAt.Value);
        }
示例#10
0
 public void ProcessEvent(IDEEvent @event)
 {
     foreach (var t in _transformers)
     {
         t.ProcessEvent(@event);
     }
 }
示例#11
0
        /*
         * if you review the type hierarchy of IDEEvent, you will realize that
         * several subclasses exist that provide access to context information that
         * is specific to the event type.
         *
         * To access the context, you should check for the runtime type of the event
         * and cast it accordingly.
         *
         * As soon as I have some more time, I will implement the visitor pattern to
         * get rid of the casting. For now, this is recommended way to access the
         * contents.
         */
        private String process(IDEEvent e, out Completion vsEvent)
        {
            CommandEvent    ce    = e as CommandEvent;
            CompletionEvent compE = e as CompletionEvent;
            DocumentEvent   docE  = e as DocumentEvent;
            WindowEvent     winE  = e as WindowEvent;
            NavigationEvent navE  = e as NavigationEvent;


            String developerId = "";


            if (compE != null)
            {
                developerId = process(compE, out vsEvent);
            }
            //if (ce != null) developerId = process(ce, out vsEvent);
            //else if (docE != null) developerId = process(docE, out vsEvent);
            //else if (winE != null) developerId = process(winE, out vsEvent);
            //else if (navE != null) developerId = process(navE, out vsEvent);
            else
            {
                vsEvent = null; //developerId = processBasic(e, out vsEvent);
            }
            return(developerId);
        }
示例#12
0
 private static void ProcessEvent(IDEEvent originalEvent, IEnumerable <IEventProcessor> processors)
 {
     foreach (var processor in processors)
     {
         processor.OnEvent(originalEvent);
     }
 }
示例#13
0
        public override void AnonymizeCodeNames(IDEEvent ideEvent)
        {
            var documentEvent = (DocumentEvent)ideEvent;

            documentEvent.Document = documentEvent.Document.ToAnonymousName();
            base.AnonymizeCodeNames(ideEvent);
        }
示例#14
0
        private void processBasic(IDEEvent e)
        {
            var eventType   = e.GetType().Name;
            var triggerTime = e.TriggeredAt ?? DateTime.MinValue;

            Console.Write("found an {0} that has been triggered at: {1})\n", eventType, triggerTime);
        }
        private static IDEStateEvent CreateStartupEventAfter(IDEEvent previousEvent)
        {
            var startupEvent = CreateStartupEvent();

            SetTriggeredAtToAfter(startupEvent, previousEvent);
            return(startupEvent);
        }
示例#16
0
        public override IEnumerable <IDEEvent> Process(IDEEvent e)
        {
            var vce = e as VersionControlEvent;

            if (vce == null)
            {
                yield return(e);
            }
            else
            {
                foreach (var a in vce.Actions)
                {
                    var clone = new VersionControlEvent
                    {
                        // ide event
                        Id             = vce.Id,
                        KaVEVersion    = vce.KaVEVersion,
                        IDESessionUUID = vce.IDESessionUUID,

                        TriggeredAt = a.ExecutedAt, // override with time of version control action
                        TriggeredBy = vce.TriggeredBy,
                        Duration    = vce.Duration,

                        ActiveDocument = vce.ActiveDocument,
                        ActiveWindow   = vce.ActiveWindow,

                        // version control event
                        Solution = vce.Solution,
                        Actions  = { a }
                    };
                    yield return(clone);
                }
            }
        }
        private static TestIDEEvent CreateSomeEventAfter(IDEEvent startupEvent)
        {
            var subsequentEvent = TestEventFactory.SomeEvent();

            SetTriggeredAtToAfter(subsequentEvent, startupEvent);
            return(subsequentEvent);
        }
示例#18
0
        private static bool IsCSharpFile(IDEEvent e)
        {
            var file         = Path.GetExtension(e.ActiveDocument.FileName);
            var isCSharpFile = file != null && file.EndsWith("cs");

            return(isCSharpFile);
        }
示例#19
0
        public override void AnonymizeStartTimes(IDEEvent ideEvent)
        {
            var buildEvent = (BuildEvent)ideEvent;

            ForEachTargetDo(buildEvent, target => target.StartedAt = null);
            base.AnonymizeStartTimes(ideEvent);
        }
        public override void AnonymizeCodeNames(IDEEvent ideEvent)
        {
            var solutionEvent = (SolutionEvent)ideEvent;

            solutionEvent.Target = solutionEvent.Target.ToAnonymousName();
            base.AnonymizeCodeNames(ideEvent);
        }
示例#21
0
        public override void AnonymizeCodeNames(IDEEvent ideEvent)
        {
            var buildEvent = (BuildEvent)ideEvent;

            ForEachTargetDo(buildEvent, target => target.Project = target.Project.ToHash());
            base.AnonymizeCodeNames(ideEvent);
        }
        public static void SetDocumentTypeIfNecessary(FileInterval interval, IDEEvent @event)
        {
            DocumentType newDocype;

            var ee = @event as EditEvent;

            if (ee != null && ee.Context2 != null)
            {
                newDocype = GuessDocumentType(ee.ActiveDocument, ee.Context2.SST);
            }
            else if (@event is CompletionEvent)
            {
                var ce = (CompletionEvent)@event;
                newDocype = GuessDocumentType(ce.ActiveDocument, ce.Context2.SST);
            }
            else
            {
                newDocype = GuessDocumentType(@event.ActiveDocument, new SST());
            }

            if (newDocype > interval.FileType)
            {
                interval.FileType = newDocype;
            }
        }
        public override void AnonymizeCodeNames(IDEEvent ideEvent)
        {
            var windowEvent = (WindowEvent)ideEvent;

            windowEvent.Window = windowEvent.Window.ToAnonymousName();
            base.AnonymizeCodeNames(ideEvent);
        }
        private void processBasic(IDEEvent e)
        {
            object t  = new Event();
            var    ce = CreateEventData <Event>(e, ref t);

            _baseContext.Events.Add(ce);
        }
示例#25
0
 public void OnEvent(IDEEvent @event)
 {
     foreach (var processor in GetProcessorsFor(@event))
     {
         processor(@event);
     }
 }
 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
 }
示例#27
0
        private static bool IsCSharpFile(IDEEvent cce)
        {
            var extension    = Path.GetExtension(cce.ActiveDocument.FileName);
            var isCSharpFile = extension != null && extension.EndsWith("cs");

            return(isCSharpFile);
        }
        private FileInteractionType?ClassifyEventType(IDEEvent e)
        {
            if ((!_currentlyDebugging && e is EditEvent) || e is CompletionEvent || IsTypingDocumentEvent(e) ||
                IsTypingCommandEvent(e))
            {
                return(FileInteractionType.Typing);
            }
            if (e is BuildEvent || IsReadingDocumentEvent(e) || IsDebuggerEvent(e))
            {
                return(FileInteractionType.Reading);
            }

            if (ShouldFilterOutToolWindowEvents(e))
            {
                return(null);
            }

            // not directly assignable to "type" or "read"... we prolong the existing type
            if (e is NavigationEvent || e is WindowEvent)
            {
                return(_cur == null || HasDocumentChanged(e) ? FileInteractionType.Reading : _cur.Type);
            }
            if (_cur != null && e is ActivityEvent)
            {
                return(_cur.Type);
            }
            return(null);
        }
        public override void AnonymizeCodeNames(IDEEvent ideEvent)
        {
            var errorEvent = (ErrorEvent)ideEvent;

            errorEvent.Content = null;
            base.AnonymizeCodeNames(ideEvent);
        }
示例#30
0
        private void parse(string[] newData)
        {
            foreach (var log in newData)
            {
                IDEEvent e = (IDEEvent)log.ParseJsonTo(typeof(IIDEEvent));
                DBInsertAgent.Instance.Visit(e);
            }

            _ts = (_ts + 1) % 10;
            if (newData.Length < 10 && _ts < 9)
            {
                return;
            }

            try
            {
                DBInsertAgent.Instance.SaveChanges();
            }
            catch (Exception e)
            {
                Logger.Instance.Log(e.ToString());
                return;
            }

            Logger.Instance.Log($"I Just parsed {newData.Length} files.");
        }