Exemplo n.º 1
0
        private void gotoView(OutlineItem item)
        {
            // get the regions

            var activeProjectItem = DTE.ActiveDocument.ProjectItem;
            var d = activeProjectItem.Document;

            var vp = new ViewParser();

            var viewTask = vp.GetViews(d, item.StartLineOfCode, item.StartLineOfCodeOffset, item.EndLineOfCode);

            viewTask.Wait();

            var views = viewTask.Result;

            vp.FindView(activeProjectItem, views);
        }
Exemplo n.º 2
0
        private void UpdateViewItems(object src, UpdateViewsEventArgs args)
        {
            // get the regions
            var item = src as OutlineItem;

            if (item == null)
            {
                return;
            }

            var activeProjectItem = item.ProjectItem;
            var d = activeProjectItem.Document;

            if (d == null)
            {
                Debug.WriteLine("No Document found for the selected item");
                return;
            }
            var c  = new RegionParser();
            var vp = new ViewParser();

            var viewTask = vp.GetViews(d, item.StartLineOfCode, item.StartLineOfCodeOffset, item.EndLineOfCode);

            viewTask.Wait();

            var views = viewTask.Result;

            if (views == null)
            {
                return;
            }

            vp.FindView(activeProjectItem, views);

            item.AddViews(views.Select(
                              x =>
                              new OutlineItem.ViewReference()
            {
                CodeElement = x.CodeElement,

                ViewTypeName = x.TypeName
            }));
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Performs outline of activated code file
        /// </summary>
        public void OutlineCode(ProjectItem activeProjectItem)
        {
            CodeElements elements;

            _displayedProjectItem = activeProjectItem;
            clearOutline();

            // get code elements in file
            try
            {
                elements = activeProjectItem.FileCodeModel.CodeElements;
            }
            catch (Exception e)

            {
                _log.Debug("Error finding elements in OutlineCode", e);
                return;
            }
            try
            {
                // get the regions
                var d = activeProjectItem.Document;
                var c = new RegionParser();
                _log.Debug("Identifying regions");

                var regionTask = c.GetRegions(d);
                var vp         = new ViewParser();


                Data = new OutlineItem();

                _log.Debug("Identifying Classes and methods");

                // "expand" each element
                for (var i = 1; i <= elements.Count; i++)
                {
                    createClassList(elements.Item(i), Data);
                }

                // set the "tracked" document to the current document
                CurrentDoc = d;

                regionTask.Wait();
                var regions = regionTask.Result;


                initSynctimer();

                _regions = new List <ICodeRegion>();
                if (regions != null)
                {
                    _regions.AddRange(regions);
                }

                //var result = vp.FindViews(activeProjectItem, views);
                Data.AddRegions(_regions);

                selectActiveCodeInTree();
                Data.ExpandAll();
            }
            catch (Exception e)
            {
                _log.Error("Failed OutlineCode2", e);
            }
        }