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

Side by Side Diff: packages/analyzer/lib/src/error.dart

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 years, 4 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 | « packages/analyzer/lib/src/dart/sdk/sdk.dart ('k') | packages/analyzer/lib/src/error/codes.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library error; 4 library analyzer.src.error;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 7
8 import 'generated/error.dart'; 8 import 'package:analyzer/error/error.dart';
9 9
10 /// The maximum line length when printing extracted source code when converting 10 /// The maximum line length when printing extracted source code when converting
11 /// an [AnalyzerError] to a string. 11 /// an [AnalyzerError] to a string.
12 final _MAX_ERROR_LINE_LENGTH = 120; 12 final _MAX_ERROR_LINE_LENGTH = 120;
13 13
14 /// A wrapper around [AnalysisError] that provides a more user-friendly string 14 /// A wrapper around [AnalysisError] that provides a more user-friendly string
15 /// representation. 15 /// representation.
16 class AnalyzerError implements Exception { 16 class AnalyzerError implements Exception {
17 final AnalysisError error; 17 final AnalysisError error;
18 18
19 AnalyzerError(this.error); 19 AnalyzerError(this.error);
20 20
21 String get message => toString(); 21 String get message => toString();
22 22
23 @override
23 String toString() { 24 String toString() {
24 var builder = new StringBuffer(); 25 var builder = new StringBuffer();
25 26
26 // Print a less friendly string representation to ensure that 27 // Print a less friendly string representation to ensure that
27 // error.source.contents is not executed, as .contents it isn't async 28 // error.source.contents is not executed, as .contents it isn't async
28 builder.write("Error in ${error.source.shortName}: ${error.message}"); 29 String sourceName = error.source.shortName;
30 sourceName ??= '<unknown source>';
31 builder.write("Error in $sourceName: ${error.message}");
29 32
30 // var content = error.source.contents.data; 33 // var content = error.source.contents.data;
31 // var beforeError = content.substring(0, error.offset); 34 // var beforeError = content.substring(0, error.offset);
32 // var lineNumber = "\n".allMatches(beforeError).length + 1; 35 // var lineNumber = "\n".allMatches(beforeError).length + 1;
33 // builder.writeln("Error on line $lineNumber of ${error.source.fullName}: " 36 // builder.writeln("Error on line $lineNumber of ${error.source.fullName}: "
34 // "${error.message}"); 37 // "${error.message}");
35 38
36 // var errorLineIndex = beforeError.lastIndexOf("\n") + 1; 39 // var errorLineIndex = beforeError.lastIndexOf("\n") + 1;
37 // var errorEndOfLineIndex = content.indexOf("\n", error.offset); 40 // var errorEndOfLineIndex = content.indexOf("\n", error.offset);
38 // if (errorEndOfLineIndex == -1) errorEndOfLineIndex = content.length; 41 // if (errorEndOfLineIndex == -1) errorEndOfLineIndex = content.length;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 /// Creates an [AnalyzerErrorGroup] from a list of lower-level 85 /// Creates an [AnalyzerErrorGroup] from a list of lower-level
83 /// [AnalysisError]s. 86 /// [AnalysisError]s.
84 AnalyzerErrorGroup.fromAnalysisErrors(Iterable<AnalysisError> errors) 87 AnalyzerErrorGroup.fromAnalysisErrors(Iterable<AnalysisError> errors)
85 : this(errors.map((e) => new AnalyzerError(e))); 88 : this(errors.map((e) => new AnalyzerError(e)));
86 89
87 /// The errors in this collection. 90 /// The errors in this collection.
88 List<AnalyzerError> get errors => 91 List<AnalyzerError> get errors =>
89 new UnmodifiableListView<AnalyzerError>(_errors); 92 new UnmodifiableListView<AnalyzerError>(_errors);
90 93
91 String get message => toString(); 94 String get message => toString();
95 @override
92 String toString() => errors.join("\n"); 96 String toString() => errors.join("\n");
93 } 97 }
OLDNEW
« no previous file with comments | « packages/analyzer/lib/src/dart/sdk/sdk.dart ('k') | packages/analyzer/lib/src/error/codes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698