OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library parser_helper; | 5 library parser_helper; |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 | 8 |
9 import 'package:compiler/src/elements/elements.dart'; | 9 import 'package:compiler/src/elements/elements.dart'; |
| 10 import 'package:compiler/src/elements/entities.dart'; |
10 import 'package:compiler/src/id_generator.dart'; | 11 import 'package:compiler/src/id_generator.dart'; |
11 import 'package:compiler/src/tree/tree.dart'; | 12 import 'package:compiler/src/tree/tree.dart'; |
12 import 'package:compiler/src/parser/element_listener.dart'; | 13 import 'package:compiler/src/parser/element_listener.dart'; |
13 import 'package:compiler/src/parser/node_listener.dart'; | 14 import 'package:compiler/src/parser/node_listener.dart'; |
14 import 'package:compiler/src/parser/diet_parser_task.dart'; | 15 import 'package:compiler/src/parser/diet_parser_task.dart'; |
15 import 'package:front_end/src/fasta/parser.dart' hide parse; | 16 import 'package:front_end/src/fasta/parser.dart' hide parse; |
16 import 'package:front_end/src/fasta/scanner.dart' hide scan; | 17 import 'package:front_end/src/fasta/scanner.dart' hide scan; |
17 import 'package:compiler/src/io/source_file.dart'; | 18 import 'package:compiler/src/io/source_file.dart'; |
18 import 'package:compiler/src/util/util.dart'; | 19 import 'package:compiler/src/util/util.dart'; |
19 | 20 |
(...skipping 19 matching lines...) Expand all Loading... |
39 | 40 |
40 import 'mock_compiler.dart'; | 41 import 'mock_compiler.dart'; |
41 | 42 |
42 class LoggerCanceler extends DiagnosticReporter { | 43 class LoggerCanceler extends DiagnosticReporter { |
43 DiagnosticOptions get options => const MockDiagnosticOptions(); | 44 DiagnosticOptions get options => const MockDiagnosticOptions(); |
44 | 45 |
45 void log(message) { | 46 void log(message) { |
46 print(message); | 47 print(message); |
47 } | 48 } |
48 | 49 |
49 void internalError(node, String message) { | 50 void internalError(Spannable node, message) { |
50 log(message); | 51 log(message); |
51 } | 52 } |
52 | 53 |
53 SourceSpan spanFromSpannable(node) { | 54 SourceSpan spanFromSpannable(node) { |
54 throw 'unsupported operation'; | 55 throw 'unsupported operation'; |
55 } | 56 } |
56 | 57 |
57 SourceSpan spanFromToken(token) => null; | 58 SourceSpan spanFromToken(token) => null; |
58 | 59 |
59 void reportError(DiagnosticMessage message, | 60 void reportError(DiagnosticMessage message, |
(...skipping 12 matching lines...) Expand all Loading... |
72 [Map arguments = const {}]) { | 73 [Map arguments = const {}]) { |
73 log(new Message(MessageTemplate.TEMPLATES[errorCode], arguments, false)); | 74 log(new Message(MessageTemplate.TEMPLATES[errorCode], arguments, false)); |
74 } | 75 } |
75 | 76 |
76 void reportHint(DiagnosticMessage message, | 77 void reportHint(DiagnosticMessage message, |
77 [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]) { | 78 [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]) { |
78 log(message); | 79 log(message); |
79 infos.forEach(log); | 80 infos.forEach(log); |
80 } | 81 } |
81 | 82 |
82 withCurrentElement(Element element, f()) => f(); | 83 withCurrentElement(Entity element, f()) => f(); |
83 | 84 |
84 @override | 85 @override |
85 DiagnosticMessage createMessage(Spannable spannable, MessageKind messageKind, | 86 DiagnosticMessage createMessage(Spannable spannable, MessageKind messageKind, |
86 [Map arguments = const {}]) { | 87 [Map arguments = const {}]) { |
87 return new DiagnosticMessage(null, spannable, | 88 return new DiagnosticMessage(null, spannable, |
88 new Message(MessageTemplate.TEMPLATES[messageKind], arguments, false)); | 89 new Message(MessageTemplate.TEMPLATES[messageKind], arguments, false)); |
89 } | 90 } |
90 | 91 |
91 @override | 92 @override |
92 bool get hasReportedError => false; | 93 bool get hasReportedError => false; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 new IdGenerator()); | 153 new IdGenerator()); |
153 PartialParser parser = new PartialParser(listener); | 154 PartialParser parser = new PartialParser(listener); |
154 reporter.withCurrentElement(unit, () => parser.parseUnit(tokens)); | 155 reporter.withCurrentElement(unit, () => parser.parseUnit(tokens)); |
155 return unit.localMembers; | 156 return unit.localMembers; |
156 } | 157 } |
157 | 158 |
158 NodeList fullParseUnit(String source, {DiagnosticReporter reporter}) { | 159 NodeList fullParseUnit(String source, {DiagnosticReporter reporter}) { |
159 return parseBodyCode(source, (parser, tokens) => parser.parseUnit(tokens), | 160 return parseBodyCode(source, (parser, tokens) => parser.parseUnit(tokens), |
160 reporter: reporter); | 161 reporter: reporter); |
161 } | 162 } |
OLD | NEW |