Exemple #1
0
		public static ITabSaver TryCreate(Lazy<IDocumentSaver> documentSaver, IDocumentTab tab) {
			var uiContext = tab.UIContext as HexViewDocumentTabUIContext;
			if (uiContext == null)
				return null;
			var buffer = uiContext.HexView.Buffer;
			return new HexTabSaver(documentSaver, buffer);
		}
Exemple #2
0
		NodeTabSaver(IMessageBoxService messageBoxService, IDocumentTab tab, IDocumentTreeNodeDecompiler documentTreeNodeDecompiler, IDecompiler decompiler, IDocumentViewer documentViewer, DocumentTreeNodeData[] nodes) {
			this.messageBoxService = messageBoxService;
			this.tab = tab;
			this.documentTreeNodeDecompiler = documentTreeNodeDecompiler;
			this.decompiler = decompiler;
			this.documentViewer = documentViewer;
			this.nodes = nodes;
		}
Exemple #3
0
		ITabSaver GetTabSaver(IDocumentTab tab) {
			if (tab == null)
				return null;
			foreach (var provider in tabSaverProviders) {
				var ts = provider.Create(tab);
				if (ts != null)
					return ts;
			}
			return null;
		}
Exemple #4
0
        public static ITabSaver TryCreate(Lazy <IDocumentSaver> documentSaver, IDocumentTab tab)
        {
            var uiContext = tab.UIContext as HexViewDocumentTabUIContext;

            if (uiContext == null)
            {
                return(null);
            }
            var buffer = uiContext.HexView.Buffer;

            return(new HexTabSaver(documentSaver, buffer));
        }
Exemple #5
0
		public static BamlTabSaver TryCreate(IDocumentTab tab, IMessageBoxService messageBoxService) {
			var uiContext = tab.UIContext as IDocumentViewer;
			if (uiContext == null)
				return null;
			var nodes = tab.Content.Nodes.ToArray();
			if (nodes.Length != 1)
				return null;
			var bamlNode = nodes[0] as BamlResourceElementNode;
			if (bamlNode == null)
				return null;

			return new BamlTabSaver(tab, bamlNode, uiContext, messageBoxService);
		}
Exemple #6
0
		public static NodeTabSaver TryCreate(IDocumentTreeNodeDecompiler documentTreeNodeDecompiler, IDocumentTab tab, IMessageBoxService messageBoxService) {
			if (tab.IsAsyncExecInProgress)
				return null;
			var uiContext = tab.UIContext as IDocumentViewer;
			if (uiContext == null)
				return null;
			var decompiler = (tab.Content as IDecompilerTabContent)?.Decompiler;
			if (decompiler == null)
				return null;
			var nodes = tab.Content.Nodes.ToArray();
			if (nodes.Length == 0)
				return null;
			return new NodeTabSaver(messageBoxService, tab, documentTreeNodeDecompiler, decompiler, uiContext, nodes);
		}
Exemple #7
0
 ITabSaver GetTabSaver(IDocumentTab tab)
 {
     if (tab == null)
     {
         return(null);
     }
     foreach (var provider in tabSaverProviders)
     {
         var ts = provider.Create(tab);
         if (ts != null)
         {
             return(ts);
         }
     }
     return(null);
 }
        bool MustRefresh(IDocumentTab tab, IEnumerable <IDsDocument> documents)
        {
            var modules = new HashSet <IDsDocument>(documents);

            if (InModifiedModuleHelper.IsInModifiedModule(modules, tab.Content.Nodes))
            {
                return(true);
            }
            var documentViewer = tab.TryGetDocumentViewer();

            if (documentViewer != null && InModifiedModuleHelper.IsInModifiedModule(DocumentTreeView.DocumentService, modules, documentViewer.Content.ReferenceCollection.Select(a => a.Data.Reference)))
            {
                return(true);
            }

            return(false);
        }
        public override void GoToLocation(IDocumentTab tab, MethodDef method, ModuleTokenId module, uint offset, bool newTab)
        {
            bool specialIpOffset;

            if (offset == EPILOG)
            {
                specialIpOffset = true;
                var mod = dbgMetadataService.Value.TryGetMetadata(module.Module, DbgLoadModuleOptions.AutoLoaded);
                if (mod?.ResolveToken(module.Token) is MethodDef md && md.Body is not null && md.Body.Instructions.Count > 0)
                {
                    offset = md.Body.Instructions[md.Body.Instructions.Count - 1].Offset;
                }
                else
                {
                    return;
                }
            }
Exemple #10
0
        static string GetHeader(int i, IDocumentTab tab)
        {
            string s;

            if (i == 10)
            {
                s = "1_0";
            }
            else if (i > 10)
            {
                s = i.ToString();
            }
            else
            {
                s = string.Format("_{0}", i);
            }
            return(string.Format("{0} {1}", s, GetShortMenuItemHeader(tab.Content.Title)));
        }
Exemple #11
0
        public static ITabSaver TryCreate(Lazy <IDocumentSaver> documentSaver, IDocumentTab tab)
        {
            var uiContext = tab.UIContext as HexBoxDocumentTabUIContext;

            if (uiContext == null)
            {
                return(null);
            }
            var doc = uiContext.DnHexBox.Document as AsmEdHexDocument;

            Debug.Assert(doc != null);
            if (doc == null)
            {
                return(null);
            }

            return(new HexTabSaver(documentSaver, doc));
        }
Exemple #12
0
        static string GetHeader(int i, IDocumentTab tab)
        {
            string s;

            if (i == 10)
            {
                s = "1_0";
            }
            else if (i > 10)
            {
                s = i.ToString();
            }
            else
            {
                s = $"_{i}";
            }
            return($"{s} {GetShortMenuItemHeader(tab.Content.Title)}");
        }
        void OnNewTabContentShownDelay(IDocumentTab documentTab)
        {
            var newNodes = documentTab.Content.Nodes.ToArray();

            if (Equals(DocumentTreeView.TreeView.SelectedItems, newNodes))
            {
                return;
            }

            // The treeview steals the focus so remember the current focused element. Don't restore
            // the focus if it's a node in the treeview.
            var focusedElem = Keyboard.FocusedElement;

            if (DocumentTreeView.TreeView.UIObject.IsKeyboardFocusWithin)
            {
                focusedElem = null;
            }
            bool tabGroupHasFocus = TabGroupService.TabGroups.Any(a => a.IsKeyboardFocusWithin);

            disableSelectionChangedEventCounter++;
            try {
                DocumentTreeView.TreeView.SelectItems(newNodes);
            }
            finally {
                disableSelectionChangedEventCounter--;
            }

            if (focusedElem != null && Keyboard.FocusedElement != focusedElem)
            {
                if (tabGroupHasFocus)
                {
                    var tab = ActiveTabContentImpl;
                    Debug.Assert(tab != null);
                    if (tab != null)
                    {
                        tab.TrySetFocus();
                    }
                }
                else
                {
                    wpfFocusService.Focus(focusedElem);
                }
            }
        }
Exemple #14
0
        internal bool ValidateDocumentTab(IDocumentTab documentTab, IView targetView, DragAction action, DockOperation operation, bool bExecute)
        {
            switch (targetView)
            {
            case IRootDock targetRoot:
            {
                return(DockIntoWindow(documentTab, targetView, action, operation, bExecute));
            }

            case IToolTab targetToolTab:
            {
                return(false);
            }

            case IDocumentTab targetDocumentTab:
            {
                return(DockIntoTab(documentTab, targetDocumentTab, action, operation, bExecute));
            }

            case ILayoutDock targetLayout:
            {
                return(false);
            }

            case IToolDock targetTool:
            {
                return(false);
            }

            case IDocumentDock targetTab:
            {
                return(DockIntoTab(documentTab, targetTab, action, operation, bExecute));
            }

            default:
            {
#if DEBUG
                Console.WriteLine($"Not supported type {targetView.GetType()}: {documentTab} -> {targetView}");
#endif
                return(false);
            }
            }
        }
Exemple #15
0
        bool GoTo(IDocumentTab tab, MethodDef method, uint ilOffset)
        {
            var documentViewer = tab.TryGetDocumentViewer();

            if (documentViewer == null || method == null)
            {
                return(false);
            }
            var methodDebugService = documentViewer.GetMethodDebugService();
            var methodStatement    = methodDebugService.FindByCodeOffset(method, ilOffset);

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

            documentViewer.MoveCaretToPosition(methodStatement.Value.Statement.TextSpan.Start);
            return(true);
        }
        public void Close(IDocumentTab tab)
        {
            if (tab == null)
            {
                throw new ArgumentNullException(nameof(tab));
            }
            var impl = tab as TabContentImpl;

            if (impl == null)
            {
                throw new InvalidOperationException();
            }
            var g = GetTabGroup(impl);

            if (g == null)
            {
                throw new InvalidOperationException();
            }
            g.Close(impl);
        }
Exemple #17
0
        ToggleCreateBreakpointInfoResult GetToggleCreateBookmarkInfo(IDocumentTab tab, VirtualSnapshotPoint?position)
        {
            using (var info = GetLocation(tab, position)) {
                var locRes = info.locRes;
                var bms    = locRes == null?Array.Empty <Bookmark>() : GetBookmarks(locRes.Value);

                if (bms.Length != 0)
                {
                    return(new ToggleCreateBreakpointInfoResult(bookmarksService, ToggleCreateBookmarkKind.Delete, bms, null));
                }
                else
                {
                    if (locRes == null || locRes.Value.Location == null)
                    {
                        return(new ToggleCreateBreakpointInfoResult(bookmarksService, ToggleCreateBookmarkKind.None, Array.Empty <Bookmark>(), null));
                    }
                    return(new ToggleCreateBreakpointInfoResult(bookmarksService, ToggleCreateBookmarkKind.Add, Array.Empty <Bookmark>(), info.TakeOwnership(locRes.Value.Location)));
                }
            }
        }
Exemple #18
0
        static ListView FindListView(IDocumentTab tab)
        {
            var o = tab.UIContext.UIObject as DependencyObject;

            while (o != null)
            {
                var lv = o as ListView;
                if (lv != null && InitDataTemplateAP.GetInitialize(lv))
                {
                    return(lv);
                }
                var children = UIUtils.GetChildren(o).ToArray();
                if (children.Length != 1)
                {
                    return(null);
                }
                o = children[0];
            }

            return(null);
        }
Exemple #19
0
        public static BamlTabSaver TryCreate(IDocumentTab tab, IMessageBoxService messageBoxService)
        {
            if (tab.IsAsyncExecInProgress)
            {
                return(null);
            }
            if (tab.UIContext is not IDocumentViewer uiContext)
            {
                return(null);
            }
            var nodes = tab.Content.Nodes.ToArray();

            if (nodes.Length != 1)
            {
                return(null);
            }
            if (nodes[0] is not BamlResourceElementNode bamlNode)
            {
                return(null);
            }
            return(new BamlTabSaver(tab, bamlNode, uiContext, messageBoxService));
        }
Exemple #20
0
        public override TextViewBookmarkLocationResult?CreateLocation(IDocumentTab tab, ITextView textView, VirtualSnapshotPoint position)
        {
            var documentViewer = tab.TryGetDocumentViewer();

            if (documentViewer == null)
            {
                return(null);
            }

            // A bookmark should be set on the current line if possible, and the current position
            // isn't necessarily at the start of the line.
            int startPos = position.Position.GetContainingLine().Start.Position;

            foreach (var data in documentViewer.ReferenceCollection.FindFrom(startPos))
            {
                if (!data.Data.IsDefinition)
                {
                    continue;
                }
                var def = data.Data.Reference as IMemberDef;
                if (def == null)
                {
                    continue;
                }
                var span = data.Span;

                var snapshot = textView.TextSnapshot;
                if (span.End > snapshot.Length)
                {
                    return(null);
                }

                var moduleId = moduleIdProvider.Create(def.Module);
                var location = dotNetBookmarkLocationFactory.Value.CreateTokenLocation(moduleId, def.MDToken.Raw);
                return(new TextViewBookmarkLocationResult(location, new SnapshotSpan(snapshot, span)));
            }

            return(null);
        }
        LocationsResult GetLocations(IDocumentTab tab, VirtualSnapshotPoint?position)
        {
            var allLocations = new List <DbgCodeLocation>();
            var textView     = GetTextView(tab);

            if (textView == null)
            {
                return(new LocationsResult(dbgManager, null, allLocations));
            }
            var pos = position ?? textView.Caret.Position.VirtualBufferPosition;

            if (pos.Position.Snapshot != textView.TextSnapshot)
            {
                throw new ArgumentException();
            }
            DbgTextViewBreakpointLocationResult?res = null;

            foreach (var loc in dbgTextViewCodeLocationService.Value.CreateLocation(tab, textView, pos))
            {
                UpdateResult(allLocations, textView, ref res, loc, useIfSameSpan: false);
            }
            SnapshotSpan span;

            if (res != null)
            {
                var resSpan  = res.Value.Span.SnapshotSpan;
                var newStart = Min(pos.Position, resSpan.Start);
                var newEnd   = Max(pos.Position, resSpan.End);
                span = new SnapshotSpan(newStart, newEnd);
            }
            else
            {
                span = new SnapshotSpan(pos.Position, new SnapshotPoint(pos.Position.Snapshot, pos.Position.Snapshot.Length));
            }
            // This one has higher priority since it already exists (eg. could be a stack frame BP location)
            UpdateResult(allLocations, textView, ref res, breakpointMarker.Value.GetLocations(textView, span), useIfSameSpan: true);
            return(new LocationsResult(dbgManager, res, allLocations));
        }
        public override DbgTextViewBreakpointLocationResult?CreateLocation(IDocumentTab tab, ITextView textView, VirtualSnapshotPoint position)
        {
            var documentViewer = tab.TryGetDocumentViewer();

            if (documentViewer == null)
            {
                return(null);
            }
            var methodDebugService = documentViewer.GetMethodDebugService();

            if (methodDebugService == null)
            {
                return(null);
            }
            var methodStatements = methodDebugService.FindByTextPosition(position.Position, FindByTextPositionOptions.None);

            if (methodStatements.Count == 0)
            {
                return(null);
            }
            var textSpan = methodStatements[0].Statement.TextSpan;
            var snapshot = textView.TextSnapshot;

            if (textSpan.End > snapshot.Length)
            {
                return(null);
            }
            var span      = new VirtualSnapshotSpan(new SnapshotSpan(snapshot, new Span(textSpan.Start, textSpan.Length)));
            var locations = new DbgCodeLocation[methodStatements.Count];

            for (int i = 0; i < methodStatements.Count; i++)
            {
                var statement = methodStatements[i];
                var moduleId  = moduleIdProvider.Create(statement.Method.Module);
                locations[i] = dbgDotNetCodeLocationFactory.Value.Create(moduleId, statement.Method.MDToken.Raw, statement.Statement.ILSpan.Start);
            }
            return(new DbgTextViewBreakpointLocationResult(locations, span));
        }
        public override TextViewBookmarkLocationResult?CreateLocation(IDocumentTab tab, ITextView textView, VirtualSnapshotPoint position)
        {
            var documentViewer = tab.TryGetDocumentViewer();

            if (documentViewer == null)
            {
                return(null);
            }
            var methodDebugService = documentViewer.GetMethodDebugService();

            if (methodDebugService == null)
            {
                return(null);
            }
            // A bookmark should be set on the current line if possible, and the current position
            // isn't necessarily at the start of the line.
            var startPos         = position.Position.GetContainingLine().Start;
            var methodStatements = methodDebugService.FindByTextPosition(startPos, FindByTextPositionOptions.None);

            if (methodStatements.Count == 0)
            {
                return(null);
            }
            var textSpan = methodStatements[0].Statement.TextSpan;
            var snapshot = textView.TextSnapshot;

            if (textSpan.End > snapshot.Length)
            {
                return(null);
            }
            var span = new VirtualSnapshotSpan(new SnapshotSpan(snapshot, new Span(textSpan.Start, textSpan.Length)));

            var statement = methodStatements[0];
            var moduleId  = moduleIdProvider.Create(statement.Method.Module);
            var location  = dotNetBookmarkLocationFactory.Value.CreateMethodBodyLocation(moduleId, statement.Method.MDToken.Raw, statement.Statement.ILSpan.Start);

            return(new TextViewBookmarkLocationResult(location, span));
        }
Exemple #24
0
        public static BamlTabSaver TryCreate(IDocumentTab tab, IMessageBoxService messageBoxService)
        {
            var uiContext = tab.UIContext as IDocumentViewer;

            if (uiContext == null)
            {
                return(null);
            }
            var nodes = tab.Content.Nodes.ToArray();

            if (nodes.Length != 1)
            {
                return(null);
            }
            var bamlNode = nodes[0] as BamlResourceElementNode;

            if (bamlNode == null)
            {
                return(null);
            }

            return(new BamlTabSaver(tab, bamlNode, uiContext, messageBoxService));
        }
        ToggleCreateBreakpointInfoResult GetToggleCreateBreakpointInfo(IDocumentTab tab, VirtualSnapshotPoint?position)
        {
            using (var info = GetLocations(tab, position)) {
                var locRes = info.locRes;
                var bps    = locRes == null?Array.Empty <DbgCodeBreakpoint>() : GetBreakpoints(locRes.Value);

                if (bps.Length != 0)
                {
                    if (bps.All(a => a.IsEnabled))
                    {
                        return(new ToggleCreateBreakpointInfoResult(dbgManager, ToggleCreateBreakpointKind.Delete, bps, Array.Empty <DbgCodeLocation>()));
                    }
                    return(new ToggleCreateBreakpointInfoResult(dbgManager, ToggleCreateBreakpointKind.Enable, bps, Array.Empty <DbgCodeLocation>()));
                }
                else
                {
                    if (locRes == null || locRes.Value.Locations.Length == 0)
                    {
                        return(new ToggleCreateBreakpointInfoResult(dbgManager, ToggleCreateBreakpointKind.None, Array.Empty <DbgCodeBreakpoint>(), Array.Empty <DbgCodeLocation>()));
                    }
                    return(new ToggleCreateBreakpointInfoResult(dbgManager, ToggleCreateBreakpointKind.Add, Array.Empty <DbgCodeBreakpoint>(), locRes.Value.Locations.Select(a => a.Clone()).ToArray()));
                }
            }
        }
Exemple #26
0
        LocationsResult GetLocation(IDocumentTab tab, VirtualSnapshotPoint?position)
        {
            var allLocations = new List <BookmarkLocation>();
            var textView     = GetTextView(tab);

            if (textView == null)
            {
                return(new LocationsResult(bookmarksService, null, allLocations));
            }
            var pos = position ?? textView.Caret.Position.VirtualBufferPosition;

            if (pos.Position.Snapshot != textView.TextSnapshot)
            {
                throw new ArgumentException();
            }
            TextViewBookmarkLocationResult?res = null;

            foreach (var lz in textViewBookmarkLocationProviders)
            {
                var result = lz.Value.CreateLocation(tab, textView, pos);
                if (result?.Location == null)
                {
                    continue;
                }
                allLocations.Add(result.Value.Location);
                if (result.Value.Span.Snapshot != textView.TextSnapshot)
                {
                    continue;
                }
                if (res == null || result.Value.Span.Start < res.Value.Span.Start)
                {
                    res = result;
                }
            }
            return(new LocationsResult(bookmarksService, res, allLocations));
        }
Exemple #27
0
		public string GetMenuHeader(IDocumentTab tab) {
			var ts = GetTabSaver(tab);
			return (ts == null ? null : ts.MenuHeader) ?? dnSpy_Resources.Button_Save;
		}
Exemple #28
0
		public bool CanSave(IDocumentTab tab) {
			var ts = GetTabSaver(tab);
			return ts != null && ts.CanSave;
		}
Exemple #29
0
		void JumpToCurrentStatement(IDocumentTab tab, bool canRefreshMethods) {
			if (tab == null)
				return;
			if (currentMethod == null)
				return;

			// 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(() => {
				tab.FollowReference(currentMethod, false, e => {
					Debug.Assert(e.Tab == tab);
					Debug.Assert(e.Tab.UIContext is IDocumentViewer);
					if (e.Success && !e.HasMovedCaret) {
						MoveCaretToCurrentStatement(e.Tab.UIContext as IDocumentViewer, canRefreshMethods);
						e.HasMovedCaret = true;
					}
				});
			}));
		}
 public BookmarkDocumentImpl(IDocumentTab tab) => this.tab = tab ?? throw new ArgumentNullException(nameof(tab));
Exemple #31
0
 public abstract IEnumerable <DbgTextViewBreakpointLocationResult> CreateLocation(IDocumentTab tab, ITextView textView, VirtualSnapshotPoint position);
Exemple #32
0
 public abstract void GoToLocation(IDocumentTab tab, MethodDef method, in ModuleTokenId module, uint offset);
Exemple #33
0
		public ITabSaver Create(IDocumentTab tab) => HexTabSaver.TryCreate(documentSaver, tab);
Exemple #34
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="result">Result></param>
 /// <param name="tab">Tab</param>
 public ShowTabContentEventArgs(ShowTabContentResult result, IDocumentTab tab)
 {
     Result        = result;
     HasMovedCaret = false;
     Tab           = tab;
 }
Exemple #35
0
		public static SerializedTab TryCreate(IDocumentTabContentFactoryService documentTabContentFactoryService, IDocumentTab tab) {
			var contentSect = new SettingsSection(CONTENT_SECTION);
			var guid = documentTabContentFactoryService.Serialize(tab.Content, contentSect);
			if (guid == null)
				return null;
			contentSect.Attribute(CONTENT_GUID_ATTR, guid.Value);

			var uiSect = new SettingsSection(UI_SECTION);
			tab.UIContext.SerializeUIState(uiSect, tab.UIContext.CreateUIState());

			var tabUISect = new SettingsSection(TAB_UI_SECTION);
			tab.SerializeUI(tabUISect);

			var paths = new List<SerializedPath>();
			foreach (var node in tab.Content.Nodes)
				paths.Add(SerializedPath.Create(node));

			var autoLoadedDocuments = new List<DsDocumentInfo>();
			foreach (var f in GetAutoLoadedDocuments(tab.Content.Nodes))
				autoLoadedDocuments.Add(f);

			return new SerializedTab(contentSect, tabUISect, uiSect, paths, autoLoadedDocuments);
		}
Exemple #36
0
		public TabVM(TabsVM owner, IDocumentTab tab) {
			Owner = owner;
			Tab = tab;
			var node = tab.Content.Nodes.FirstOrDefault().GetTopNode();
			document = node?.Document;
		}
Exemple #37
0
		public void JumpToCurrentStatement(IDocumentTab tab) => JumpToCurrentStatement(tab, true);
Exemple #38
0
        public static SerializedTab TryCreate(IDocumentTabContentFactoryService documentTabContentFactoryService, IDocumentTab tab)
        {
            var contentSect = new SettingsSection(CONTENT_SECTION);
            var guid        = documentTabContentFactoryService.Serialize(tab.Content, contentSect);

            if (guid == null)
            {
                return(null);
            }
            contentSect.Attribute(CONTENT_GUID_ATTR, guid.Value);

            var uiSect = new SettingsSection(UI_SECTION);

            tab.UIContext.SerializeUIState(uiSect, tab.UIContext.CreateUIState());

            var tabUISect = new SettingsSection(TAB_UI_SECTION);

            tab.SerializeUI(tabUISect);

            var paths = new List <SerializedPath>();

            foreach (var node in tab.Content.Nodes)
            {
                paths.Add(SerializedPath.Create(node));
            }

            var autoLoadedDocuments = new List <DsDocumentInfo>();

            foreach (var f in GetAutoLoadedDocuments(tab.Content.Nodes))
            {
                autoLoadedDocuments.Add(f);
            }

            return(new SerializedTab(contentSect, tabUISect, uiSect, paths, autoLoadedDocuments));
        }
Exemple #39
0
		public void Save(IDocumentTab tab) {
			var ts = GetTabSaver(tab);
			if (ts == null || !ts.CanSave)
				return;
			ts.Save();
		}
Exemple #40
0
 public ITabSaver Create(IDocumentTab tab) => NodeTabSaver.TryCreate(documentTreeNodeDecompiler, tab, messageBoxService);
Exemple #41
0
 public override void GoToLocation(IDocumentTab tab, MethodDef method, in ModuleTokenId module, uint offset)
Exemple #42
0
        public static NodeTabSaver TryCreate(IDocumentTreeNodeDecompiler documentTreeNodeDecompiler, IDocumentTab tab, IMessageBoxService messageBoxService)
        {
            if (tab.IsAsyncExecInProgress)
            {
                return(null);
            }
            var uiContext = tab.UIContext as IDocumentViewer;

            if (uiContext == null)
            {
                return(null);
            }
            var decompiler = (tab.Content as IDecompilerTabContent)?.Decompiler;

            if (decompiler == null)
            {
                return(null);
            }
            var nodes = tab.Content.Nodes.ToArray();

            if (nodes.Length == 0)
            {
                return(null);
            }
            return(new NodeTabSaver(messageBoxService, tab, documentTreeNodeDecompiler, decompiler, uiContext, nodes));
        }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="result">Result></param>
		/// <param name="tab">Tab</param>
		public ShowTabContentEventArgs(ShowTabContentResult result, IDocumentTab tab) {
			Result = result;
			HasMovedCaret = false;
			Tab = tab;
		}
Exemple #44
0
		bool GoTo(IDocumentTab tab, MethodDef method, uint? ilOffset, object @ref) {
			if (method == null || ilOffset == null)
				return false;
			var documentViewer = tab.TryGetDocumentViewer();
			if (documentViewer == null)
				return false;
			var methodDebugService = documentViewer.GetMethodDebugService();
			var methodStatement = methodDebugService.FindByCodeOffset(method, ilOffset.Value);
			if (methodStatement == null)
				return false;

			var textSpan = methodStatement.Value.Statement.TextSpan;
			var loc = FindLocation(documentViewer.Content.ReferenceCollection.FindFrom(textSpan.Start), documentViewer.TextView.TextSnapshot, methodStatement.Value.Statement.TextSpan.End, @ref);
			if (loc == null)
				loc = textSpan.Start;

			documentViewer.MoveCaretToPosition(loc.Value);
			return true;
		}
Exemple #45
0
		BamlTabSaver(IDocumentTab tab, BamlResourceElementNode bamlNode, IDocumentViewer documentViewer, IMessageBoxService messageBoxService) {
			this.tab = tab;
			this.bamlNode = bamlNode;
			this.documentViewer = documentViewer;
			this.messageBoxService = messageBoxService;
		}
Exemple #46
0
		static ITokenResolver GetResolver(IDocumentTabService documentTabService, out IDocumentTab tab) {
			tab = documentTabService.ActiveTab;
			if (tab == null)
				return null;
			return tab.Content.Nodes.FirstOrDefault().GetModule();
		}
 ITextView GetTextView(IDocumentTab tab) => (tab?.UIContext as IDocumentViewer)?.TextView;
Exemple #48
0
		bool GoTo(IDocumentTab tab, MethodDef method, uint ilOffset) {
			var documentViewer = tab.TryGetDocumentViewer();
			if (documentViewer == null || method == null)
				return false;
			var methodDebugService = documentViewer.GetMethodDebugService();
			var methodStatement = methodDebugService.FindByCodeOffset(method, ilOffset);
			if (methodStatement == null)
				return false;

			documentViewer.MoveCaretToPosition(methodStatement.Value.Statement.TextSpan.Start);
			return true;
		}
Exemple #49
0
		public ITabSaver Create(IDocumentTab tab) => BamlTabSaver.TryCreate(tab, messageBoxService);
Exemple #50
0
		public ITabSaver Create(IDocumentTab tab) => NodeTabSaver.TryCreate(documentTreeNodeDecompiler, tab, messageBoxService);