Ejemplo n.º 1
0
		public static IList<MethodSourceStatement> GetStatements(IDocumentViewer documentViewer, int textPosition) {
			if (documentViewer == null)
				return null;
			var methodDebugService = documentViewer.GetMethodDebugService();
			var methodStatements = methodDebugService.FindByTextPosition(textPosition, sameMethod: true);
			return methodStatements.Count == 0 ? null : methodStatements;
		}
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        public static IList <MethodSourceStatement> GetStatements(IDocumentViewer documentViewer, int textPosition, FindByTextPositionOptions options)
        {
            if (documentViewer == null)
            {
                return(null);
            }
            var methodDebugService = documentViewer.GetMethodDebugService();
            var methodStatements   = methodDebugService.FindByTextPosition(textPosition, options | FindByTextPositionOptions.SameMethod);

            return(methodStatements.Count == 0 ? null : methodStatements);
        }
Ejemplo n.º 4
0
        public static IList <MethodSourceStatement> GetStatements(IDocumentViewer documentViewer, int textPosition)
        {
            if (documentViewer == null)
            {
                return(null);
            }
            var methodDebugService = documentViewer.GetMethodDebugService();
            var methodStatements   = methodDebugService.FindByTextPosition(textPosition);

            if (methodStatements.Count == 0)
            {
                return(null);
            }

            var span     = methodStatements[0].Statement.TextSpan;
            var snapshot = documentViewer.TextView.TextSnapshot;

            Debug.Assert(span.End <= snapshot.Length);
            Debug.Assert(textPosition <= snapshot.Length);
            if (span.End > snapshot.Length)
            {
                return(null);
            }
            if (textPosition > snapshot.Length)
            {
                return(null);
            }
            var line1    = snapshot.GetLineFromPosition(span.Start);
            var line2    = snapshot.GetLineFromPosition(span.End);
            var textLine = snapshot.GetLineFromPosition(textPosition);

            if (!(line1.LineNumber <= textLine.LineNumber && textLine.LineNumber <= line2.LineNumber))
            {
                return(null);
            }

            return(methodStatements);
        }
Ejemplo n.º 5
0
 public static bool VerifyAndGetCurrentDebuggedMethod(IDocumentViewer documentViewer, ModuleTokenId serToken, out IMethodDebugService methodDebugService)
 {
     methodDebugService = documentViewer.GetMethodDebugService();
     return(methodDebugService.TryGetMethodDebugInfo(serToken) != null);
 }
Ejemplo n.º 6
0
 List <ILCodeBreakpoint> GetILCodeBreakpoints(IDocumentViewer documentViewer, int textPosition) =>
 GetILCodeBreakpoints(documentViewer, documentViewer.GetMethodDebugService().FindByTextPosition(textPosition, sameMethod: false));
Ejemplo n.º 7
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);
			}
		}
Ejemplo n.º 8
0
		List<ILCodeBreakpoint> GetILCodeBreakpoints(IDocumentViewer documentViewer, int textPosition) =>
			GetILCodeBreakpoints(documentViewer, documentViewer.GetMethodDebugService().FindByTextPosition(textPosition, sameMethod: false));
Ejemplo n.º 9
0
		public static bool VerifyAndGetCurrentDebuggedMethod(IDocumentViewer documentViewer, ModuleTokenId serToken, out IMethodDebugService methodDebugService) {
			methodDebugService = documentViewer.GetMethodDebugService();
			return methodDebugService.TryGetMethodDebugInfo(serToken) != null;
		}