//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public int EnumCodeContexts (IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum) { // // Enumerates the code contexts for a given position in a source file. // LoggingUtils.PrintFunction (); try { string fileName; TEXT_POSITION [] startPos = new TEXT_POSITION [1]; TEXT_POSITION [] endPos = new TEXT_POSITION [1]; LoggingUtils.RequireOk (pDocPos.GetFileName (out fileName)); LoggingUtils.RequireOk (pDocPos.GetRange (startPos, endPos)); DebuggeeDocumentContext documentContext = new DebuggeeDocumentContext (m_debugger.Engine, fileName, startPos [0], endPos [0]); CLangDebuggeeCodeContext codeContext = CLangDebuggeeCodeContext.GetCodeContextForDocumentContext (m_debugger, documentContext); if (codeContext == null) { throw new InvalidOperationException ("Failed evaluating code-context for location."); } CLangDebuggeeCodeContext [] codeContexts = new CLangDebuggeeCodeContext [] { codeContext }; ppEnum = new DebuggeeCodeContext.Enumerator (codeContexts); return Constants.S_OK; } catch (Exception e) { LoggingUtils.HandleException (e); ppEnum = null; return Constants.E_FAIL; } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public int EnumCodeContexts (out IEnumDebugCodeContexts2 enumCodeContexts) { // // Retrieves a list of all code contexts associated with this document context. // LoggingUtils.PrintFunction (); try { IDebugCodeContext2 [] codeContexts; if (m_codeContext != null) { codeContexts = new IDebugCodeContext2 [] { m_codeContext }; } else { codeContexts = new IDebugCodeContext2 [0]; } enumCodeContexts = new DebuggeeCodeContext.Enumerator (codeContexts); if (enumCodeContexts == null) { throw new InvalidOperationException (); } return Constants.S_OK; } catch (Exception e) { LoggingUtils.HandleException (e); enumCodeContexts = null; return Constants.E_FAIL; } }