Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(878)

Side by Side Diff: experimental/visual_studio_plugin/src/MsAd7.BaseImpl/DocumentContext.cs

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2010 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file.
4 using System;
5 using System.Collections.Generic;
6 using System.Diagnostics;
7 using Google.MsAd7.BaseImpl.Ad7Enumerators;
8 using Google.MsAd7.BaseImpl.Interfaces;
9 using Microsoft.VisualStudio;
10 using Microsoft.VisualStudio.Debugger.Interop;
11
12 namespace Google.MsAd7.BaseImpl {
13 /// <summary>
14 /// For documentation of IDebugDocumentContext2 members, please see the VS 200 8 MSDN
15 /// documentation.
16 /// </summary>
17 public class DocumentContext : IDebugDocumentContext2
18 {
19 public DocumentContext(string path, uint line, uint column) {
20 path_ = path;
21 line_ = line;
22 column_ = column;
23 }
24
25 public DocumentContext(DocumentPosition pos) {
26 path_ = pos.Path;
27 line_ = pos.BeginPos.dwLine;
28 column_ = pos.BeginPos.dwColumn;
29 }
30
31 public string Path {
32 get { return path_; }
33 set { path_ = value; }
34 }
35
36 public uint Line {
37 get { return line_; }
38 set { line_ = value; }
39 }
40
41 public uint Column {
42 get { return column_; }
43 set { column_ = value; }
44 }
45
46 public IList<CodeContext> CodeContexts {
47 get { return codeContexts_; }
48 }
49
50 /// <summary>
51 /// This generator helps with conversion between addresses and code location s.
52 /// </summary>
53 /// <param name="addr">The address of the desired DocumentContext in the cod e.</param>
54 /// <param name="dbg">The debugger which should be queried to obtain a code location.</param>
55 /// <returns>The DocumentContext corresponding to addr or null.</returns>
56 public static DocumentContext FromAddress(UInt64 addr, ISimpleDebugger dbg) {
57 DocumentPosition pos = dbg.Symbols.PositionFromAddress(addr);
58 if (pos == null) {
59 return null;
60 }
61
62 var result = new DocumentContext(pos);
63
64 IEnumerable<ulong> addrs = dbg.Symbols.AddressesFromPosition(pos);
65 foreach (ulong a in addrs) {
66 pos = dbg.Symbols.PositionFromAddress(a);
67 var cc = new CodeContext(
68 string.Format("{0}:{1}", pos.Path, pos.BeginPos.dwLine),
69 a,
70 1,
71 result);
72 result.AddCodeContext(cc);
73 }
74
75 return result;
76 }
77
78 /// <summary>
79 /// A document context can contain of many CodeContext instances.
80 /// </summary>
81 /// <param name="ctx">A CodeContext to be added to this document context.</p aram>
82 public void AddCodeContext(CodeContext ctx) {
83 if (!codeContexts_.Contains(ctx)) {
84 codeContexts_.Add(ctx);
85 }
86 }
87
88 #region Implementation of IDebugDocumentContext2
89
90 public int GetDocument(out IDebugDocument2 ppDocument) {
91 Debug.WriteLine("DocumentContext.GetDocument");
92
93 // According to MSDN, we don't implement this unless we supply a
94 // custom document type.
95 ppDocument = null;
96 return VSConstants.S_FALSE;
97 }
98
99 public int GetName(enum_GETNAME_TYPE gnType, out string pbstrFileName) {
100 Debug.WriteLine("DocumentContext.GetName");
101
102 pbstrFileName = path_;
103 return VSConstants.S_OK;
104 }
105
106 public int EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts) {
107 Debug.WriteLine("DocumentContext.EnumCodeContexts");
108 ppEnumCodeCxts =
109 new CodeContextEnumerator(
110 codeContexts_.ConvertAll(e => (IDebugCodeContext2) e));
111 return VSConstants.S_OK;
112 }
113
114 public int GetLanguageInfo(ref string pbstrLanguage, ref Guid pguidLanguage) {
115 Debug.WriteLine("DocumentContext.GetLanguageInfo");
116
117 // For now, just assume C/C++
118 pbstrLanguage = "C++";
119 pguidLanguage = Guids.guidLanguageCpp;
120 return VSConstants.S_OK;
121 }
122
123 public int GetStatementRange(TEXT_POSITION[] pBegPosition,
124 TEXT_POSITION[] pEndPosition) {
125 Debug.WriteLine("DocumentContext.GetStatementRange");
126 pBegPosition[0].dwLine = line_;
127 pBegPosition[0].dwColumn = column_;
128 pEndPosition[0].dwLine = line_;
129 pEndPosition[0].dwColumn = column_;
130 return VSConstants.S_OK;
131 }
132
133 public int GetSourceRange(TEXT_POSITION[] pBegPosition,
134 TEXT_POSITION[] pEndPosition) {
135 Debug.WriteLine("DocumentContext.GetSourceRange");
136 pBegPosition[0].dwLine = line_;
137 pBegPosition[0].dwColumn = column_;
138 pEndPosition[0].dwLine = line_;
139 pEndPosition[0].dwColumn = column_;
140 return VSConstants.S_OK;
141 }
142
143 public int Compare(enum_DOCCONTEXT_COMPARE compare,
144 IDebugDocumentContext2[] rgpDocContextSet,
145 uint dwDocContextSetLen,
146 out uint pdwDocContext) {
147 Debug.WriteLine("DocumentContext.Compare");
148 throw new NotImplementedException();
149 }
150
151 public int Seek(int nCount, out IDebugDocumentContext2 ppDocContext) {
152 Debug.WriteLine("DocumentContext.Seek");
153
154 // Seek only needs to be implemented if we're trying to support a
155 // nontraditional document format.
156 ppDocContext = null;
157 return VSConstants.E_NOTIMPL;
158 }
159
160 #endregion
161
162 #region Private Implementation
163
164 readonly List<CodeContext> codeContexts_ = new List<CodeContext>();
165 uint column_;
166 uint line_;
167 string path_;
168
169 #endregion
170 }
171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698