| 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;
|
| + }
|
| +}
|
|
|