Skip to content

Commit 2cc0275

Browse files
author
Dart CI
committed
Version 2.12.0-109.0.dev
Merge commit 'cec14bbf71c4e854b2b324fa18656949d9b42f05' into 'dev'
2 parents 97cfd05 + cec14bb commit 2cc0275

40 files changed

+647
-605
lines changed

pkg/_fe_analyzer_shared/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Logic that is shared between the front_end and analyzer packages.
44
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/_fe_analyzer_shared
55

66
environment:
7-
sdk: '>=2.6.0 <3.0.0'
7+
sdk: '>=2.9.0 <3.0.0'
88
dependencies:
99
meta: ^1.0.2
1010
dev_dependencies:

pkg/analyzer/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: This package provides a library that performs static analysis of Da
44
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/analyzer
55

66
environment:
7-
sdk: '>=2.7.0 <3.0.0'
7+
sdk: '>=2.9.0 <3.0.0'
88

99
dependencies:
1010
_fe_analyzer_shared: ^14.0.0

pkg/analyzer_plugin/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: Dart Team <misc@dartlang.org>
55
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_plugin
66

77
environment:
8-
sdk: '>=2.3.0 <3.0.0'
8+
sdk: '>=2.9.0 <3.0.0'
99

1010
dependencies:
1111
analyzer: '>=0.39.12 <0.41.0'

pkg/dartdev/benchmark/bench.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ abstract class Benchmark {
105105
class DartStartup extends Benchmark {
106106
DartStartup()
107107
: super(
108-
'dart-startup',
108+
'script-startup',
109109
'Benchmark the startup time of a minimal Dart script (μs).',
110110
);
111111

@@ -141,7 +141,7 @@ class DartStartup extends Benchmark {
141141
class DartRunStartup extends Benchmark {
142142
DartRunStartup()
143143
: super(
144-
'dart-run-startup',
144+
'run-script-startup',
145145
'Benchmark the startup time of a minimal Dart script, executed with '
146146
'\`dart run\` (μs).',
147147
);

pkg/dartdev/lib/src/commands/analyze.dart

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class AnalyzeCommand extends DartdevCommand {
2424
/// message. The width left for the severity label plus the separator width.
2525
static const int _bodyIndentWidth = _severityWidth + 3;
2626

27+
static final String _bodyIndent = ' ' * _bodyIndentWidth;
28+
2729
static final int _pipeCodeUnit = '|'.codeUnitAt(0);
2830

2931
static final int _slashCodeUnit = '\\'.codeUnitAt(0);
@@ -62,6 +64,7 @@ class AnalyzeCommand extends DartdevCommand {
6264

6365
@override
6466
String get invocation => '${super.invocation} [<directory>]';
67+
6568
@override
6669
FutureOr<int> run() async {
6770
if (argResults.rest.length > 1) {
@@ -167,6 +170,10 @@ class AnalyzeCommand extends DartdevCommand {
167170

168171
log.stdout('');
169172

173+
final wrapWidth = dartdevUsageLineLength == null
174+
? null
175+
: (dartdevUsageLineLength - _bodyIndentWidth);
176+
170177
for (final AnalysisError error in errors) {
171178
// error • Message ... at path.dart:line:col • (code)
172179

@@ -183,19 +190,28 @@ class AnalyzeCommand extends DartdevCommand {
183190
'(${error.code})',
184191
);
185192

186-
var padding = ' ' * _bodyIndentWidth;
187193
if (verbose) {
188194
for (var message in error.contextMessages) {
189-
log.stdout('$padding${message.message} '
190-
'at ${message.filePath}:${message.line}:${message.column}');
195+
// Wrap longer context messages.
196+
var contextMessage = wrapText(
197+
'${message.message} at '
198+
'${message.filePath}:${message.line}:${message.column}',
199+
width: wrapWidth);
200+
log.stdout('$_bodyIndent'
201+
'${contextMessage.replaceAll('\n', '\n$_bodyIndent')}');
191202
}
192203
}
204+
193205
if (error.correction != null) {
194-
log.stdout('$padding${error.correction}');
206+
// Wrap longer correction messages.
207+
var correction = wrapText(error.correction, width: wrapWidth);
208+
log.stdout(
209+
'$_bodyIndent${correction.replaceAll('\n', '\n$_bodyIndent')}');
195210
}
211+
196212
if (verbose) {
197213
if (error.url != null) {
198-
log.stdout('$padding${error.url}');
214+
log.stdout('$_bodyIndent${error.url}');
199215
}
200216
}
201217
}

pkg/dartdev/lib/src/utils.dart

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,39 @@ extension FileSystemEntityExtension on FileSystemEntity {
6868

6969
bool get isDartFile => this is File && p.extension(path) == '.dart';
7070
}
71+
72+
/// Wraps [text] to the given [width], if provided.
73+
String wrapText(String text, {int width}) {
74+
if (width == null) {
75+
return text;
76+
}
77+
78+
var buffer = StringBuffer();
79+
var lineMaxEndIndex = width;
80+
var lineStartIndex = 0;
81+
82+
while (true) {
83+
if (lineMaxEndIndex >= text.length) {
84+
buffer.write(text.substring(lineStartIndex, text.length));
85+
break;
86+
} else {
87+
var lastSpaceIndex = text.lastIndexOf(' ', lineMaxEndIndex);
88+
if (lastSpaceIndex == -1 || lastSpaceIndex <= lineStartIndex) {
89+
// No space between [lineStartIndex] and [lineMaxEndIndex]. Get the
90+
// _next_ space.
91+
lastSpaceIndex = text.indexOf(' ', lineMaxEndIndex);
92+
if (lastSpaceIndex == -1) {
93+
// No space at all after [lineStartIndex].
94+
lastSpaceIndex = text.length;
95+
buffer.write(text.substring(lineStartIndex, lastSpaceIndex));
96+
break;
97+
}
98+
}
99+
buffer.write(text.substring(lineStartIndex, lastSpaceIndex));
100+
buffer.writeln();
101+
lineStartIndex = lastSpaceIndex + 1;
102+
}
103+
lineMaxEndIndex = lineStartIndex + width;
104+
}
105+
return buffer.toString();
106+
}

pkg/dartdev/test/utils_test.dart

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'dart:convert';
66
import 'dart:io';
77

88
import 'package:dartdev/src/utils.dart';
9-
import 'package:path/path.dart';
9+
import 'package:path/path.dart' as path;
1010
import 'package:test/test.dart';
1111

1212
void main() {
@@ -32,7 +32,7 @@ void main() {
3232

3333
test('nested', () {
3434
var dir = Directory('foo');
35-
expect(relativePath(join(dir.absolute.path, 'path'), dir), 'path');
35+
expect(relativePath(path.join(dir.absolute.path, 'path'), dir), 'path');
3636
});
3737
});
3838

@@ -93,10 +93,10 @@ void main() {
9393
test('name', () {
9494
expect(Directory('').name, '');
9595
expect(Directory('dirName').name, 'dirName');
96-
expect(Directory('dirName$separator').name, 'dirName');
96+
expect(Directory('dirName${path.separator}').name, 'dirName');
9797
expect(File('').name, '');
9898
expect(File('foo.dart').name, 'foo.dart');
99-
expect(File('${separator}foo.dart').name, 'foo.dart');
99+
expect(File('${path.separator}foo.dart').name, 'foo.dart');
100100
expect(File('bar.bart').name, 'bar.bart');
101101
});
102102
});
@@ -133,6 +133,66 @@ void main() {
133133
orderedEquals(['pub', 'publish', '--help']));
134134
});
135135
});
136+
137+
group('wrapText', () {
138+
test('oneLine_wordLongerThanLine', () {
139+
expect(wrapText('http://long-url', width: 10), equals('http://long-url'));
140+
});
141+
142+
test('singleLine', () {
143+
expect(wrapText('one two', width: 10), equals('one two'));
144+
});
145+
146+
test('singleLine_exactLength', () {
147+
expect(wrapText('one twoooo', width: 10), equals('one twoooo'));
148+
});
149+
150+
test('singleLine_exactLength_minusOne', () {
151+
expect(wrapText('one twooo', width: 10), equals('one twooo'));
152+
});
153+
154+
test('singleLine_exactLength_plusOne', () {
155+
expect(wrapText('one twooooo', width: 10), equals('one\ntwooooo'));
156+
});
157+
158+
test('twoLines_exactLength', () {
159+
expect(wrapText('one two three four', width: 10),
160+
equals('one two\nthree four'));
161+
});
162+
163+
test('twoLines_exactLength_minusOne', () {
164+
expect(wrapText('one two three fou', width: 10),
165+
equals('one two\nthree fou'));
166+
});
167+
168+
test('twoLines_exactLength_plusOne', () {
169+
expect(wrapText('one two three fourr', width: 10),
170+
equals('one two\nthree\nfourr'));
171+
});
172+
173+
test('twoLines_lastLineEndsWithSpace', () {
174+
expect(wrapText('one two three ', width: 10), equals('one two\nthree '));
175+
});
176+
177+
test('twoLines_multipleSpacesAtSplit', () {
178+
expect(
179+
wrapText('one two. Three', width: 10), equals('one two. \nThree'));
180+
});
181+
182+
test('twoLines_noSpaceLastLine', () {
183+
expect(wrapText('one two three', width: 10), equals('one two\nthree'));
184+
});
185+
186+
test('twoLines_wordLongerThanLine_firstLine', () {
187+
expect(wrapText('http://long-url word', width: 10),
188+
equals('http://long-url\nword'));
189+
});
190+
191+
test('twoLines_wordLongerThanLine_lastLine', () {
192+
expect(wrapText('word http://long-url', width: 10),
193+
equals('word\nhttp://long-url'));
194+
});
195+
});
136196
}
137197

138198
const String _packageData = '''{

runtime/lib/mirrors.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,12 @@ static InstancePtr CreateLibraryDependencyMirror(Thread* thread,
435435
const LibraryPrefix& prefix,
436436
const bool is_import,
437437
const bool is_deferred) {
438-
const Library& importee = Library::Handle(ns.library());
438+
const Library& importee = Library::Handle(ns.target());
439439
const Array& show_names = Array::Handle(ns.show_names());
440440
const Array& hide_names = Array::Handle(ns.hide_names());
441441

442-
Object& metadata = Object::Handle(ns.GetMetadata());
442+
const Library& owner = Library::Handle(ns.owner());
443+
Object& metadata = Object::Handle(owner.GetMetadata(ns));
443444
if (metadata.IsError()) {
444445
Exceptions::PropagateError(Error::Cast(metadata));
445446
UNREACHABLE();

runtime/vm/canonical_tables.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,38 @@ class CanonicalTypeArgumentsTraits {
254254
typedef UnorderedHashSet<CanonicalTypeArgumentsTraits>
255255
CanonicalTypeArgumentsSet;
256256

257+
class MetadataMapTraits {
258+
public:
259+
static const char* Name() { return "MetadataMapTraits"; }
260+
static bool ReportStats() { return false; }
261+
static bool IsMatch(const Object& key, const Object& candidate) {
262+
return key.raw() == candidate.raw();
263+
}
264+
static uword Hash(const Object& key) {
265+
#if !defined(DART_PRECOMPILED_RUNTIME)
266+
if (key.IsLibrary()) {
267+
return String::Hash(Library::Cast(key).url());
268+
} else if (key.IsClass()) {
269+
return String::Hash(Class::Cast(key).Name());
270+
} else if (key.IsPatchClass()) {
271+
return Hash(Object::Handle(PatchClass::Cast(key).patched_class()));
272+
} else if (key.IsFunction()) {
273+
return CombineHashes(String::Hash(Function::Cast(key).name()),
274+
Hash(Object::Handle(Function::Cast(key).Owner())));
275+
} else if (key.IsField()) {
276+
return CombineHashes(String::Hash(Field::Cast(key).name()),
277+
Hash(Object::Handle(Field::Cast(key).Owner())));
278+
} else if (key.IsTypeParameter()) {
279+
return TypeParameter::Cast(key).Hash();
280+
} else if (key.IsNamespace()) {
281+
return Hash(Library::Handle(Namespace::Cast(key).target()));
282+
}
283+
#endif
284+
UNREACHABLE();
285+
}
286+
};
287+
typedef UnorderedHashMap<MetadataMapTraits> MetadataMap;
288+
257289
} // namespace dart
258290

259291
#endif // RUNTIME_VM_CANONICAL_TABLES_H_

runtime/vm/clustered_snapshot.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5836,7 +5836,12 @@ ZoneGrowableArray<Object*>* Serializer::Serialize(SerializationRoots* roots) {
58365836
WriteUnsigned(num_objects);
58375837
WriteUnsigned(canonical_clusters.length());
58385838
WriteUnsigned(clusters.length());
5839-
WriteUnsigned(initial_field_table_->NumFieldIds());
5839+
// TODO(dartbug.com/36097): Not every snapshot carries the field table.
5840+
if (current_loading_unit_id_ <= LoadingUnit::kRootId) {
5841+
WriteUnsigned(initial_field_table_->NumFieldIds());
5842+
} else {
5843+
WriteUnsigned(0);
5844+
}
58405845

58415846
for (SerializationCluster* cluster : canonical_clusters) {
58425847
cluster->WriteAndMeasureAlloc(this);
@@ -6572,8 +6577,8 @@ void Deserializer::Deserialize(DeserializationRoots* roots) {
65726577
refs_ = Array::New(num_objects_ + kFirstReference, Heap::kOld);
65736578
if (initial_field_table_len > 0) {
65746579
initial_field_table_->AllocateIndex(initial_field_table_len - 1);
6580+
ASSERT_EQUAL(initial_field_table_->NumFieldIds(), initial_field_table_len);
65756581
}
6576-
ASSERT_EQUAL(initial_field_table_->NumFieldIds(), initial_field_table_len);
65776582

65786583
{
65796584
NoSafepointScope no_safepoint;

0 commit comments

Comments
 (0)