OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 // Utility function shared between different parts of analyzer2dart. | |
6 | |
7 library analyzer2dart.util; | |
8 | |
9 import 'package:analyzer/analyzer.dart'; | |
10 import 'package:analyzer/src/generated/source.dart'; | |
11 import 'package:compiler/src/elements/elements.dart' show PublicName; | |
12 import 'package:compiler/src/universe/universe.dart'; | |
13 import 'package:compiler/src/io/source_file.dart'; | |
14 | |
15 CallStructure createCallStructureFromMethodInvocation(ArgumentList node) { | |
16 int arity = 0; | |
17 List<String> namedArguments = <String>[]; | |
18 for (Expression argument in node.arguments) { | |
19 if (argument is NamedExpression) { | |
20 namedArguments.add(argument.name.label.name); | |
21 } else { | |
22 arity++; | |
23 } | |
24 } | |
25 return new CallStructure(arity, namedArguments); | |
26 } | |
27 | |
28 Selector createSelectorFromMethodInvocation(ArgumentList node, | |
29 String name) { | |
30 CallStructure callStructure = createCallStructureFromMethodInvocation(node); | |
31 // TODO(johnniwinther): Support private names. | |
32 return new Selector(SelectorKind.CALL, new PublicName(name), callStructure); | |
33 } | |
34 | |
35 /// Prints [message] together with source code pointed to by [node] from | |
36 /// [source]. | |
37 void reportSourceMessage(Source source, AstNode node, String message) { | |
38 SourceFile sourceFile = | |
39 new StringSourceFile.fromName(source.fullName, source.contents.data); | |
40 | |
41 print(sourceFile.getLocationMessage(message, node.offset, node.end)); | |
42 } | |
OLD | NEW |