| 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 } | 323 } |
| 324 | 324 |
| 325 return path.relative(resourceUri.path, from: entryDir); | 325 return path.relative(resourceUri.path, from: entryDir); |
| 326 } | 326 } |
| 327 | 327 |
| 328 /// Given an annotated [node] and a [test] function, returns the first matching | 328 /// Given an annotated [node] and a [test] function, returns the first matching |
| 329 /// constant valued annotation. | 329 /// constant valued annotation. |
| 330 /// | 330 /// |
| 331 /// For example if we had the ClassDeclaration node for `FontElement`: | 331 /// For example if we had the ClassDeclaration node for `FontElement`: |
| 332 /// | 332 /// |
| 333 /// @JsName('HTMLFontElement') | 333 /// @js.JS('HTMLFontElement') |
| 334 /// @deprecated | 334 /// @deprecated |
| 335 /// class FontElement { ... } | 335 /// class FontElement { ... } |
| 336 /// | 336 /// |
| 337 /// We could match `@deprecated` with a test function like: | 337 /// We could match `@deprecated` with a test function like: |
| 338 /// | 338 /// |
| 339 /// (v) => v.type.name == 'Deprecated' && v.type.element.library.isDartCore | 339 /// (v) => v.type.name == 'Deprecated' && v.type.element.library.isDartCore |
| 340 /// | 340 /// |
| 341 DartObject findAnnotation(Element element, bool test(DartObject value)) { | 341 DartObject findAnnotation(Element element, bool test(DartObject value)) { |
| 342 for (var metadata in element.metadata) { | 342 for (var metadata in element.metadata) { |
| 343 var value = metadata.constantValue; | 343 var value = metadata.constantValue; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 | 422 |
| 423 bool isInlineJS(Element e) => e is FunctionElement && | 423 bool isInlineJS(Element e) => e is FunctionElement && |
| 424 e.library.source.uri.toString() == 'dart:_foreign_helper' && | 424 e.library.source.uri.toString() == 'dart:_foreign_helper' && |
| 425 e.name == 'JS'; | 425 e.name == 'JS'; |
| 426 | 426 |
| 427 bool isDartMathMinMax(Element e) => e is FunctionElement && | 427 bool isDartMathMinMax(Element e) => e is FunctionElement && |
| 428 e.library.source.uri.toString() == 'dart:math' && | 428 e.library.source.uri.toString() == 'dart:math' && |
| 429 (e.name == 'min' || e.name == 'max'); | 429 (e.name == 'min' || e.name == 'max'); |
| OLD | NEW |