| OLD | NEW | 
|---|
| 1 // Copyright (c) 2015, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Helper for creating HTML visualization of the source map information | 5 /// Helper for creating HTML visualization of the source map information | 
| 6 /// generated by a [SourceMapProcessor]. | 6 /// generated by a [SourceMapProcessor]. | 
| 7 | 7 | 
| 8 library sourcemap.html.helper; | 8 library sourcemap.html.helper; | 
| 9 | 9 | 
| 10 import 'dart:convert'; | 10 import 'dart:convert'; | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 102       return sourceLocationIndexMap.length; | 102       return sourceLocationIndexMap.length; | 
| 103     }); | 103     }); | 
| 104   } | 104   } | 
| 105 | 105 | 
| 106   int getIndex(SourceLocation sourceLocation) { | 106   int getIndex(SourceLocation sourceLocation) { | 
| 107     return sourceLocationIndexMap[sourceLocation]; | 107     return sourceLocationIndexMap[sourceLocation]; | 
| 108   } | 108   } | 
| 109 } | 109 } | 
| 110 | 110 | 
| 111 abstract class CssColorScheme { | 111 abstract class CssColorScheme { | 
| 112   String singleLocationToCssColor(var id); | 112   String singleLocationToCssColor(int id); | 
| 113 | 113 | 
| 114   String multiLocationToCssColor(List ids); | 114   String multiLocationToCssColor(List<int> ids); | 
| 115 | 115 | 
| 116   bool get showLocationAsSpan; | 116   bool get showLocationAsSpan; | 
| 117 } | 117 } | 
| 118 | 118 | 
| 119 class CustomColorScheme implements CssColorScheme { | 119 class CustomColorScheme implements CssColorScheme { | 
| 120   final bool showLocationAsSpan; | 120   final bool showLocationAsSpan; | 
| 121   final Function single; | 121   final Function single; | 
| 122   final Function multi; | 122   final Function multi; | 
| 123 | 123 | 
| 124   CustomColorScheme( | 124   CustomColorScheme( | 
| 125       {this.showLocationAsSpan: false, | 125       {this.showLocationAsSpan: false, | 
| 126       String this.single(var id), | 126       String this.single(int id), | 
| 127       String this.multi(List ids)}); | 127       String this.multi(List<int> ids)}); | 
| 128 | 128 | 
| 129   String singleLocationToCssColor(var id) => single != null ? single(id) : null; | 129   String singleLocationToCssColor(int id) => single != null ? single(id) : null; | 
| 130 | 130 | 
| 131   String multiLocationToCssColor(List ids) => multi != null ? multi(ids) : null; | 131   String multiLocationToCssColor(List<int> ids) => | 
|  | 132       multi != null ? multi(ids) : null; | 
| 132 } | 133 } | 
| 133 | 134 | 
| 134 class PatternCssColorScheme implements CssColorScheme { | 135 class PatternCssColorScheme implements CssColorScheme { | 
| 135   const PatternCssColorScheme(); | 136   const PatternCssColorScheme(); | 
| 136 | 137 | 
| 137   bool get showLocationAsSpan => true; | 138   bool get showLocationAsSpan => true; | 
| 138 | 139 | 
| 139   String singleLocationToCssColor(int index) { | 140   String singleLocationToCssColor(int index) { | 
| 140     return "background:${toPattern(index)};"; | 141     return "background:${toPattern(index)};"; | 
| 141   } | 142   } | 
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 218     return convertAnnotatedCodeToHtml(text, annotations, | 219     return convertAnnotatedCodeToHtml(text, annotations, | 
| 219         colorScheme: colorScheme, | 220         colorScheme: colorScheme, | 
| 220         elementScheme: new HighlightLinkScheme(name), | 221         elementScheme: new HighlightLinkScheme(name), | 
| 221         windowSize: 3); | 222         windowSize: 3); | 
| 222   } | 223   } | 
| 223 } | 224 } | 
| 224 | 225 | 
| 225 class ElementScheme { | 226 class ElementScheme { | 
| 226   const ElementScheme(); | 227   const ElementScheme(); | 
| 227 | 228 | 
| 228   String getName(var id, Set ids) => null; | 229   String getName(int id, Set<int> ids) => null; | 
| 229   String getHref(var id, Set ids) => null; | 230   String getHref(int id, Set<int> ids) => null; | 
| 230   String onClick(var id, Set ids) => null; | 231   String onClick(int id, Set<int> ids) => null; | 
| 231   String onMouseOver(var id, Set ids) => null; | 232   String onMouseOver(int id, Set<int> ids) => null; | 
| 232   String onMouseOut(var id, Set ids) => null; | 233   String onMouseOut(int id, Set<int> ids) => null; | 
| 233 } | 234 } | 
| 234 | 235 | 
| 235 class HighlightLinkScheme implements ElementScheme { | 236 class HighlightLinkScheme implements ElementScheme { | 
| 236   final String name; | 237   final String name; | 
| 237 | 238 | 
| 238   HighlightLinkScheme(this.name); | 239   HighlightLinkScheme(this.name); | 
| 239 | 240 | 
| 240   @override | 241   @override | 
| 241   String getName(int id, Set<int> indices) { | 242   String getName(int id, Set<int> indices) { | 
| 242     return 'js$id'; | 243     return 'js$id'; | 
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 618       String dartCode = truncate(codePoint.dartCode, 50); | 619       String dartCode = truncate(codePoint.dartCode, 50); | 
| 619       buffer.write('<td class="code">${dartCode}</td>'); | 620       buffer.write('<td class="code">${dartCode}</td>'); | 
| 620       buffer.write('<td>${escape(codePoint.sourceLocation.shortText)}</td>'); | 621       buffer.write('<td>${escape(codePoint.sourceLocation.shortText)}</td>'); | 
| 621     } | 622     } | 
| 622     buffer.write('</tr>'); | 623     buffer.write('</tr>'); | 
| 623   }); | 624   }); | 
| 624   buffer.write('</table>'); | 625   buffer.write('</table>'); | 
| 625 | 626 | 
| 626   return buffer.toString(); | 627   return buffer.toString(); | 
| 627 } | 628 } | 
| OLD | NEW | 
|---|