~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
                                        if (!NeedsDocumentation (data, member))
91
91
                                                continue;
92
92
                                        int offset;
93
 
                                        var ctx = (unit.ParsedFile as CSharpParsedFile).GetTypeResolveContext (document.Compilation, member.Region.Begin);
 
93
                                        var ctx = (unit.ParsedFile as CSharpUnresolvedFile).GetTypeResolveContext (document.Compilation, member.Region.Begin);
94
94
                                        var resolvedMember = member.CreateResolved (ctx);
95
95
                                        string indent = GetIndent (data, resolvedMember, out offset);
96
96
                                        string documentation = GenerateDocumentation (data, resolvedMember, indent);
107
107
                
108
108
                static bool NeedsDocumentation (TextEditorData data, IUnresolvedEntity member)
109
109
                {
110
 
                        int lineNr = member.Region.BeginLine;
 
110
                        int lineNr = member.Region.BeginLine - 1;
111
111
                        DocumentLine line;
112
112
                        do {
113
113
                                line = data.Document.GetLine (lineNr--);
114
114
                        } while (lineNr > 0 && data.Document.GetLineIndent (line).Length == line.Length);
115
 
                        int start = data.Document.GetLineIndent (line).Length;
116
 
                        if (start + 3 < line.Length && data.Document.GetTextAt (start, 3) == "///")
117
 
                                return false;
118
 
                        return true;
 
115
                        return !data.Document.GetTextAt (line).TrimStart ().StartsWith ("///", StringComparison.Ordinal);
119
116
                }
120
117
                
121
118
                static string GetIndent (TextEditorData data, IEntity member, out int offset)
154
151
                                foreach (var attr in section.Attributes) {
155
152
                                        result.Append (" ");
156
153
                                        result.Append (attr.Key);
157
 
                                        result.Append ("='");
 
154
                                        result.Append ("=\"");
158
155
                                        result.Append (attr.Value);
159
 
                                        result.Append ("'");
160
 
                                }
161
 
                                result.AppendLine (">");
162
 
                                
163
 
                                result.Append (indent);
164
 
                                result.Append (prefix);
 
156
                                        result.Append ("\"");
 
157
                                }
 
158
                                if (section.Name == "summary")
 
159
                                {
 
160
                                        result.AppendLine (">");
 
161
                                        result.Append (indent);
 
162
                                        result.Append (prefix);
 
163
                                }
 
164
                                else
 
165
                                {
 
166
                                        result.Append (">");
 
167
                                }
165
168
                                bool inTag = false;
166
169
                                int column = indent.Length + prefix.Length;
167
170
                                StringBuilder curWord = new StringBuilder ();
170
173
                                                inTag = true;
171
174
                                        if (ch == '>')
172
175
                                                inTag = false;
173
 
                                        if (!inTag && char.IsWhiteSpace (ch)) {
 
176
 
 
177
                                        if (ch =='\n') {
 
178
                                                result.Append (curWord.ToString ());
 
179
                                                curWord.Length = 0;
 
180
 
 
181
                                                result.AppendLine ();
 
182
                                                result.Append (indent);
 
183
                                                result.Append (prefix);
 
184
                                                column = indent.Length + prefix .Length;
 
185
                                        } else if (!inTag && char.IsWhiteSpace (ch)) {
174
186
                                                if (column + curWord.Length > 120) {
175
187
                                                        result.Length--; // trunk last char white space.
176
188
                                                        result.AppendLine ();
186
198
                                                curWord.Append (ch);
187
199
                                        }
188
200
                                }
189
 
                                result.AppendLine (curWord.ToString ());
190
 
                                
191
 
                                result.Append (indent);
192
 
                                result.Append (prefix);
 
201
                                if (section.Name == "summary")
 
202
                                {
 
203
                                        result.AppendLine(curWord.ToString ());
 
204
                                        result.Append(indent);
 
205
                                        result.Append(prefix);
 
206
                                }
 
207
                                else
 
208
                                {
 
209
                                        result.Append(curWord.ToString ());
 
210
                                }
 
211
 
193
212
                                result.Append ("</");
194
213
                                result.Append (section.Name);
195
214
                                result.Append (">");
220
239
                                foreach (var attr in section.Attributes) {
221
240
                                        result.Append (" ");
222
241
                                        result.Append (attr.Key);
223
 
                                        result.Append ("='");
 
242
                                        result.Append ("=\"");
224
243
                                        result.Append (attr.Value);
225
 
                                        result.Append ("'");
226
 
                                }
227
 
                                result.AppendLine (">");
228
 
                                
229
 
                                result.Append (indent);
230
 
                                result.Append ("/// ");
 
244
                                        result.Append ("\"");
 
245
                                }
 
246
                                if (section.Name == "summary")
 
247
                                {
 
248
                                        result.AppendLine (">");
 
249
                                        result.Append (indent);
 
250
                                        result.Append ("/// ");
 
251
                                        result.AppendLine ();
 
252
                                        result.Append (indent);
 
253
                                        result.Append ("/// ");
 
254
                                }
 
255
                                else
 
256
                                {
 
257
                                        result.Append (">");
 
258
                                }
 
259
 
231
260
//                              bool inTag = false;
232
261
//                              int column = indent.Length + "/// ".Length;
233
 
                                
234
 
                                result.AppendLine ();
235
 
                                result.Append (indent);
236
 
                                result.Append ("/// </");
 
262
 
 
263
                                result.Append ("</");
237
264
                                result.Append (section.Name);
238
265
                                result.Append (">");
239
266
                        }