69
69
TaskStore comments = new TaskStore ();
70
70
Dictionary<string, TaskPriority> priorities = new Dictionary<string, TaskPriority> ();
71
HashSet<Solution> loadedSlns = new HashSet<Solution> ();
72
73
public CommentTasksView ()
128
129
col.Clicked += new EventHandler (Resort);
130
131
LoadColumnsVisibility ();
133
comments.BeginTaskUpdates ();
135
foreach (var item in IdeApp.Workspace.Items) {
136
LoadWorkspaceItemContents (item);
139
comments.EndTaskUpdates ();
132
142
comments.TasksAdded += (TaskEventHandler) DispatchService.GuiDispatch (new TaskEventHandler (GeneratedTaskAdded));
133
143
comments.TasksRemoved += (TaskEventHandler) DispatchService.GuiDispatch (new TaskEventHandler (GeneratedTaskRemoved));
135
145
PropertyService.PropertyChanged += (EventHandler<PropertyChangedEventArgs>) DispatchService.GuiDispatch (new EventHandler<PropertyChangedEventArgs> (OnPropertyUpdated));
139
149
// Initialize with existing tags.
140
foreach (Task t in comments)
150
foreach (Task t in comments)
141
151
AddGeneratedTask (t);
171
181
comments.BeginTaskUpdates ();
173
Solution sol = e.Item as Solution;
175
// Load all tags that are stored in pidb files
176
foreach (Project p in sol.GetAllProjects ()) {
177
ProjectDom pContext = ProjectDomService.GetProjectDom (p);
178
if (pContext == null)
180
foreach (ProjectFile file in p.Files) {
181
IList<Tag> tags = pContext.GetSpecialComments (file.Name);
183
UpdateCommentTags (sol, file.Name, tags);
183
LoadWorkspaceItemContents (e.Item);
189
186
comments.EndTaskUpdates ();
190
void LoadWorkspaceItemContents (WorkspaceItem wob)
192
foreach (var sln in wob.GetAllSolutions ())
193
LoadSolutionContents (sln);
196
void LoadSolutionContents (Solution sln)
198
loadedSlns.Add (sln);
200
// Load all tags that are stored in pidb files
201
foreach (Project p in sln.GetAllProjects ()) {
202
ProjectDom pContext = ProjectDomService.GetProjectDom (p);
203
if (pContext == null)
205
foreach (ProjectFile file in p.Files) {
206
IList<Tag> tags = pContext.GetSpecialComments (file.Name);
207
if (tags != null && tags.Count > 0)
208
UpdateCommentTags (sln, file.Name, tags);
193
213
void OnWorkspaceItemUnloaded (object sender, WorkspaceItemEventArgs e)
215
foreach (var sln in e.Item.GetAllSolutions ())
216
loadedSlns.Remove (sln);
195
217
comments.RemoveItemTasks (e.Item, true);
198
220
void OnCommentTasksChanged (object sender, CommentTasksChangedEventArgs e)
200
if (e.Project != null)
201
UpdateCommentTags (e.Project, e.FileName, e.TagComments);
222
//because of parse queueing, it's possible for this event to come in after the solution is closed
223
//so we track which solutions are currently open so that we don't leak memory by holding
224
// on to references to closed projects
225
if (e.Project != null && e.Project.ParentSolution != null && loadedSlns.Contains (e.Project.ParentSolution))
226
UpdateCommentTags (e.Project.ParentSolution, e.FileName, e.TagComments);
204
229
void OnCommentTagsChanged (object sender, EventArgs e)
206
231
ReloadPriorities ();
209
void UpdateCommentTags (IWorkspaceObject wob, FilePath fileName, IEnumerable<Tag> tagComments)
234
void UpdateCommentTags (Solution wob, FilePath fileName, IEnumerable<Tag> tagComments)
211
236
if (fileName == FilePath.Null)
218
243
foreach (Tag tag in tagComments) {
219
244
if (!priorities.ContainsKey (tag.Key))
221
Task t = new Task (fileName,
223
tag.Region.Start.Column - 1,
224
tag.Region.Start.Line,
225
TaskSeverity.Information,
247
//prepend the tag if it's not already there
248
string desc = tag.Text.Trim ();
249
if (!desc.StartsWith (tag.Key)) {
250
if (desc.StartsWith (":"))
251
desc = tag.Key + desc;
252
else if (tag.Key.EndsWith (":"))
253
desc = tag.Key + " " + desc;
255
desc = tag.Key + ": " + desc;
258
Task t = new Task (fileName, desc, tag.Region.Start.Column - 1, tag.Region.Start.Line,
259
TaskSeverity.Information, priorities[tag.Key], wob);
228
260
newTasks.Add (t);