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

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: Use [program]. 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9d1943d8eb1dcd91882b8541fb57781df4e4670c 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,26 @@ 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) {
+ Program program =
+ new Program(uriToSource: CompilerContext.current.uriToSource);
+ program.libraries.add(parent);
+ parent.parent = program;
+ Location result = node.location;
+ program.libraries.clear();
+ parent.parent = null;
+ return result;
+ } else {
+ return null;
+ }
+ } else {
+ return node.location;
+ }
+}
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698