Exemplo n.º 1
0
        public void FollowNode(TreeNodeData node, bool newTab, bool?useCodeRef)
        {
            var tokNode = node as IMDTokenNode;
            var @ref    = tokNode?.Reference;

            var entityNode = node as EntityNode;
            var srcRef     = entityNode?.SourceRef;

            bool code = useCodeRef ?? srcRef != null;

            if (code)
            {
                if (srcRef == null)
                {
                    return;
                }
                documentTabService.FollowReference(srcRef.Value.Method, newTab, true, a => {
                    if (!a.HasMovedCaret && a.Success && srcRef != null)
                    {
                        a.HasMovedCaret = GoTo(a.Tab, srcRef.Value.Method, srcRef.Value.ILOffset, srcRef.Value.Reference);
                    }
                });
            }
            else
            {
                if (@ref == null)
                {
                    return;
                }
                documentTabService.FollowReference(@ref, newTab);
            }
        }
Exemplo n.º 2
0
		public static bool GoToIL(IModuleIdProvider moduleIdProvider, IDocumentTabService documentTabService, IDsDocument document, uint token, uint ilOffset, bool newTab) {
			if (document == null)
				return false;

			var method = document.ModuleDef.ResolveToken(token) as MethodDef;
			if (method == null)
				return false;

			var modId = moduleIdProvider.Create(method.Module);
			var key = new ModuleTokenId(modId, method.MDToken);

			bool found = documentTabService.DocumentTreeView.FindNode(method.Module) != null;
			if (found) {
				documentTabService.FollowReference(method, newTab, true, e => {
					Debug.Assert(e.Tab.UIContext is IDocumentViewer);
					if (e.Success && !e.HasMovedCaret) {
						MoveCaretTo(e.Tab.UIContext as IDocumentViewer, key, ilOffset);
						e.HasMovedCaret = true;
					}
				});
				return true;
			}

			Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => {
				documentTabService.FollowReference(method, newTab, true, e => {
					Debug.Assert(e.Tab.UIContext is IDocumentViewer);
					if (e.Success && !e.HasMovedCaret) {
						MoveCaretTo(e.Tab.UIContext as IDocumentViewer, key, ilOffset);
						e.HasMovedCaret = true;
					}
				});
			}));
			return true;
		}
Exemplo n.º 3
0
        public override bool Handle(HexView hexView, object reference, IList <string> tags)
        {
            bool newTab = tags.Contains(PredefinedHexReferenceHandlerTags.NewTab);

            documentTabService.FollowReference(reference, newTab: newTab);
            return(true);
        }
        public static bool GoToIL(IModuleIdProvider moduleIdProvider, IDocumentTabService documentTabService, IDsDocument document, uint token, uint ilOffset, bool newTab)
        {
            if (document == null)
            {
                return(false);
            }

            var method = document.ModuleDef.ResolveToken(token) as MethodDef;

            if (method == null)
            {
                return(false);
            }

            var modId = moduleIdProvider.Create(method.Module);
            var key   = new ModuleTokenId(modId, method.MDToken);

            bool found = documentTabService.DocumentTreeView.FindNode(method.Module) != null;

            if (found)
            {
                documentTabService.FollowReference(method, newTab, true, e =>
                {
                    Debug.Assert(e.Tab.UIContext is IDocumentViewer);
                    if (e.Success && !e.HasMovedCaret)
                    {
                        MoveCaretTo(e.Tab.UIContext as IDocumentViewer, key, ilOffset);
                        e.HasMovedCaret = true;
                    }
                });
                return(true);
            }

            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
            {
                documentTabService.FollowReference(method, newTab, true, e =>
                {
                    Debug.Assert(e.Tab.UIContext is IDocumentViewer);
                    if (e.Success && !e.HasMovedCaret)
                    {
                        MoveCaretTo(e.Tab.UIContext as IDocumentViewer, key, ilOffset);
                        e.HasMovedCaret = true;
                    }
                });
            }));
            return(true);
        }
Exemplo n.º 5
0
        bool GoTo(DotNetTokenReference tokenRef, ReadOnlyCollection <object> options)
        {
            bool newTab = options.Any(a => StringComparer.Ordinal.Equals(PredefinedReferenceNavigatorOptions.NewTab, a));
            var  module = GetModule(tokenRef.Module, options);

            if (module == null)
            {
                return(false);
            }

            var def = module.ResolveToken(tokenRef.Token) as IMemberDef;

            if (def == null)
            {
                return(false);
            }

            bool found = documentTabService.DocumentTreeView.FindNode(def.Module) != null;

            if (found)
            {
                documentTabService.FollowReference(def, newTab, true, e => {
                    Debug.Assert(e.Tab.UIContext is IDocumentViewer);
                    if (e.Success && !e.HasMovedCaret)
                    {
                        MoveCaretTo(e.Tab.UIContext as IDocumentViewer, def);
                        e.HasMovedCaret = true;
                    }
                });
                return(true);
            }

            // If it wasn't found, it will be added to the treeview with a slight delay, make sure our code gets executed
            // after it's happened.
            uiDispatcher.UIBackground(() => {
                documentTabService.FollowReference(def, newTab, true, e => {
                    Debug.Assert(e.Tab.UIContext is IDocumentViewer);
                    if (e.Success && !e.HasMovedCaret)
                    {
                        MoveCaretTo(e.Tab.UIContext as IDocumentViewer, def);
                        e.HasMovedCaret = true;
                    }
                });
            });
            return(true);
        }
Exemplo n.º 6
0
            public override void Execute(IMenuItemContext context)
            {
                var ep = GetEntryPoint(documentTabService, context);

                if (ep != null)
                {
                    documentTabService.FollowReference(ep);
                }
            }
Exemplo n.º 7
0
            public override void Execute(IMenuItemContext context)
            {
                var ep = GetModuleCctor(context);

                if (ep != null)
                {
                    documentTabService.FollowReference(ep);
                }
            }
Exemplo n.º 8
0
        static void ExecuteInternal(IDocumentTabService documentTabService, MDTableContext context)
        {
            var @ref = GetAddressReference(context);

            if (@ref != null)
            {
                documentTabService.FollowReference(@ref);
            }
        }
Exemplo n.º 9
0
 public void OnNewArgs(IAppCommandLineArgs args)
 {
     if (!SelectMember(args))
     {
         var mod = GetLoadedFiles(args).FirstOrDefault();
         if (mod != null)
         {
             documentTabService.FollowReference((object)mod.Assembly ?? mod);
         }
         else
         {
             foreach (var filename in args.Filenames)
             {
                 var key      = new FilenameKey(filename);
                 var document = documentTabService.DocumentTreeView.DocumentService.GetDocuments().FirstOrDefault(a => a.Key.Equals(key));
                 if (document != null)
                 {
                     documentTabService.FollowReference(document);
                     break;
                 }
             }
         }
     }
 }
Exemplo n.º 10
0
        bool GoToCore(DbgLoadModuleReference moduleRef, ReadOnlyCollection <object> options)
        {
            bool canShowMessageBox = true;
            var  md = LoadModule(moduleRef.Module, moduleRef.UseMemory, ref canShowMessageBox);

            if (md == null)
            {
                return(false);
            }

            // The file could've been added lazily to the list so add a short delay before we select it
            bool newTab = options.Any(a => StringComparer.Ordinal.Equals(PredefinedReferenceNavigatorOptions.NewTab, a));

            uiDispatcher.UIBackground(() => documentTabService.FollowReference(md, newTab));
            return(true);
        }
Exemplo n.º 11
0
        public void FollowResult(ISearchResult searchResult, bool newTab)
        {
            var @ref = searchResult == null ? null : searchResult.Reference;

            if (@ref != null)
            {
                documentTabService.FollowReference(@ref, newTab, true, a => {
                    if (!a.HasMovedCaret && a.Success)
                    {
                        if (searchResult.ObjectInfo is BodyResult bodyResult)
                        {
                            a.HasMovedCaret = GoTo(a.Tab, searchResult.Object as MethodDef, bodyResult.ILOffset);
                        }
                    }
                });
            }
        }
Exemplo n.º 12
0
        static void Execute(IDocumentTabService documentTabService, ResourceRef resRef)
        {
            if (resRef == null)
            {
                return;
            }
            var modNode = documentTabService.DocumentTreeView.FindNode(resRef.Module);

            Debug.Assert(modNode != null);
            if (modNode == null)
            {
                return;
            }
            modNode.TreeNode.EnsureChildrenLoaded();
            var resDirNode = modNode.TreeNode.DataChildren.FirstOrDefault(a => a is ResourcesFolderNode);

            Debug.Assert(resDirNode != null);
            if (resDirNode == null)
            {
                return;
            }
            resDirNode.TreeNode.EnsureChildrenLoaded();
            var resSetNode = resDirNode.TreeNode.DataChildren.FirstOrDefault(a => a is ResourceElementSetNode && ((ResourceElementSetNode)a).Name == resRef.Filename);

            Debug.Assert(resSetNode != null);
            if (resSetNode == null)
            {
                return;
            }
            resSetNode.TreeNode.EnsureChildrenLoaded();
            var resNode = resSetNode.TreeNode.DataChildren.FirstOrDefault(a => a is ResourceElementNode && ((ResourceElementNode)a).Name == resRef.ResourceName);

            Debug.Assert(resNode != null);
            if (resNode == null)
            {
                return;
            }
            documentTabService.FollowReference(resNode);
        }
Exemplo n.º 13
0
		static void Execute(IDocumentTabService documentTabService, ResourceRef resRef) {
			if (resRef == null)
				return;
			var modNode = documentTabService.DocumentTreeView.FindNode(resRef.Module);
			Debug.Assert(modNode != null);
			if (modNode == null)
				return;
			modNode.TreeNode.EnsureChildrenLoaded();
			var resDirNode = modNode.TreeNode.DataChildren.FirstOrDefault(a => a is ResourcesFolderNode);
			Debug.Assert(resDirNode != null);
			if (resDirNode == null)
				return;
			resDirNode.TreeNode.EnsureChildrenLoaded();
			var resSetNode = resDirNode.TreeNode.DataChildren.FirstOrDefault(a => a is ResourceElementSetNode && ((ResourceElementSetNode)a).Name == resRef.Filename);
			Debug.Assert(resSetNode != null);
			if (resSetNode == null)
				return;
			resSetNode.TreeNode.EnsureChildrenLoaded();
			var resNode = resSetNode.TreeNode.DataChildren.FirstOrDefault(a => a is ResourceElementNode && ((ResourceElementNode)a).Name == resRef.ResourceName);
			Debug.Assert(resNode != null);
			if (resNode == null)
				return;
			documentTabService.FollowReference(resNode);
		}
Exemplo n.º 14
0
        internal static void GoToFile(IDocumentTabService documentTabService, IDsDocument document, bool newTab)
        {
            if (document == null)
            {
                return;
            }
            var obj = (object)document.ModuleDef ?? document;

            // The file could've been added lazily to the list so add a short delay before we select it
            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => documentTabService.FollowReference(obj, newTab)));
        }