OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // Utility function shared between different parts of analyzer2dart. | 5 // Utility function shared between different parts of analyzer2dart. |
6 | 6 |
7 library analyzer2dart.util; | 7 library analyzer2dart.util; |
8 | 8 |
9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
11 import 'package:compiler/implementation/universe/universe.dart'; | 11 import 'package:compiler/src/universe/universe.dart'; |
12 import 'package:compiler/implementation/source_file.dart'; | 12 import 'package:compiler/src/source_file.dart'; |
13 | 13 |
14 Selector createSelectorFromMethodInvocation(ArgumentList node, | 14 Selector createSelectorFromMethodInvocation(ArgumentList node, |
15 String name) { | 15 String name) { |
16 int arity = 0; | 16 int arity = 0; |
17 List<String> namedArguments = <String>[]; | 17 List<String> namedArguments = <String>[]; |
18 for (Expression argument in node.arguments) { | 18 for (Expression argument in node.arguments) { |
19 if (argument is NamedExpression) { | 19 if (argument is NamedExpression) { |
20 namedArguments.add(argument.name.label.name); | 20 namedArguments.add(argument.name.label.name); |
21 } else { | 21 } else { |
22 arity++; | 22 arity++; |
23 } | 23 } |
24 } | 24 } |
25 return new Selector.call(name, null, arity, namedArguments); | 25 return new Selector.call(name, null, arity, namedArguments); |
26 } | 26 } |
27 | 27 |
28 /// Prints [message] together with source code pointed to by [node] from | 28 /// Prints [message] together with source code pointed to by [node] from |
29 /// [source]. | 29 /// [source]. |
30 void reportSourceMessage(Source source, AstNode node, String message) { | 30 void reportSourceMessage(Source source, AstNode node, String message) { |
31 SourceFile sourceFile = | 31 SourceFile sourceFile = |
32 new StringSourceFile(source.fullName, source.contents.data); | 32 new StringSourceFile(source.fullName, source.contents.data); |
33 | 33 |
34 print(sourceFile.getLocationMessage(message, node.offset, node.end)); | 34 print(sourceFile.getLocationMessage(message, node.offset, node.end)); |
35 } | 35 } |
OLD | NEW |