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

Issue 2788373002: Add Source.getTextLine and use it to display source snippets in error messages. (Closed)

Created:
3 years, 8 months ago by ahe
Modified:
3 years, 7 months ago
CC:
reviews_dartlang.org, dart-fe-team+reviews_google.com, Johnni Winther
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Add Source.getTextLine and use it to display source snippets in error messages. R=asgerf@google.com, johnniwinther@google.com Committed: https://github.com/dart-lang/sdk/commit/ddda1829576480fdd9d9cfe6ce28e1c00a077945

Patch Set 1 #

Total comments: 4

Patch Set 2 : Address comments. #

Total comments: 4

Patch Set 3 : Rename LineColumnProvider to LocationProvider #

Patch Set 4 : Rename LineColumnProvider to LocationProvider #

Patch Set 5 : Remove getLine, getColumn, and getLineText. #

Total comments: 6

Patch Set 6 : dartfmt #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+315 lines, -422 lines) Patch
D pkg/compiler/lib/src/io/line_column_provider.dart View 1 2 1 chunk +0 lines, -82 lines 0 comments Download
A pkg/compiler/lib/src/io/location_provider.dart View 1 2 3 4 1 chunk +56 lines, -0 lines 0 comments Download
M pkg/compiler/lib/src/io/source_file.dart View 1 2 3 4 5 8 chunks +58 lines, -106 lines 0 comments Download
M pkg/compiler/lib/src/io/source_information.dart View 1 2 3 4 3 chunks +8 lines, -4 lines 0 comments Download
M pkg/compiler/lib/src/io/source_map_builder.dart View 1 2 5 chunks +11 lines, -9 lines 0 comments Download
M pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart View 1 2 5 chunks +9 lines, -9 lines 0 comments Download
M pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart View 1 2 5 chunks +9 lines, -9 lines 0 comments Download
M pkg/compiler/lib/src/use_unused_api.dart View 1 2 2 chunks +2 lines, -3 lines 0 comments Download
M pkg/front_end/lib/src/fasta/messages.dart View 1 2 chunks +19 lines, -9 lines 0 comments Download
M pkg/kernel/lib/ast.dart View 1 2 3 4 5 3 chunks +57 lines, -16 lines 1 comment Download
D tests/compiler/dart2js/line_column_provider_test.dart View 1 2 1 chunk +0 lines, -109 lines 0 comments Download
A + tests/compiler/dart2js/location_collector_test.dart View 1 2 2 chunks +13 lines, -11 lines 0 comments Download
M tests/compiler/dart2js/message_span_test.dart View 1 2 2 chunks +8 lines, -2 lines 0 comments Download
M tests/compiler/dart2js/source_map_validator_helper.dart View 1 2 3 4 2 chunks +4 lines, -2 lines 0 comments Download
M tests/compiler/dart2js/sourcemaps/diff.dart View 1 2 3 4 5 5 chunks +51 lines, -43 lines 0 comments Download
M tests/compiler/dart2js/sourcemaps/diff_view.dart View 1 2 3 4 1 chunk +2 lines, -1 line 0 comments Download
M tests/compiler/dart2js/sourcemaps/sourcemap_helper.dart View 1 2 3 4 2 chunks +3 lines, -2 lines 0 comments Download
M tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart View 1 2 3 4 3 chunks +4 lines, -4 lines 0 comments Download
M tests/compiler/dart2js/warnings_checker.dart View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 24 (7 generated)
ahe
3 years, 8 months ago (2017-04-03 08:28:34 UTC) #5
asgerf
LGTM with comments addressed https://codereview.chromium.org/2788373002/diff/60001/pkg/compiler/lib/src/io/source_file.dart File pkg/compiler/lib/src/io/source_file.dart (right): https://codereview.chromium.org/2788373002/diff/60001/pkg/compiler/lib/src/io/source_file.dart#newcode197 pkg/compiler/lib/src/io/source_file.dart:197: // [package:kernel/ast.dart](../../../../kernel/lib/ast.dart). Any reason not ...
3 years, 8 months ago (2017-04-03 08:34:55 UTC) #6
ahe
PTAL, significant changes. https://codereview.chromium.org/2788373002/diff/60001/pkg/compiler/lib/src/io/source_file.dart File pkg/compiler/lib/src/io/source_file.dart (right): https://codereview.chromium.org/2788373002/diff/60001/pkg/compiler/lib/src/io/source_file.dart#newcode197 pkg/compiler/lib/src/io/source_file.dart:197: // [package:kernel/ast.dart](../../../../kernel/lib/ast.dart). On 2017/04/03 08:34:55, asgerf ...
3 years, 8 months ago (2017-04-03 09:26:39 UTC) #7
ahe
Johnni: I've made significant changes to source_file from dart2js.
3 years, 8 months ago (2017-04-03 09:28:02 UTC) #8
asgerf
https://codereview.chromium.org/2788373002/diff/80001/pkg/kernel/lib/ast.dart File pkg/kernel/lib/ast.dart (right): https://codereview.chromium.org/2788373002/diff/80001/pkg/kernel/lib/ast.dart#newcode4251 pkg/kernel/lib/ast.dart:4251: result = result.substring(0, result.length - 1); The 'nextLine' variable ...
3 years, 8 months ago (2017-04-03 09:55:25 UTC) #9
Johnni Winther
dart2js changes LGTM
3 years, 8 months ago (2017-04-03 10:21:48 UTC) #11
ahe
I went a bit further getting rid of dart2js SourceFile API in favor of package:kernel. ...
3 years, 8 months ago (2017-04-03 14:57:08 UTC) #12
asgerf
https://codereview.chromium.org/2788373002/diff/140001/tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart File tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart (right): https://codereview.chromium.org/2788373002/diff/140001/tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart#newcode518 tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart:518: dartCodeBuffer.write(sourceFile.kernelSource.getTextLine(line + 1)); Wouldn't it be better to keep ...
3 years, 8 months ago (2017-04-03 15:19:14 UTC) #13
ahe
https://codereview.chromium.org/2788373002/diff/140001/tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart File tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart (right): https://codereview.chromium.org/2788373002/diff/140001/tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart#newcode518 tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart:518: dartCodeBuffer.write(sourceFile.kernelSource.getTextLine(line + 1)); On 2017/04/03 15:19:14, asgerf wrote: > ...
3 years, 8 months ago (2017-04-03 15:34:55 UTC) #14
asgerf
https://codereview.chromium.org/2788373002/diff/140001/tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart File tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart (right): https://codereview.chromium.org/2788373002/diff/140001/tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart#newcode518 tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart:518: dartCodeBuffer.write(sourceFile.kernelSource.getTextLine(line + 1)); On 2017/04/03 15:34:55, ahe wrote: > ...
3 years, 8 months ago (2017-04-04 08:33:59 UTC) #15
asgerf
lgtm https://codereview.chromium.org/2788373002/diff/140001/pkg/kernel/lib/ast.dart File pkg/kernel/lib/ast.dart (right): https://codereview.chromium.org/2788373002/diff/140001/pkg/kernel/lib/ast.dart#newcode4265 pkg/kernel/lib/ast.dart:4265: "${lineStarts.length}."); length -> last
3 years, 8 months ago (2017-04-04 08:53:05 UTC) #16
ahe
Thank you! https://codereview.chromium.org/2788373002/diff/140001/tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart File tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart (right): https://codereview.chromium.org/2788373002/diff/140001/tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart#newcode518 tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart:518: dartCodeBuffer.write(sourceFile.kernelSource.getTextLine(line + 1)); On 2017/04/04 08:33:59, asgerf ...
3 years, 8 months ago (2017-04-04 09:03:07 UTC) #17
ahe
Thank you! https://codereview.chromium.org/2788373002/diff/140001/pkg/kernel/lib/ast.dart File pkg/kernel/lib/ast.dart (right): https://codereview.chromium.org/2788373002/diff/140001/pkg/kernel/lib/ast.dart#newcode4265 pkg/kernel/lib/ast.dart:4265: "${lineStarts.length}."); On 2017/04/04 08:53:05, asgerf wrote: > ...
3 years, 8 months ago (2017-04-05 11:34:23 UTC) #18
ahe
Committed patchset #6 (id:160001) manually as ddda1829576480fdd9d9cfe6ce28e1c00a077945 (presubmit successful).
3 years, 8 months ago (2017-04-05 13:02:57 UTC) #20
sra1
https://codereview.chromium.org/2788373002/diff/160001/pkg/kernel/lib/ast.dart File pkg/kernel/lib/ast.dart (right): https://codereview.chromium.org/2788373002/diff/160001/pkg/kernel/lib/ast.dart#newcode4274 pkg/kernel/lib/ast.dart:4274: "The value of '$name' ($value) must be between $min ...
3 years, 7 months ago (2017-05-04 05:44:40 UTC) #22
sra1
On 2017/05/04 05:44:40, sra1 wrote: > https://codereview.chromium.org/2788373002/diff/160001/pkg/kernel/lib/ast.dart > File pkg/kernel/lib/ast.dart (right): > > https://codereview.chromium.org/2788373002/diff/160001/pkg/kernel/lib/ast.dart#newcode4274 > ...
3 years, 7 months ago (2017-05-04 06:03:29 UTC) #23
ahe
3 years, 7 months ago (2017-05-04 07:33:32 UTC) #24
Message was sent while issue was closed.
On 2017/05/04 06:03:29, sra1 wrote:
> On 2017/05/04 05:44:40, sra1 wrote:
> >
https://codereview.chromium.org/2788373002/diff/160001/pkg/kernel/lib/ast.dart
> > File pkg/kernel/lib/ast.dart (right):
> > 
> >
>
https://codereview.chromium.org/2788373002/diff/160001/pkg/kernel/lib/ast.dar...
> > pkg/kernel/lib/ast.dart:4274: "The value of '$name' ($value) must be between
> > $min and $max.");
> > Please remove this interpolation.
> > 
> > It is expensive to interpolate this string for every range check.
> > I measure ~1% of dart2js time in allocating the strings for _Smi.toString
> > The information in this interpolated string is pretty redundant with what
the
> > RangeError will print without a 'message' parameter.
> > 
> > If you remove this parameter you will get an error like:
> > 
> > RangeError (offset): Invalid value: Not in range 0..20, inclusive: 100
> > 
> > So you could delete this helper and call RangeError.checkValueInRange from
the
> > two call sites.
> 
> I can make the changes. I just want to understand why we are doing
interpolation
> here.

I should have thought about the cost of interpolation, my bad. The message from
RangeError is horrible, and I don't understand it.

The ideal solution would be to fix RangeError, and if that fails, we can do the
range check ourselves.

Powered by Google App Engine
This is Rietveld 408576698