int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts) { ppEnumCodeCxts = CodeContextEnum.Create(this); return(VSConstants.S_OK); }
public int EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts) { ppEnumCodeCxts = new CodeContextEnum(CodeContext != null ? new[] { CodeContext } : Enumerable.Empty<IDebugCodeContext2>()); return VSConstants.S_OK; }
public int EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum) { DLog.Debug(DContext.VSDebuggerComCall, "IDebugProgram2.EnumCodeContexts"); ppEnum = null; string fileName; if (ErrorHandler.Failed(pDocPos.GetFileName(out fileName))) return VSConstants.E_INVALIDARG; var beginPosition = new TEXT_POSITION[1]; var endPosition = new TEXT_POSITION[1]; if (ErrorHandler.Failed(pDocPos.GetRange(beginPosition, endPosition))) return VSConstants.E_INVALIDARG; // Search matching document var doc = MapFile.FindDocument(fileName); if (doc == null) throw new ArgumentException("Unknown document " + fileName); DLog.Debug(DContext.VSDebuggerComCall, "document {0} positions {1}/{2} - {3}/{4}", fileName, (int)beginPosition[0].dwLine, (int)beginPosition[0].dwColumn, (int)endPosition[0].dwLine, (int)endPosition[0].dwColumn); // Search positions var documentPositions = doc.FindAll((int)beginPosition[0].dwLine + 1, (int)beginPosition[0].dwColumn + 1, (int)endPosition[0].dwLine + 1, (int)endPosition[0].dwColumn + 1) .ToList(); if (documentPositions.Count == 0) { DLog.Debug(DContext.VSDebuggerComCall, "found nothing."); return VSConstants.E_FAIL; } List<DebugCodeContext> list = new List<DebugCodeContext>(); foreach (var pos in documentPositions) { var loc = GetLocationFromPositionAsync(pos).Await(VmTimeout); if (loc == null) continue; // only find one location per method. if(list.Any(c=>c.Location.IsSameMethod(loc.Location))) continue; var ctx = new DebugCodeContext(loc.Location); ctx.DocumentContext = new DebugDocumentContext(loc, ctx); DLog.Debug(DContext.VSDebuggerComCall, "found {0}: {1}", loc.Description, loc.Location); list.Add(ctx); } DLog.Debug(DContext.VSDebuggerComCall, "done."); if (list.Count == 0) return VSConstants.E_FAIL; ppEnum = new CodeContextEnum(list); return VSConstants.S_OK; }