OLD | NEW |
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 source_map_builder; | 5 library source_map_builder; |
6 | 6 |
7 import 'util/util.dart'; | 7 import 'util/util.dart'; |
8 import 'scanner/scannerlib.dart' show Token; | 8 import 'scanner/scannerlib.dart' show Token; |
9 import 'source_file.dart'; | 9 import 'source_file.dart'; |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 void addMapping(int targetOffset, SourceFileLocation sourceLocation) { | 51 void addMapping(int targetOffset, SourceFileLocation sourceLocation) { |
52 entries.add(new SourceMapEntry(sourceLocation, targetOffset)); | 52 entries.add(new SourceMapEntry(sourceLocation, targetOffset)); |
53 } | 53 } |
54 | 54 |
55 void printStringListOn(List<String> strings, StringBuffer buffer) { | 55 void printStringListOn(List<String> strings, StringBuffer buffer) { |
56 bool first = true; | 56 bool first = true; |
57 buffer.add('['); | 57 buffer.add('['); |
58 for (String string in strings) { | 58 for (String string in strings) { |
59 if (!first) buffer.add(','); | 59 if (!first) buffer.add(','); |
60 buffer.add("'"); | 60 buffer.add('"'); |
61 writeJsonEscapedCharsOn(string.charCodes.iterator(), buffer, null); | 61 writeJsonEscapedCharsOn(string.charCodes.iterator(), buffer, null); |
62 buffer.add("'"); | 62 buffer.add('"'); |
63 first = false; | 63 first = false; |
64 } | 64 } |
65 buffer.add(']'); | 65 buffer.add(']'); |
66 } | 66 } |
67 | 67 |
68 String build(SourceFile targetFile) { | 68 String build(SourceFile targetFile) { |
69 StringBuffer buffer = new StringBuffer(); | 69 StringBuffer buffer = new StringBuffer(); |
70 buffer.add('{\n'); | 70 buffer.add('{\n'); |
71 buffer.add(' "version": 3,\n'); | 71 buffer.add(' "version": 3,\n'); |
72 buffer.add(' "mappings": "'); | 72 buffer.add(' "mappings": "'); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 int getColumn() => sourceFile.getColumn(getLine(), token.charOffset); | 180 int getColumn() => sourceFile.getColumn(getLine(), token.charOffset); |
181 | 181 |
182 String getSourceName() { | 182 String getSourceName() { |
183 if (token.isIdentifier()) return token.slowToString(); | 183 if (token.isIdentifier()) return token.slowToString(); |
184 return null; | 184 return null; |
185 } | 185 } |
186 | 186 |
187 bool isValid() => token.charOffset < sourceFile.text.length; | 187 bool isValid() => token.charOffset < sourceFile.text.length; |
188 } | 188 } |
OLD | NEW |