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; |
11 import 'package:analyzer/src/generated/ast.dart' | 11 import 'package:analyzer/src/generated/ast.dart' |
12 show | 12 show |
13 ImportDirective, | 13 ImportDirective, |
14 ExportDirective, | 14 ExportDirective, |
15 PartDirective, | 15 PartDirective, |
16 CompilationUnit, | 16 CompilationUnit, |
17 Identifier, | 17 Identifier, |
18 AnnotatedNode, | 18 AnnotatedNode, |
19 AstNode, | 19 AstNode, |
20 Expression, | 20 Expression, |
21 SimpleIdentifier, | 21 SimpleIdentifier, |
22 MethodInvocation; | 22 MethodInvocation; |
23 import 'package:analyzer/src/generated/constant.dart' show DartObject; | 23 import 'package:analyzer/src/generated/constant.dart' show DartObject; |
24 import 'package:analyzer/src/generated/element.dart'; | 24 import 'package:analyzer/src/generated/element.dart'; |
25 import 'package:analyzer/src/generated/engine.dart' | 25 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
26 show ParseDartTask, AnalysisContext; | |
27 import 'package:analyzer/src/generated/error.dart' show ErrorCode; | 26 import 'package:analyzer/src/generated/error.dart' show ErrorCode; |
| 27 import 'package:analyzer/src/task/dart.dart' show ParseDartTask; |
28 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; | 28 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; |
29 import 'package:analyzer/src/generated/source.dart' show LineInfo, Source; | 29 import 'package:analyzer/src/generated/source.dart' show LineInfo, Source; |
30 import 'package:analyzer/analyzer.dart' show parseDirectives; | 30 import 'package:analyzer/analyzer.dart' show parseDirectives; |
31 import 'package:crypto/crypto.dart' show CryptoUtils, MD5; | 31 import 'package:crypto/crypto.dart' show CryptoUtils, MD5; |
32 import 'package:source_span/source_span.dart'; | 32 import 'package:source_span/source_span.dart'; |
33 | 33 |
34 import 'codegen/js_names.dart' show invalidVariableName; | 34 import 'codegen/js_names.dart' show invalidVariableName; |
35 | 35 |
36 bool isDartPrivateLibrary(LibraryElement library) { | 36 bool isDartPrivateLibrary(LibraryElement library) { |
37 var uri = library.source.uri; | 37 var uri = library.source.uri; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 final prefix = 'dev_compiler.'; | 413 final prefix = 'dev_compiler.'; |
414 if (name.startsWith(prefix)) { | 414 if (name.startsWith(prefix)) { |
415 return name.substring(prefix.length); | 415 return name.substring(prefix.length); |
416 } else { | 416 } else { |
417 // TODO(jmesserly): this is for backwards compat, but not sure it's very | 417 // TODO(jmesserly): this is for backwards compat, but not sure it's very |
418 // useful to log this. | 418 // useful to log this. |
419 return 'AnalyzerMessage'; | 419 return 'AnalyzerMessage'; |
420 } | 420 } |
421 } | 421 } |
422 | 422 |
423 bool isInlineJS(Element e) => e is FunctionElement && | 423 bool isInlineJS(Element e) => |
| 424 e is FunctionElement && |
424 e.library.source.uri.toString() == 'dart:_foreign_helper' && | 425 e.library.source.uri.toString() == 'dart:_foreign_helper' && |
425 e.name == 'JS'; | 426 e.name == 'JS'; |
426 | 427 |
427 bool isDartMathMinMax(Element e) => e is FunctionElement && | 428 bool isDartMathMinMax(Element e) => |
| 429 e is FunctionElement && |
428 e.library.source.uri.toString() == 'dart:math' && | 430 e.library.source.uri.toString() == 'dart:math' && |
429 (e.name == 'min' || e.name == 'max'); | 431 (e.name == 'min' || e.name == 'max'); |
OLD | NEW |