OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'package:compiler/src/commandline_options.dart'; | 6 import 'package:compiler/src/commandline_options.dart'; |
7 import 'package:compiler/src/common.dart'; | 7 import 'package:compiler/src/common.dart'; |
8 import 'package:compiler/src/common_elements.dart'; | 8 import 'package:compiler/src/common_elements.dart'; |
9 import 'package:compiler/src/compiler.dart'; | 9 import 'package:compiler/src/compiler.dart'; |
10 import 'package:compiler/src/elements/entities.dart'; | 10 import 'package:compiler/src/elements/entities.dart'; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 Map<int, String> annotations = <int, String>{}; | 118 Map<int, String> annotations = <int, String>{}; |
119 actualMap.forEach((Id id, ActualData data) { | 119 actualMap.forEach((Id id, ActualData data) { |
120 annotations[data.sourceSpan.begin] = data.value; | 120 annotations[data.sourceSpan.begin] = data.value; |
121 }); | 121 }); |
122 return withAnnotations(annotations); | 122 return withAnnotations(annotations); |
123 } | 123 } |
124 | 124 |
125 String get diffCode { | 125 String get diffCode { |
126 Map<int, String> annotations = <int, String>{}; | 126 Map<int, String> annotations = <int, String>{}; |
127 actualMap.forEach((Id id, ActualData data) { | 127 actualMap.forEach((Id id, ActualData data) { |
128 String expected = expectedMap[id]; | 128 String expected = expectedMap[id] ?? ''; |
129 if (data.value != expected) { | 129 if (data.value != expected) { |
130 expected ??= '---'; | |
131 annotations[data.sourceSpan.begin] = '${expected} | ${data.value}'; | 130 annotations[data.sourceSpan.begin] = '${expected} | ${data.value}'; |
132 } | 131 } |
133 }); | 132 }); |
134 expectedMap.forEach((Id id, String expected) { | 133 expectedMap.forEach((Id id, String expected) { |
135 if (!actualMap.containsKey(id)) { | 134 if (!actualMap.containsKey(id)) { |
136 int offset = compiler.reporter | 135 int offset = compiler.reporter |
137 .spanFromSpannable( | 136 .spanFromSpannable( |
138 computeSpannable(elementEnvironment, mainUri, id)) | 137 computeSpannable(elementEnvironment, mainUri, id)) |
139 .begin; | 138 .begin; |
140 annotations[offset] = '${expected} | ---'; | 139 annotations[offset] = '${expected} | ---'; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 id = new NodeId(annotation.offset); | 248 id = new NodeId(annotation.offset); |
250 expected = text; | 249 expected = text; |
251 } else { | 250 } else { |
252 id = new ElementId(text.substring(0, colonPos)); | 251 id = new ElementId(text.substring(0, colonPos)); |
253 expected = text.substring(colonPos + 1); | 252 expected = text.substring(colonPos + 1); |
254 } | 253 } |
255 map[id] = expected; | 254 map[id] = expected; |
256 } | 255 } |
257 return map; | 256 return map; |
258 } | 257 } |
OLD | NEW |