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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart

Issue 11726005: Dartdoc comments retrieved as metadata through dart2js mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library mirrors_util; 5 library mirrors_util;
6 6
7 // TODO(rnystrom): Use "package:" URL (#4968). 7 // TODO(rnystrom): Use "package:" URL (#4968).
8 import 'mirrors.dart'; 8 import 'mirrors.dart';
9 9
10 //------------------------------------------------------------------------------ 10 //------------------------------------------------------------------------------
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 type = object; 106 type = object;
107 object = null; 107 object = null;
108 return type; 108 return type;
109 } else { 109 } else {
110 return push(queue.removeFirst()); 110 return push(queue.removeFirst());
111 } 111 }
112 } 112 }
113 113
114 bool get hasNext => !queue.isEmpty || object != null; 114 bool get hasNext => !queue.isEmpty || object != null;
115 } 115 }
116
117 final RegExp _singleLineCommentStart = new RegExp(r'^///? ?(.*)');
118 final RegExp _multiLineCommentStartEnd =
119 new RegExp(r'^/\*\*? ?([\s\S]*)\*/$', multiLine: true);
120 final RegExp _multiLineCommentLineStart = new RegExp(r'^[ \t]*\* ?(.*)');
121
122 /**
123 * Pulls the raw text out of a comment (i.e. removes the comment
124 * characters).
125 */
126 String stripComment(String comment) {
127 Match match = _singleLineCommentStart.firstMatch(comment);
128 if (match != null) {
129 return match[1];
130 }
131 match = _multiLineCommentStartEnd.firstMatch(comment);
132 if (match != null) {
133 comment = match[1];
134 bool first = true;
135 var sb = new StringBuffer();
136 Iterator<String> lines = comment.split('\n').iterator();
137 while (lines.hasNext) {
ahe 2013/01/08 11:59:43 lines.moveNext()
Johnni Winther 2013/01/08 13:39:46 Changed to use List and index.
138 String line = lines.next();
139 if (first) {
140 sb.add(line); // Add the first line unprocessed.
141 first = false;
142 continue;
143 }
144 sb.add('\n');
145 match = _multiLineCommentLineStart.firstMatch(line);
146 if (match != null) {
147 sb.add(match[1]);
148 } else if (lines.hasNext || !line.trim().isEmpty) {
ahe 2013/01/08 11:59:43 This wont work with the new iterators :-(
Johnni Winther 2013/01/08 13:39:46 Refactored.
149 // Do not add the last line if it only contains white space.
150 // This interprets cases like
151 // /*
152 // * Foo
153 // */
154 // as "\nFoo\n" and not as "\nFoo\n ".
155 sb.add(line);
156 }
157 }
158 return sb.toString();
159 }
160 throw new ArgumentError('Invalid comment $comment');
161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698