OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 sourcemap.html_parts; | 5 library sourcemap.html_parts; |
6 | 6 |
7 import 'sourcemap_html_helper.dart'; | 7 import 'sourcemap_html_helper.dart'; |
8 | 8 |
9 class Annotation { | 9 class Annotation { |
10 final id; | 10 final id; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 return ConstHtmlPart.fromJson(json, strategy); | 155 return ConstHtmlPart.fromJson(json, strategy); |
156 case HtmlPartKind.NEWLINE: | 156 case HtmlPartKind.NEWLINE: |
157 return const NewLine(); | 157 return const NewLine(); |
158 case HtmlPartKind.TEXT: | 158 case HtmlPartKind.TEXT: |
159 return HtmlText.fromJson(json, strategy); | 159 return HtmlText.fromJson(json, strategy); |
160 case HtmlPartKind.TAG: | 160 case HtmlPartKind.TAG: |
161 return TagPart.fromJson(json, strategy); | 161 return TagPart.fromJson(json, strategy); |
162 case HtmlPartKind.LINE_NUMBER: | 162 case HtmlPartKind.LINE_NUMBER: |
163 return LineNumber.fromJson(json, strategy); | 163 return LineNumber.fromJson(json, strategy); |
164 } | 164 } |
| 165 return null; |
165 } | 166 } |
166 } | 167 } |
167 } | 168 } |
168 | 169 |
169 class ConstHtmlPart implements HtmlPart { | 170 class ConstHtmlPart implements HtmlPart { |
170 final String html; | 171 final String html; |
171 | 172 |
172 const ConstHtmlPart(this.html); | 173 const ConstHtmlPart(this.html); |
173 | 174 |
174 HtmlPartKind get kind => HtmlPartKind.CONST; | 175 HtmlPartKind get kind => HtmlPartKind.CONST; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 AnnotationData annotationDataForSpan = | 313 AnnotationData annotationDataForSpan = |
313 context.getAnnotationData(included, forSpan: true); | 314 context.getAnnotationData(included, forSpan: true); |
314 | 315 |
315 String head = subsequentCode; | 316 String head = subsequentCode; |
316 String tail = ''; | 317 String tail = ''; |
317 if (subsequentCode.length > 1) { | 318 if (subsequentCode.length > 1) { |
318 head = subsequentCode.substring(0, 1); | 319 head = subsequentCode.substring(0, 1); |
319 tail = subsequentCode.substring(1); | 320 tail = subsequentCode.substring(1); |
320 } | 321 } |
321 | 322 |
322 void addForSpan(AnnotationData data) { | |
323 htmlParts.add(new TagPart(data.tag, | |
324 properties: data.properties, | |
325 content: [new HtmlText(subsequentCode)])); | |
326 } | |
327 | |
328 if (annotationData != null && annotationDataForSpan != null) { | 323 if (annotationData != null && annotationDataForSpan != null) { |
329 htmlParts.add(new TagPart(annotationDataForSpan.tag, | 324 htmlParts.add(new TagPart(annotationDataForSpan.tag, |
330 properties: annotationDataForSpan.properties, | 325 properties: annotationDataForSpan.properties, |
331 content: [ | 326 content: [ |
332 new TagPart(annotationData.tag, | 327 new TagPart(annotationData.tag, |
333 properties: annotationData.properties, | 328 properties: annotationData.properties, |
334 content: [new HtmlText(head)]), | 329 content: [new HtmlText(head)]), |
335 new HtmlText(tail) | 330 new HtmlText(tail) |
336 ])); | 331 ])); |
337 } else if (annotationDataForSpan != null) { | 332 } else if (annotationDataForSpan != null) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 | 477 |
483 Annotation decodeAnnotation(Map json) { | 478 Annotation decodeAnnotation(Map json) { |
484 return new Annotation(json['id'], json['codeOffset'], json['title'], | 479 return new Annotation(json['id'], json['codeOffset'], json['title'], |
485 data: json['data']); | 480 data: json['data']); |
486 } | 481 } |
487 | 482 |
488 encodeLineAnnotation(lineAnnotation) => lineAnnotation; | 483 encodeLineAnnotation(lineAnnotation) => lineAnnotation; |
489 | 484 |
490 decodeLineAnnotation(json) => json; | 485 decodeLineAnnotation(json) => json; |
491 } | 486 } |
OLD | NEW |