| 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 /// Holds a couple utility functions used at various places in the system. | 5 /// Holds a couple utility functions used at various places in the system. |
| 6 library dev_compiler.src.utils; | 6 library dev_compiler.src.utils; |
| 7 | 7 |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 if (result.startsWith(new RegExp('[0-9]')) || invalidVariableName(result)) { | 72 if (result.startsWith(new RegExp('[0-9]')) || invalidVariableName(result)) { |
| 73 return '\$$result'; | 73 return '\$$result'; |
| 74 } | 74 } |
| 75 return result; | 75 return result; |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Invalid characters for identifiers, which would need to be escaped. | 78 // Invalid characters for identifiers, which would need to be escaped. |
| 79 final _invalidCharInIdentifier = new RegExp(r'[^A-Za-z_$0-9]'); | 79 final _invalidCharInIdentifier = new RegExp(r'[^A-Za-z_$0-9]'); |
| 80 | 80 |
| 81 /// Returns all libraries transitively imported or exported from [start]. | 81 /// Returns all libraries transitively imported or exported from [start]. |
| 82 Iterable<LibraryElement> reachableLibraries(LibraryElement start) { | 82 List<LibraryElement> reachableLibraries(LibraryElement start) { |
| 83 var results = <LibraryElement>[]; | 83 var results = <LibraryElement>[]; |
| 84 var seen = new Set(); | 84 var seen = new Set(); |
| 85 void find(LibraryElement lib) { | 85 void find(LibraryElement lib) { |
| 86 if (seen.contains(lib)) return; | 86 if (seen.contains(lib)) return; |
| 87 seen.add(lib); | 87 seen.add(lib); |
| 88 results.add(lib); | 88 results.add(lib); |
| 89 lib.importedLibraries.forEach(find); | 89 lib.importedLibraries.forEach(find); |
| 90 lib.exportedLibraries.forEach(find); | 90 lib.exportedLibraries.forEach(find); |
| 91 } | 91 } |
| 92 find(start); | 92 find(start); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 lineInfo.getLocation(++lineEnd).lineNumber == lineNum); | 462 lineInfo.getLocation(++lineEnd).lineNumber == lineNum); |
| 463 | 463 |
| 464 var text = content.substring(start, end); | 464 var text = content.substring(start, end); |
| 465 var lineText = content.substring(lineStart, lineEnd); | 465 var lineText = content.substring(lineStart, lineEnd); |
| 466 return new SourceSpanWithContext(startLoc, endLoc, text, lineText); | 466 return new SourceSpanWithContext(startLoc, endLoc, text, lineText); |
| 467 } | 467 } |
| 468 | 468 |
| 469 bool isInlineJS(Element e) => e is FunctionElement && | 469 bool isInlineJS(Element e) => e is FunctionElement && |
| 470 e.library.source.uri.toString() == 'dart:_foreign_helper' && | 470 e.library.source.uri.toString() == 'dart:_foreign_helper' && |
| 471 e.name == 'JS'; | 471 e.name == 'JS'; |
| OLD | NEW |