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

Side by Side Diff: tests/compiler/dart2js/sourcemaps/diff_view.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 unified diff | Download patch
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 sourcemap.diff_view; 5 library sourcemap.diff_view;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 nextSourceMappedLocationIndex++; 845 nextSourceMappedLocationIndex++;
846 } 846 }
847 } 847 }
848 848
849 // Associate JavaScript offsets with [Element]s. 849 // Associate JavaScript offsets with [Element]s.
850 StringSourceFile sourceFile = new StringSourceFile.fromName(filename, code); 850 StringSourceFile sourceFile = new StringSourceFile.fromName(filename, code);
851 Map<int, Element> elementMap = <int, Element>{}; 851 Map<int, Element> elementMap = <int, Element>{};
852 sourceMaps.elementSourceMapInfos 852 sourceMaps.elementSourceMapInfos
853 .forEach((Element element, SourceMapInfo info) { 853 .forEach((Element element, SourceMapInfo info) {
854 CodePosition position = info.jsCodePositions[info.node]; 854 CodePosition position = info.jsCodePositions[info.node];
855 elementMap[sourceFile.getLine(position.startPosition)] = element; 855 elementMap[sourceFile.getLocation(position.startPosition).line - 1] =
856 element;
856 }); 857 });
857 858
858 codeLines = convertAnnotatedCodeToCodeLines(code, annotations); 859 codeLines = convertAnnotatedCodeToCodeLines(code, annotations);
859 return new CodeLinesResult(codeLines, coverage, elementMap, 860 return new CodeLinesResult(codeLines, coverage, elementMap,
860 sourceMaps.sourceFileManager, codeSources); 861 sourceMaps.sourceFileManager, codeSources);
861 } 862 }
862 863
863 /// Visitor that computes a map from [js.Node]s to all attached source 864 /// Visitor that computes a map from [js.Node]s to all attached source
864 /// locations. 865 /// locations.
865 class SourceLocationCollector extends js.BaseVisitor { 866 class SourceLocationCollector extends js.BaseVisitor {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 if (data.annotationType == AnnotationType.WITHOUT_SOURCE_INFO) { 956 if (data.annotationType == AnnotationType.WITHOUT_SOURCE_INFO) {
956 return new AnnotationData(tag: 'span', properties: { 957 return new AnnotationData(tag: 'span', properties: {
957 'title': annotation.title, 958 'title': annotation.title,
958 'class': '${ClassNames.marker} ' 959 'class': '${ClassNames.marker} '
959 '${data.annotationType.className}' 960 '${data.annotationType.className}'
960 }); 961 });
961 } 962 }
962 } 963 }
963 return null; 964 return null;
964 } 965 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698