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

Unified Diff: tests/compiler/dart2js/sourcemaps/diff.dart

Issue 2788373002: Add Source.getTextLine and use it to display source snippets in error messages. (Closed)
Patch Set: dartfmt Created 3 years, 8 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: tests/compiler/dart2js/sourcemaps/diff.dart
diff --git a/tests/compiler/dart2js/sourcemaps/diff.dart b/tests/compiler/dart2js/sourcemaps/diff.dart
index 7505892879b7f86bd67e3a519048c82504685e47..7be8f761bc297168259152d98bbc9d837ecf4a7f 100644
--- a/tests/compiler/dart2js/sourcemaps/diff.dart
+++ b/tests/compiler/dart2js/sourcemaps/diff.dart
@@ -447,25 +447,29 @@ class DiffCreator {
align(classes[0].children, classes[1].children,
match: (a, b) => a.name == b.name,
handleSkew: (int listIndex, Interval childRange) {
- addSkewedChildren(listIndex, classes[listIndex], childRange);
- }, handleMatched: (List<int> indices) {
- List<BasicEntity> entities = [
- classes[0].getChild(indices[0]),
- classes[1].getChild(indices[1])
- ];
- if (entities.every((e) => e is Statics)) {
- addMatchingContainers(entities);
- } else {
- addLines(DiffKind.MATCHING, entities.map((e) => e.interval).toList(),
- codeSourceFromEntities(entities));
- }
- }, handleUnmatched: (List<int> indices) {
- List<Interval> intervals = [
- classes[0].getChild(indices[0]).interval,
- classes[1].getChild(indices[1]).interval
- ];
- addLines(DiffKind.UNMATCHED, intervals);
- });
+ addSkewedChildren(listIndex, classes[listIndex], childRange);
+ },
+ handleMatched: (List<int> indices) {
+ List<BasicEntity> entities = [
+ classes[0].getChild(indices[0]),
+ classes[1].getChild(indices[1])
+ ];
+ if (entities.every((e) => e is Statics)) {
+ addMatchingContainers(entities);
+ } else {
+ addLines(
+ DiffKind.MATCHING,
+ entities.map((e) => e.interval).toList(),
+ codeSourceFromEntities(entities));
+ }
+ },
+ handleUnmatched: (List<int> indices) {
+ List<Interval> intervals = [
+ classes[0].getChild(indices[0]).interval,
+ classes[1].getChild(indices[1]).interval
+ ];
+ addLines(DiffKind.UNMATCHED, intervals);
+ });
addLines(DiffKind.MATCHING, classes.map((c) => c.footer).toList());
}
@@ -481,25 +485,29 @@ class DiffCreator {
align(blocks[0].children, blocks[1].children,
match: (a, b) => a.name == b.name,
handleSkew: (int listIndex, Interval childRange) {
- addSkewedChildren(listIndex, blocks[listIndex], childRange);
- }, handleMatched: (List<int> indices) {
- List<BasicEntity> entities = [
- blocks[0].getChild(indices[0]),
- blocks[1].getChild(indices[1])
- ];
- if (entities.every((e) => e is LibraryClass)) {
- addMatchingContainers(entities);
- } else {
- addLines(DiffKind.MATCHING, entities.map((e) => e.interval).toList(),
- codeSourceFromEntities(entities));
- }
- }, handleUnmatched: (List<int> indices) {
- List<Interval> intervals = [
- blocks[0].getChild(indices[0]).interval,
- blocks[1].getChild(indices[1]).interval
- ];
- addLines(DiffKind.UNMATCHED, intervals);
- });
+ addSkewedChildren(listIndex, blocks[listIndex], childRange);
+ },
+ handleMatched: (List<int> indices) {
+ List<BasicEntity> entities = [
+ blocks[0].getChild(indices[0]),
+ blocks[1].getChild(indices[1])
+ ];
+ if (entities.every((e) => e is LibraryClass)) {
+ addMatchingContainers(entities);
+ } else {
+ addLines(
+ DiffKind.MATCHING,
+ entities.map((e) => e.interval).toList(),
+ codeSourceFromEntities(entities));
+ }
+ },
+ handleUnmatched: (List<int> indices) {
+ List<Interval> intervals = [
+ blocks[0].getChild(indices[0]).interval,
+ blocks[1].getChild(indices[1]).interval
+ ];
+ addLines(DiffKind.UNMATCHED, intervals);
+ });
addLines(DiffKind.MATCHING, blocks.map((b) => b.footer).toList());
}
@@ -540,8 +548,8 @@ class DiffCreator {
line.htmlParts.add(new ConstHtmlPart('</span>'));
lines.add(line);
if (codeSource.begin != null) {
- int startLine = sourceFile.getLine(codeSource.begin);
- int endLine = sourceFile.getLine(codeSource.end) + 1;
+ int startLine = sourceFile.getLocation(codeSource.begin).line - 1;
+ int endLine = sourceFile.getLocation(codeSource.end).line;
for (CodeLine codeLine in convertAnnotatedCodeToCodeLines(
sourceFile.slowText(), const <Annotation>[],
startLine: startLine, endLine: endLine)) {
@@ -592,8 +600,8 @@ class DiffCreator {
currentCodeSource = null;
for (CodeSource codeSource in codeSources) {
Interval interval = new Interval(
- sourceFile.getLine(codeSource.begin),
- sourceFile.getLine(codeSource.end) + 1);
+ sourceFile.getLocation(codeSource.begin).line - 1,
+ sourceFile.getLocation(codeSource.end).line);
if (interval.contains(dartCodeLine.lineNo)) {
currentCodeSource = codeSource;
currentLineInterval = interval;
@@ -639,7 +647,7 @@ class DiffCreator {
for (CodeLocation location in codeLineAnnotation.codeLocations) {
SourceFile sourceFile = sourceFileManager.getSourceFile(location.uri);
- int line = sourceFile.getLine(location.offset);
+ int line = sourceFile.getLocation(location.offset).line - 1;
if (currentUri != location.uri) {
restart(jsCodeLine, location, line);
} else if (interval.inWindow(line, windowSize: 2)) {

Powered by Google App Engine
This is Rietveld 408576698