Beispiel #1
0
        protected void Fire(CompletionEvent @event)
        {
            @event.ProposalCount      = _lastDisplayedItems.Length;
            @event.ProposalCollection = _lastDisplayedItems.Take(ProposalTransformationLimit).ToProposalCollection();

            base.Fire(@event);
        }
Beispiel #2
0
        private void process(CompletionEvent e)
        {
            var snapshotOfEnclosingType = e.Context2.SST;
            var enclosingTypeName       = snapshotOfEnclosingType.EnclosingType.FullName;

            Console.Write("found a CompletionEvent (was triggered in: {0})\n", enclosingTypeName);
        }
Beispiel #3
0
        public void SetUpSubsequentCompletionEvents()
        {
            _proposalCollection = LookupItemsMockUtils.MockLookupItemList(5).ToProposalCollection();
            var now            = DateTime.Now;
            var activeWindow   = Names.Window("w testWindow");
            var activeDocument = Names.Document("d testDocument");

            _event = new CompletionEvent
            {
                IDESessionUUID     = "TestUUID",
                ActiveWindow       = activeWindow,
                ActiveDocument     = activeDocument,
                TriggeredAt        = now,
                ProposalCollection = _proposalCollection,
                TerminatedAt       = now.AddMilliseconds(100)
            };

            _subsequentEvent = new CompletionEvent
            {
                IDESessionUUID     = "TestUUID",
                ActiveWindow       = activeWindow,
                ActiveDocument     = activeDocument,
                TriggeredAt        = now.AddMilliseconds(200),
                ProposalCollection = new ProposalCollection(_proposalCollection.Proposals.Take(3).ToList()),
                TerminatedAt       = now.AddMilliseconds(300),
                TerminatedState    = TerminationState.Applied,
                TerminatedBy       = EventTrigger.Shortcut
            };
        }
Beispiel #4
0
        private void OnCompletionEvent(CompletionEvent @event)
        {
            if (Difference(_manualCodeCompletionTrigger, @event) < TimeSpan.FromSeconds(1) ||
                Difference(_filteredCompletion, @event) < TimeSpan.FromSeconds(1))
            {
                // ReSharper disable once PossibleInvalidOperationException
                DurationInManualCompletion += @event.Duration.Value;

                if (@event.TerminatedState == TerminationState.Filtered)
                {
                    _filteredCompletion = @event;
                }
                else
                {
                    if (@event.TerminatedState == TerminationState.Applied)
                    {
                        NumberOfAppliedCompletions++;
                    }
                    else if (@event.TerminatedState == TerminationState.Cancelled)
                    {
                        NumberOfCancelledCompletions++;
                    }
                    _filteredCompletion = NoCompletion;
                }
                _manualCodeCompletionTrigger = NoTrigger;
            }
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public string GetTemporalIndex(CompletionEvent @event)
        {
            var date       = @event.TriggeredAt ?? DateTime.MinValue;
            var dateStr    = string.Format("{0:0000}{1:00}{2:00}", date.Year, date.Month, date.Day);
            var encTypeStr = @event.Context2.SST.EnclosingType.GetHashCode();

            return(string.Format("{0}_{1}_{2}", @event.IDESessionUUID, dateStr, encTypeStr));
        }
 protected void OnCompletionEvent()
 {
     CompletionEvent?.Invoke(this, new CompletionEventArgs(new Character(
                                                               characterNameText.Text,
                                                               characterRaceText.Text,
                                                               (int)hpNumeric.Value,
                                                               (int)acNumeric.Value)));
 }
Beispiel #8
0
 private void TimerCallback(Object o)
 {
     timeLeft = timeLeft > countingSpeed ? timeLeft - countingSpeed : 0;
     log?.Log($"\r{_message} | {timeLeft.ToString("F2")} sec left");
     if (timeLeft == 0)
     {
         CompletionEvent.Set(); timer.Dispose(); GC.Collect();
     }
 }
Beispiel #9
0
        public void ReadCompletionEvents_NoTriggerInfo()
        {
            var e1 = new CompletionEvent
            {
                ActiveDocument = Names.Document("... somefile.cs")
            };

            Write(e1);
            AssertCompletionEvents();
        }
Beispiel #10
0
        public void ReadCompletionEvents_Null()
        {
            var e1 = new CompletionEvent
            {
                TriggeredAt    = DateTime.Now,
                ActiveDocument = Names.Document("... somefile.cs")
            };

            Write(e1, null);
            AssertCompletionEvents(e1);
        }
Beispiel #11
0
        public void ReadCompletionEvents_NoCSharpFile()
        {
            var e1 = new CompletionEvent
            {
                TriggeredAt    = DateTime.Now,
                ActiveDocument = Names.Document("... somefile.xml")
            };

            Write(e1);
            AssertCompletionEvents();
        }
        public void ShouldAlwaysMapToEditing()
        {
            var @event = new CompletionEvent
            {
                Selections         = Lists.NewList <IProposalSelection>(),
                ProposalCollection = new ProposalCollection(),
                Context2           = new Context(),
                TerminatedState    = TerminationState.Unknown
            };

            AssertMapsToActivities(@event, Activity.Development);
        }
        internal override void process(CompletionEvent e)
        {
            if (e.TerminatedState == TerminationState.Applied && e.Selections.Count > 0)
            {
                _numberCompletionChanges += e.Selections.Count;
            }

            if (e.ActiveDocument != null && e.ActiveDocument.Identifier != null)
            {
                addDocumentName(e.ActiveDocument.Identifier);
            }
        }
Beispiel #14
0
        private static bool IsMergable(CompletionEvent @event)
        {
            var eventIsIntermediateFilterEvent = (@event.TriggeredBy == EventTrigger.Automatic) &&
                                                 (@event.TerminatedState == TerminationState.Filtered);
            // If there is no selection, we know that there was no interaction. If there is one selection, it may be
            // the previous selection or an initial selection (if there was no selection before). We cannot distinguish
            // this here. However, since we never merge the initial event (triggeredBy != Automatic), we know whether
            // there was an inital selection or not. Therefore, we can deduce that a selection was made during or after
            // the filtering.
            var eventContainsNoInteractions = (@event.Selections.Count <= 1);

            return(eventIsIntermediateFilterEvent && eventContainsNoInteractions);
        }
Beispiel #15
0
        private String process(CompletionEvent e, out Completion vsEvent)
        {
            var snapshotOfEnclosingType = e.Context2.SST;
            var enclosingTypeName       = snapshotOfEnclosingType.EnclosingType.FullName;

            vsEvent        = new Completion(enclosingTypeName);
            vsEvent.cEvent = e;


            //writer.WriteLine("found a CompletionEvent (was triggered in: "+enclosingTypeName+")");

            return(e.IDESessionUUID);
        }
Beispiel #16
0
        public void FormatsCompletionEventSelections()
        {
            var completionEvent = new CompletionEvent
            {
                ProposalCollection =
                {
                    new Proposal {
                        Name = Names.Field("[FieldType,P] [TestClass,P].SomeField")
                    },
                    new Proposal {
                        Name = Names.Event("[EventType`1[[T -> EventArgsType,P]],P] [DeclaringType,P].E")
                    },
                    new Proposal {
                        Name = Names.Method("[ReturnType,P] [DeclaringType,P].M([ParameterType,P] p)")
                    }
                },
                Selections =
                {
                    new ProposalSelection
                    {
                        Proposal = new Proposal{
                            Name = Names.Field("[FieldType,P] [TestClass,P].SomeField")
                        },
                        SelectedAfter = TimeSpan.FromSeconds(1)
                    },
                    new ProposalSelection
                    {
                        Proposal =
                            new Proposal
                        {
                            Name = Names.Event("[EventType`1[[T -> EventArgsType,P]],P] [DeclaringType,P].E")
                        },
                        SelectedAfter = TimeSpan.FromSeconds(2)
                    },
                    new ProposalSelection
                    {
                        Proposal =
                            new Proposal
                        {
                            Name = Names.Method("[ReturnType,P] [DeclaringType,P].M([ParameterType,P] p)")
                        },
                        SelectedAfter = TimeSpan.FromSeconds(3)
                    }
                }
            };

            var view = new EventViewModel(completionEvent);

            Assert.IsNotNullOrEmpty(view.XamlSelectionsRepresentation);
        }
Beispiel #17
0
        public void FormatsCompletionEventContext()
        {
            var completionEvent = new CompletionEvent
            {
                Context2 = { SST               = new SST {
                                 EnclosingType = Names.Type("TestClass,TestProject")
                             } }
            };

            var view = new EventViewModel(completionEvent);

            Assert.AreEqual(
                "\r\n\r\n<Span Foreground=\"Blue\">class</Span> <Span Foreground=\"#2B91AF\">TestClass</Span>\r\n{\r\n}",
                view.XamlContextRepresentation);
        }
Beispiel #18
0
        public void EscapesSpecialCharsInCodeCompletionContext()
        {
            var completionEvent = new CompletionEvent
            {
                Context2 = { SST               = new SST {
                                 EnclosingType = Names.Type("C`1[[T]],TestProject")
                             } }
            };

            var view = new EventViewModel(completionEvent);

            Assert.AreEqual(
                "\r\n\r\n<Span Foreground=\"Blue\">class</Span> <Span Foreground=\"#2B91AF\">C</Span>&lt;<Bold>T</Bold>&gt;\r\n{\r\n}",
                view.XamlContextRepresentation);
        }
        private void OnCompletionEvent(CompletionEvent @event)
        {
            var date = @event.GetTriggerDate();

            EnsureEntryForDay(date);

            // ReSharper disable once PossibleInvalidOperationException
            Statistic[date] += @event.Duration.Value;

            if (!_developerCountedToday && date != _today)
            {
                _today = date;
                NumberOfDeveloperDaysWithCompletionUsage++;
            }
        }
Beispiel #20
0
        public void EscapesSpecialCharsInRawView()
        {
            var completionEvent = new CompletionEvent
            {
                ProposalCollection =
                {
                    new Proposal {
                        Name = Names.General("TypeLookupItem:TestDelegate<string>[]")
                    }
                }
            };

            var view = new EventViewModel(completionEvent);

            StringAssert.Contains("TestDelegate&lt;string&gt;[]", view.XamlRawRepresentation);
        }
Beispiel #21
0
        public void EscapesSpecialCharsInProposals()
        {
            var completionEvent = new CompletionEvent
            {
                ProposalCollection =
                {
                    new Proposal {
                        Name = Names.General("TypeLookupItem:TestDelegate<string>[]")
                    }
                }
            };

            var view = new EventViewModel(completionEvent);

            Assert.AreEqual("• TypeLookupItem:TestDelegate&lt;string&gt;[]\r\n", view.XamlProposalsRepresentation);
        }
Beispiel #22
0
        public void ReadEvents_HappyPath()
        {
            var e1 = new CommandEvent
            {
                TriggeredAt    = DateTime.Now,
                ActiveDocument = Names.Document("... somefile.cs")
            };
            var e2 = new CompletionEvent
            {
                TriggeredAt    = DateTime.Now,
                ActiveDocument = Names.Document("... otherfile.cs")
            };

            Write(e1, e2);
            AssertEvents(e1, e2);
        }
Beispiel #23
0
        private static CompletionEvent CreateCompletionEvent()
        {
            var e = new CompletionEvent();

            AddBasicInformation(e);
            e.Context2 = CreateContext(
                new ContinueStatement(),
                new ExpressionStatement {
                Expression = new CompletionExpression()
            });
            e.ProposalCollection = new ProposalCollection
            {
                new Proposal()
            };
            return(e);
        }
 public void SetComplete()
 {
     lock (mSync)
     {
         if (IsComplete)
         {
             RFStatic.Log.Info(typeof(RFProcessingTracker), "Second completion event for request {0}", ProcessingKey);
         }
         else
         {
             RFStatic.Log.Info(typeof(RFProcessingTracker), "First completion event for request {0}", ProcessingKey);
             CyclesRemaining(0);
             ProcessingCycles = 0;
             IsComplete       = true;
             EndTime          = DateTimeOffset.Now;
             CompletionEvent.Set();
         }
     }
 }
Beispiel #25
0
        public void HandlePrefixChanged(string newPrefix, IEnumerable <ILookupItem> displayedLookupItems)
        {
            _event.TerminatedState = TerminationState.Filtered;
            _event.TerminatedAt    = DateTime.Now;
            _event.TerminatedBy    = EventTrigger.Automatic;
            var lastSelection = _event.Selections.LastOrDefault();

            Fire(_event);

            _event          = Create <CompletionEvent>();
            _event.Context2 = _context;
            HandleDisplayedItemsChanged(displayedLookupItems);
            if (lastSelection != null &&
                _lastDisplayedItems.Any(l => l != null && l.ToProposal().Equals(lastSelection.Proposal)))
            {
                _event.Selections.Add(lastSelection);
            }
            _event.TriggeredBy = EventTrigger.Automatic;
        }
Beispiel #26
0
        private void AssertIndex(string sessionId, DateTime?date, ITypeName type, string expected)
        {
            var e = new CompletionEvent
            {
                IDESessionUUID = sessionId,
                TriggeredAt    = date,
                Context2       = new Context
                {
                    SST = new SST
                    {
                        EnclosingType = type
                    }
                }
            };

            var actual = _sut.GetTemporalIndex(e);

            Assert.AreEqual(expected, actual);
        }
Beispiel #27
0
        public void EscapesSpecialCharsInLongRawView()
        {
            var completionEvent = new CompletionEvent
            {
                ProposalCollection =
                {
                    new Proposal {
                        Name = Names.General("TypeLookupItem:TestDelegate<string>[]")
                    },
                    // filler to make the overall serialization longer than 50000 characters
                    new Proposal {
                        Name = Names.General(new string('a', 50000))
                    }
                }
            };

            var view = new EventViewModel(completionEvent);

            StringAssert.Contains("TestDelegate&lt;string&gt;[]", view.XamlRawRepresentation);
        }
Beispiel #28
0
        public void OnlyOneCompletionEventInFile()
        {
            Mock.Get(_ioHelper).Setup(io => io.FindExports()).Returns(new List <string> {
                "a"
            });

            var ce1 = new CompletionEvent {
                Id = "1"
            };

            Mock.Get(_ioHelper)
            .Setup(io => io.ReadCompletionEvents("a"))
            .Returns(Lists.NewList(ce1));

            Mock.Get(_microCommitGenerator).Setup(t => t.GetTemporalIndex(ce1)).Returns("k1");

            _sut.Run();

            Mock.Get(_microCommitGenerator)
            .Verify(t => t.FindFirstAndLast(It.IsAny <List <CompletionEvent> >()), Times.Never);
        }
Beispiel #29
0
        public void EscapesSpecialCharsInSelections()
        {
            var completionEvent = new CompletionEvent
            {
                Selections =
                {
                    new ProposalSelection
                    {
                        Proposal = new Proposal{
                            Name = Names.General("TypeLookupItem:TestDelegate<string>[]")
                        },
                        SelectedAfter = TimeSpan.FromSeconds(1)
                    }
                }
            };

            var view = new EventViewModel(completionEvent);

            Assert.AreEqual(
                "• <Bold>00:00:01 at index -1</Bold> TypeLookupItem:TestDelegate&lt;string&gt;[]\r\n",
                view.XamlSelectionsRepresentation);
        }
Beispiel #30
0
        public void DoesntAddHighlightingToEncodedSpecialChars()
        {
            var completionEvent = new CompletionEvent
            {
                Selections =
                {
                    new ProposalSelection
                    {
                        Proposal =
                            new Proposal
                        {
                            Name = Names.Type("System.Threading.ThreadLocal`1[[T -> T]], mscorlib, 4.0.0.0")
                        },
                        SelectedAfter = TimeSpan.FromSeconds(1)
                    }
                }
            };

            var view = new EventViewModel(completionEvent);

            Assert.AreEqual(
                "• <Bold>00:00:01 at index -1</Bold> System.Threading.ThreadLocal`1[[T -&gt; T]], mscorlib, 4.0.0.0\r\n",
                view.XamlSelectionsRepresentation);
        }