Beispiel #1
0
        private void OnFindSymbolReferences(object _)
        {
            var client = CurrentSuite.Client;
            var pos    = Editor.CaretOffset;

            client.Send(new ClientMessage.FindSymbolReferences(CurrentTest.Id, CurrentTest.Version, pos));
            var msg = client.Receive <ServerMessage.FindSymbolReferences>();

            if (msg.symbols.Length == 0)
            {
                StatusText = "No symbols found!";
                return;
            }

            var items = new List <PopupItemViewModel>();

            foreach (var s in msg.symbols)
            {
                int symbolId = s.SymbolId;

                foreach (var definition in s.Definitions)
                {
                    var f    = definition.Location.File;
                    var file = CurrentSolution.GetFile(f.FileId);
                    if (file.Version != f.FileVersion)
                    {
                        continue;
                    }

                    items.Add(new PopupItemViewModel(symbolId, file, definition.Location.Span, true, Editor.IntelliSensePopup));
                }

                foreach (var reference in s.References)
                {
                    var f    = reference.File;
                    var file = CurrentSolution.GetFile(f.FileId);
                    if (file.Version != f.FileVersion)
                    {
                        continue;
                    }

                    foreach (var span in reference.Spans)
                    {
                        items.Add(new PopupItemViewModel(symbolId, file, span, false, Editor.IntelliSensePopup));
                    }
                }
            }

            InitGotoList(items);

            Editor.IntelliSensePopup.IsVisible = true;
        }
Beispiel #2
0
        private void OnFindSymbolDefinitions(object _)
        {
            var client = CurrentSuite.Client;
            var pos    = Editor.CaretOffset;

            client.Send(new ClientMessage.FindSymbolDefinitions(CurrentTest.Id, CurrentTest.Version, pos));

            var msg = client.Receive <ServerMessage.FindSymbolDefinitions>();


            if (msg.definitions.Length == 0)
            {
                StatusText = "No symbols found!";
            }
            else if (msg.definitions.Length == 1)
            {
                Editor.SelectText(msg.definitions[0].Location);
            }
            else
            {
                var items = new List <PopupItemViewModel>();
                Editor.IntelliSensePopup.Items.Clear();

                foreach (var definition in msg.definitions.OrderBy(d => d.Location.Span.StartPos))
                {
                    int symbolId = definition.SymbolId;
                    var loc      = definition.Location;
                    var f        = loc.File;
                    var file     = CurrentSolution.GetFile(f.FileId);

                    if (file.Version != f.FileVersion)
                    {
                        continue;
                    }

                    items.Add(new PopupItemViewModel(symbolId, file, loc.Span, true, Editor.IntelliSensePopup));
                }

                InitGotoList(items);

                Editor.IntelliSensePopup.IsVisible = true;
            }
        }