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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 fasta.messages; 5 library fasta.messages;
6 6
7 import 'package:kernel/ast.dart' show Location; 7 import 'package:kernel/ast.dart' show Library, Location, Program, TreeNode;
8 8
9 import 'util/relativize.dart' show relativizeUri; 9 import 'util/relativize.dart' show relativizeUri;
10 10
11 import 'compiler_context.dart' show CompilerContext; 11 import 'compiler_context.dart' show CompilerContext;
12 12
13 import 'errors.dart' show InputError; 13 import 'errors.dart' show InputError;
14 14
15 import 'colors.dart' show cyan, magenta; 15 import 'colors.dart' show cyan, magenta;
16 16
17 const bool hideWarnings = false; 17 const bool hideWarnings = false;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 if (charOffset == -1) return null; 85 if (charOffset == -1) return null;
86 String path = relativizeUri(uri); 86 String path = relativizeUri(uri);
87 return getLocation(path, charOffset); 87 return getLocation(path, charOffset);
88 } 88 }
89 89
90 String getSourceLine(Location location) { 90 String getSourceLine(Location location) {
91 if (location == null) return null; 91 if (location == null) return null;
92 return CompilerContext.current.uriToSource[location.file] 92 return CompilerContext.current.uriToSource[location.file]
93 ?.getTextLine(location.line); 93 ?.getTextLine(location.line);
94 } 94 }
95
96 Location getLocationFromNode(TreeNode node) {
97 if (node.enclosingProgram == null) {
98 TreeNode parent = node;
99 while (parent != null && parent is! Library) {
100 parent = parent.parent;
101 }
102 if (parent is Library) {
103 Program program =
104 new Program(uriToSource: CompilerContext.current.uriToSource);
105 program.libraries.add(parent);
106 parent.parent = program;
107 Location result = node.location;
108 program.libraries.clear();
109 parent.parent = null;
110 return result;
111 } else {
112 return null;
113 }
114 } else {
115 return node.location;
116 }
117 }
OLDNEW
« 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