Beispiel #1
0
        public void Toggle(IDocumentViewer documentViewer, int textPosition)
        {
            var statements = documentViewer.GetMethodDebugService().FindByTextPosition(textPosition, sameMethod: false);
            var ilbps      = GetILCodeBreakpoints(documentViewer, statements);

            if (ilbps.Count > 0)
            {
                if (IsEnabled(ilbps))
                {
                    foreach (var ilbp in ilbps)
                    {
                        Remove(ilbp);
                    }
                }
                else
                {
                    foreach (var bpm in ilbps)
                    {
                        bpm.IsEnabled = true;
                    }
                }
            }
            else if (statements.Count > 0)
            {
                foreach (var methodStatement in statements)
                {
                    var md    = methodStatement.Method;
                    var modId = moduleIdProvider.Create(md.Module);
                    var key   = new ModuleTokenId(modId, md.MDToken);
                    Add(new ILCodeBreakpoint(key, methodStatement.Statement.BinSpan.Start));
                }
                documentViewer.MoveCaretToPosition(statements[0].Statement.TextSpan.Start);
            }
        }
Beispiel #2
0
        static bool MoveCaretTo(IDocumentViewer documentViewer, IMemberDef def)
        {
            if (documentViewer == null)
            {
                return(false);
            }
            var data = documentViewer.ReferenceCollection.FirstOrNull(a => a.Data.IsDefinition && a.Data.Reference == def);

            if (data == null)
            {
                return(false);
            }
            documentViewer.MoveCaretToPosition(data.Value.Span.Start);
            return(true);
        }
Beispiel #3
0
		public static bool MoveCaretTo(IDocumentViewer documentViewer, ModuleTokenId key, uint ilOffset) {
			if (documentViewer == null)
				return false;

			IMethodDebugService methodDebugService;
			if (!VerifyAndGetCurrentDebuggedMethod(documentViewer, key, out methodDebugService))
				return false;

			var sourceStatement = methodDebugService.TryGetMethodDebugInfo(key).GetSourceStatementByCodeOffset(ilOffset);
			if (sourceStatement == null)
				return false;

			documentViewer.MoveCaretToPosition(sourceStatement.Value.TextSpan.Start);
			return true;
		}
Beispiel #4
0
        public static bool MoveCaretTo(IDocumentViewer documentViewer, ModuleTokenId key, uint ilOffset)
        {
            if (documentViewer == null)
            {
                return(false);
            }

            IMethodDebugService methodDebugService;

            if (!VerifyAndGetCurrentDebuggedMethod(documentViewer, key, out methodDebugService))
            {
                return(false);
            }

            var sourceStatement = methodDebugService.TryGetMethodDebugInfo(key).GetSourceStatementByCodeOffset(ilOffset);

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

            documentViewer.MoveCaretToPosition(sourceStatement.Value.TextSpan.Start);
            return(true);
        }
Beispiel #5
0
		public void Toggle(IDocumentViewer documentViewer, int textPosition) {
			var statements = documentViewer.GetMethodDebugService().FindByTextPosition(textPosition, sameMethod: false);
			var ilbps = GetILCodeBreakpoints(documentViewer, statements);
			if (ilbps.Count > 0) {
				if (IsEnabled(ilbps)) {
					foreach (var ilbp in ilbps)
						Remove(ilbp);
				}
				else {
					foreach (var bpm in ilbps)
						bpm.IsEnabled = true;
				}
			}
			else if (statements.Count > 0) {
				foreach (var methodStatement in statements) {
					var md = methodStatement.Method;
					var modId = moduleIdProvider.Create(md.Module);
					var key = new ModuleTokenId(modId, md.MDToken);
					Add(new ILCodeBreakpoint(key, methodStatement.Statement.BinSpan.Start));
				}
				documentViewer.MoveCaretToPosition(statements[0].Statement.TextSpan.Start);
			}
		}