Version 2.15.0-208.0.dev
Merge commit '669073094db4c60970c95d6b0cce4455d53af3a4' into 'dev'
diff --git a/pkg/analysis_server/test/benchmarks_test.dart b/pkg/analysis_server/test/benchmarks_test.dart
index ca9b731..87a822e 100644
--- a/pkg/analysis_server/test/benchmarks_test.dart
+++ b/pkg/analysis_server/test/benchmarks_test.dart
@@ -27,8 +27,8 @@
const benchmarkIdsToSkip = {
'analysis-flutter-analyze',
- 'das-flutter-completion',
- 'lsp-flutter-completion'
+ 'das-flutter',
+ 'lsp-flutter',
};
for (var benchmarkId in benchmarks) {
diff --git a/pkg/analyzer/lib/src/dart/analysis/dependency/library_builder.dart b/pkg/analyzer/lib/src/dart/analysis/dependency/library_builder.dart
index 437064a..d65f695 100644
--- a/pkg/analyzer/lib/src/dart/analysis/dependency/library_builder.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/dependency/library_builder.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'dart:typed_data';
+
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/src/dart/analysis/dependency/node.dart';
@@ -140,7 +142,7 @@
/// It is mixed into every API token signature, because for example even
/// though types of two functions might be the same, their locations
/// are different.
- late List<int> uriSignature;
+ late Uint8List uriSignature;
/// The precomputed signature of the enclosing class name, or `null` if
/// outside a class.
@@ -148,7 +150,7 @@
/// It is mixed into every API token signature of every class member, because
/// for example even though types of two methods might be the same, their
/// locations are different.
- List<int>? enclosingClassNameSignature;
+ Uint8List? enclosingClassNameSignature;
_LibraryBuilder(this.uri, this.units);
@@ -669,15 +671,15 @@
}
/// Return the signature for all tokens of the [node].
- List<int> _computeNodeTokenSignature(AstNode? node) {
+ Uint8List _computeNodeTokenSignature(AstNode? node) {
if (node == null) {
- return const <int>[];
+ return Uint8List(0);
}
return _computeTokenSignature(node.beginToken, node.endToken);
}
/// Return the signature for tokens from [begin] to [end] (both including).
- List<int> _computeTokenSignature(Token begin, Token end) {
+ Uint8List _computeTokenSignature(Token begin, Token end) {
var signature = _newApiSignatureBuilder();
_appendTokens(signature, begin, end);
return signature.toByteList();
diff --git a/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart b/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart
index 96ec456..b9b7403 100644
--- a/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'dart:typed_data';
+
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/element/element.dart';
@@ -52,7 +54,7 @@
/// Construct and return a new [Dependencies] with the given [tokenSignature]
/// and all recorded references to external nodes in the given AST nodes.
- Dependencies collect(List<int> tokenSignature,
+ Dependencies collect(Uint8List tokenSignature,
{String? enclosingClassName,
String? thisNodeName,
List<ConstructorInitializer>? constructorInitializers,
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 0c1cd75..b0eccb6 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -80,7 +80,7 @@
/// TODO(scheglov) Clean up the list of implicitly analyzed files.
class AnalysisDriver implements AnalysisDriverGeneric {
/// The version of data format, should be incremented on every format change.
- static const int DATA_VERSION = 184;
+ static const int DATA_VERSION = 185;
/// The number of exception contexts allowed to write. Once this field is
/// zero, we stop writing any new exception contexts in this process.
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
index c2a3f5b..d44f37d 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
@@ -21,6 +21,7 @@
import 'package:analyzer/src/dart/analysis/performance_logger.dart';
import 'package:analyzer/src/dart/analysis/referenced_names.dart';
import 'package:analyzer/src/dart/analysis/unlinked_api_signature.dart';
+import 'package:analyzer/src/dart/analysis/unlinked_data.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/scanner/reader.dart';
import 'package:analyzer/src/dart/scanner/scanner.dart';
@@ -31,8 +32,6 @@
import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:analyzer/src/source/source_resource.dart';
import 'package:analyzer/src/summary/api_signature.dart';
-import 'package:analyzer/src/summary/format.dart';
-import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary/package_bundle_reader.dart';
import 'package:analyzer/src/summary2/informative_data.dart';
import 'package:analyzer/src/util/either.dart';
@@ -123,13 +122,13 @@
Set<String>? _definedClassMemberNames;
Set<String>? _definedTopLevelNames;
Set<String>? _referencedNames;
- List<int>? _unlinkedSignature;
+ Uint8List? _unlinkedSignature;
String? _unlinkedKey;
String? _informativeKey;
AnalysisDriverUnlinkedUnit? _driverUnlinkedUnit;
- List<int>? _apiSignature;
+ Uint8List? _apiSignature;
- UnlinkedUnit2? _unlinked2;
+ UnlinkedUnit? _unlinked2;
List<FileState?>? _importedFiles;
List<FileState?>? _exportedFiles;
@@ -156,7 +155,7 @@
);
/// The unlinked API signature of the file.
- List<int> get apiSignature => _apiSignature!;
+ Uint8List get apiSignature => _apiSignature!;
/// The content of the file.
String get content => _content!;
@@ -327,11 +326,11 @@
return librarySignatureBuilder.toHex();
}
- /// The [UnlinkedUnit2] of the file.
- UnlinkedUnit2 get unlinked2 => _unlinked2!;
+ /// The [UnlinkedUnit] of the file.
+ UnlinkedUnit get unlinked2 => _unlinked2!;
/// The MD5 signature based on the content, feature sets, language version.
- List<int> get unlinkedSignature => _unlinkedSignature!;
+ Uint8List get unlinkedSignature => _unlinkedSignature!;
/// Return the [uri] string.
String get uriStr => uri.toString();
@@ -409,12 +408,12 @@
var bytes = _getUnlinkedBytes();
// Read the unlinked bundle.
- _driverUnlinkedUnit = AnalysisDriverUnlinkedUnit.fromBuffer(bytes);
- _unlinked2 = _driverUnlinkedUnit!.unit2;
+ _driverUnlinkedUnit = AnalysisDriverUnlinkedUnit.fromBytes(bytes);
+ _unlinked2 = _driverUnlinkedUnit!.unit;
_lineInfo = LineInfo(_unlinked2!.lineStarts);
// Prepare API signature.
- var newApiSignature = Uint8List.fromList(_unlinked2!.apiSignature);
+ var newApiSignature = _unlinked2!.apiSignature;
bool apiSignatureChanged = _apiSignature != null &&
!_equalByteLists(_apiSignature, newApiSignature);
_apiSignature = newApiSignature;
@@ -495,25 +494,25 @@
}
/// Return the bytes of the unlinked summary - existing or new.
- List<int> _getUnlinkedBytes() {
+ Uint8List _getUnlinkedBytes() {
var bytes = _fsState._byteStore.get(_unlinkedKey!);
if (bytes != null && bytes.isNotEmpty) {
- return bytes;
+ return bytes as Uint8List;
}
var unit = parse();
return _fsState._logger.run('Create unlinked for $path', () {
var unlinkedUnit = serializeAstUnlinked2(unit);
var definedNames = computeDefinedNames(unit);
- var referencedNames = computeReferencedNames(unit).toList();
- var subtypedNames = computeSubtypedNames(unit).toList();
- var bytes = AnalysisDriverUnlinkedUnitBuilder(
- unit2: unlinkedUnit,
- definedTopLevelNames: definedNames.topLevelNames.toList(),
- definedClassMemberNames: definedNames.classMemberNames.toList(),
+ var referencedNames = computeReferencedNames(unit);
+ var subtypedNames = computeSubtypedNames(unit);
+ var bytes = AnalysisDriverUnlinkedUnit(
+ definedTopLevelNames: definedNames.topLevelNames,
+ definedClassMemberNames: definedNames.classMemberNames,
referencedNames: referencedNames,
subtypedNames: subtypedNames,
- ).toBuffer();
+ unit: unlinkedUnit,
+ ).toBytes();
_fsState._byteStore.put(_unlinkedKey!, bytes);
counterUnlinkedBytes += bytes.length;
counterUnlinkedLinkedBytes += bytes.length;
@@ -584,9 +583,9 @@
return directive.uri;
}
- static UnlinkedUnit2Builder serializeAstUnlinked2(CompilationUnit unit) {
- var exports = <UnlinkedNamespaceDirectiveBuilder>[];
- var imports = <UnlinkedNamespaceDirectiveBuilder>[];
+ static UnlinkedUnit serializeAstUnlinked2(CompilationUnit unit) {
+ var exports = <UnlinkedNamespaceDirective>[];
+ var imports = <UnlinkedNamespaceDirective>[];
var parts = <String>[];
var hasDartCoreImport = false;
var hasLibraryDirective = false;
@@ -612,19 +611,22 @@
}
if (!hasDartCoreImport) {
imports.add(
- UnlinkedNamespaceDirectiveBuilder(
+ UnlinkedNamespaceDirective(
+ configurations: [],
uri: 'dart:core',
),
);
}
- return UnlinkedUnit2Builder(
- apiSignature: computeUnlinkedApiSignature(unit),
+ return UnlinkedUnit(
+ apiSignature: Uint8List.fromList(computeUnlinkedApiSignature(unit)),
exports: exports,
- imports: imports,
- parts: parts,
hasLibraryDirective: hasLibraryDirective,
hasPartOfDirective: hasPartOfDirective,
- lineStarts: unit.lineInfo!.lineStarts,
+ imports: imports,
+ lineStarts: Uint32List.fromList(unit.lineInfo!.lineStarts),
+ partOfName: null,
+ partOfUri: null,
+ parts: parts,
);
}
@@ -646,13 +648,13 @@
return true;
}
- static UnlinkedNamespaceDirectiveBuilder _serializeNamespaceDirective(
+ static UnlinkedNamespaceDirective _serializeNamespaceDirective(
NamespaceDirective directive) {
- return UnlinkedNamespaceDirectiveBuilder(
+ return UnlinkedNamespaceDirective(
configurations: directive.configurations.map((configuration) {
var name = configuration.name.components.join('.');
var value = configuration.value?.stringValue ?? '';
- return UnlinkedNamespaceDirectiveConfigurationBuilder(
+ return UnlinkedNamespaceDirectiveConfiguration(
name: name,
value: value,
uri: configuration.uri.stringValue ?? '',
diff --git a/pkg/analyzer/lib/src/dart/analysis/unlinked_api_signature.dart b/pkg/analyzer/lib/src/dart/analysis/unlinked_api_signature.dart
index 6dc30c4..1658a93 100644
--- a/pkg/analyzer/lib/src/dart/analysis/unlinked_api_signature.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/unlinked_api_signature.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'dart:typed_data';
+
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/src/dart/ast/token.dart';
@@ -10,7 +12,7 @@
/// Return the bytes of the unlinked API signature of the given [unit].
///
/// If API signatures of two units are different, they may have different APIs.
-List<int> computeUnlinkedApiSignature(CompilationUnit unit) {
+Uint8List computeUnlinkedApiSignature(CompilationUnit unit) {
var computer = _UnitApiSignatureComputer();
computer.compute(unit);
return computer.signature.toByteList();
diff --git a/pkg/analyzer/lib/src/dart/analysis/unlinked_data.dart b/pkg/analyzer/lib/src/dart/analysis/unlinked_data.dart
new file mode 100644
index 0000000..2c7b78b
--- /dev/null
+++ b/pkg/analyzer/lib/src/dart/analysis/unlinked_data.dart
@@ -0,0 +1,213 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:typed_data';
+
+import 'package:analyzer/src/summary2/data_reader.dart';
+import 'package:analyzer/src/summary2/data_writer.dart';
+
+/// Unlinked information about a compilation unit.
+class AnalysisDriverUnlinkedUnit {
+ /// Set of class member names defined by the unit.
+ final Set<String> definedClassMemberNames;
+
+ /// Set of top-level names defined by the unit.
+ final Set<String> definedTopLevelNames;
+
+ /// Set of external names referenced by the unit.
+ final Set<String> referencedNames;
+
+ /// Set of names which are used in `extends`, `with` or `implements` clauses
+ /// in the file. Import prefixes and type arguments are not included.
+ final Set<String> subtypedNames;
+
+ /// Unlinked information for the unit.
+ final UnlinkedUnit unit;
+
+ AnalysisDriverUnlinkedUnit({
+ required this.definedClassMemberNames,
+ required this.definedTopLevelNames,
+ required this.referencedNames,
+ required this.subtypedNames,
+ required this.unit,
+ });
+
+ factory AnalysisDriverUnlinkedUnit.fromBytes(Uint8List bytes) {
+ return AnalysisDriverUnlinkedUnit.read(
+ SummaryDataReader(bytes),
+ );
+ }
+
+ factory AnalysisDriverUnlinkedUnit.read(SummaryDataReader reader) {
+ return AnalysisDriverUnlinkedUnit(
+ definedClassMemberNames: reader.readStringUtf8Set(),
+ definedTopLevelNames: reader.readStringUtf8Set(),
+ referencedNames: reader.readStringUtf8Set(),
+ subtypedNames: reader.readStringUtf8Set(),
+ unit: UnlinkedUnit.read(reader),
+ );
+ }
+
+ Uint8List toBytes() {
+ var byteSink = ByteSink();
+ var sink = BufferedSink(byteSink);
+ write(sink);
+ return sink.flushAndTake();
+ }
+
+ void write(BufferedSink sink) {
+ sink.writeStringUtf8Iterable(definedClassMemberNames);
+ sink.writeStringUtf8Iterable(definedTopLevelNames);
+ sink.writeStringUtf8Iterable(referencedNames);
+ sink.writeStringUtf8Iterable(subtypedNames);
+ unit.write(sink);
+ }
+}
+
+/// Unlinked information about a namespace directive.
+class UnlinkedNamespaceDirective {
+ /// The configurations that control which library will actually be used.
+ final List<UnlinkedNamespaceDirectiveConfiguration> configurations;
+
+ /// The URI referenced by this directive, nad used by default when none
+ /// of the [configurations] matches.
+ final String uri;
+
+ UnlinkedNamespaceDirective({
+ required this.configurations,
+ required this.uri,
+ });
+
+ factory UnlinkedNamespaceDirective.read(SummaryDataReader reader) {
+ return UnlinkedNamespaceDirective(
+ configurations: reader.readTypedList(
+ () => UnlinkedNamespaceDirectiveConfiguration.read(reader),
+ ),
+ uri: reader.readStringUtf8(),
+ );
+ }
+
+ void write(BufferedSink sink) {
+ sink.writeList<UnlinkedNamespaceDirectiveConfiguration>(
+ configurations,
+ (x) {
+ x.write(sink);
+ },
+ );
+ sink.writeStringUtf8(uri);
+ }
+}
+
+/// Unlinked information about a namespace directive configuration.
+class UnlinkedNamespaceDirectiveConfiguration {
+ /// The name of the declared variable used in the condition.
+ final String name;
+
+ /// The URI to be used if the condition is true.
+ final String uri;
+
+ /// The value to which the value of the declared variable will be compared,
+ /// or the empty string if the condition does not include an equality test.
+ final String value;
+
+ UnlinkedNamespaceDirectiveConfiguration({
+ required this.name,
+ required this.uri,
+ required this.value,
+ });
+
+ factory UnlinkedNamespaceDirectiveConfiguration.read(
+ SummaryDataReader reader,
+ ) {
+ return UnlinkedNamespaceDirectiveConfiguration(
+ name: reader.readStringUtf8(),
+ uri: reader.readStringUtf8(),
+ value: reader.readStringUtf8(),
+ );
+ }
+
+ void write(BufferedSink sink) {
+ sink.writeStringUtf8(name);
+ sink.writeStringUtf8(uri);
+ sink.writeStringUtf8(value);
+ }
+}
+
+/// Unlinked information about a compilation unit.
+class UnlinkedUnit {
+ /// The MD5 hash signature of the API portion of this unit. It depends on all
+ /// tokens that might affect APIs of declarations in the unit.
+ /// TODO(scheglov) Do we need it?
+ final Uint8List apiSignature;
+
+ /// URIs of `export` directives.
+ final List<UnlinkedNamespaceDirective> exports;
+
+ /// Is `true` if the unit contains a `library` directive.
+ final bool hasLibraryDirective;
+
+ /// Is `true` if the unit contains a `part of` directive.
+ final bool hasPartOfDirective;
+
+ /// URIs of `import` directives.
+ final List<UnlinkedNamespaceDirective> imports;
+
+ /// Offsets of the first character of each line in the source code.
+ final Uint32List lineStarts;
+
+ /// The library name of the `part of my.name;` directive.
+ final String? partOfName;
+
+ /// URI of the `part of 'uri';` directive.
+ final String? partOfUri;
+
+ /// URIs of `part` directives.
+ final List<String> parts;
+
+ UnlinkedUnit({
+ required this.apiSignature,
+ required this.exports,
+ required this.hasLibraryDirective,
+ required this.hasPartOfDirective,
+ required this.imports,
+ required this.lineStarts,
+ required this.partOfName,
+ required this.partOfUri,
+ required this.parts,
+ });
+
+ factory UnlinkedUnit.read(SummaryDataReader reader) {
+ return UnlinkedUnit(
+ apiSignature: reader.readUint8List(),
+ exports: reader.readTypedList(
+ () => UnlinkedNamespaceDirective.read(reader),
+ ),
+ hasLibraryDirective: reader.readBool(),
+ hasPartOfDirective: reader.readBool(),
+ imports: reader.readTypedList(
+ () => UnlinkedNamespaceDirective.read(reader),
+ ),
+ lineStarts: reader.readUInt30List(),
+ partOfName: reader.readOptionalStringUtf8(),
+ partOfUri: reader.readOptionalStringUtf8(),
+ parts: reader.readStringUtf8List(),
+ );
+ }
+
+ void write(BufferedSink sink) {
+ sink.writeUint8List(apiSignature);
+ sink.writeList<UnlinkedNamespaceDirective>(exports, (x) {
+ x.write(sink);
+ });
+ sink.writeBool(hasLibraryDirective);
+ sink.writeBool(hasPartOfDirective);
+ sink.writeList<UnlinkedNamespaceDirective>(imports, (x) {
+ x.write(sink);
+ });
+ sink.writeUint30List(lineStarts);
+ sink.writeOptionalStringUtf8(partOfName);
+ sink.writeOptionalStringUtf8(partOfUri);
+ sink.writeStringUtf8Iterable(parts);
+ }
+}
diff --git a/pkg/analyzer/lib/src/dart/micro/library_graph.dart b/pkg/analyzer/lib/src/dart/micro/library_graph.dart
index faf698f..4e56df0 100644
--- a/pkg/analyzer/lib/src/dart/micro/library_graph.dart
+++ b/pkg/analyzer/lib/src/dart/micro/library_graph.dart
@@ -896,7 +896,7 @@
/// the signatures of the cycles that the [libraries] reference
/// directly. So, indirectly it is based on the transitive closure of all
/// files that [libraries] reference (but we don't compute these files).
- late List<int> signature;
+ late Uint8List signature;
/// The hash of all the paths of the files in this cycle.
late String cyclePathsHash;
diff --git a/pkg/analyzer/lib/src/summary/api_signature.dart b/pkg/analyzer/lib/src/summary/api_signature.dart
index 3b60046..f16423a 100644
--- a/pkg/analyzer/lib/src/summary/api_signature.dart
+++ b/pkg/analyzer/lib/src/summary/api_signature.dart
@@ -108,13 +108,15 @@
/// For testing only: retrieve the internal representation of the data that
/// has been collected.
- List<int> getBytes_forDebug() {
- return Uint8List.view(_data.buffer, 0, _offset).toList();
+ Uint8List getBytes_forDebug() {
+ return Uint8List.view(_data.buffer, 0, _offset);
}
/// Return the bytes of the MD5 hash of the data collected so far.
- List<int> toByteList() {
- return md5.convert(Uint8List.view(_data.buffer, 0, _offset)).bytes;
+ Uint8List toByteList() {
+ var data = _data.buffer.asUint8List(0, _offset);
+ var bytes = md5.convert(data).bytes;
+ return bytes is Uint8List ? bytes : Uint8List.fromList(bytes);
}
/// Return a hex-encoded MD5 signature of the data collected so far.
@@ -125,7 +127,7 @@
/// Return the MD5 hash of the data collected so far as [Uint32List].
Uint32List toUint32List() {
var bytes = toByteList();
- return Uint8List.fromList(bytes).buffer.asUint32List();
+ return bytes.buffer.asUint32List();
}
/// Ensure that [spaceNeeded] bytes can be added to [_data] at [_offset]
diff --git a/pkg/analyzer/lib/src/summary/format.dart b/pkg/analyzer/lib/src/summary/format.dart
index e59c7f2..42602414 100644
--- a/pkg/analyzer/lib/src/summary/format.dart
+++ b/pkg/analyzer/lib/src/summary/format.dart
@@ -1830,277 +1830,6 @@
String toString() => convert.json.encode(toJson());
}
-class AnalysisDriverUnlinkedUnitBuilder extends Object
- with _AnalysisDriverUnlinkedUnitMixin
- implements idl.AnalysisDriverUnlinkedUnit {
- List<String>? _definedClassMemberNames;
- List<String>? _definedTopLevelNames;
- List<String>? _referencedNames;
- List<String>? _subtypedNames;
- UnlinkedUnit2Builder? _unit2;
-
- @override
- List<String> get definedClassMemberNames =>
- _definedClassMemberNames ??= <String>[];
-
- /// List of class member names defined by the unit.
- set definedClassMemberNames(List<String> value) {
- this._definedClassMemberNames = value;
- }
-
- @override
- List<String> get definedTopLevelNames => _definedTopLevelNames ??= <String>[];
-
- /// List of top-level names defined by the unit.
- set definedTopLevelNames(List<String> value) {
- this._definedTopLevelNames = value;
- }
-
- @override
- List<String> get referencedNames => _referencedNames ??= <String>[];
-
- /// List of external names referenced by the unit.
- set referencedNames(List<String> value) {
- this._referencedNames = value;
- }
-
- @override
- List<String> get subtypedNames => _subtypedNames ??= <String>[];
-
- /// List of names which are used in `extends`, `with` or `implements` clauses
- /// in the file. Import prefixes and type arguments are not included.
- set subtypedNames(List<String> value) {
- this._subtypedNames = value;
- }
-
- @override
- UnlinkedUnit2Builder? get unit2 => _unit2;
-
- /// Unlinked information for the unit.
- set unit2(UnlinkedUnit2Builder? value) {
- this._unit2 = value;
- }
-
- AnalysisDriverUnlinkedUnitBuilder(
- {List<String>? definedClassMemberNames,
- List<String>? definedTopLevelNames,
- List<String>? referencedNames,
- List<String>? subtypedNames,
- UnlinkedUnit2Builder? unit2})
- : _definedClassMemberNames = definedClassMemberNames,
- _definedTopLevelNames = definedTopLevelNames,
- _referencedNames = referencedNames,
- _subtypedNames = subtypedNames,
- _unit2 = unit2;
-
- /// Flush [informative] data recursively.
- void flushInformative() {
- _unit2?.flushInformative();
- }
-
- /// Accumulate non-[informative] data into [signature].
- void collectApiSignature(api_sig.ApiSignature signatureSink) {
- var referencedNames = this._referencedNames;
- if (referencedNames == null) {
- signatureSink.addInt(0);
- } else {
- signatureSink.addInt(referencedNames.length);
- for (var x in referencedNames) {
- signatureSink.addString(x);
- }
- }
- var definedTopLevelNames = this._definedTopLevelNames;
- if (definedTopLevelNames == null) {
- signatureSink.addInt(0);
- } else {
- signatureSink.addInt(definedTopLevelNames.length);
- for (var x in definedTopLevelNames) {
- signatureSink.addString(x);
- }
- }
- var definedClassMemberNames = this._definedClassMemberNames;
- if (definedClassMemberNames == null) {
- signatureSink.addInt(0);
- } else {
- signatureSink.addInt(definedClassMemberNames.length);
- for (var x in definedClassMemberNames) {
- signatureSink.addString(x);
- }
- }
- var subtypedNames = this._subtypedNames;
- if (subtypedNames == null) {
- signatureSink.addInt(0);
- } else {
- signatureSink.addInt(subtypedNames.length);
- for (var x in subtypedNames) {
- signatureSink.addString(x);
- }
- }
- signatureSink.addBool(this._unit2 != null);
- this._unit2?.collectApiSignature(signatureSink);
- }
-
- List<int> toBuffer() {
- fb.Builder fbBuilder = fb.Builder();
- return fbBuilder.finish(finish(fbBuilder), "ADUU");
- }
-
- fb.Offset finish(fb.Builder fbBuilder) {
- fb.Offset? offset_definedClassMemberNames;
- fb.Offset? offset_definedTopLevelNames;
- fb.Offset? offset_referencedNames;
- fb.Offset? offset_subtypedNames;
- fb.Offset? offset_unit2;
- var definedClassMemberNames = _definedClassMemberNames;
- if (!(definedClassMemberNames == null || definedClassMemberNames.isEmpty)) {
- offset_definedClassMemberNames = fbBuilder.writeList(
- definedClassMemberNames
- .map((b) => fbBuilder.writeString(b))
- .toList());
- }
- var definedTopLevelNames = _definedTopLevelNames;
- if (!(definedTopLevelNames == null || definedTopLevelNames.isEmpty)) {
- offset_definedTopLevelNames = fbBuilder.writeList(
- definedTopLevelNames.map((b) => fbBuilder.writeString(b)).toList());
- }
- var referencedNames = _referencedNames;
- if (!(referencedNames == null || referencedNames.isEmpty)) {
- offset_referencedNames = fbBuilder.writeList(
- referencedNames.map((b) => fbBuilder.writeString(b)).toList());
- }
- var subtypedNames = _subtypedNames;
- if (!(subtypedNames == null || subtypedNames.isEmpty)) {
- offset_subtypedNames = fbBuilder.writeList(
- subtypedNames.map((b) => fbBuilder.writeString(b)).toList());
- }
- var unit2 = _unit2;
- if (unit2 != null) {
- offset_unit2 = unit2.finish(fbBuilder);
- }
- fbBuilder.startTable();
- if (offset_definedClassMemberNames != null) {
- fbBuilder.addOffset(2, offset_definedClassMemberNames);
- }
- if (offset_definedTopLevelNames != null) {
- fbBuilder.addOffset(1, offset_definedTopLevelNames);
- }
- if (offset_referencedNames != null) {
- fbBuilder.addOffset(0, offset_referencedNames);
- }
- if (offset_subtypedNames != null) {
- fbBuilder.addOffset(3, offset_subtypedNames);
- }
- if (offset_unit2 != null) {
- fbBuilder.addOffset(4, offset_unit2);
- }
- return fbBuilder.endTable();
- }
-}
-
-idl.AnalysisDriverUnlinkedUnit readAnalysisDriverUnlinkedUnit(
- List<int> buffer) {
- fb.BufferContext rootRef = fb.BufferContext.fromBytes(buffer);
- return const _AnalysisDriverUnlinkedUnitReader().read(rootRef, 0);
-}
-
-class _AnalysisDriverUnlinkedUnitReader
- extends fb.TableReader<_AnalysisDriverUnlinkedUnitImpl> {
- const _AnalysisDriverUnlinkedUnitReader();
-
- @override
- _AnalysisDriverUnlinkedUnitImpl createObject(
- fb.BufferContext bc, int offset) =>
- _AnalysisDriverUnlinkedUnitImpl(bc, offset);
-}
-
-class _AnalysisDriverUnlinkedUnitImpl extends Object
- with _AnalysisDriverUnlinkedUnitMixin
- implements idl.AnalysisDriverUnlinkedUnit {
- final fb.BufferContext _bc;
- final int _bcOffset;
-
- _AnalysisDriverUnlinkedUnitImpl(this._bc, this._bcOffset);
-
- List<String>? _definedClassMemberNames;
- List<String>? _definedTopLevelNames;
- List<String>? _referencedNames;
- List<String>? _subtypedNames;
- idl.UnlinkedUnit2? _unit2;
-
- @override
- List<String> get definedClassMemberNames {
- return _definedClassMemberNames ??=
- const fb.ListReader<String>(fb.StringReader())
- .vTableGet(_bc, _bcOffset, 2, const <String>[]);
- }
-
- @override
- List<String> get definedTopLevelNames {
- return _definedTopLevelNames ??=
- const fb.ListReader<String>(fb.StringReader())
- .vTableGet(_bc, _bcOffset, 1, const <String>[]);
- }
-
- @override
- List<String> get referencedNames {
- return _referencedNames ??= const fb.ListReader<String>(fb.StringReader())
- .vTableGet(_bc, _bcOffset, 0, const <String>[]);
- }
-
- @override
- List<String> get subtypedNames {
- return _subtypedNames ??= const fb.ListReader<String>(fb.StringReader())
- .vTableGet(_bc, _bcOffset, 3, const <String>[]);
- }
-
- @override
- idl.UnlinkedUnit2? get unit2 {
- return _unit2 ??=
- const _UnlinkedUnit2Reader().vTableGetOrNull(_bc, _bcOffset, 4);
- }
-}
-
-abstract class _AnalysisDriverUnlinkedUnitMixin
- implements idl.AnalysisDriverUnlinkedUnit {
- @override
- Map<String, Object> toJson() {
- Map<String, Object> _result = <String, Object>{};
- var local_definedClassMemberNames = definedClassMemberNames;
- if (local_definedClassMemberNames.isNotEmpty) {
- _result["definedClassMemberNames"] = local_definedClassMemberNames;
- }
- var local_definedTopLevelNames = definedTopLevelNames;
- if (local_definedTopLevelNames.isNotEmpty) {
- _result["definedTopLevelNames"] = local_definedTopLevelNames;
- }
- var local_referencedNames = referencedNames;
- if (local_referencedNames.isNotEmpty) {
- _result["referencedNames"] = local_referencedNames;
- }
- var local_subtypedNames = subtypedNames;
- if (local_subtypedNames.isNotEmpty) {
- _result["subtypedNames"] = local_subtypedNames;
- }
- var local_unit2 = unit2;
- if (local_unit2 != null) {
- _result["unit2"] = local_unit2.toJson();
- }
- return _result;
- }
-
- @override
- Map<String, Object?> toMap() => {
- "definedClassMemberNames": definedClassMemberNames,
- "definedTopLevelNames": definedTopLevelNames,
- "referencedNames": referencedNames,
- "subtypedNames": subtypedNames,
- "unit2": unit2,
- };
-
- @override
- String toString() => convert.json.encode(toJson());
-}
-
class AvailableDeclarationBuilder extends Object
with _AvailableDeclarationMixin
implements idl.AvailableDeclaration {
diff --git a/pkg/analyzer/lib/src/summary/format.fbs b/pkg/analyzer/lib/src/summary/format.fbs
index 18b2f2a..67ee567 100644
--- a/pkg/analyzer/lib/src/summary/format.fbs
+++ b/pkg/analyzer/lib/src/summary/format.fbs
@@ -293,25 +293,6 @@
usedNames:[uint] (id: 14);
}
-/// Information about an unlinked unit.
-table AnalysisDriverUnlinkedUnit {
- /// List of class member names defined by the unit.
- definedClassMemberNames:[string] (id: 2);
-
- /// List of top-level names defined by the unit.
- definedTopLevelNames:[string] (id: 1);
-
- /// List of external names referenced by the unit.
- referencedNames:[string] (id: 0);
-
- /// List of names which are used in `extends`, `with` or `implements` clauses
- /// in the file. Import prefixes and type arguments are not included.
- subtypedNames:[string] (id: 3);
-
- /// Unlinked information for the unit.
- unit2:UnlinkedUnit2 (id: 4);
-}
-
/// Information about a single declaration.
table AvailableDeclaration {
children:[AvailableDeclaration] (id: 0);
diff --git a/pkg/analyzer/lib/src/summary/idl.dart b/pkg/analyzer/lib/src/summary/idl.dart
index d715b69..cb5eb79 100644
--- a/pkg/analyzer/lib/src/summary/idl.dart
+++ b/pkg/analyzer/lib/src/summary/idl.dart
@@ -259,34 +259,6 @@
List<int> get usedNames;
}
-/// Information about an unlinked unit.
-@TopLevel('ADUU')
-abstract class AnalysisDriverUnlinkedUnit extends base.SummaryClass {
- factory AnalysisDriverUnlinkedUnit.fromBuffer(List<int> buffer) =>
- generated.readAnalysisDriverUnlinkedUnit(buffer);
-
- /// List of class member names defined by the unit.
- @Id(2)
- List<String> get definedClassMemberNames;
-
- /// List of top-level names defined by the unit.
- @Id(1)
- List<String> get definedTopLevelNames;
-
- /// List of external names referenced by the unit.
- @Id(0)
- List<String> get referencedNames;
-
- /// List of names which are used in `extends`, `with` or `implements` clauses
- /// in the file. Import prefixes and type arguments are not included.
- @Id(3)
- List<String> get subtypedNames;
-
- /// Unlinked information for the unit.
- @Id(4)
- UnlinkedUnit2? get unit2;
-}
-
/// Information about a single declaration.
abstract class AvailableDeclaration extends base.SummaryClass {
@Id(0)
diff --git a/pkg/analyzer/lib/src/summary2/data_reader.dart b/pkg/analyzer/lib/src/summary2/data_reader.dart
index a961d0d..f9986ed 100644
--- a/pkg/analyzer/lib/src/summary2/data_reader.dart
+++ b/pkg/analyzer/lib/src/summary2/data_reader.dart
@@ -85,6 +85,20 @@
return utf8.decode(bytes);
}
+ List<String> readStringUtf8List() {
+ return readTypedList(readStringUtf8);
+ }
+
+ Set<String> readStringUtf8Set() {
+ var length = readUInt30();
+ var result = <String>{};
+ for (var i = 0; i < length; i++) {
+ var item = readStringUtf8();
+ result.add(item);
+ }
+ return result;
+ }
+
List<T> readTypedList<T>(T Function() read) {
var length = readUInt30();
return List<T>.generate(length, (_) {
diff --git a/pkg/analyzer/lib/src/summary2/data_writer.dart b/pkg/analyzer/lib/src/summary2/data_writer.dart
index d7aedcd..3f560a8 100644
--- a/pkg/analyzer/lib/src/summary2/data_writer.dart
+++ b/pkg/analyzer/lib/src/summary2/data_writer.dart
@@ -161,6 +161,13 @@
writeUint8List(bytes as Uint8List);
}
+ void writeStringUtf8Iterable(Iterable<String> items) {
+ writeUInt30(items.length);
+ for (var item in items) {
+ writeStringUtf8(item);
+ }
+ }
+
@pragma("vm:prefer-inline")
void writeUInt30(int value) {
assert(value >= 0 && value >> 30 == 0);
diff --git a/runtime/bin/socket.cc b/runtime/bin/socket.cc
index ac9d95d..2333b43 100644
--- a/runtime/bin/socket.cc
+++ b/runtime/bin/socket.cc
@@ -658,6 +658,7 @@
int64_t buffer_num_bytes = 0;
DartUtils::GetInt64Value(ThrowIfError(Dart_GetNativeArgument(args, 1)),
&buffer_num_bytes);
+ int64_t buffer_num_bytes_allocated = buffer_num_bytes;
uint8_t* buffer = nullptr;
Dart_Handle data = IOBuffer::Allocate(buffer_num_bytes, &buffer);
if (Dart_IsNull(data)) {
@@ -665,16 +666,21 @@
}
ASSERT(buffer != nullptr);
- OSError os_error;
+ // Can't rely on RAII since Dart_ThrowException won't call destructors.
+ OSError* os_error = new OSError();
SocketControlMessage* control_messages;
const intptr_t messages_read = SocketBase::ReceiveMessage(
socket->fd(), buffer, &buffer_num_bytes, &control_messages,
- SocketBase::kAsync, &os_error);
+ SocketBase::kAsync, os_error);
if (messages_read < 0) {
ASSERT(messages_read == -1);
- Dart_ThrowException(DartUtils::NewDartOSError(&os_error));
+ Dart_Handle error = DartUtils::NewDartOSError(os_error);
+ delete os_error;
+ Dart_ThrowException(error);
}
- if (buffer_num_bytes > 0) {
+ delete os_error;
+ if (buffer_num_bytes > 0 && buffer_num_bytes != buffer_num_bytes_allocated) {
+ // If received fewer than allocated buffer size, truncate buffer.
uint8_t* new_buffer = nullptr;
Dart_Handle new_data = IOBuffer::Allocate(buffer_num_bytes, &new_buffer);
if (Dart_IsNull(new_data)) {
@@ -789,7 +795,8 @@
SocketControlMessage(level, type, copied_data, data.size_in_bytes());
}
- OSError os_error;
+ // Can't rely on RAII since Dart_ThrowException won't call destructors.
+ OSError* os_error = new OSError();
intptr_t bytes_written;
{
Dart_Handle buffer_dart = Dart_GetNativeArgument(args, 1);
@@ -800,12 +807,15 @@
reinterpret_cast<uint8_t*>(data.data()) + offset;
bytes_written = SocketBase::SendMessage(
socket->fd(), buffer_at_offset, length, control_messages,
- num_control_messages, SocketBase::kAsync, &os_error);
+ num_control_messages, SocketBase::kAsync, os_error);
}
if (bytes_written < 0) {
- Dart_ThrowException(DartUtils::NewDartOSError(&os_error));
+ Dart_Handle error = DartUtils::NewDartOSError(os_error);
+ delete os_error;
+ Dart_ThrowException(error);
}
+ delete os_error;
Dart_SetIntegerReturnValue(args, bytes_written);
}
diff --git a/tools/VERSION b/tools/VERSION
index a79611d..5443c65 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 15
PATCH 0
-PRERELEASE 207
+PRERELEASE 208
PRERELEASE_PATCH 0
\ No newline at end of file