Version 2.15.0-213.0.dev
Merge commit '639350b13ef7064bc89e6bc2268f449f2d9c8b2c' into 'dev'
diff --git a/build/dart/dart_action.gni b/build/dart/dart_action.gni
index 334a09a..0643c87 100644
--- a/build/dart/dart_action.gni
+++ b/build/dart/dart_action.gni
@@ -363,7 +363,7 @@
# The arguments to pass to the Dart script.
#
# packages (optional):
-# The un-rebased path to the .packages file.
+# The un-rebased path to the package_config.json file.
#
# Forwarded to action() with the usual meaning:
# depfile
diff --git a/pkg/_fe_analyzer_shared/pubspec.yaml b/pkg/_fe_analyzer_shared/pubspec.yaml
index 0e1fea0..80c6ed3 100644
--- a/pkg/_fe_analyzer_shared/pubspec.yaml
+++ b/pkg/_fe_analyzer_shared/pubspec.yaml
@@ -1,5 +1,5 @@
name: _fe_analyzer_shared
-version: 28.0.0
+version: 29.0.0
description: Logic that is shared between the front_end and analyzer packages.
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/_fe_analyzer_shared
diff --git a/pkg/analysis_server/test/client/impl/abstract_client.dart b/pkg/analysis_server/test/client/impl/abstract_client.dart
index caa0386..d067b8d 100644
--- a/pkg/analysis_server/test/client/impl/abstract_client.dart
+++ b/pkg/analysis_server/test/client/impl/abstract_client.dart
@@ -136,7 +136,7 @@
return response;
}
- File newFile(String path, String content, [int stamp]);
+ File newFile(String path, String content);
Folder newFolder(String path);
diff --git a/pkg/analysis_server/test/client/impl/completion_driver.dart b/pkg/analysis_server/test/client/impl/completion_driver.dart
index 60083d6..bbdeee9 100644
--- a/pkg/analysis_server/test/client/impl/completion_driver.dart
+++ b/pkg/analysis_server/test/client/impl/completion_driver.dart
@@ -131,8 +131,8 @@
}
@override
- File newFile(String path, String content, [int? stamp]) => resourceProvider
- .newFile(resourceProvider.convertPath(path), content, stamp);
+ File newFile(String path, String content) =>
+ resourceProvider.newFile(resourceProvider.convertPath(path), content);
@override
Folder newFolder(String path) =>
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index 1a8d912..a067cd4 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -1,4 +1,4 @@
-## 2.6.0-dev
+## 2.6.0
* Deprecated `AnalysisResult.state`, check for specific valid or invalid subtypes.
* Deprecated `ResultState`.
* Deprecated `LibraryElement.hasExtUri`, FFI should be used instead.
diff --git a/pkg/analyzer/lib/file_system/file_system.dart b/pkg/analyzer/lib/file_system/file_system.dart
index e71b153..52bb3d7 100644
--- a/pkg/analyzer/lib/file_system/file_system.dart
+++ b/pkg/analyzer/lib/file_system/file_system.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/src/generated/source.dart';
import 'package:path/path.dart';
import 'package:watcher/watcher.dart';
@@ -29,7 +31,7 @@
/// Synchronously read the entire file contents as a list of bytes.
/// Throws a [FileSystemException] if the operation fails.
- List<int> readAsBytesSync();
+ Uint8List readAsBytesSync();
/// Synchronously read the entire file contents as a [String].
/// Throws [FileSystemException] if the file does not exist.
diff --git a/pkg/analyzer/lib/file_system/memory_file_system.dart b/pkg/analyzer/lib/file_system/memory_file_system.dart
index 76b90a1..f6d3b10 100644
--- a/pkg/analyzer/lib/file_system/memory_file_system.dart
+++ b/pkg/analyzer/lib/file_system/memory_file_system.dart
@@ -159,21 +159,31 @@
return link;
}
- File newFile(String path, String content, [int? stamp]) {
- var bytes = utf8.encode(content);
+ File newFile(
+ String path,
+ String content, [
+ @Deprecated('This parameter is not used and will be removed') int? stamp,
+ ]) {
+ var bytes = utf8.encode(content) as Uint8List;
+ // ignore: deprecated_member_use_from_same_package
return newFileWithBytes(path, bytes, stamp);
}
- File newFileWithBytes(String path, List<int> bytes, [int? stamp]) {
+ File newFileWithBytes(
+ String path,
+ List<int> bytes, [
+ @Deprecated('This parameter is not used and will be removed') int? stamp,
+ ]) {
_ensureAbsoluteAndNormalized(path);
+ bytes = bytes is Uint8List ? bytes : Uint8List.fromList(bytes);
var parentPath = pathContext.dirname(path);
var parentData = _newFolder(parentPath);
_addToParentFolderData(parentData, path);
_pathToData[path] = _FileData(
- bytes: Uint8List.fromList(bytes),
- timeStamp: stamp ?? nextStamp++,
+ bytes: bytes,
+ timeStamp: nextStamp++,
);
_notifyWatchers(path, ChangeType.ADD);
@@ -322,13 +332,13 @@
return result;
}
- void _setFileContent(String path, List<int> bytes) {
+ void _setFileContent(String path, Uint8List bytes) {
var parentPath = pathContext.dirname(path);
var parentData = _newFolder(parentPath);
_addToParentFolderData(parentData, path);
_pathToData[path] = _FileData(
- bytes: Uint8List.fromList(bytes),
+ bytes: bytes,
timeStamp: nextStamp++,
);
_notifyWatchers(path, ChangeType.MODIFY);
@@ -511,12 +521,13 @@
@override
void writeAsBytesSync(List<int> bytes) {
+ bytes = bytes is Uint8List ? bytes : Uint8List.fromList(bytes);
provider._setFileContent(path, bytes);
}
@override
void writeAsStringSync(String content) {
- var bytes = utf8.encode(content);
+ var bytes = utf8.encode(content) as Uint8List;
writeAsBytesSync(bytes);
}
}
diff --git a/pkg/analyzer/lib/file_system/overlay_file_system.dart b/pkg/analyzer/lib/file_system/overlay_file_system.dart
index e66c643..dbac07b 100644
--- a/pkg/analyzer/lib/file_system/overlay_file_system.dart
+++ b/pkg/analyzer/lib/file_system/overlay_file_system.dart
@@ -189,7 +189,7 @@
}
@override
- List<int> readAsBytesSync() {
+ Uint8List readAsBytesSync() {
String? content = provider._getOverlayContent(path);
if (content != null) {
return utf8.encode(content) as Uint8List;
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
index 239d1cb..f0f35eb 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
@@ -119,12 +119,8 @@
String? _content;
String? _contentHash;
LineInfo? _lineInfo;
- Set<String>? _definedClassMemberNames;
- Set<String>? _definedTopLevelNames;
- Set<String>? _referencedNames;
Uint8List? _unlinkedSignature;
String? _unlinkedKey;
- String? _informativeKey;
AnalysisDriverUnlinkedUnit? _driverUnlinkedUnit;
Uint8List? _apiSignature;
@@ -165,14 +161,12 @@
/// The class member names defined by the file.
Set<String> get definedClassMemberNames {
- return _definedClassMemberNames ??=
- _driverUnlinkedUnit!.definedClassMemberNames.toSet();
+ return _driverUnlinkedUnit!.definedClassMemberNames;
}
/// The top-level names defined by the file.
Set<String> get definedTopLevelNames {
- return _definedTopLevelNames ??=
- _driverUnlinkedUnit!.definedTopLevelNames.toSet();
+ return _driverUnlinkedUnit!.definedTopLevelNames;
}
/// Return the set of all directly referenced files - imported, exported or
@@ -295,7 +289,7 @@
/// The external names referenced by the file.
Set<String> get referencedNames {
- return _referencedNames ??= _driverUnlinkedUnit!.referencedNames.toSet();
+ return _driverUnlinkedUnit!.referencedNames;
}
@visibleForTesting
@@ -340,16 +334,6 @@
return other is FileState && other.uri == uri;
}
- Uint8List getInformativeBytes({CompilationUnit? unit}) {
- var bytes = _fsState._byteStore.get(_informativeKey!);
- if (bytes == null) {
- unit ??= parse();
- bytes = writeUnitInformative(unit);
- _fsState._byteStore.put(_informativeKey!, bytes);
- }
- return bytes;
- }
-
void internal_setLibraryCycle(LibraryCycle? cycle) {
_libraryCycle = cycle;
}
@@ -399,9 +383,8 @@
signature.addBool(_exists!);
_unlinkedSignature = signature.toByteList();
var signatureHex = hex.encode(_unlinkedSignature!);
- _unlinkedKey = '$signatureHex.unlinked2';
// TODO(scheglov) Use the path as the key, and store the signature.
- _informativeKey = '$signatureHex.ast';
+ _unlinkedKey = '$signatureHex.unlinked2';
}
// Prepare the unlinked unit.
@@ -521,11 +504,6 @@
/// Invalidate any data that depends on the current unlinked data of the file,
/// because [refresh] is going to recompute the unlinked data.
void _invalidateCurrentUnresolvedData() {
- // Invalidate unlinked information.
- _definedTopLevelNames = null;
- _definedClassMemberNames = null;
- _referencedNames = null;
-
if (_driverUnlinkedUnit != null) {
for (var name in _driverUnlinkedUnit!.subtypedNames) {
var files = _fsState._subtypedNameToFiles[name];
@@ -621,6 +599,7 @@
hasLibraryDirective: hasLibraryDirective,
hasPartOfDirective: hasPartOfDirective,
imports: imports,
+ informativeBytes: writeUnitInformative(unit),
lineStarts: Uint32List.fromList(unit.lineInfo!.lineStarts),
partOfName: null,
partOfUri: null,
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
index 6278c6f..0c0000f 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
@@ -648,17 +648,6 @@
var unitElement = unit.declaredElement as CompilationUnitElementImpl;
- // TODO(scheglov) Hack: set types for top-level variables
- // Otherwise TypeResolverVisitor will set declared types, and because we
- // don't run InferStaticVariableTypeTask, we will stuck with these declared
- // types. And we don't need to run this task - resynthesized elements have
- // inferred types.
- for (var e in unitElement.topLevelVariables) {
- if (!e.isSynthetic) {
- e.type;
- }
- }
-
unit.accept(
ResolutionVisitor(
unitElement: unitElement,
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_context.dart b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
index 7973df8..72092ad 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
@@ -117,7 +117,7 @@
var unitsInformativeBytes = <Uri, Uint8List>{};
for (var library in cycle.libraries) {
for (var file in library.libraryFiles) {
- unitsInformativeBytes[file.uri] = file.getInformativeBytes();
+ unitsInformativeBytes[file.uri] = file.unlinked2.informativeBytes;
}
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/unlinked_data.dart b/pkg/analyzer/lib/src/dart/analysis/unlinked_data.dart
index 2c7b78b..5ab1857 100644
--- a/pkg/analyzer/lib/src/dart/analysis/unlinked_data.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/unlinked_data.dart
@@ -153,6 +153,9 @@
/// URIs of `import` directives.
final List<UnlinkedNamespaceDirective> imports;
+ /// Encoded informative data.
+ final Uint8List informativeBytes;
+
/// Offsets of the first character of each line in the source code.
final Uint32List lineStarts;
@@ -171,6 +174,7 @@
required this.hasLibraryDirective,
required this.hasPartOfDirective,
required this.imports,
+ required this.informativeBytes,
required this.lineStarts,
required this.partOfName,
required this.partOfUri,
@@ -188,6 +192,7 @@
imports: reader.readTypedList(
() => UnlinkedNamespaceDirective.read(reader),
),
+ informativeBytes: reader.readUint8List(),
lineStarts: reader.readUInt30List(),
partOfName: reader.readOptionalStringUtf8(),
partOfUri: reader.readOptionalStringUtf8(),
@@ -205,6 +210,7 @@
sink.writeList<UnlinkedNamespaceDirective>(imports, (x) {
x.write(sink);
});
+ sink.writeUint8List(informativeBytes);
sink.writeUint30List(lineStarts);
sink.writeOptionalStringUtf8(partOfName);
sink.writeOptionalStringUtf8(partOfUri);
diff --git a/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart b/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart
index 30be965..90b93ea 100644
--- a/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart
@@ -679,17 +679,6 @@
var unitElement = unit.declaredElement as CompilationUnitElementImpl;
- // TODO(scheglov) Hack: set types for top-level variables
- // Otherwise TypeResolverVisitor will set declared types, and because we
- // don't run InferStaticVariableTypeTask, we will stuck with these declared
- // types. And we don't need to run this task - resynthesized elements have
- // inferred types.
- for (var e in unitElement.topLevelVariables) {
- if (!e.isSynthetic) {
- e.type;
- }
- }
-
unit.accept(
ResolutionVisitor(
unitElement: unitElement,
diff --git a/pkg/analyzer/lib/src/dart/micro/library_graph.dart b/pkg/analyzer/lib/src/dart/micro/library_graph.dart
index c1b1c9f..9e6cb1c 100644
--- a/pkg/analyzer/lib/src/dart/micro/library_graph.dart
+++ b/pkg/analyzer/lib/src/dart/micro/library_graph.dart
@@ -15,6 +15,7 @@
import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/dart/analysis/feature_set_provider.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/micro/cider_byte_store.dart';
import 'package:analyzer/src/dart/scanner/reader.dart';
@@ -23,10 +24,10 @@
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/utilities_dart.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/link.dart' as graph
show DependencyWalker, Node;
+import 'package:analyzer/src/summary2/data_reader.dart';
+import 'package:analyzer/src/summary2/data_writer.dart';
import 'package:analyzer/src/summary2/informative_data.dart';
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
import 'package:analyzer/src/util/performance/operation_performance.dart';
@@ -42,6 +43,74 @@
libraryWalker.walk(libraryWalker.getNode(file));
}
+class CiderUnitTopLevelDeclarations {
+ final List<String> extensionNames;
+ final List<String> functionNames;
+ final List<String> typeNames;
+ final List<String> variableNames;
+
+ CiderUnitTopLevelDeclarations({
+ required this.extensionNames,
+ required this.functionNames,
+ required this.typeNames,
+ required this.variableNames,
+ });
+
+ factory CiderUnitTopLevelDeclarations.read(SummaryDataReader reader) {
+ return CiderUnitTopLevelDeclarations(
+ extensionNames: reader.readStringUtf8List(),
+ functionNames: reader.readStringUtf8List(),
+ typeNames: reader.readStringUtf8List(),
+ variableNames: reader.readStringUtf8List(),
+ );
+ }
+
+ void write(BufferedSink sink) {
+ sink.writeStringUtf8Iterable(extensionNames);
+ sink.writeStringUtf8Iterable(functionNames);
+ sink.writeStringUtf8Iterable(typeNames);
+ sink.writeStringUtf8Iterable(variableNames);
+ }
+}
+
+class CiderUnlinkedUnit {
+ /// Top-level declarations of the unit.
+ final CiderUnitTopLevelDeclarations topLevelDeclarations;
+
+ /// Unlinked summary of the compilation unit.
+ final UnlinkedUnit unit;
+
+ CiderUnlinkedUnit({
+ required this.topLevelDeclarations,
+ required this.unit,
+ });
+
+ factory CiderUnlinkedUnit.fromBytes(Uint8List bytes) {
+ return CiderUnlinkedUnit.read(
+ SummaryDataReader(bytes),
+ );
+ }
+
+ factory CiderUnlinkedUnit.read(SummaryDataReader reader) {
+ return CiderUnlinkedUnit(
+ topLevelDeclarations: CiderUnitTopLevelDeclarations.read(reader),
+ unit: UnlinkedUnit.read(reader),
+ );
+ }
+
+ Uint8List toBytes() {
+ var byteSink = ByteSink();
+ var sink = BufferedSink(byteSink);
+ write(sink);
+ return sink.flushAndTake();
+ }
+
+ void write(BufferedSink sink) {
+ topLevelDeclarations.write(sink);
+ unit.write(sink);
+ }
+}
+
class FileState {
final FileSystemState _fsState;
@@ -85,20 +154,12 @@
late Uint8List _digest;
late bool _exists;
- late List<int> _apiSignature;
- late UnlinkedUnit2 unlinked2;
- late TopLevelDeclarations topLevelDeclarations;
- Uint8List? informativeBytes;
+ late CiderUnlinkedUnit unlinked;
LibraryCycle? _libraryCycle;
/// id of the cache entry with unlinked data.
late int unlinkedId;
- /// id of the cache entry with informative data.
- /// We use a separate entry because there is no good way to efficiently
- /// store a raw byte array.
- late int informativeId;
-
FileState._(
this._fsState,
this.path,
@@ -109,7 +170,7 @@
this._packageLanguageVersion,
);
- List<int> get apiSignature => _apiSignature;
+ List<int> get apiSignature => unlinked.unit.apiSignature;
List<int> get digest => _digest;
@@ -124,7 +185,7 @@
return _libraryCycle!;
}
- LineInfo get lineInfo => LineInfo(unlinked2.lineStarts);
+ LineInfo get lineInfo => LineInfo(unlinked.unit.lineStarts);
/// The resolved signature of the file, that depends on the [libraryCycle]
/// signature, and the content of the file.
@@ -231,22 +292,15 @@
});
String unlinkedKey = '$path.unlinked';
- String informativeKey = '$path.informative';
// Prepare bytes of the unlinked bundle - existing or new.
// TODO(migration): should not be nullable
Uint8List? unlinkedBytes;
- Uint8List? informativeBytes;
{
var unlinkedData = _fsState._byteStore.get(unlinkedKey, _digest);
- var informativeData = _fsState._byteStore.get(informativeKey, _digest);
unlinkedBytes = unlinkedData?.bytes;
- informativeBytes = informativeData?.bytes;
- if (unlinkedBytes == null ||
- unlinkedBytes.isEmpty ||
- informativeBytes == null ||
- informativeBytes.isEmpty) {
+ if (unlinkedBytes == null || unlinkedBytes.isEmpty) {
var content = performance.run('content', (_) {
return getContent();
});
@@ -258,48 +312,29 @@
});
performance.run('unlinked', (performance) {
- var unlinkedBuilder = serializeAstCiderUnlinked(_digest, unit);
- unlinkedBytes = unlinkedBuilder.toBuffer();
+ var unlinkedBuilder = serializeAstCiderUnlinked(unit);
+ unlinkedBytes = unlinkedBuilder.toBytes();
performance.getDataInt('length').add(unlinkedBytes!.length);
unlinkedData =
_fsState._byteStore.putGet(unlinkedKey, _digest, unlinkedBytes!);
unlinkedBytes = unlinkedData!.bytes;
});
- performance.run('informative', (performance) {
- informativeBytes = writeUnitInformative(unit);
- performance.getDataInt('length').add(informativeBytes!.length);
- informativeData = _fsState._byteStore
- .putGet(informativeKey, _digest, informativeBytes!);
- informativeBytes = informativeData!.bytes;
- });
+ unlinked = CiderUnlinkedUnit.fromBytes(unlinkedBytes!);
- var decoded = CiderUnlinkedUnit.fromBuffer(unlinkedBytes!);
- unlinked2 = decoded.unlinkedUnit!;
-
- var unitDeclarations = decoded.topLevelDeclarations!;
- topLevelDeclarations = TopLevelDeclarations(
- extensionNames: unitDeclarations.extensionNames.toList(),
- functionNames: unitDeclarations.functionNames.toList(),
- typeNames: unitDeclarations.typeNames.toList(),
- variableNames: unitDeclarations.variableNames.toList(),
- );
-
+ // TODO(scheglov) We decode above only because we call it here.
performance.run('prefetch', (_) {
- _prefetchDirectReferences(unlinked2);
+ _prefetchDirectReferences(unlinked.unit);
});
}
unlinkedId = unlinkedData!.id;
- informativeId = informativeData!.id;
- this.informativeBytes = Uint8List.fromList(informativeBytes!);
}
// Read the unlinked bundle.
- unlinked2 = CiderUnlinkedUnit.fromBuffer(unlinkedBytes!).unlinkedUnit!;
- _apiSignature = Uint8List.fromList(unlinked2.apiSignature);
+ unlinked = CiderUnlinkedUnit.fromBytes(unlinkedBytes!);
// Build the graph.
- for (var directive in unlinked2.imports) {
+ for (var directive in unlinked.unit.imports) {
var file = _fileForRelativeUri(
relativeUri: directive.uri,
performance: performance,
@@ -308,7 +343,7 @@
importedFiles.add(file);
}
}
- for (var directive in unlinked2.exports) {
+ for (var directive in unlinked.unit.exports) {
var file = _fileForRelativeUri(
relativeUri: directive.uri,
performance: performance,
@@ -317,7 +352,7 @@
exportedFiles.add(file);
}
}
- for (var uri in unlinked2.parts) {
+ for (var uri in unlinked.unit.parts) {
var file = _fileForRelativeUri(
containingLibrary: this,
relativeUri: uri,
@@ -327,15 +362,15 @@
partedFiles.add(file);
}
}
- if (unlinked2.hasPartOfDirective) {
+ if (unlinked.unit.hasPartOfDirective) {
if (containingLibrary == null) {
_fsState.testView.partsDiscoveredLibraries.add(path);
- var libraryName = unlinked2.partOfName;
- var libraryUri = unlinked2.partOfUri;
+ var libraryName = unlinked.unit.partOfName;
+ var libraryUri = unlinked.unit.partOfUri;
partOfLibrary = null;
- if (libraryName.isNotEmpty) {
+ if (libraryName != null) {
_findPartOfNameLibrary(performance: performance);
- } else if (libraryUri.isNotEmpty) {
+ } else if (libraryUri != null) {
partOfLibrary = _fileForRelativeUri(
relativeUri: libraryUri,
performance: performance,
@@ -424,7 +459,7 @@
}
}
- void _prefetchDirectReferences(UnlinkedUnit2 unlinkedUnit2) {
+ void _prefetchDirectReferences(UnlinkedUnit unlinkedUnit2) {
if (_fsState.prefetchFiles == null) {
return;
}
@@ -447,28 +482,27 @@
}
}
- for (var directive in unlinked2.imports) {
+ for (var directive in unlinked.unit.imports) {
findPathForUri(directive.uri);
}
- for (var directive in unlinked2.exports) {
+ for (var directive in unlinked.unit.exports) {
findPathForUri(directive.uri);
}
- for (var uri in unlinked2.parts) {
+ for (var uri in unlinked.unit.parts) {
findPathForUri(uri);
}
_fsState.prefetchFiles!(paths.toList());
}
- static CiderUnlinkedUnitBuilder serializeAstCiderUnlinked(
- List<int> digest, CompilationUnit unit) {
- var exports = <UnlinkedNamespaceDirectiveBuilder>[];
- var imports = <UnlinkedNamespaceDirectiveBuilder>[];
+ static CiderUnlinkedUnit serializeAstCiderUnlinked(CompilationUnit unit) {
+ var exports = <UnlinkedNamespaceDirective>[];
+ var imports = <UnlinkedNamespaceDirective>[];
var parts = <String>[];
var hasDartCoreImport = false;
var hasLibraryDirective = false;
var hasPartOfDirective = false;
- var partOfUriStr = '';
- var partOfName = '';
+ String? partOfName;
+ String? partOfUriStr;
for (var directive in unit.directives) {
if (directive is ExportDirective) {
var builder = _serializeNamespaceDirective(directive);
@@ -497,7 +531,8 @@
}
if (!hasDartCoreImport) {
imports.add(
- UnlinkedNamespaceDirectiveBuilder(
+ UnlinkedNamespaceDirective(
+ configurations: [],
uri: 'dart:core',
),
);
@@ -528,21 +563,22 @@
}
}
- var unlinkedBuilder = UnlinkedUnit2Builder(
+ var unlinkedUnit = UnlinkedUnit(
apiSignature: computeUnlinkedApiSignature(unit),
exports: exports,
- imports: imports,
- parts: parts,
hasLibraryDirective: hasLibraryDirective,
hasPartOfDirective: hasPartOfDirective,
+ imports: imports,
+ informativeBytes: writeUnitInformative(unit),
+ lineStarts: Uint32List.fromList(unit.lineInfo!.lineStarts),
partOfName: partOfName,
partOfUri: partOfUriStr,
- lineStarts: unit.lineInfo!.lineStarts,
+ parts: parts,
);
- return CiderUnlinkedUnitBuilder(
- contentDigest: digest,
- unlinkedUnit: unlinkedBuilder,
- topLevelDeclarations: CiderUnitTopLevelDeclarationsBuilder(
+
+ return CiderUnlinkedUnit(
+ unit: unlinkedUnit,
+ topLevelDeclarations: CiderUnitTopLevelDeclarations(
extensionNames: declaredExtensions,
functionNames: declaredFunctions,
typeNames: declaredTypes,
@@ -551,13 +587,14 @@
);
}
- static UnlinkedNamespaceDirectiveBuilder _serializeNamespaceDirective(
- NamespaceDirective directive) {
- return UnlinkedNamespaceDirectiveBuilder(
+ static UnlinkedNamespaceDirective _serializeNamespaceDirective(
+ NamespaceDirective directive,
+ ) {
+ 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 ?? '',
@@ -638,7 +675,6 @@
var result = <int>{};
for (var file in _pathToFile.values) {
result.add(file.unlinkedId);
- result.add(file.informativeId);
}
return result;
}
@@ -771,20 +807,21 @@
}
}
+ var topLevelDeclarations = file.unlinked.topLevelDeclarations;
addDeclaration(
- file.topLevelDeclarations.extensionNames,
+ topLevelDeclarations.extensionNames,
FileTopLevelDeclarationKind.extension,
);
addDeclaration(
- file.topLevelDeclarations.functionNames,
+ topLevelDeclarations.functionNames,
FileTopLevelDeclarationKind.function,
);
addDeclaration(
- file.topLevelDeclarations.typeNames,
+ topLevelDeclarations.typeNames,
FileTopLevelDeclarationKind.type,
);
addDeclaration(
- file.topLevelDeclarations.variableNames,
+ topLevelDeclarations.variableNames,
FileTopLevelDeclarationKind.variable,
);
}
@@ -917,26 +954,6 @@
}
}
-/// Kind of a top-level declaration.
-///
-/// We don't need it to be precise, just enough to support quick fixes.
-enum TopLevelDeclarationKind { type, extension, function, variable }
-
-/// Information about a single top-level declaration.
-class TopLevelDeclarations {
- final List<String> extensionNames;
- final List<String> functionNames;
- final List<String> typeNames;
- final List<String> variableNames;
-
- TopLevelDeclarations({
- required this.extensionNames,
- required this.functionNames,
- required this.typeNames,
- required this.variableNames,
- });
-}
-
class _FakeSource implements Source {
@override
final String fullName;
diff --git a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
index f60649d..ab564f3 100644
--- a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
+++ b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
@@ -168,7 +168,6 @@
// Schedule disposing references to cached unlinked data.
for (var removedFile in removedFiles) {
removedCacheIds.add(removedFile.unlinkedId);
- removedCacheIds.add(removedFile.informativeId);
}
// Remove libraries represented by removed files.
@@ -405,7 +404,6 @@
var removedFiles = fsState!.removeUnusedFiles(files);
for (var removedFile in removedFiles) {
removedCacheIds.add(removedFile.unlinkedId);
- removedCacheIds.add(removedFile.informativeId);
}
}
@@ -545,7 +543,7 @@
file.exists,
file.getContent(),
file.lineInfo,
- file.unlinked2.hasPartOfDirective,
+ file.unlinked.unit.hasPartOfDirective,
fileResult.unit,
fileResult.errors,
);
@@ -825,10 +823,8 @@
var unitsInformativeBytes = <Uri, Uint8List>{};
for (var library in cycle.libraries) {
for (var file in library.libraryFiles) {
- var informativeBytes = file.informativeBytes;
- if (informativeBytes != null) {
- unitsInformativeBytes[file.uri] = informativeBytes;
- }
+ var informativeBytes = file.unlinked.unit.informativeBytes;
+ unitsInformativeBytes[file.uri] = informativeBytes;
}
}
@@ -856,7 +852,7 @@
String? partUriStr;
if (partIndex >= 0) {
- partUriStr = libraryFile.unlinked2.parts[partIndex];
+ partUriStr = libraryFile.unlinked.unit.parts[partIndex];
}
partIndex++;
diff --git a/pkg/analyzer/lib/src/summary/format.dart b/pkg/analyzer/lib/src/summary/format.dart
index 9e2e91b..e85a569 100644
--- a/pkg/analyzer/lib/src/summary/format.dart
+++ b/pkg/analyzer/lib/src/summary/format.dart
@@ -3363,395 +3363,6 @@
String toString() => convert.json.encode(toJson());
}
-class CiderUnitTopLevelDeclarationsBuilder extends Object
- with _CiderUnitTopLevelDeclarationsMixin
- implements idl.CiderUnitTopLevelDeclarations {
- List<String>? _extensionNames;
- List<String>? _functionNames;
- List<String>? _typeNames;
- List<String>? _variableNames;
-
- @override
- List<String> get extensionNames => _extensionNames ??= <String>[];
-
- set extensionNames(List<String> value) {
- this._extensionNames = value;
- }
-
- @override
- List<String> get functionNames => _functionNames ??= <String>[];
-
- set functionNames(List<String> value) {
- this._functionNames = value;
- }
-
- @override
- List<String> get typeNames => _typeNames ??= <String>[];
-
- set typeNames(List<String> value) {
- this._typeNames = value;
- }
-
- @override
- List<String> get variableNames => _variableNames ??= <String>[];
-
- set variableNames(List<String> value) {
- this._variableNames = value;
- }
-
- CiderUnitTopLevelDeclarationsBuilder(
- {List<String>? extensionNames,
- List<String>? functionNames,
- List<String>? typeNames,
- List<String>? variableNames})
- : _extensionNames = extensionNames,
- _functionNames = functionNames,
- _typeNames = typeNames,
- _variableNames = variableNames;
-
- /// Flush [informative] data recursively.
- void flushInformative() {}
-
- /// Accumulate non-[informative] data into [signature].
- void collectApiSignature(api_sig.ApiSignature signatureSink) {
- var extensionNames = this._extensionNames;
- if (extensionNames == null) {
- signatureSink.addInt(0);
- } else {
- signatureSink.addInt(extensionNames.length);
- for (var x in extensionNames) {
- signatureSink.addString(x);
- }
- }
- var functionNames = this._functionNames;
- if (functionNames == null) {
- signatureSink.addInt(0);
- } else {
- signatureSink.addInt(functionNames.length);
- for (var x in functionNames) {
- signatureSink.addString(x);
- }
- }
- var typeNames = this._typeNames;
- if (typeNames == null) {
- signatureSink.addInt(0);
- } else {
- signatureSink.addInt(typeNames.length);
- for (var x in typeNames) {
- signatureSink.addString(x);
- }
- }
- var variableNames = this._variableNames;
- if (variableNames == null) {
- signatureSink.addInt(0);
- } else {
- signatureSink.addInt(variableNames.length);
- for (var x in variableNames) {
- signatureSink.addString(x);
- }
- }
- }
-
- fb.Offset finish(fb.Builder fbBuilder) {
- fb.Offset? offset_extensionNames;
- fb.Offset? offset_functionNames;
- fb.Offset? offset_typeNames;
- fb.Offset? offset_variableNames;
- var extensionNames = _extensionNames;
- if (!(extensionNames == null || extensionNames.isEmpty)) {
- offset_extensionNames = fbBuilder.writeList(
- extensionNames.map((b) => fbBuilder.writeString(b)).toList());
- }
- var functionNames = _functionNames;
- if (!(functionNames == null || functionNames.isEmpty)) {
- offset_functionNames = fbBuilder.writeList(
- functionNames.map((b) => fbBuilder.writeString(b)).toList());
- }
- var typeNames = _typeNames;
- if (!(typeNames == null || typeNames.isEmpty)) {
- offset_typeNames = fbBuilder
- .writeList(typeNames.map((b) => fbBuilder.writeString(b)).toList());
- }
- var variableNames = _variableNames;
- if (!(variableNames == null || variableNames.isEmpty)) {
- offset_variableNames = fbBuilder.writeList(
- variableNames.map((b) => fbBuilder.writeString(b)).toList());
- }
- fbBuilder.startTable();
- if (offset_extensionNames != null) {
- fbBuilder.addOffset(0, offset_extensionNames);
- }
- if (offset_functionNames != null) {
- fbBuilder.addOffset(1, offset_functionNames);
- }
- if (offset_typeNames != null) {
- fbBuilder.addOffset(2, offset_typeNames);
- }
- if (offset_variableNames != null) {
- fbBuilder.addOffset(3, offset_variableNames);
- }
- return fbBuilder.endTable();
- }
-}
-
-class _CiderUnitTopLevelDeclarationsReader
- extends fb.TableReader<_CiderUnitTopLevelDeclarationsImpl> {
- const _CiderUnitTopLevelDeclarationsReader();
-
- @override
- _CiderUnitTopLevelDeclarationsImpl createObject(
- fb.BufferContext bc, int offset) =>
- _CiderUnitTopLevelDeclarationsImpl(bc, offset);
-}
-
-class _CiderUnitTopLevelDeclarationsImpl extends Object
- with _CiderUnitTopLevelDeclarationsMixin
- implements idl.CiderUnitTopLevelDeclarations {
- final fb.BufferContext _bc;
- final int _bcOffset;
-
- _CiderUnitTopLevelDeclarationsImpl(this._bc, this._bcOffset);
-
- List<String>? _extensionNames;
- List<String>? _functionNames;
- List<String>? _typeNames;
- List<String>? _variableNames;
-
- @override
- List<String> get extensionNames {
- return _extensionNames ??= const fb.ListReader<String>(fb.StringReader())
- .vTableGet(_bc, _bcOffset, 0, const <String>[]);
- }
-
- @override
- List<String> get functionNames {
- return _functionNames ??= const fb.ListReader<String>(fb.StringReader())
- .vTableGet(_bc, _bcOffset, 1, const <String>[]);
- }
-
- @override
- List<String> get typeNames {
- return _typeNames ??= const fb.ListReader<String>(fb.StringReader())
- .vTableGet(_bc, _bcOffset, 2, const <String>[]);
- }
-
- @override
- List<String> get variableNames {
- return _variableNames ??= const fb.ListReader<String>(fb.StringReader())
- .vTableGet(_bc, _bcOffset, 3, const <String>[]);
- }
-}
-
-abstract class _CiderUnitTopLevelDeclarationsMixin
- implements idl.CiderUnitTopLevelDeclarations {
- @override
- Map<String, Object> toJson() {
- Map<String, Object> _result = <String, Object>{};
- var local_extensionNames = extensionNames;
- if (local_extensionNames.isNotEmpty) {
- _result["extensionNames"] = local_extensionNames;
- }
- var local_functionNames = functionNames;
- if (local_functionNames.isNotEmpty) {
- _result["functionNames"] = local_functionNames;
- }
- var local_typeNames = typeNames;
- if (local_typeNames.isNotEmpty) {
- _result["typeNames"] = local_typeNames;
- }
- var local_variableNames = variableNames;
- if (local_variableNames.isNotEmpty) {
- _result["variableNames"] = local_variableNames;
- }
- return _result;
- }
-
- @override
- Map<String, Object?> toMap() => {
- "extensionNames": extensionNames,
- "functionNames": functionNames,
- "typeNames": typeNames,
- "variableNames": variableNames,
- };
-
- @override
- String toString() => convert.json.encode(toJson());
-}
-
-class CiderUnlinkedUnitBuilder extends Object
- with _CiderUnlinkedUnitMixin
- implements idl.CiderUnlinkedUnit {
- List<int>? _contentDigest;
- CiderUnitTopLevelDeclarationsBuilder? _topLevelDeclarations;
- UnlinkedUnit2Builder? _unlinkedUnit;
-
- @override
- List<int> get contentDigest => _contentDigest ??= <int>[];
-
- /// The hash signature of the contents of the file.
- set contentDigest(List<int> value) {
- assert(value.every((e) => e >= 0));
- this._contentDigest = value;
- }
-
- @override
- CiderUnitTopLevelDeclarationsBuilder? get topLevelDeclarations =>
- _topLevelDeclarations;
-
- /// Top-level declarations of the unit.
- set topLevelDeclarations(CiderUnitTopLevelDeclarationsBuilder? value) {
- this._topLevelDeclarations = value;
- }
-
- @override
- UnlinkedUnit2Builder? get unlinkedUnit => _unlinkedUnit;
-
- /// Unlinked summary of the compilation unit.
- set unlinkedUnit(UnlinkedUnit2Builder? value) {
- this._unlinkedUnit = value;
- }
-
- CiderUnlinkedUnitBuilder(
- {List<int>? contentDigest,
- CiderUnitTopLevelDeclarationsBuilder? topLevelDeclarations,
- UnlinkedUnit2Builder? unlinkedUnit})
- : _contentDigest = contentDigest,
- _topLevelDeclarations = topLevelDeclarations,
- _unlinkedUnit = unlinkedUnit;
-
- /// Flush [informative] data recursively.
- void flushInformative() {
- _topLevelDeclarations?.flushInformative();
- _unlinkedUnit?.flushInformative();
- }
-
- /// Accumulate non-[informative] data into [signature].
- void collectApiSignature(api_sig.ApiSignature signatureSink) {
- var contentDigest = this._contentDigest;
- if (contentDigest == null) {
- signatureSink.addInt(0);
- } else {
- signatureSink.addInt(contentDigest.length);
- for (var x in contentDigest) {
- signatureSink.addInt(x);
- }
- }
- signatureSink.addBool(this._topLevelDeclarations != null);
- this._topLevelDeclarations?.collectApiSignature(signatureSink);
- signatureSink.addBool(this._unlinkedUnit != null);
- this._unlinkedUnit?.collectApiSignature(signatureSink);
- }
-
- typed_data.Uint8List toBuffer() {
- fb.Builder fbBuilder = fb.Builder();
- return fbBuilder.finish(finish(fbBuilder), "CUUN");
- }
-
- fb.Offset finish(fb.Builder fbBuilder) {
- fb.Offset? offset_contentDigest;
- fb.Offset? offset_topLevelDeclarations;
- fb.Offset? offset_unlinkedUnit;
- var contentDigest = _contentDigest;
- if (!(contentDigest == null || contentDigest.isEmpty)) {
- offset_contentDigest = fbBuilder.writeListUint32(contentDigest);
- }
- var topLevelDeclarations = _topLevelDeclarations;
- if (topLevelDeclarations != null) {
- offset_topLevelDeclarations = topLevelDeclarations.finish(fbBuilder);
- }
- var unlinkedUnit = _unlinkedUnit;
- if (unlinkedUnit != null) {
- offset_unlinkedUnit = unlinkedUnit.finish(fbBuilder);
- }
- fbBuilder.startTable();
- if (offset_contentDigest != null) {
- fbBuilder.addOffset(0, offset_contentDigest);
- }
- if (offset_topLevelDeclarations != null) {
- fbBuilder.addOffset(1, offset_topLevelDeclarations);
- }
- if (offset_unlinkedUnit != null) {
- fbBuilder.addOffset(2, offset_unlinkedUnit);
- }
- return fbBuilder.endTable();
- }
-}
-
-idl.CiderUnlinkedUnit readCiderUnlinkedUnit(List<int> buffer) {
- fb.BufferContext rootRef = fb.BufferContext.fromBytes(buffer);
- return const _CiderUnlinkedUnitReader().read(rootRef, 0);
-}
-
-class _CiderUnlinkedUnitReader extends fb.TableReader<_CiderUnlinkedUnitImpl> {
- const _CiderUnlinkedUnitReader();
-
- @override
- _CiderUnlinkedUnitImpl createObject(fb.BufferContext bc, int offset) =>
- _CiderUnlinkedUnitImpl(bc, offset);
-}
-
-class _CiderUnlinkedUnitImpl extends Object
- with _CiderUnlinkedUnitMixin
- implements idl.CiderUnlinkedUnit {
- final fb.BufferContext _bc;
- final int _bcOffset;
-
- _CiderUnlinkedUnitImpl(this._bc, this._bcOffset);
-
- List<int>? _contentDigest;
- idl.CiderUnitTopLevelDeclarations? _topLevelDeclarations;
- idl.UnlinkedUnit2? _unlinkedUnit;
-
- @override
- List<int> get contentDigest {
- return _contentDigest ??=
- const fb.Uint32ListReader().vTableGet(_bc, _bcOffset, 0, const <int>[]);
- }
-
- @override
- idl.CiderUnitTopLevelDeclarations? get topLevelDeclarations {
- return _topLevelDeclarations ??=
- const _CiderUnitTopLevelDeclarationsReader()
- .vTableGetOrNull(_bc, _bcOffset, 1);
- }
-
- @override
- idl.UnlinkedUnit2? get unlinkedUnit {
- return _unlinkedUnit ??=
- const _UnlinkedUnit2Reader().vTableGetOrNull(_bc, _bcOffset, 2);
- }
-}
-
-abstract class _CiderUnlinkedUnitMixin implements idl.CiderUnlinkedUnit {
- @override
- Map<String, Object> toJson() {
- Map<String, Object> _result = <String, Object>{};
- var local_contentDigest = contentDigest;
- if (local_contentDigest.isNotEmpty) {
- _result["contentDigest"] = local_contentDigest;
- }
- var local_topLevelDeclarations = topLevelDeclarations;
- if (local_topLevelDeclarations != null) {
- _result["topLevelDeclarations"] = local_topLevelDeclarations.toJson();
- }
- var local_unlinkedUnit = unlinkedUnit;
- if (local_unlinkedUnit != null) {
- _result["unlinkedUnit"] = local_unlinkedUnit.toJson();
- }
- return _result;
- }
-
- @override
- Map<String, Object?> toMap() => {
- "contentDigest": contentDigest,
- "topLevelDeclarations": topLevelDeclarations,
- "unlinkedUnit": unlinkedUnit,
- };
-
- @override
- String toString() => convert.json.encode(toJson());
-}
-
class DiagnosticMessageBuilder extends Object
with _DiagnosticMessageMixin
implements idl.DiagnosticMessage {
@@ -4167,669 +3778,3 @@
@override
String toString() => convert.json.encode(toJson());
}
-
-class UnlinkedNamespaceDirectiveBuilder extends Object
- with _UnlinkedNamespaceDirectiveMixin
- implements idl.UnlinkedNamespaceDirective {
- List<UnlinkedNamespaceDirectiveConfigurationBuilder>? _configurations;
- String? _uri;
-
- @override
- List<UnlinkedNamespaceDirectiveConfigurationBuilder> get configurations =>
- _configurations ??= <UnlinkedNamespaceDirectiveConfigurationBuilder>[];
-
- /// The configurations that control which library will actually be used.
- set configurations(
- List<UnlinkedNamespaceDirectiveConfigurationBuilder> value) {
- this._configurations = value;
- }
-
- @override
- String get uri => _uri ??= '';
-
- /// The URI referenced by this directive, nad used by default when none
- /// of the [configurations] matches.
- set uri(String value) {
- this._uri = value;
- }
-
- UnlinkedNamespaceDirectiveBuilder(
- {List<UnlinkedNamespaceDirectiveConfigurationBuilder>? configurations,
- String? uri})
- : _configurations = configurations,
- _uri = uri;
-
- /// Flush [informative] data recursively.
- void flushInformative() {
- _configurations?.forEach((b) => b.flushInformative());
- }
-
- /// Accumulate non-[informative] data into [signature].
- void collectApiSignature(api_sig.ApiSignature signatureSink) {
- var configurations = this._configurations;
- if (configurations == null) {
- signatureSink.addInt(0);
- } else {
- signatureSink.addInt(configurations.length);
- for (var x in configurations) {
- x.collectApiSignature(signatureSink);
- }
- }
- signatureSink.addString(this._uri ?? '');
- }
-
- fb.Offset finish(fb.Builder fbBuilder) {
- fb.Offset? offset_configurations;
- fb.Offset? offset_uri;
- var configurations = _configurations;
- if (!(configurations == null || configurations.isEmpty)) {
- offset_configurations = fbBuilder
- .writeList(configurations.map((b) => b.finish(fbBuilder)).toList());
- }
- var uri = _uri;
- if (uri != null) {
- offset_uri = fbBuilder.writeString(uri);
- }
- fbBuilder.startTable();
- if (offset_configurations != null) {
- fbBuilder.addOffset(0, offset_configurations);
- }
- if (offset_uri != null) {
- fbBuilder.addOffset(1, offset_uri);
- }
- return fbBuilder.endTable();
- }
-}
-
-class _UnlinkedNamespaceDirectiveReader
- extends fb.TableReader<_UnlinkedNamespaceDirectiveImpl> {
- const _UnlinkedNamespaceDirectiveReader();
-
- @override
- _UnlinkedNamespaceDirectiveImpl createObject(
- fb.BufferContext bc, int offset) =>
- _UnlinkedNamespaceDirectiveImpl(bc, offset);
-}
-
-class _UnlinkedNamespaceDirectiveImpl extends Object
- with _UnlinkedNamespaceDirectiveMixin
- implements idl.UnlinkedNamespaceDirective {
- final fb.BufferContext _bc;
- final int _bcOffset;
-
- _UnlinkedNamespaceDirectiveImpl(this._bc, this._bcOffset);
-
- List<idl.UnlinkedNamespaceDirectiveConfiguration>? _configurations;
- String? _uri;
-
- @override
- List<idl.UnlinkedNamespaceDirectiveConfiguration> get configurations {
- return _configurations ??=
- const fb.ListReader<idl.UnlinkedNamespaceDirectiveConfiguration>(
- _UnlinkedNamespaceDirectiveConfigurationReader())
- .vTableGet(_bc, _bcOffset, 0,
- const <idl.UnlinkedNamespaceDirectiveConfiguration>[]);
- }
-
- @override
- String get uri {
- return _uri ??= const fb.StringReader().vTableGet(_bc, _bcOffset, 1, '');
- }
-}
-
-abstract class _UnlinkedNamespaceDirectiveMixin
- implements idl.UnlinkedNamespaceDirective {
- @override
- Map<String, Object> toJson() {
- Map<String, Object> _result = <String, Object>{};
- var local_configurations = configurations;
- if (local_configurations.isNotEmpty) {
- _result["configurations"] =
- local_configurations.map((_value) => _value.toJson()).toList();
- }
- var local_uri = uri;
- if (local_uri != '') {
- _result["uri"] = local_uri;
- }
- return _result;
- }
-
- @override
- Map<String, Object?> toMap() => {
- "configurations": configurations,
- "uri": uri,
- };
-
- @override
- String toString() => convert.json.encode(toJson());
-}
-
-class UnlinkedNamespaceDirectiveConfigurationBuilder extends Object
- with _UnlinkedNamespaceDirectiveConfigurationMixin
- implements idl.UnlinkedNamespaceDirectiveConfiguration {
- String? _name;
- String? _uri;
- String? _value;
-
- @override
- String get name => _name ??= '';
-
- /// The name of the declared variable used in the condition.
- set name(String value) {
- this._name = value;
- }
-
- @override
- String get uri => _uri ??= '';
-
- /// The URI to be used if the condition is true.
- set uri(String value) {
- this._uri = value;
- }
-
- @override
- String get value => _value ??= '';
-
- /// 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.
- set value(String value) {
- this._value = value;
- }
-
- UnlinkedNamespaceDirectiveConfigurationBuilder(
- {String? name, String? uri, String? value})
- : _name = name,
- _uri = uri,
- _value = value;
-
- /// Flush [informative] data recursively.
- void flushInformative() {}
-
- /// Accumulate non-[informative] data into [signature].
- void collectApiSignature(api_sig.ApiSignature signatureSink) {
- signatureSink.addString(this._name ?? '');
- signatureSink.addString(this._value ?? '');
- signatureSink.addString(this._uri ?? '');
- }
-
- fb.Offset finish(fb.Builder fbBuilder) {
- fb.Offset? offset_name;
- fb.Offset? offset_uri;
- fb.Offset? offset_value;
- var name = _name;
- if (name != null) {
- offset_name = fbBuilder.writeString(name);
- }
- var uri = _uri;
- if (uri != null) {
- offset_uri = fbBuilder.writeString(uri);
- }
- var value = _value;
- if (value != null) {
- offset_value = fbBuilder.writeString(value);
- }
- fbBuilder.startTable();
- if (offset_name != null) {
- fbBuilder.addOffset(0, offset_name);
- }
- if (offset_uri != null) {
- fbBuilder.addOffset(2, offset_uri);
- }
- if (offset_value != null) {
- fbBuilder.addOffset(1, offset_value);
- }
- return fbBuilder.endTable();
- }
-}
-
-class _UnlinkedNamespaceDirectiveConfigurationReader
- extends fb.TableReader<_UnlinkedNamespaceDirectiveConfigurationImpl> {
- const _UnlinkedNamespaceDirectiveConfigurationReader();
-
- @override
- _UnlinkedNamespaceDirectiveConfigurationImpl createObject(
- fb.BufferContext bc, int offset) =>
- _UnlinkedNamespaceDirectiveConfigurationImpl(bc, offset);
-}
-
-class _UnlinkedNamespaceDirectiveConfigurationImpl extends Object
- with _UnlinkedNamespaceDirectiveConfigurationMixin
- implements idl.UnlinkedNamespaceDirectiveConfiguration {
- final fb.BufferContext _bc;
- final int _bcOffset;
-
- _UnlinkedNamespaceDirectiveConfigurationImpl(this._bc, this._bcOffset);
-
- String? _name;
- String? _uri;
- String? _value;
-
- @override
- String get name {
- return _name ??= const fb.StringReader().vTableGet(_bc, _bcOffset, 0, '');
- }
-
- @override
- String get uri {
- return _uri ??= const fb.StringReader().vTableGet(_bc, _bcOffset, 2, '');
- }
-
- @override
- String get value {
- return _value ??= const fb.StringReader().vTableGet(_bc, _bcOffset, 1, '');
- }
-}
-
-abstract class _UnlinkedNamespaceDirectiveConfigurationMixin
- implements idl.UnlinkedNamespaceDirectiveConfiguration {
- @override
- Map<String, Object> toJson() {
- Map<String, Object> _result = <String, Object>{};
- var local_name = name;
- if (local_name != '') {
- _result["name"] = local_name;
- }
- var local_uri = uri;
- if (local_uri != '') {
- _result["uri"] = local_uri;
- }
- var local_value = value;
- if (local_value != '') {
- _result["value"] = local_value;
- }
- return _result;
- }
-
- @override
- Map<String, Object?> toMap() => {
- "name": name,
- "uri": uri,
- "value": value,
- };
-
- @override
- String toString() => convert.json.encode(toJson());
-}
-
-class UnlinkedUnit2Builder extends Object
- with _UnlinkedUnit2Mixin
- implements idl.UnlinkedUnit2 {
- List<int>? _apiSignature;
- List<UnlinkedNamespaceDirectiveBuilder>? _exports;
- bool? _hasLibraryDirective;
- bool? _hasPartOfDirective;
- List<UnlinkedNamespaceDirectiveBuilder>? _imports;
- List<int>? _lineStarts;
- String? _partOfName;
- String? _partOfUri;
- List<String>? _parts;
-
- @override
- List<int> get apiSignature => _apiSignature ??= <int>[];
-
- /// 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.
- set apiSignature(List<int> value) {
- assert(value.every((e) => e >= 0));
- this._apiSignature = value;
- }
-
- @override
- List<UnlinkedNamespaceDirectiveBuilder> get exports =>
- _exports ??= <UnlinkedNamespaceDirectiveBuilder>[];
-
- /// URIs of `export` directives.
- set exports(List<UnlinkedNamespaceDirectiveBuilder> value) {
- this._exports = value;
- }
-
- @override
- bool get hasLibraryDirective => _hasLibraryDirective ??= false;
-
- /// Is `true` if the unit contains a `library` directive.
- set hasLibraryDirective(bool value) {
- this._hasLibraryDirective = value;
- }
-
- @override
- bool get hasPartOfDirective => _hasPartOfDirective ??= false;
-
- /// Is `true` if the unit contains a `part of` directive.
- set hasPartOfDirective(bool value) {
- this._hasPartOfDirective = value;
- }
-
- @override
- List<UnlinkedNamespaceDirectiveBuilder> get imports =>
- _imports ??= <UnlinkedNamespaceDirectiveBuilder>[];
-
- /// URIs of `import` directives.
- set imports(List<UnlinkedNamespaceDirectiveBuilder> value) {
- this._imports = value;
- }
-
- @override
- List<int> get lineStarts => _lineStarts ??= <int>[];
-
- /// Offsets of the first character of each line in the source code.
- set lineStarts(List<int> value) {
- assert(value.every((e) => e >= 0));
- this._lineStarts = value;
- }
-
- @override
- String get partOfName => _partOfName ??= '';
-
- /// The library name of the `part of my.name;` directive.
- set partOfName(String value) {
- this._partOfName = value;
- }
-
- @override
- String get partOfUri => _partOfUri ??= '';
-
- /// URI of the `part of 'uri';` directive.
- set partOfUri(String value) {
- this._partOfUri = value;
- }
-
- @override
- List<String> get parts => _parts ??= <String>[];
-
- /// URIs of `part` directives.
- set parts(List<String> value) {
- this._parts = value;
- }
-
- UnlinkedUnit2Builder(
- {List<int>? apiSignature,
- List<UnlinkedNamespaceDirectiveBuilder>? exports,
- bool? hasLibraryDirective,
- bool? hasPartOfDirective,
- List<UnlinkedNamespaceDirectiveBuilder>? imports,
- List<int>? lineStarts,
- String? partOfName,
- String? partOfUri,
- List<String>? parts})
- : _apiSignature = apiSignature,
- _exports = exports,
- _hasLibraryDirective = hasLibraryDirective,
- _hasPartOfDirective = hasPartOfDirective,
- _imports = imports,
- _lineStarts = lineStarts,
- _partOfName = partOfName,
- _partOfUri = partOfUri,
- _parts = parts;
-
- /// Flush [informative] data recursively.
- void flushInformative() {
- _exports?.forEach((b) => b.flushInformative());
- _imports?.forEach((b) => b.flushInformative());
- _lineStarts = null;
- }
-
- /// Accumulate non-[informative] data into [signature].
- void collectApiSignature(api_sig.ApiSignature signatureSink) {
- var apiSignature = this._apiSignature;
- if (apiSignature == null) {
- signatureSink.addInt(0);
- } else {
- signatureSink.addInt(apiSignature.length);
- for (var x in apiSignature) {
- signatureSink.addInt(x);
- }
- }
- var exports = this._exports;
- if (exports == null) {
- signatureSink.addInt(0);
- } else {
- signatureSink.addInt(exports.length);
- for (var x in exports) {
- x.collectApiSignature(signatureSink);
- }
- }
- var imports = this._imports;
- if (imports == null) {
- signatureSink.addInt(0);
- } else {
- signatureSink.addInt(imports.length);
- for (var x in imports) {
- x.collectApiSignature(signatureSink);
- }
- }
- signatureSink.addBool(this._hasPartOfDirective == true);
- var parts = this._parts;
- if (parts == null) {
- signatureSink.addInt(0);
- } else {
- signatureSink.addInt(parts.length);
- for (var x in parts) {
- signatureSink.addString(x);
- }
- }
- signatureSink.addBool(this._hasLibraryDirective == true);
- signatureSink.addString(this._partOfUri ?? '');
- signatureSink.addString(this._partOfName ?? '');
- }
-
- typed_data.Uint8List toBuffer() {
- fb.Builder fbBuilder = fb.Builder();
- return fbBuilder.finish(finish(fbBuilder), "UUN2");
- }
-
- fb.Offset finish(fb.Builder fbBuilder) {
- fb.Offset? offset_apiSignature;
- fb.Offset? offset_exports;
- fb.Offset? offset_imports;
- fb.Offset? offset_lineStarts;
- fb.Offset? offset_partOfName;
- fb.Offset? offset_partOfUri;
- fb.Offset? offset_parts;
- var apiSignature = _apiSignature;
- if (!(apiSignature == null || apiSignature.isEmpty)) {
- offset_apiSignature = fbBuilder.writeListUint32(apiSignature);
- }
- var exports = _exports;
- if (!(exports == null || exports.isEmpty)) {
- offset_exports =
- fbBuilder.writeList(exports.map((b) => b.finish(fbBuilder)).toList());
- }
- var imports = _imports;
- if (!(imports == null || imports.isEmpty)) {
- offset_imports =
- fbBuilder.writeList(imports.map((b) => b.finish(fbBuilder)).toList());
- }
- var lineStarts = _lineStarts;
- if (!(lineStarts == null || lineStarts.isEmpty)) {
- offset_lineStarts = fbBuilder.writeListUint32(lineStarts);
- }
- var partOfName = _partOfName;
- if (partOfName != null) {
- offset_partOfName = fbBuilder.writeString(partOfName);
- }
- var partOfUri = _partOfUri;
- if (partOfUri != null) {
- offset_partOfUri = fbBuilder.writeString(partOfUri);
- }
- var parts = _parts;
- if (!(parts == null || parts.isEmpty)) {
- offset_parts = fbBuilder
- .writeList(parts.map((b) => fbBuilder.writeString(b)).toList());
- }
- fbBuilder.startTable();
- if (offset_apiSignature != null) {
- fbBuilder.addOffset(0, offset_apiSignature);
- }
- if (offset_exports != null) {
- fbBuilder.addOffset(1, offset_exports);
- }
- fbBuilder.addBool(6, _hasLibraryDirective == true);
- fbBuilder.addBool(3, _hasPartOfDirective == true);
- if (offset_imports != null) {
- fbBuilder.addOffset(2, offset_imports);
- }
- if (offset_lineStarts != null) {
- fbBuilder.addOffset(5, offset_lineStarts);
- }
- if (offset_partOfName != null) {
- fbBuilder.addOffset(8, offset_partOfName);
- }
- if (offset_partOfUri != null) {
- fbBuilder.addOffset(7, offset_partOfUri);
- }
- if (offset_parts != null) {
- fbBuilder.addOffset(4, offset_parts);
- }
- return fbBuilder.endTable();
- }
-}
-
-idl.UnlinkedUnit2 readUnlinkedUnit2(List<int> buffer) {
- fb.BufferContext rootRef = fb.BufferContext.fromBytes(buffer);
- return const _UnlinkedUnit2Reader().read(rootRef, 0);
-}
-
-class _UnlinkedUnit2Reader extends fb.TableReader<_UnlinkedUnit2Impl> {
- const _UnlinkedUnit2Reader();
-
- @override
- _UnlinkedUnit2Impl createObject(fb.BufferContext bc, int offset) =>
- _UnlinkedUnit2Impl(bc, offset);
-}
-
-class _UnlinkedUnit2Impl extends Object
- with _UnlinkedUnit2Mixin
- implements idl.UnlinkedUnit2 {
- final fb.BufferContext _bc;
- final int _bcOffset;
-
- _UnlinkedUnit2Impl(this._bc, this._bcOffset);
-
- List<int>? _apiSignature;
- List<idl.UnlinkedNamespaceDirective>? _exports;
- bool? _hasLibraryDirective;
- bool? _hasPartOfDirective;
- List<idl.UnlinkedNamespaceDirective>? _imports;
- List<int>? _lineStarts;
- String? _partOfName;
- String? _partOfUri;
- List<String>? _parts;
-
- @override
- List<int> get apiSignature {
- return _apiSignature ??=
- const fb.Uint32ListReader().vTableGet(_bc, _bcOffset, 0, const <int>[]);
- }
-
- @override
- List<idl.UnlinkedNamespaceDirective> get exports {
- return _exports ??= const fb.ListReader<idl.UnlinkedNamespaceDirective>(
- _UnlinkedNamespaceDirectiveReader())
- .vTableGet(_bc, _bcOffset, 1, const <idl.UnlinkedNamespaceDirective>[]);
- }
-
- @override
- bool get hasLibraryDirective {
- return _hasLibraryDirective ??=
- const fb.BoolReader().vTableGet(_bc, _bcOffset, 6, false);
- }
-
- @override
- bool get hasPartOfDirective {
- return _hasPartOfDirective ??=
- const fb.BoolReader().vTableGet(_bc, _bcOffset, 3, false);
- }
-
- @override
- List<idl.UnlinkedNamespaceDirective> get imports {
- return _imports ??= const fb.ListReader<idl.UnlinkedNamespaceDirective>(
- _UnlinkedNamespaceDirectiveReader())
- .vTableGet(_bc, _bcOffset, 2, const <idl.UnlinkedNamespaceDirective>[]);
- }
-
- @override
- List<int> get lineStarts {
- return _lineStarts ??=
- const fb.Uint32ListReader().vTableGet(_bc, _bcOffset, 5, const <int>[]);
- }
-
- @override
- String get partOfName {
- return _partOfName ??=
- const fb.StringReader().vTableGet(_bc, _bcOffset, 8, '');
- }
-
- @override
- String get partOfUri {
- return _partOfUri ??=
- const fb.StringReader().vTableGet(_bc, _bcOffset, 7, '');
- }
-
- @override
- List<String> get parts {
- return _parts ??= const fb.ListReader<String>(fb.StringReader())
- .vTableGet(_bc, _bcOffset, 4, const <String>[]);
- }
-}
-
-abstract class _UnlinkedUnit2Mixin implements idl.UnlinkedUnit2 {
- @override
- Map<String, Object> toJson() {
- Map<String, Object> _result = <String, Object>{};
- var local_apiSignature = apiSignature;
- if (local_apiSignature.isNotEmpty) {
- _result["apiSignature"] = local_apiSignature;
- }
- var local_exports = exports;
- if (local_exports.isNotEmpty) {
- _result["exports"] =
- local_exports.map((_value) => _value.toJson()).toList();
- }
- var local_hasLibraryDirective = hasLibraryDirective;
- if (local_hasLibraryDirective != false) {
- _result["hasLibraryDirective"] = local_hasLibraryDirective;
- }
- var local_hasPartOfDirective = hasPartOfDirective;
- if (local_hasPartOfDirective != false) {
- _result["hasPartOfDirective"] = local_hasPartOfDirective;
- }
- var local_imports = imports;
- if (local_imports.isNotEmpty) {
- _result["imports"] =
- local_imports.map((_value) => _value.toJson()).toList();
- }
- var local_lineStarts = lineStarts;
- if (local_lineStarts.isNotEmpty) {
- _result["lineStarts"] = local_lineStarts;
- }
- var local_partOfName = partOfName;
- if (local_partOfName != '') {
- _result["partOfName"] = local_partOfName;
- }
- var local_partOfUri = partOfUri;
- if (local_partOfUri != '') {
- _result["partOfUri"] = local_partOfUri;
- }
- var local_parts = parts;
- if (local_parts.isNotEmpty) {
- _result["parts"] = local_parts;
- }
- return _result;
- }
-
- @override
- Map<String, Object?> toMap() => {
- "apiSignature": apiSignature,
- "exports": exports,
- "hasLibraryDirective": hasLibraryDirective,
- "hasPartOfDirective": hasPartOfDirective,
- "imports": imports,
- "lineStarts": lineStarts,
- "partOfName": partOfName,
- "partOfUri": partOfUri,
- "parts": parts,
- };
-
- @override
- String toString() => convert.json.encode(toJson());
-}
diff --git a/pkg/analyzer/lib/src/summary/format.fbs b/pkg/analyzer/lib/src/summary/format.fbs
index 67ee567..44e5dc8 100644
--- a/pkg/analyzer/lib/src/summary/format.fbs
+++ b/pkg/analyzer/lib/src/summary/format.fbs
@@ -403,30 +403,6 @@
signature:[uint] (id: 0);
}
-/// Top-level declarations in a compilation unit.
-table CiderUnitTopLevelDeclarations {
- extensionNames:[string] (id: 0);
-
- functionNames:[string] (id: 1);
-
- typeNames:[string] (id: 2);
-
- variableNames:[string] (id: 3);
-}
-
-/// Information about a compilation unit, contains the content hash
-/// and unlinked summary.
-table CiderUnlinkedUnit {
- /// The hash signature of the contents of the file.
- contentDigest:[uint] (id: 0);
-
- /// Top-level declarations of the unit.
- topLevelDeclarations:CiderUnitTopLevelDeclarations (id: 1);
-
- /// Unlinked summary of the compilation unit.
- unlinkedUnit:UnlinkedUnit2 (id: 2);
-}
-
table DiagnosticMessage {
/// The absolute and normalized path of the file associated with this message.
filePath:string (id: 0);
@@ -460,60 +436,6 @@
fake:uint (id: 0);
}
-/// Unlinked summary information about a namespace directive.
-table UnlinkedNamespaceDirective {
- /// The configurations that control which library will actually be used.
- configurations:[UnlinkedNamespaceDirectiveConfiguration] (id: 0);
-
- /// The URI referenced by this directive, nad used by default when none
- /// of the [configurations] matches.
- uri:string (id: 1);
-}
-
-/// Unlinked summary information about a namespace directive configuration.
-table UnlinkedNamespaceDirectiveConfiguration {
- /// The name of the declared variable used in the condition.
- name:string (id: 0);
-
- /// The URI to be used if the condition is true.
- uri:string (id: 2);
-
- /// 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.
- value:string (id: 1);
-}
-
-/// Unlinked summary information about a compilation unit.
-table UnlinkedUnit2 {
- /// 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.
- apiSignature:[uint] (id: 0);
-
- /// URIs of `export` directives.
- exports:[UnlinkedNamespaceDirective] (id: 1);
-
- /// Is `true` if the unit contains a `library` directive.
- hasLibraryDirective:bool (id: 6);
-
- /// Is `true` if the unit contains a `part of` directive.
- hasPartOfDirective:bool (id: 3);
-
- /// URIs of `import` directives.
- imports:[UnlinkedNamespaceDirective] (id: 2);
-
- /// Offsets of the first character of each line in the source code.
- lineStarts:[uint] (id: 5);
-
- /// The library name of the `part of my.name;` directive.
- partOfName:string (id: 8);
-
- /// URI of the `part of 'uri';` directive.
- partOfUri:string (id: 7);
-
- /// URIs of `part` directives.
- parts:[string] (id: 4);
-}
-
root_type PackageBundle;
file_identifier "PBdl";
diff --git a/pkg/analyzer/lib/src/summary/idl.dart b/pkg/analyzer/lib/src/summary/idl.dart
index cb5eb79..a17feaf 100644
--- a/pkg/analyzer/lib/src/summary/idl.dart
+++ b/pkg/analyzer/lib/src/summary/idl.dart
@@ -435,41 +435,6 @@
List<int> get signature;
}
-/// Top-level declarations in a compilation unit.
-abstract class CiderUnitTopLevelDeclarations extends base.SummaryClass {
- @Id(0)
- List<String> get extensionNames;
-
- @Id(1)
- List<String> get functionNames;
-
- @Id(2)
- List<String> get typeNames;
-
- @Id(3)
- List<String> get variableNames;
-}
-
-/// Information about a compilation unit, contains the content hash
-/// and unlinked summary.
-@TopLevel('CUUN')
-abstract class CiderUnlinkedUnit extends base.SummaryClass {
- factory CiderUnlinkedUnit.fromBuffer(List<int> buffer) =>
- generated.readCiderUnlinkedUnit(buffer);
-
- /// The hash signature of the contents of the file.
- @Id(0)
- List<int> get contentDigest;
-
- /// Top-level declarations of the unit.
- @Id(1)
- CiderUnitTopLevelDeclarations? get topLevelDeclarations;
-
- /// Unlinked summary of the compilation unit.
- @Id(2)
- UnlinkedUnit2? get unlinkedUnit;
-}
-
abstract class DiagnosticMessage extends base.SummaryClass {
/// The absolute and normalized path of the file associated with this message.
@Id(0)
@@ -606,77 +571,3 @@
@Id(0)
int get fake;
}
-
-/// Unlinked summary information about a namespace directive.
-abstract class UnlinkedNamespaceDirective extends base.SummaryClass {
- /// The configurations that control which library will actually be used.
- @Id(0)
- List<UnlinkedNamespaceDirectiveConfiguration> get configurations;
-
- /// The URI referenced by this directive, nad used by default when none
- /// of the [configurations] matches.
- @Id(1)
- String get uri;
-}
-
-/// Unlinked summary information about a namespace directive configuration.
-abstract class UnlinkedNamespaceDirectiveConfiguration
- extends base.SummaryClass {
- /// The name of the declared variable used in the condition.
- @Id(0)
- String get name;
-
- /// The URI to be used if the condition is true.
- @Id(2)
- String get 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.
- @Id(1)
- String get value;
-}
-
-/// Unlinked summary information about a compilation unit.
-@TopLevel('UUN2')
-abstract class UnlinkedUnit2 extends base.SummaryClass {
- factory UnlinkedUnit2.fromBuffer(List<int> buffer) =>
- generated.readUnlinkedUnit2(buffer);
-
- /// 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.
- @Id(0)
- List<int> get apiSignature;
-
- /// URIs of `export` directives.
- @Id(1)
- List<UnlinkedNamespaceDirective> get exports;
-
- /// Is `true` if the unit contains a `library` directive.
- @Id(6)
- bool get hasLibraryDirective;
-
- /// Is `true` if the unit contains a `part of` directive.
- @Id(3)
- bool get hasPartOfDirective;
-
- /// URIs of `import` directives.
- @Id(2)
- List<UnlinkedNamespaceDirective> get imports;
-
- /// Offsets of the first character of each line in the source code.
- @informative
- @Id(5)
- List<int> get lineStarts;
-
- /// The library name of the `part of my.name;` directive.
- @Id(8)
- String get partOfName;
-
- /// URI of the `part of 'uri';` directive.
- @Id(7)
- String get partOfUri;
-
- /// URIs of `part` directives.
- @Id(4)
- List<String> get parts;
-}
diff --git a/pkg/analyzer/lib/src/summary/package_bundle_reader.dart b/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
index 557f22c..6b789a8 100644
--- a/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
+++ b/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
@@ -162,7 +162,7 @@
Uint8List bytes;
if (resourceProvider != null) {
var file = resourceProvider.getFile(path);
- bytes = file.readAsBytesSync() as Uint8List;
+ bytes = file.readAsBytesSync();
} else {
io.File file = io.File(path);
bytes = file.readAsBytesSync();
diff --git a/pkg/analyzer/pubspec.yaml b/pkg/analyzer/pubspec.yaml
index 7871444..8ce05d6 100644
--- a/pkg/analyzer/pubspec.yaml
+++ b/pkg/analyzer/pubspec.yaml
@@ -1,5 +1,5 @@
name: analyzer
-version: 2.6.0-dev
+version: 2.6.0
description: This package provides a library that performs static analysis of Dart code.
homepage: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer
@@ -7,7 +7,7 @@
sdk: '>=2.14.0 <3.0.0'
dependencies:
- _fe_analyzer_shared: ^28.0.0
+ _fe_analyzer_shared: ^29.0.0
cli_util: ^0.3.0
collection: ^1.15.0
convert: ^3.0.0
diff --git a/pkg/analyzer/test/file_system/file_system_test_support.dart b/pkg/analyzer/test/file_system/file_system_test_support.dart
index 6b5d0e2..722474a 100644
--- a/pkg/analyzer/test/file_system/file_system_test_support.dart
+++ b/pkg/analyzer/test/file_system/file_system_test_support.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/file_system/file_system.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:path/path.dart' as path;
@@ -203,8 +205,8 @@
}
test_lengthSync_existing() {
- File file = getFile(exists: true);
- List<int> bytes = <int>[1, 2, 3, 4, 5];
+ var file = getFile(exists: true);
+ var bytes = Uint8List.fromList([1, 2, 3, 4, 5]);
file.writeAsBytesSync(bytes);
expect(file.lengthSync, bytes.length);
@@ -393,8 +395,9 @@
test_writeAsBytesSync_existing() {
File file = getFile(exists: true);
- file.writeAsBytesSync(<int>[99, 99]);
- expect(file.readAsBytesSync(), <int>[99, 99]);
+ var bytes = Uint8List.fromList([99, 99]);
+ file.writeAsBytesSync(bytes);
+ expect(file.readAsBytesSync(), bytes);
}
test_writeAsBytesSync_notExisting();
diff --git a/pkg/analyzer/test/file_system/memory_file_system_test.dart b/pkg/analyzer/test/file_system/memory_file_system_test.dart
index 94b56ef..9eecb33 100644
--- a/pkg/analyzer/test/file_system/memory_file_system_test.dart
+++ b/pkg/analyzer/test/file_system/memory_file_system_test.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/file_system/file_system.dart';
import 'package:analyzer/file_system/memory_file_system.dart';
import 'package:analyzer/src/generated/engine.dart' show TimestampedData;
@@ -265,9 +267,10 @@
test_writeAsBytesSync_notExisting() {
File file = getFile(exists: false);
- file.writeAsBytesSync(<int>[99, 99]);
+ var bytes = Uint8List.fromList([99, 99]);
+ file.writeAsBytesSync(bytes);
expect(file.exists, true);
- expect(file.readAsBytesSync(), <int>[99, 99]);
+ expect(file.readAsBytesSync(), bytes);
}
@override
@@ -354,7 +357,7 @@
}
test_newFileWithBytes() {
- List<int> bytes = <int>[1, 2, 3, 4, 5];
+ var bytes = Uint8List.fromList([1, 2, 3, 4, 5]);
provider.newFileWithBytes(defaultFilePath, bytes);
Resource file = provider.getResource(defaultFilePath);
diff --git a/pkg/analyzer/test/file_system/overlay_file_system_test.dart b/pkg/analyzer/test/file_system/overlay_file_system_test.dart
index 78d9cbf..fd9a6df 100644
--- a/pkg/analyzer/test/file_system/overlay_file_system_test.dart
+++ b/pkg/analyzer/test/file_system/overlay_file_system_test.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/file_system/file_system.dart';
import 'package:analyzer/file_system/memory_file_system.dart';
import 'package:analyzer/file_system/overlay_file_system.dart';
@@ -360,14 +362,18 @@
test_writeAsBytesSync_withoutOverlay() {
File file = _file(exists: true);
- file.writeAsBytesSync(<int>[99, 99]);
- expect(file.readAsBytesSync(), <int>[99, 99]);
+ var bytes = Uint8List.fromList([99, 99]);
+ file.writeAsBytesSync(bytes);
+ expect(file.readAsBytesSync(), bytes);
}
test_writeAsBytesSync_withOverlay() {
File file = _file(exists: true, withOverlay: true);
- expect(() => file.writeAsBytesSync(<int>[99, 99]),
- throwsA(_isFileSystemException));
+ var bytes = Uint8List.fromList([99, 99]);
+ expect(
+ () => file.writeAsBytesSync(bytes),
+ throwsA(_isFileSystemException),
+ );
}
test_writeAsStringSync_withoutOverlay() {
diff --git a/pkg/analyzer/test/file_system/physical_file_system_test.dart b/pkg/analyzer/test/file_system/physical_file_system_test.dart
index 3d33576..8794f1d 100644
--- a/pkg/analyzer/test/file_system/physical_file_system_test.dart
+++ b/pkg/analyzer/test/file_system/physical_file_system_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:io' as io;
+import 'dart:typed_data';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/physical_file_system.dart';
@@ -131,8 +132,11 @@
test_writeAsBytesSync_notExisting() {
File file = getFile(exists: false);
- expect(() => file.writeAsBytesSync(<int>[99, 99]),
- throwsA(isFileSystemException));
+ var bytes = Uint8List.fromList([99, 99]);
+ expect(
+ () => file.writeAsBytesSync(bytes),
+ throwsA(isFileSystemException),
+ );
}
@override
diff --git a/pkg/analyzer/test/generated/constant_test.dart b/pkg/analyzer/test/generated/constant_test.dart
index 8bbf1fa..8de1d7f 100644
--- a/pkg/analyzer/test/generated/constant_test.dart
+++ b/pkg/analyzer/test/generated/constant_test.dart
@@ -48,50 +48,6 @@
await _assertValueInt(74 ^ 42, "74 ^ 42");
}
- test_constructorInvocation_assert_false() async {
- var result = await _getExpressionValue("const C(0)", context: '''
-class C {
- const C(int x) : assert(x > 0);
-}
-''');
- expect(result.isValid, isFalse);
- }
-
- test_constructorInvocation_assert_inherited() async {
- var result = await _getExpressionValue(
- "const Center(name: 'v')",
- context: '''
-class Align {
- final double? widthFactor;
- const Align({String name, this.widthFactor})
- assert(widthFactor == null || widthFactor >= 0.0);
-}
-class Center extends Align {
- const Center({String name})
- : super(name: name);
-}
-''',
- );
- expect(result.isValid, isTrue);
- DartObject value = result.value!;
- assertType(value.type, 'Center');
- DartObject superclassFields =
- value.getField(GenericState.SUPERCLASS_FIELD)!;
- DartObject widthFactor = superclassFields.getField('widthFactor')!;
- expect(widthFactor.isNull, isTrue);
- }
-
- test_constructorInvocation_assert_true() async {
- var result = await _getExpressionValue("const C(3)", context: '''
-class C {
- const C(int x) : assert(x > 0);
-}
-''');
- expect(result.isValid, isTrue);
- DartObject value = result.value!;
- assertType(value.type, 'C');
- }
-
test_constructorInvocation_fieldInitializer() async {
var result = await _getExpressionValue("const C(2)", context: '''
class C {
diff --git a/pkg/analyzer/test/generated/non_error_resolver_test.dart b/pkg/analyzer/test/generated/non_error_resolver_test.dart
index a1cdefa..3770d7c 100644
--- a/pkg/analyzer/test/generated/non_error_resolver_test.dart
+++ b/pkg/analyzer/test/generated/non_error_resolver_test.dart
@@ -13,49 +13,12 @@
main() {
defineReflectiveSuite(() {
- defineReflectiveTests(NonConstantValueInInitializer);
defineReflectiveTests(NonErrorResolverTest);
defineReflectiveTests(NonErrorResolverWithoutNullSafetyTest);
});
}
@reflectiveTest
-class NonConstantValueInInitializer extends PubPackageResolutionTest {
- test_intLiteralInDoubleContext_const_exact() async {
- await assertNoErrorsInCode(r'''
-// @dart = 2.9
-const double x = 0;
-class C {
- const C(double y) : assert(y is double), assert(x is double);
-}
-@C(0)
-@C(-0)
-@C(0x0)
-@C(-0x0)
-void main() {
- const C(0);
- const C(-0);
- const C(0x0);
- const C(-0x0);
-}
-''');
- }
-
- test_isCheckInConstAssert() async {
- await assertNoErrorsInCode(r'''
-// @dart = 2.9
-class C {
- const C() : assert(1 is int);
-}
-
-void main() {
- const C();
-}
-''');
- }
-}
-
-@reflectiveTest
class NonErrorResolverTest extends PubPackageResolutionTest
with NonErrorResolverTestCases {
test_await_flattened() async {
@@ -1790,26 +1753,6 @@
''');
}
- test_intLiteralInDoubleContext_const() async {
- await assertNoErrorsInCode(r'''
-class C {
- const C(double x)
- : assert((x + 3) / 2 == 1.5)
- , assert(x == 0.0);
-}
-@C(0)
-@C(-0)
-@C(0x0)
-@C(-0x0)
-void main() {
- const C(0);
- const C(-0);
- const C(0x0);
- const C(-0x0);
-}
-''');
- }
-
test_invalidAnnotation_constantVariable_field() async {
await assertNoErrorsInCode(r'''
@A.C
diff --git a/pkg/analyzer/test/resource_utils.dart b/pkg/analyzer/test/resource_utils.dart
index 680004d..3337265 100644
--- a/pkg/analyzer/test/resource_utils.dart
+++ b/pkg/analyzer/test/resource_utils.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/file_system/file_system.dart';
import 'package:analyzer/file_system/memory_file_system.dart';
import 'package:analyzer/src/generated/source.dart';
@@ -62,7 +64,7 @@
File newFile(String posixPath, String content) =>
_provider.newFile(posixToOSPath(posixPath), content);
- File newFileWithBytes(String posixPath, List<int> bytes) =>
+ File newFileWithBytes(String posixPath, Uint8List bytes) =>
_provider.newFileWithBytes(posixToOSPath(posixPath), bytes);
Folder newFolder(String posixPath) =>
diff --git a/pkg/analyzer/test/src/dart/constant/evaluation_test.dart b/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
index f2dd07e..33de914 100644
--- a/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
+++ b/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
@@ -20,6 +20,8 @@
defineReflectiveSuite(() {
defineReflectiveTests(ConstantVisitorTest);
defineReflectiveTests(ConstantVisitorWithoutNullSafetyTest);
+ defineReflectiveTests(InstanceCreationEvaluatorTest);
+ defineReflectiveTests(InstanceCreationEvaluatorWithoutNullSafetyTest);
});
}
@@ -318,152 +320,6 @@
);
}
- test_instanceCreationExpression_redirecting_typeParameter() async {
- await resolveTestCode('''
-class A<T> {
- final Object f;
- const A(): this.named(T);
- const A.named(Object t): f = t;
-}
-const a = const A<int>();
-''');
- var result = _evaluateConstant('a');
- expect(result, isNotNull);
- }
-
- test_instanceCreationExpression_typeParameter() async {
- await resolveTestCode('''
-class A<T> {
- final Object f;
- const A(): f = T;
-}
-const a = const A<int>();
-''');
- var result = _evaluateConstant('a');
- var aElement = findElement.class_('A');
- var expectedType = aElement.instantiate(
- typeArguments: [typeProvider.intType],
- nullabilitySuffix: NullabilitySuffix.none);
- expect(result.type, expectedType);
- }
-
- test_instanceCreationExpression_typeParameter_implicitTypeArgs() async {
- await resolveTestCode('''
-class A<T> {
- final Object f;
- const A(): f = T;
-}
-const a = const A();
-''');
- var result = _evaluateConstant('a');
- var aElement = findElement.class_('A');
- var expectedType = aElement.instantiate(
- typeArguments: [typeProvider.dynamicType],
- nullabilitySuffix: NullabilitySuffix.none);
- expect(result.type, expectedType);
- }
-
- test_instanceCreationExpression_typeParameter_super() async {
- await resolveTestCode('''
-class A<T> {
- final Object f;
- const A(Object t): f = t;
-}
-class B<T> extends A<T> {
- const B(): super(T);
-}
-const a = const B<int>();
-''');
- var result = _evaluateConstant('a');
- var bElement = findElement.class_('B');
- var expectedType = bElement.instantiate(
- typeArguments: [typeProvider.intType],
- nullabilitySuffix: NullabilitySuffix.none);
- expect(result.type, expectedType);
- }
-
- test_instanceCreationExpression_typeParameter_superNonGeneric() async {
- await resolveTestCode('''
-class A {
- final Object f;
- const A(Object t): f = t;
-}
-class B<T> extends A {
- const B(): super(T);
-}
-const a = const B<int>();
-''');
- var result = _evaluateConstant('a');
- expect(result, isNotNull);
- }
-
- test_instanceCreationExpression_typeParameter_typeAlias() async {
- await resolveTestCode('''
-class A<T, U> {
- final Object f, g;
- const A(): f = T, g = U;
-}
-typedef B<S> = A<int, S>;
-const a = const B<String>();
-''');
- var result = _evaluateConstant('a');
- var aElement = findElement.class_('A');
- var expectedType = aElement.instantiate(
- typeArguments: [typeProvider.intType, typeProvider.stringType],
- nullabilitySuffix: NullabilitySuffix.none);
- expect(result.type, expectedType);
- }
-
- test_instanceCreationExpression_typeParameter_withoutConstructorTearoffs() async {
- await resolveTestCode('''
-// @dart=2.12
-class A<T> {
- final Object f;
- const A(): f = T;
-}
-const a = const A<int>();
-''');
- var result = _evaluateConstant('a', errorCodes: [
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
- ]);
- var aElement = findElement.class_('A');
- var expectedType = aElement.instantiate(
- typeArguments: [typeProvider.intType],
- nullabilitySuffix: NullabilitySuffix.none);
- expect(result.type, expectedType);
- }
-
- test_typeParameter() async {
- await resolveTestCode('''
-class A<X> {
- const A();
- void m() {
- const x = X;
- }
-}
-''');
- var result = _evaluateConstantLocal('x', errorCodes: [
- CompileTimeErrorCode.INVALID_CONSTANT,
- ]);
- expect(result, isNull);
- }
-
- test_visitAsExpression_potentialConstType() async {
- await assertNoErrorsInCode('''
-const num three = 3;
-
-class C<T extends num> {
- final T w;
- const C() : w = three as T;
-}
-
-void main() {
- const C<int>().w;
-}
-''');
- }
-
test_visitBinaryExpression_gtGtGt_negative_fewerBits() async {
await resolveTestCode('''
const c = 0xFFFFFFFF >>> 8;
@@ -1027,6 +883,21 @@
expect(result.toSetValue()!.map((e) => e.toIntValue()), [1, 2, 3, 4]);
}
+ test_typeParameter() async {
+ await resolveTestCode('''
+class A<X> {
+ const A();
+ void m() {
+ const x = X;
+ }
+}
+''');
+ var result = _evaluateConstantLocal('x', errorCodes: [
+ CompileTimeErrorCode.INVALID_CONSTANT,
+ ]);
+ expect(result, isNull);
+ }
+
test_visitAsExpression_instanceOfSameClass() async {
await resolveTestCode('''
const a = const A();
@@ -1522,91 +1393,6 @@
errorCodes: [CompileTimeErrorCode.INVALID_CONSTANT]);
}
- test_visitInstanceCreationExpression_bool_fromEnvironment() async {
- await resolveTestCode('''
-const a = bool.fromEnvironment('a');
-const b = bool.fromEnvironment('b', defaultValue: true);
-''');
- expect(
- _evaluateConstant('a'),
- _boolValue(false),
- );
- expect(
- _evaluateConstant('a', declaredVariables: {'a': 'true'}),
- _boolValue(true),
- );
-
- expect(
- _evaluateConstant(
- 'b',
- declaredVariables: {'b': 'bbb'},
- lexicalEnvironment: {'defaultValue': _boolValue(true)},
- ),
- _boolValue(true),
- );
- }
-
- test_visitInstanceCreationExpression_bool_hasEnvironment() async {
- await resolveTestCode('''
-const a = bool.hasEnvironment('a');
-''');
- expect(
- _evaluateConstant('a'),
- _boolValue(false),
- );
-
- expect(
- _evaluateConstant('a', declaredVariables: {'a': '42'}),
- _boolValue(true),
- );
- }
-
- test_visitInstanceCreationExpression_int_fromEnvironment() async {
- await resolveTestCode('''
-const a = int.fromEnvironment('a');
-const b = int.fromEnvironment('b', defaultValue: 42);
-''');
- expect(
- _evaluateConstant('a'),
- _intValue(0),
- );
- expect(
- _evaluateConstant('a', declaredVariables: {'a': '5'}),
- _intValue(5),
- );
-
- expect(
- _evaluateConstant(
- 'b',
- declaredVariables: {'b': 'bbb'},
- lexicalEnvironment: {'defaultValue': _intValue(42)},
- ),
- _intValue(42),
- );
- }
-
- test_visitInstanceCreationExpression_string_fromEnvironment() async {
- await resolveTestCode('''
-const a = String.fromEnvironment('a');
-''');
- expect(
- _evaluateConstant('a'),
- DartObjectImpl(
- typeSystem,
- typeProvider.stringType,
- StringState(''),
- ),
- );
- expect(
- _evaluateConstant('a', declaredVariables: {'a': 'test'}),
- DartObjectImpl(
- typeSystem,
- typeProvider.stringType,
- StringState('test'),
- ),
- );
- }
-
test_visitIntegerLiteral() async {
await resolveTestCode('''
const double d = 3;
@@ -1930,7 +1716,9 @@
expect(result.type, typeProvider.intType);
expect(result.toIntValue(), 3);
}
+}
+class ConstantVisitorTestSupport extends PubPackageResolutionTest {
void _assertBoolValue(DartObjectImpl result, bool value) {
expect(result.type, typeProvider.boolType);
expect(result.toBoolValue(), value);
@@ -1941,6 +1729,24 @@
expect(result.toIntValue(), value);
}
+ void _assertTypeArguments(DartObject value, List<String>? typeArgumentNames) {
+ var typeArguments = (value as DartObjectImpl).typeArguments;
+ if (typeArguments == null) {
+ expect(typeArguments, typeArgumentNames);
+ return;
+ }
+ expect(
+ typeArguments.map((arg) => arg.getDisplayString(withNullability: true)),
+ equals(typeArgumentNames),
+ );
+ }
+
+ /// Asserts that evaluation of [name] results in no errors, and a non-null
+ /// [DartObject].
+ void _assertValidConstant(String name) {
+ _evaluateConstant(name);
+ }
+
DartObjectImpl _boolValue(bool value) {
if (identical(value, false)) {
return DartObjectImpl(
@@ -1958,28 +1764,6 @@
fail("Invalid boolean value used in test");
}
- DartObjectImpl _intValue(int value) {
- return DartObjectImpl(
- typeSystem,
- typeProvider.intType,
- IntState(value),
- );
- }
-}
-
-class ConstantVisitorTestSupport extends PubPackageResolutionTest {
- void _assertTypeArguments(DartObject value, List<String>? typeArgumentNames) {
- var typeArguments = (value as DartObjectImpl).typeArguments;
- if (typeArguments == null) {
- expect(typeArguments, typeArgumentNames);
- return;
- }
- expect(
- typeArguments.map((arg) => arg.getDisplayString(withNullability: true)),
- equals(typeArgumentNames),
- );
- }
-
DartObjectImpl _evaluateConstant(
String name, {
List<ErrorCode>? errorCodes,
@@ -2058,6 +1842,14 @@
}
return result;
}
+
+ DartObjectImpl _intValue(int value) {
+ return DartObjectImpl(
+ typeSystem,
+ typeProvider.intType,
+ IntState(value),
+ );
+ }
}
@reflectiveTest
@@ -2073,3 +1865,339 @@
expect(result.type, typeProvider.nullType);
}
}
+
+@reflectiveTest
+class InstanceCreationEvaluatorTest extends ConstantVisitorTestSupport
+ with InstanceCreationEvaluatorTestCases {
+ test_fieldInitializer_typeParameter() async {
+ await resolveTestCode('''
+class A<T> {
+ final Object f;
+ const A(): f = T;
+}
+const a = const A<int>();
+''');
+ var result = _evaluateConstant('a');
+ var aElement = findElement.class_('A');
+ var expectedType = aElement.instantiate(
+ typeArguments: [typeProvider.intType],
+ nullabilitySuffix: NullabilitySuffix.none);
+ expect(result.type, expectedType);
+ }
+
+ test_fieldInitializer_typeParameter_implicitTypeArgs() async {
+ await resolveTestCode('''
+class A<T> {
+ final Object f;
+ const A(): f = T;
+}
+const a = const A();
+''');
+ var result = _evaluateConstant('a');
+ var aElement = findElement.class_('A');
+ var expectedType = aElement.instantiate(
+ typeArguments: [typeProvider.dynamicType],
+ nullabilitySuffix: NullabilitySuffix.none);
+ expect(result.type, expectedType);
+ }
+
+ test_fieldInitializer_typeParameter_typeAlias() async {
+ await resolveTestCode('''
+class A<T, U> {
+ final Object f, g;
+ const A(): f = T, g = U;
+}
+typedef B<S> = A<int, S>;
+const a = const B<String>();
+''');
+ var result = _evaluateConstant('a');
+ var aElement = findElement.class_('A');
+ var expectedType = aElement.instantiate(
+ typeArguments: [typeProvider.intType, typeProvider.stringType],
+ nullabilitySuffix: NullabilitySuffix.none);
+ expect(result.type, expectedType);
+ }
+
+ test_fieldInitializer_typeParameter_withoutConstructorTearoffs() async {
+ await resolveTestCode('''
+// @dart=2.12
+class A<T> {
+ final Object f;
+ const A(): f = T;
+}
+const a = const A<int>();
+''');
+ var result = _evaluateConstant('a', errorCodes: [
+ CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+ CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+ ]);
+ var aElement = findElement.class_('A');
+ var expectedType = aElement.instantiate(
+ typeArguments: [typeProvider.intType],
+ nullabilitySuffix: NullabilitySuffix.none);
+ expect(result.type, expectedType);
+ }
+
+ test_fieldInitializer_visitAsExpression_potentialConstType() async {
+ await assertNoErrorsInCode('''
+const num three = 3;
+
+class C<T extends num> {
+ final T w;
+ const C() : w = three as T;
+}
+
+void main() {
+ const C<int>().w;
+}
+''');
+ }
+
+ test_redirectingConstructor_typeParameter() async {
+ await resolveTestCode('''
+class A<T> {
+ final Object f;
+ const A(): this.named(T);
+ const A.named(Object t): f = t;
+}
+const a = const A<int>();
+''');
+ var result = _evaluateConstant('a');
+ expect(result, isNotNull);
+ }
+
+ test_superInitializer_typeParameter() async {
+ await resolveTestCode('''
+class A<T> {
+ final Object f;
+ const A(Object t): f = t;
+}
+class B<T> extends A<T> {
+ const B(): super(T);
+}
+const a = const B<int>();
+''');
+ var result = _evaluateConstant('a');
+ var bElement = findElement.class_('B');
+ var expectedType = bElement.instantiate(
+ typeArguments: [typeProvider.intType],
+ nullabilitySuffix: NullabilitySuffix.none);
+ expect(result.type, expectedType);
+ }
+
+ test_superInitializer_typeParameter_superNonGeneric() async {
+ await resolveTestCode('''
+class A {
+ final Object f;
+ const A(Object t): f = t;
+}
+class B<T> extends A {
+ const B(): super(T);
+}
+const a = const B<int>();
+''');
+ var result = _evaluateConstant('a');
+ expect(result, isNotNull);
+ }
+}
+
+@reflectiveTest
+mixin InstanceCreationEvaluatorTestCases on ConstantVisitorTestSupport {
+ test_assertInitializer_intInDoubleContext_assertIsDouble_true() async {
+ await resolveTestCode('''
+class A {
+ const A(double x): assert(x is double);
+}
+const a = const A(0);
+''');
+ _assertValidConstant('a');
+ }
+
+ test_assertInitializer_intInDoubleContext_false() async {
+ await resolveTestCode('''
+class A {
+ const A(double x): assert((x + 3) / 2 == 1.5);
+}
+const a = const A(1);
+''');
+ _evaluateConstantOrNull(
+ 'a',
+ errorCodes: [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION],
+ );
+ }
+
+ test_assertInitializer_intInDoubleContext_true() async {
+ await resolveTestCode('''
+class A {
+ const A(double x): assert((x + 3) / 2 == 1.5);
+}
+const a = const A(0);
+''');
+ _assertValidConstant('a');
+ }
+
+ test_assertInitializer_simple_false() async {
+ await resolveTestCode('''
+class A {
+ const A(): assert(1 is String);
+}
+const a = const A();
+''');
+ _evaluateConstantOrNull(
+ 'a',
+ errorCodes: [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION],
+ );
+ }
+
+ test_assertInitializer_simple_true() async {
+ await resolveTestCode('''
+class A {
+ const A(): assert(1 is int);
+}
+const a = const A();
+''');
+ _assertValidConstant('a');
+ }
+
+ test_assertInitializer_simpleInSuperInitializer_false() async {
+ await resolveTestCode('''
+class A {
+ const A(): assert(1 is String);
+}
+class B extends A {
+ const B() : super();
+}
+const b = const B();
+''');
+ _evaluateConstantOrNull(
+ 'b',
+ errorCodes: [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION],
+ );
+ }
+
+ test_assertInitializer_simpleInSuperInitializer_true() async {
+ await resolveTestCode('''
+class A {
+ const A(): assert(1 is int);
+}
+class B extends A {
+ const B() : super();
+}
+const b = const B();
+''');
+ _assertValidConstant('b');
+ }
+
+ test_assertInitializer_usingArgument_false() async {
+ await resolveTestCode('''
+class A {
+ const A(int x): assert(x > 0);
+}
+const a = const A(0);
+''');
+ _evaluateConstantOrNull(
+ 'a',
+ errorCodes: [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION],
+ );
+ }
+
+ test_assertInitializer_usingArgument_true() async {
+ await resolveTestCode('''
+class A {
+ const A(int x): assert(x > 0);
+}
+const a = const A(1);
+''');
+ _assertValidConstant('a');
+ }
+
+ test_bool_fromEnvironment() async {
+ await resolveTestCode('''
+const a = bool.fromEnvironment('a');
+const b = bool.fromEnvironment('b', defaultValue: true);
+''');
+ expect(
+ _evaluateConstant('a'),
+ _boolValue(false),
+ );
+ expect(
+ _evaluateConstant('a', declaredVariables: {'a': 'true'}),
+ _boolValue(true),
+ );
+
+ expect(
+ _evaluateConstant(
+ 'b',
+ declaredVariables: {'b': 'bbb'},
+ lexicalEnvironment: {'defaultValue': _boolValue(true)},
+ ),
+ _boolValue(true),
+ );
+ }
+
+ test_bool_hasEnvironment() async {
+ await resolveTestCode('''
+const a = bool.hasEnvironment('a');
+''');
+ expect(
+ _evaluateConstant('a'),
+ _boolValue(false),
+ );
+
+ expect(
+ _evaluateConstant('a', declaredVariables: {'a': '42'}),
+ _boolValue(true),
+ );
+ }
+
+ test_int_fromEnvironment() async {
+ await resolveTestCode('''
+const a = int.fromEnvironment('a');
+const b = int.fromEnvironment('b', defaultValue: 42);
+''');
+ expect(
+ _evaluateConstant('a'),
+ _intValue(0),
+ );
+ expect(
+ _evaluateConstant('a', declaredVariables: {'a': '5'}),
+ _intValue(5),
+ );
+
+ expect(
+ _evaluateConstant(
+ 'b',
+ declaredVariables: {'b': 'bbb'},
+ lexicalEnvironment: {'defaultValue': _intValue(42)},
+ ),
+ _intValue(42),
+ );
+ }
+
+ test_string_fromEnvironment() async {
+ await resolveTestCode('''
+const a = String.fromEnvironment('a');
+''');
+ expect(
+ _evaluateConstant('a'),
+ DartObjectImpl(
+ typeSystem,
+ typeProvider.stringType,
+ StringState(''),
+ ),
+ );
+ expect(
+ _evaluateConstant('a', declaredVariables: {'a': 'test'}),
+ DartObjectImpl(
+ typeSystem,
+ typeProvider.stringType,
+ StringState('test'),
+ ),
+ );
+ }
+}
+
+@reflectiveTest
+class InstanceCreationEvaluatorWithoutNullSafetyTest
+ extends ConstantVisitorTestSupport
+ with InstanceCreationEvaluatorTestCases, WithoutNullSafetyMixin {}
diff --git a/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart b/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
index 6e07a14..52f968e 100644
--- a/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
+++ b/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
@@ -4,6 +4,7 @@
import 'package:analyzer/src/dart/error/syntactic_errors.dart';
import 'package:analyzer/src/dart/micro/cider_byte_store.dart';
+import 'package:analyzer/src/dart/micro/library_graph.dart';
import 'package:analyzer/src/dart/micro/resolve_file.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer/src/lint/registry.dart';
@@ -743,6 +744,32 @@
expect(fileResolver.testView!.resolvedLibraries, <Object>[]);
}
+ test_getFilesWithTopLevelDeclarations_cached() async {
+ await assertNoErrorsInCode(r'''
+int a = 0;
+var b = 1 + 2;
+''');
+
+ void assertHasOneVariable() {
+ var files = fileResolver.getFilesWithTopLevelDeclarations('a');
+ expect(files, hasLength(1));
+ var file = files.single;
+ expect(file.file.path, result.path);
+ expect(file.kind, FileTopLevelDeclarationKind.variable);
+ }
+
+ // Ask to check that it works when parsed.
+ assertHasOneVariable();
+
+ // Create a new resolved, but reuse the cache.
+ createFileResolver();
+
+ await resolveTestFile();
+
+ // Ask again, when unlinked information is read from the cache.
+ assertHasOneVariable();
+ }
+
test_getLibraryByUri() {
newFile('/workspace/dart/my/lib/a.dart', content: r'''
class A {}
diff --git a/pkg/compiler/testing.json b/pkg/compiler/testing.json
index 7885980..923911a 100644
--- a/pkg/compiler/testing.json
+++ b/pkg/compiler/testing.json
@@ -3,7 +3,7 @@
"":"for details. All rights reserved. Use of this source code is governed by a",
"":"BSD-style license that can be found in the LICENSE.md file.",
- "packages": "../../.packages",
+ "packages": "../../.dart_tool/package_config.json",
"analyze": {
"options": "analysis_options.yaml",
diff --git a/pkg/dev_compiler/test/sourcemap/testing.json b/pkg/dev_compiler/test/sourcemap/testing.json
index 03c2722..5f6e6a8 100644
--- a/pkg/dev_compiler/test/sourcemap/testing.json
+++ b/pkg/dev_compiler/test/sourcemap/testing.json
@@ -2,7 +2,7 @@
"":"Copyright (c) 2017, 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.md file.",
- "packages": "../../../../.packages",
+ "packages": "../../../../.dart_tool/package_config.json",
"suites": [
{
"name": "sourcemaps_ddk",
diff --git a/pkg/front_end/test/fasta/parser/testing.json b/pkg/front_end/test/fasta/parser/testing.json
index b3ae4c8..8265d1e 100644
--- a/pkg/front_end/test/fasta/parser/testing.json
+++ b/pkg/front_end/test/fasta/parser/testing.json
@@ -2,7 +2,7 @@
"":"Copyright (c) 2016, 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.md file.",
- "packages": "../../../../../.packages",
+ "packages": "../../../../../.dart_tool/package_config.json",
"suites": [
{
"name": "parser",
diff --git a/pkg/front_end/test/fasta/scanner/testing.json b/pkg/front_end/test/fasta/scanner/testing.json
index be732cb..711f0cf 100644
--- a/pkg/front_end/test/fasta/scanner/testing.json
+++ b/pkg/front_end/test/fasta/scanner/testing.json
@@ -2,7 +2,7 @@
"":"Copyright (c) 2016, 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.md file.",
- "packages": "../../../../../.packages",
+ "packages": "../../../../../.dart_tool/package_config.json",
"suites": [
{
"name": "scanner",
diff --git a/pkg/front_end/test/lint_suite.dart b/pkg/front_end/test/lint_suite.dart
index af61e9a..130a452 100644
--- a/pkg/front_end/test/lint_suite.dart
+++ b/pkg/front_end/test/lint_suite.dart
@@ -169,7 +169,8 @@
description.cache.firstToken = scanner.tokenize();
description.cache.lineStarts = scanner.lineStarts;
- Uri dotPackages = description.uri.resolve(".packages");
+ Uri dotPackages =
+ description.uri.resolve(".dart_tool/package_config.json");
while (true) {
if (new File.fromUri(dotPackages).existsSync()) {
break;
@@ -178,7 +179,8 @@
if (dotPackages.pathSegments.length < Uri.base.pathSegments.length) {
break;
}
- dotPackages = dotPackages.resolve("../.packages");
+ dotPackages =
+ dotPackages.resolve("../../.dart_tool/package_config.json");
}
File dotPackagesFile = new File.fromUri(dotPackages);
diff --git a/pkg/front_end/testing.json b/pkg/front_end/testing.json
index 8c5b79e..63cd5db 100644
--- a/pkg/front_end/testing.json
+++ b/pkg/front_end/testing.json
@@ -2,7 +2,7 @@
"": "Copyright (c) 2016, 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.md file.",
- "packages": "../../.packages",
+ "packages": "../../.dart_tool/package_config.json",
"suites": [
{
"name": "messages",
diff --git a/pkg/front_end/testing_with_lints.json b/pkg/front_end/testing_with_lints.json
index 6cdef88..4570a39 100644
--- a/pkg/front_end/testing_with_lints.json
+++ b/pkg/front_end/testing_with_lints.json
@@ -3,7 +3,7 @@
"ignored_2":"for details. All rights reserved. Use of this source code is governed by a",
"ignored_3":"BSD-style license that can be found in the LICENSE.md file.",
- "packages": "../../.packages",
+ "packages": "../../.dart_tool/package_config.json",
"analyze": {
"options": "analysis_options.yaml",
"uris": [
diff --git a/pkg/testing/testing.json b/pkg/testing/testing.json
index 722834d..78faafc 100644
--- a/pkg/testing/testing.json
+++ b/pkg/testing/testing.json
@@ -3,7 +3,7 @@
"":"for details. All rights reserved. Use of this source code is governed by a",
"":"BSD-style license that can be found in the LICENSE.md file.",
- "packages": "../../.packages",
+ "packages": "../../.dart_tool/package_config.json",
"suites": [
{
diff --git a/runtime/observatory/BUILD.gn b/runtime/observatory/BUILD.gn
index 80b6d6e..86647e8 100644
--- a/runtime/observatory/BUILD.gn
+++ b/runtime/observatory/BUILD.gn
@@ -13,7 +13,7 @@
# dart2js produces a .deps file, but it is not in a format that is understood
# by ninja, so we explicitly list all the sources here.
- inputs = [ "../../.packages" ] + observatory_sources
+ inputs = [ "../../.dart_tool/package_config.json" ] + observatory_sources
output = "$target_gen_dir/observatory/web/main.dart.js"
outputs = [ output ]
@@ -24,7 +24,7 @@
args = [
"-o",
rebase_path(output),
- "--packages=" + rebase_path("../../.packages"),
+ "--packages=" + rebase_path("../../.dart_tool/package_config.json"),
"--no-sound-null-safety",
]
if (is_debug) {
diff --git a/runtime/observatory/lib/object_graph.dart b/runtime/observatory/lib/object_graph.dart
index 85f64df..18e0fae 100644
--- a/runtime/observatory/lib/object_graph.dart
+++ b/runtime/observatory/lib/object_graph.dart
@@ -590,6 +590,22 @@
this._graph, this._cid, this.name, this.libName, this.libUri);
}
+class _SyntheticSnapshotClass implements SnapshotClass {
+ final _SyntheticSnapshotObject _node;
+ _SyntheticSnapshotClass(this._node);
+
+ String get name => _node.description;
+ String get qualifiedName => _node.description;
+
+ int get shallowSize => _node.shallowSize;
+ int get externalSize => _node.externalSize;
+ int get internalSize => _node.internalSize;
+ int get ownedSize => 0;
+
+ int get instanceCount => 1;
+ Iterable<SnapshotObject> get instances => <SnapshotObject>[_node];
+}
+
/// The analyzed graph from a heap snapshot.
abstract class SnapshotGraph {
String get description;
@@ -674,19 +690,19 @@
var mlive = mergedRoot;
capacity._description = "Capacity + External";
- capacity._klass = live.klass;
- capacity._internalSize = _capacity!;
- capacity._externalSize = _totalExternalSize!;
- capacity._retainedSize = capacity._internalSize + capacity._externalSize;
+ capacity._klass = new _SyntheticSnapshotClass(capacity);
+ capacity._internalSize = 0; // No shallow size.
+ capacity._externalSize = 0; // No shallow size.
+ capacity._retainedSize = _capacity! + _totalExternalSize!;
capacity._successors = <SnapshotObject>[live, uncollected, fragmentation];
capacity._predecessors = <SnapshotObject>[];
capacity._children = <SnapshotObject>[live, uncollected, fragmentation];
mcapacity._description = "Capacity + External";
- mcapacity._klass = mlive.klass;
- mcapacity._internalSize = _capacity!;
- mcapacity._externalSize = _totalExternalSize!;
- mcapacity._retainedSize = mcapacity._internalSize + mcapacity._externalSize;
+ mcapacity._klass = capacity._klass;
+ mcapacity._internalSize = 0; // No shallow size.
+ mcapacity._externalSize = 0; // No shallow size.
+ mcapacity._retainedSize = _capacity! + _totalExternalSize!;
mcapacity._children = <SnapshotMergedDominator>[
mlive,
muncollected,
@@ -695,7 +711,7 @@
mcapacity._objects = <SnapshotObject>[capacity];
uncollected._description = "Uncollected Garbage";
- uncollected._klass = live.klass;
+ uncollected._klass = new _SyntheticSnapshotClass(uncollected);
uncollected._internalSize = _totalInternalSize! - _liveInternalSize!;
uncollected._externalSize = _totalExternalSize! - _liveExternalSize!;
uncollected._retainedSize =
@@ -706,7 +722,7 @@
uncollected._children = <SnapshotObject>[];
muncollected._description = "Uncollected Garbage";
- muncollected._klass = mlive.klass;
+ muncollected._klass = uncollected._klass;
muncollected._internalSize = _totalInternalSize! - _liveInternalSize!;
muncollected._externalSize = _totalExternalSize! - _liveExternalSize!;
muncollected._retainedSize =
@@ -716,7 +732,7 @@
muncollected._objects = <SnapshotObject>[uncollected];
fragmentation._description = "Free";
- fragmentation._klass = live.klass;
+ fragmentation._klass = new _SyntheticSnapshotClass(fragmentation);
fragmentation._internalSize = _capacity! - _totalInternalSize!;
fragmentation._externalSize = 0;
fragmentation._retainedSize = fragmentation._internalSize;
@@ -726,7 +742,7 @@
fragmentation._children = <SnapshotObject>[];
mfragmentation._description = "Free";
- mfragmentation._klass = mlive.klass;
+ mfragmentation._klass = fragmentation._klass;
mfragmentation._internalSize = _capacity! - _totalInternalSize!;
mfragmentation._externalSize = 0;
mfragmentation._retainedSize = mfragmentation._internalSize;
diff --git a/runtime/observatory/lib/src/elements/heap_snapshot.dart b/runtime/observatory/lib/src/elements/heap_snapshot.dart
index c8a5829..7deb8c7 100644
--- a/runtime/observatory/lib/src/elements/heap_snapshot.dart
+++ b/runtime/observatory/lib/src/elements/heap_snapshot.dart
@@ -792,7 +792,7 @@
break;
case HeapSnapshotTreeMode.mergedDominatorTreeDiff:
var root = MergedDominatorDiff.from(
- _snapshotA!.mergedRoot, _snapshotB!.mergedRoot);
+ _snapshotA!.extendedMergedRoot, _snapshotB!.extendedMergedRoot);
_tree = new VirtualTreeElement(_createMergedDominatorDiff,
_updateMergedDominatorDiff, _getChildrenMergedDominatorDiff,
items: _getChildrenMergedDominatorDiff(root), queue: _r.queue);
@@ -816,7 +816,7 @@
case HeapSnapshotTreeMode.mergedDominatorTreeMapDiff:
if (mergedDiffSelection == null) {
mergedDiffSelection = MergedDominatorDiff.from(
- _snapshotA!.mergedRoot, _snapshotB!.mergedRoot);
+ _snapshotA!.extendedMergedRoot, _snapshotB!.extendedMergedRoot);
}
_createTreeMap(
report, new MergedDominatorDiffTreeMap(this), mergedDiffSelection);
diff --git a/runtime/observatory_2/BUILD.gn b/runtime/observatory_2/BUILD.gn
index 412e378..b21c2f0 100644
--- a/runtime/observatory_2/BUILD.gn
+++ b/runtime/observatory_2/BUILD.gn
@@ -13,7 +13,7 @@
# dart2js produces a .deps file, but it is not in a format that is understood
# by ninja, so we explicitly list all the sources here.
- inputs = [ "../../.packages" ] + observatory_sources
+ inputs = [ "../../.dart_tool/package_config.json" ] + observatory_sources
output = "$target_gen_dir/observatory/web/main.dart.js"
outputs = [ output ]
@@ -24,7 +24,7 @@
args = [
"-o",
rebase_path(output),
- "--packages=" + rebase_path("../../.packages"),
+ "--packages=" + rebase_path("../../.dart_tool/package_config.json"),
]
if (is_debug) {
args += [ "--enable-asserts" ]
diff --git a/runtime/vm/os_thread.h b/runtime/vm/os_thread.h
index b1019e8..1f6a0e3 100644
--- a/runtime/vm/os_thread.h
+++ b/runtime/vm/os_thread.h
@@ -305,8 +305,9 @@
friend class IsolateGroup; // to access set_thread(Thread*).
friend class OSThreadIterator;
- friend class ThreadInterrupterWin;
friend class ThreadInterrupterFuchsia;
+ friend class ThreadInterrupterMacOS;
+ friend class ThreadInterrupterWin;
friend class ThreadPool; // to access owning_thread_pool_worker_
};
diff --git a/runtime/vm/signal_handler_macos.cc b/runtime/vm/signal_handler_macos.cc
index 70e5319..0e0c591 100644
--- a/runtime/vm/signal_handler_macos.cc
+++ b/runtime/vm/signal_handler_macos.cc
@@ -91,24 +91,11 @@
}
void SignalHandler::Install(SignalAction action) {
- struct sigaction act = {};
- act.sa_handler = NULL;
- act.sa_sigaction = action;
- sigemptyset(&act.sa_mask);
- act.sa_flags = SA_RESTART | SA_SIGINFO;
- int r = sigaction(SIGPROF, &act, NULL);
- ASSERT(r == 0);
+ // Nothing to do on MacOS.
}
void SignalHandler::Remove() {
- // Ignore future SIGPROF signals because by default SIGPROF will terminate
- // the process and we may have some signals in flight.
- struct sigaction act = {};
- act.sa_handler = SIG_IGN;
- sigemptyset(&act.sa_mask);
- act.sa_flags = 0;
- int r = sigaction(SIGPROF, &act, NULL);
- ASSERT(r == 0);
+ // Nothing to do on MacOS.
}
} // namespace dart
diff --git a/runtime/vm/thread_interrupter.cc b/runtime/vm/thread_interrupter.cc
index be990ab..978b428 100644
--- a/runtime/vm/thread_interrupter.cc
+++ b/runtime/vm/thread_interrupter.cc
@@ -66,15 +66,6 @@
void ThreadInterrupter::Startup() {
ASSERT(initialized_);
- if (IsDebuggerAttached()) {
- MonitorLocker shutdown_ml(monitor_);
- shutdown_ = true;
- if (FLAG_trace_thread_interrupter) {
- OS::PrintErr(
- "ThreadInterrupter disabled because a debugger is attached.\n");
- }
- return;
- }
if (FLAG_trace_thread_interrupter) {
OS::PrintErr("ThreadInterrupter starting up.\n");
}
diff --git a/runtime/vm/thread_interrupter.h b/runtime/vm/thread_interrupter.h
index c5d770e..8921ebe 100644
--- a/runtime/vm/thread_interrupter.h
+++ b/runtime/vm/thread_interrupter.h
@@ -102,8 +102,6 @@
static std::atomic<intptr_t> sample_buffer_lock_;
static std::atomic<intptr_t> sample_buffer_waiters_;
- static bool IsDebuggerAttached();
-
static bool InDeepSleep() {
return current_wait_time_ == Monitor::kNoTimeout;
}
diff --git a/runtime/vm/thread_interrupter_android.cc b/runtime/vm/thread_interrupter_android.cc
index dbdd331..2f8ed98 100644
--- a/runtime/vm/thread_interrupter_android.cc
+++ b/runtime/vm/thread_interrupter_android.cc
@@ -61,10 +61,6 @@
#endif
} // namespace
-bool ThreadInterrupter::IsDebuggerAttached() {
- return false;
-}
-
void ThreadInterrupter::InterruptThread(OSThread* thread) {
if (FLAG_trace_thread_interrupter) {
OS::PrintErr("ThreadInterrupter interrupting %p\n",
diff --git a/runtime/vm/thread_interrupter_fuchsia.cc b/runtime/vm/thread_interrupter_fuchsia.cc
index b295569..235bbed 100644
--- a/runtime/vm/thread_interrupter_fuchsia.cc
+++ b/runtime/vm/thread_interrupter_fuchsia.cc
@@ -227,10 +227,6 @@
}
};
-bool ThreadInterrupter::IsDebuggerAttached() {
- return false;
-}
-
void ThreadInterrupter::InterruptThread(OSThread* thread) {
if (FLAG_trace_thread_interrupter) {
OS::PrintErr("ThreadInterrupter suspending %p\n",
diff --git a/runtime/vm/thread_interrupter_linux.cc b/runtime/vm/thread_interrupter_linux.cc
index ee623db..5d7661d 100644
--- a/runtime/vm/thread_interrupter_linux.cc
+++ b/runtime/vm/thread_interrupter_linux.cc
@@ -48,10 +48,6 @@
}
};
-bool ThreadInterrupter::IsDebuggerAttached() {
- return false;
-}
-
void ThreadInterrupter::InterruptThread(OSThread* thread) {
if (FLAG_trace_thread_interrupter) {
OS::PrintErr("ThreadInterrupter interrupting %p\n",
diff --git a/runtime/vm/thread_interrupter_macos.cc b/runtime/vm/thread_interrupter_macos.cc
index ba9ce5a..4a1cb85 100644
--- a/runtime/vm/thread_interrupter_macos.cc
+++ b/runtime/vm/thread_interrupter_macos.cc
@@ -5,12 +5,15 @@
#include "platform/globals.h"
#if defined(DART_HOST_OS_MACOS)
-#include <assert.h> // NOLINT
-#include <errno.h> // NOLINT
-#include <stdbool.h> // NOLINT
-#include <sys/sysctl.h> // NOLINT
-#include <sys/types.h> // NOLINT
-#include <unistd.h> // NOLINT
+#include <assert.h> // NOLINT
+#include <errno.h> // NOLINT
+#include <mach/kern_return.h> // NOLINT
+#include <mach/mach.h> // NOLINT
+#include <mach/thread_act.h> // NOLINT
+#include <stdbool.h> // NOLINT
+#include <sys/sysctl.h> // NOLINT
+#include <sys/types.h> // NOLINT
+#include <unistd.h> // NOLINT
#include "vm/flags.h"
#include "vm/os.h"
@@ -24,70 +27,110 @@
DECLARE_FLAG(bool, trace_thread_interrupter);
-// Returns true if the current process is being debugged (either
-// running under the debugger or has a debugger attached post facto).
-// Code from https://developer.apple.com/library/content/qa/qa1361/_index.html
-bool ThreadInterrupter::IsDebuggerAttached() {
- struct kinfo_proc info;
- // Initialize the flags so that, if sysctl fails for some bizarre
- // reason, we get a predictable result.
- info.kp_proc.p_flag = 0;
- // Initialize mib, which tells sysctl the info we want, in this case
- // we're looking for information about a specific process ID.
- int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()};
- size_t size = sizeof(info);
+#if defined(HOST_ARCH_X64)
+#define THREAD_STATE_FLAVOR x86_THREAD_STATE64
+#define THREAD_STATE_FLAVOR_SIZE x86_THREAD_STATE64_COUNT
+typedef x86_thread_state64_t thread_state_flavor_t;
+#elif defined(HOST_ARCH_ARM64)
+#define THREAD_STATE_FLAVOR ARM_THREAD_STATE64
+#define THREAD_STATE_FLAVOR_SIZE ARM_THREAD_STATE64_COUNT
+typedef arm_thread_state64_t thread_state_flavor_t;
+#elif defined(HOST_ARCH_ARM)
+#define THREAD_STATE_FLAVOR ARM_THREAD_STATE32
+#define THREAD_STATE_FLAVOR_SIZE ARM_THREAD_STATE32_COUNT
+typedef arm_thread_state32_t thread_state_flavor_t;
+#else
+#error "Unsupported architecture."
+#endif // HOST_ARCH_...
- // Call sysctl.
- size = sizeof(info);
- int junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
- ASSERT(junk == 0);
- // We're being debugged if the P_TRACED flag is set.
- return ((info.kp_proc.p_flag & P_TRACED) != 0);
-}
-
-class ThreadInterrupterMacOS : public AllStatic {
+class ThreadInterrupterMacOS {
public:
- static void ThreadInterruptSignalHandler(int signal,
- siginfo_t* info,
- void* context_) {
- if (signal != SIGPROF) {
- return;
- }
- Thread* thread = Thread::Current();
- if (thread == NULL) {
- return;
- }
- ThreadInterrupter::SampleBufferWriterScope scope;
- if (!scope.CanSample()) {
- return;
- }
- // Extract thread state.
- ucontext_t* context = reinterpret_cast<ucontext_t*>(context_);
- mcontext_t mcontext = context->uc_mcontext;
- InterruptedThreadState its;
- its.pc = SignalHandler::GetProgramCounter(mcontext);
- its.fp = SignalHandler::GetFramePointer(mcontext);
- its.csp = SignalHandler::GetCStackPointer(mcontext);
- its.dsp = SignalHandler::GetDartStackPointer(mcontext);
- its.lr = SignalHandler::GetLinkRegister(mcontext);
- Profiler::SampleThread(thread, its);
+ explicit ThreadInterrupterMacOS(OSThread* os_thread) : os_thread_(os_thread) {
+ ASSERT(os_thread != nullptr);
+ mach_thread_ = pthread_mach_thread_np(os_thread->id());
+ ASSERT(reinterpret_cast<void*>(mach_thread_) != nullptr);
+ res = thread_suspend(mach_thread_);
}
+
+ void CollectSample() {
+ if (res != KERN_SUCCESS) {
+ return;
+ }
+ auto count = static_cast<mach_msg_type_number_t>(THREAD_STATE_FLAVOR_SIZE);
+ thread_state_flavor_t state;
+ kern_return_t res =
+ thread_get_state(mach_thread_, THREAD_STATE_FLAVOR,
+ reinterpret_cast<thread_state_t>(&state), &count);
+ ASSERT(res == KERN_SUCCESS);
+ Thread* thread = static_cast<Thread*>(os_thread_->thread());
+ if (thread == nullptr) {
+ return;
+ }
+ Profiler::SampleThread(thread, ProcessState(state));
+ }
+
+ ~ThreadInterrupterMacOS() {
+ if (res != KERN_SUCCESS) {
+ return;
+ }
+ res = thread_resume(mach_thread_);
+ ASSERT(res == KERN_SUCCESS);
+ }
+
+ private:
+ static InterruptedThreadState ProcessState(thread_state_flavor_t state) {
+ InterruptedThreadState its;
+#if defined(HOST_ARCH_X64)
+ its.pc = state.__rip;
+ its.fp = state.__rbp;
+ its.csp = state.__rsp;
+ its.dsp = state.__rsp;
+ its.lr = 0;
+#elif defined(HOST_ARCH_ARM64)
+ its.pc = state.__pc;
+ its.fp = state.__fp;
+ its.csp = state.__sp;
+ its.dsp = state.__sp;
+ its.lr = state.__lr;
+#elif defined(HOST_ARCH_ARM)
+ its.pc = state.__pc;
+ its.fp = state.__fp;
+ its.csp = state.__sp;
+ its.dsp = state.__sp;
+ its.lr = state.__lr;
+#endif // HOST_ARCH_...
+
+#if defined(TARGET_ARCH_ARM64) && !defined(USING_SIMULATOR)
+ its.dsp = state.__x[SPREG];
+#endif
+ return its;
+ }
+
+ kern_return_t res;
+ OSThread* os_thread_;
+ mach_port_t mach_thread_;
};
-void ThreadInterrupter::InterruptThread(OSThread* thread) {
+void ThreadInterrupter::InterruptThread(OSThread* os_thread) {
+ ASSERT(!OSThread::Compare(OSThread::GetCurrentThreadId(), os_thread->id()));
if (FLAG_trace_thread_interrupter) {
- OS::PrintErr("ThreadInterrupter interrupting %p\n", thread->id());
+ OS::PrintErr("ThreadInterrupter interrupting %p\n", os_thread->id());
}
- int result = pthread_kill(thread->id(), SIGPROF);
- ASSERT((result == 0) || (result == ESRCH));
+
+ ThreadInterrupter::SampleBufferWriterScope scope;
+ if (!scope.CanSample()) {
+ return;
+ }
+ ThreadInterrupterMacOS interrupter(os_thread);
+ interrupter.CollectSample();
}
void ThreadInterrupter::InstallSignalHandler() {
- SignalHandler::Install(&ThreadInterrupterMacOS::ThreadInterruptSignalHandler);
+ // Nothing to do on MacOS.
}
void ThreadInterrupter::RemoveSignalHandler() {
- SignalHandler::Remove();
+ // Nothing to do on MacOS.
}
#endif // !PRODUCT
diff --git a/runtime/vm/thread_interrupter_win.cc b/runtime/vm/thread_interrupter_win.cc
index bfbf5d1..3db5023 100644
--- a/runtime/vm/thread_interrupter_win.cc
+++ b/runtime/vm/thread_interrupter_win.cc
@@ -90,10 +90,6 @@
}
};
-bool ThreadInterrupter::IsDebuggerAttached() {
- return false;
-}
-
void ThreadInterrupter::InterruptThread(OSThread* thread) {
if (FLAG_trace_thread_interrupter) {
OS::PrintErr("ThreadInterrupter suspending %p\n",
diff --git a/tools/VERSION b/tools/VERSION
index c6199a3..3ce629c 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 15
PATCH 0
-PRERELEASE 212
+PRERELEASE 213
PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/tools/bots/flutter/compile_flutter.sh b/tools/bots/flutter/compile_flutter.sh
index 35c3e81..511855c 100755
--- a/tools/bots/flutter/compile_flutter.sh
+++ b/tools/bots/flutter/compile_flutter.sh
@@ -83,7 +83,7 @@
mkdir flutter_patched_sdk
$checkout/tools/sdks/dart-sdk/bin/dart \
- --packages=$checkout/.packages \
+ --packages=$checkout/.dart_tool/package_config.json \
$checkout/pkg/front_end/tool/_fasta/compile_platform.dart \
dart:core \
-Ddart.vm.product=false \
@@ -97,7 +97,7 @@
vm_outline_strong.dill
$checkout/tools/sdks/dart-sdk/bin/dart \
- --packages=$checkout/.packages \
+ --packages=$checkout/.dart_tool/package_config.json \
$checkout/pkg/front_end/tool/_fasta/compile_platform.dart \
--nnbd-agnostic \
--target=flutter \
diff --git a/utils/compile_platform.gni b/utils/compile_platform.gni
index 37c3407..0523ac3 100644
--- a/utils/compile_platform.gni
+++ b/utils/compile_platform.gni
@@ -46,7 +46,7 @@
}
script = "$_dart_root/pkg/front_end/tool/_fasta/compile_platform.dart"
- packages = "$_dart_root/.packages"
+ packages = "$_dart_root/.dart_tool/package_config.json"
outputs = invoker.outputs
diff --git a/utils/compiler/BUILD.gn b/utils/compiler/BUILD.gn
index e724494..90190b8 100644
--- a/utils/compiler/BUILD.gn
+++ b/utils/compiler/BUILD.gn
@@ -41,7 +41,7 @@
outputs = [ "$target_gen_dir/dart2js.dart" ]
- packages = "../../.packages"
+ packages = "../../.dart_tool/package_config.json"
args = [ "--output_dir=$output_dir" ]
}
@@ -63,7 +63,7 @@
vm_args = []
main_dart = "$target_gen_dir/dart2js.dart"
training_args = [
- "--packages=" + rebase_path("../../.packages"),
+ "--packages=" + rebase_path("../../.dart_tool/package_config.json"),
"--libraries-spec=" + rebase_path("$sdk_root/lib/libraries.json"),
# Specifying the platform explicitly elides running the CFE on the sdk
diff --git a/utils/dartanalyzer/BUILD.gn b/utils/dartanalyzer/BUILD.gn
index b7d2486..87291fd 100644
--- a/utils/dartanalyzer/BUILD.gn
+++ b/utils/dartanalyzer/BUILD.gn
@@ -40,7 +40,7 @@
"../../sdk:write_version_file",
]
script = "../../pkg/analyzer/tool/summary/build_sdk_summaries.dart"
- packages = "../../.packages"
+ packages = "../../.dart_tool/package_config.json"
output = "$root_gen_dir/strong.sum"
outputs = [ output ]
vm_args = [ "-Dsdk_hash=$sdk_hash" ]
diff --git a/utils/dartdevc/BUILD.gn b/utils/dartdevc/BUILD.gn
index 74c0cc3..67e0411 100644
--- a/utils/dartdevc/BUILD.gn
+++ b/utils/dartdevc/BUILD.gn
@@ -59,7 +59,7 @@
script = "../../pkg/compiler/lib/src/dart2js.dart"
- packages = "../../.packages"
+ packages = "../../.dart_tool/package_config.json"
vm_args = [ "-Dsdk_hash=$sdk_hash" ]
diff --git a/utils/gen_kernel/BUILD.gn b/utils/gen_kernel/BUILD.gn
index 0df5722..8206342 100644
--- a/utils/gen_kernel/BUILD.gn
+++ b/utils/gen_kernel/BUILD.gn
@@ -14,7 +14,7 @@
]
gen_kernel_script = "$_dart_root/pkg/vm/bin/gen_kernel.dart"
platform_dill = "$root_out_dir/vm_platform_strong.dill"
- dot_packages = rebase_path("$_dart_root/.packages")
+ dot_packages = rebase_path("$_dart_root/.dart_tool/package_config.json")
inputs = [
gen_kernel_script,
diff --git a/utils/kernel-service/BUILD.gn b/utils/kernel-service/BUILD.gn
index 4d464c4..506dd49 100644
--- a/utils/kernel-service/BUILD.gn
+++ b/utils/kernel-service/BUILD.gn
@@ -101,7 +101,7 @@
# consuming/producing kernel.
"-Dsdk_hash=$sdk_hash",
- "--packages=" + scheme + ":///.packages",
+ "--packages=" + scheme + ":///.dart_tool/package_config.json",
"--platform=" + rebase_path("$root_out_dir/vm_platform_strong.dill"),
"--filesystem-root=" + rebase_path("../../"),
"--filesystem-scheme=" + scheme,