~ubuntu-branches/ubuntu/lucid/monodevelop/lucid

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-02-02 11:39:59 UTC
  • mfrom: (1.2.6 upstream) (1.3.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100202113959-s4exdz7er7igylz2
Tags: 2.2.1+dfsg-1
* New upstream release
* debian/control:
  + Standards version 3.8.4 (no changes needed)
* debian/patches/remove_support_for_non_debian_functionality.patch,
  debian/patches/remove_support_for_soft_debugger.patch,
  debian/patches/remove_support_for_moonlight.patch,
  debian/rules:
  + Split patch into two pieces, to make it easier to enable either
    SDB or Moonlight support with a rebuild
* debian/monodevelop-moonlight.install,
  debian/monodevelop-debugger-sdb.install,
  debian/control:
  + Create packaging data for the Soft Debugger addin and Moonlight addin -
    and comment them out of debian/control as we can't provide them on
    Debian for now

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
                
69
69
                TaskStore comments = new TaskStore ();
70
70
                Dictionary<string, TaskPriority> priorities = new Dictionary<string, TaskPriority> ();
 
71
                HashSet<Solution> loadedSlns = new HashSet<Solution> ();
71
72
 
72
73
                public CommentTasksView ()
73
74
                {
128
129
                        col.Clicked += new EventHandler (Resort);
129
130
 
130
131
                        LoadColumnsVisibility ();
 
132
                        
 
133
                        comments.BeginTaskUpdates ();
 
134
                        try {
 
135
                                foreach (var item in IdeApp.Workspace.Items) {
 
136
                                        LoadWorkspaceItemContents (item);
 
137
                                }
 
138
                        } finally {
 
139
                                comments.EndTaskUpdates ();
 
140
                        }
131
141
 
132
142
                        comments.TasksAdded += (TaskEventHandler) DispatchService.GuiDispatch (new TaskEventHandler (GeneratedTaskAdded));
133
143
                        comments.TasksRemoved += (TaskEventHandler) DispatchService.GuiDispatch (new TaskEventHandler (GeneratedTaskRemoved));
134
144
 
135
145
                        PropertyService.PropertyChanged += (EventHandler<PropertyChangedEventArgs>) DispatchService.GuiDispatch (new EventHandler<PropertyChangedEventArgs> (OnPropertyUpdated));
136
 
 
 
146
                        
137
147
                        CreateMenu ();
138
148
                        
139
149
                        // Initialize with existing tags.
140
 
                        foreach (Task t in comments) 
 
150
                        foreach (Task t in comments)
141
151
                                AddGeneratedTask (t);
142
152
                }
143
153
 
170
180
                {
171
181
                        comments.BeginTaskUpdates ();
172
182
                        try {
173
 
                                Solution sol = e.Item as Solution;
174
 
                                if (sol != null) {
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)
179
 
                                                        continue;
180
 
                                                foreach (ProjectFile file in p.Files) {
181
 
                                                        IList<Tag> tags = pContext.GetSpecialComments (file.Name);
182
 
                                                        if (tags !=null)
183
 
                                                                UpdateCommentTags (sol, file.Name, tags);
184
 
                                                }
185
 
                                        }
186
 
                                }
 
183
                                LoadWorkspaceItemContents (e.Item);
187
184
                        }
188
185
                        finally {
189
186
                                comments.EndTaskUpdates ();
190
187
                        }
191
188
                }
192
189
                
 
190
                void LoadWorkspaceItemContents (WorkspaceItem wob)
 
191
                {
 
192
                        foreach (var sln in wob.GetAllSolutions ())
 
193
                                LoadSolutionContents (sln);
 
194
                }
 
195
                
 
196
                void LoadSolutionContents (Solution sln)
 
197
                {
 
198
                        loadedSlns.Add (sln);
 
199
                        
 
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)
 
204
                                        continue;
 
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);
 
209
                                }
 
210
                        }
 
211
                }
 
212
                
193
213
                void OnWorkspaceItemUnloaded (object sender, WorkspaceItemEventArgs e)
194
214
                {
 
215
                        foreach (var sln in e.Item.GetAllSolutions ())
 
216
                                loadedSlns.Remove (sln);
195
217
                        comments.RemoveItemTasks (e.Item, true);
196
218
                }               
197
219
 
198
220
                void OnCommentTasksChanged (object sender, CommentTasksChangedEventArgs e)
199
221
                {
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);
202
227
                }
203
228
                
204
229
                void OnCommentTagsChanged (object sender, EventArgs e)
206
231
                        ReloadPriorities ();
207
232
                }
208
233
                
209
 
                void UpdateCommentTags (IWorkspaceObject wob, FilePath fileName, IEnumerable<Tag> tagComments)
 
234
                void UpdateCommentTags (Solution wob, FilePath fileName, IEnumerable<Tag> tagComments)
210
235
                {
211
236
                        if (fileName == FilePath.Null)
212
237
                                return;
218
243
                                foreach (Tag tag in tagComments) {
219
244
                                        if (!priorities.ContainsKey (tag.Key))
220
245
                                                continue;
221
 
                                        Task t = new Task (fileName,
222
 
                                                              tag.Key + tag.Text,
223
 
                                                              tag.Region.Start.Column - 1,
224
 
                                                              tag.Region.Start.Line,
225
 
                                                              TaskSeverity.Information, 
226
 
                                                              priorities[tag.Key],
227
 
                                                              wob);
 
246
                                        
 
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;
 
254
                                                else
 
255
                                                        desc = tag.Key + ": " + desc;
 
256
                                        }
 
257
                                        
 
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);
229
261
                                }
230
262
                        }