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

Unified Diff: pkg/kernel/lib/ast.dart

Issue 2587673004: Include source in kernel. (Closed)
Patch Set: Fixed some rebase errors Created 3 years, 12 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 | « pkg/kernel/lib/analyzer/loader.dart ('k') | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/lib/ast.dart
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index 71316b5406eeaedbf6e74c5a748bec6f6ae49155..aaf08707017143f4d9724089a90e662a708f50c7 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -3504,17 +3504,17 @@ class Supertype extends Node {
class Program extends TreeNode {
final List<Library> libraries;
- /// Map from a source file uri to a line-starts table.
+ /// Map from a source file uri to a line-starts table and source code.
/// Given a source file uri and a offset in that file one can translate
/// it to a line:column position in that file.
- final Map<String, List<int>> uriToLineStarts;
+ final Map<String, Source> uriToSource;
/// Reference to the main method in one of the libraries.
Procedure mainMethod;
- Program([List<Library> libraries, Map<String, List<int>> uriToLineStarts])
+ Program([List<Library> libraries, Map<String, Source> uriToSource])
: libraries = libraries ?? <Library>[],
- uriToLineStarts = uriToLineStarts ?? {} {
+ uriToSource = uriToSource ?? <String, Source>{} {
setParents(libraries, this);
}
@@ -3533,7 +3533,7 @@ class Program extends TreeNode {
/// Translates an offset to line and column numbers in the given file.
Location getLocation(String file, int offset) {
- List<int> lines = uriToLineStarts[file];
+ List<int> lines = uriToSource[file].lineStarts;
int low = 0, high = lines.length - 1;
while (low < high) {
int mid = high - ((high - low) >> 1); // Get middle, rounding up.
@@ -3651,3 +3651,10 @@ class _ChildReplacer extends Transformer {
}
}
}
+
+class Source {
+ final List<int> lineStarts;
+ final String source;
+
+ Source(this.lineStarts, this.source);
+}
« no previous file with comments | « pkg/kernel/lib/analyzer/loader.dart ('k') | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698