Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Unified Diff: pkg/front_end/lib/src/fasta/messages.dart

Issue 2955443002: Add regression tests from Luke's bug reports. Part 1. (Closed)
Patch Set: Fix type errors and incorrectly named tests. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/messages.dart
diff --git a/pkg/front_end/lib/src/fasta/messages.dart b/pkg/front_end/lib/src/fasta/messages.dart
index b48926c00e36537e62891a5895b02c633588c8e4..9cdebc20aeb46ea89ff0e59d1d19f5362c60665c 100644
--- a/pkg/front_end/lib/src/fasta/messages.dart
+++ b/pkg/front_end/lib/src/fasta/messages.dart
@@ -4,7 +4,7 @@
library fasta.messages;
-import 'package:kernel/ast.dart' show Location;
+import 'package:kernel/ast.dart' show Library, Location, Program, TreeNode;
import 'util/relativize.dart' show relativizeUri;
@@ -92,3 +92,25 @@ String getSourceLine(Location location) {
return CompilerContext.current.uriToSource[location.file]
?.getTextLine(location.line);
}
+
+Location getLocationFromNode(TreeNode node) {
+ if (node.enclosingProgram == null) {
+ TreeNode parent = node;
+ while (parent != null && parent is! Library) {
+ parent = parent.parent;
+ }
+ if (parent is Library) {
+ // ignore: UNUSED_LOCAL_VARIABLE
+ Program program = new Program(
Johnni Winther 2017/06/23 10:51:44 Maybe remove `Program program = ` and add a commen
ahe 2017/06/23 12:21:51 I've changed the code to make it more obvious. IMO
+ libraries: <Library>[parent],
+ uriToSource: CompilerContext.current.uriToSource);
+ Location result = node.location;
+ parent.parent = null;
+ return result;
+ } else {
+ return null;
+ }
+ } else {
+ return node.location;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698