33// BSD-style license that can be found in the LICENSE file.
44
55import 'dart:async' ;
6- import 'dart:typed_data' ;
76
87import 'package:analyzer/dart/analysis/results.dart' ;
98import 'package:analyzer/dart/ast/ast.dart' ;
@@ -17,15 +16,11 @@ import 'package:analyzer/src/dart/analysis/driver_event.dart' as driver_events;
1716import 'package:analyzer/src/dart/analysis/file_state.dart' ;
1817import 'package:analyzer/src/dart/analysis/status.dart' ;
1918import 'package:analyzer/src/error/codes.dart' ;
20- import 'package:analyzer/src/fine/library_manifest.dart' ;
2119import 'package:analyzer/src/fine/requirements.dart' ;
2220import 'package:analyzer/src/lint/linter.dart' ;
23- import 'package:analyzer/src/summary2/data_reader.dart' ;
24- import 'package:analyzer/src/summary2/data_writer.dart' ;
2521import 'package:analyzer/src/test_utilities/lint_registration_mixin.dart' ;
2622import 'package:analyzer/src/utilities/extensions/async.dart' ;
2723import 'package:analyzer_utilities/testing/tree_string_sink.dart' ;
28- import 'package:collection/collection.dart' ;
2924import 'package:linter/src/rules.dart' ;
3025import 'package:test/test.dart' ;
3126import 'package:test_reflective_loader/test_reflective_loader.dart' ;
@@ -11710,11 +11705,6 @@ int get b => 0;
1171011705 collector.take ();
1171111706 }
1171211707
11713- _assertLibraryManifestSerialization (
11714- driver: driver,
11715- libraryUri: libraryUri,
11716- );
11717-
1171811708 modifyFile2 (testFile, updatedCode);
1171911709 driver.changeFile2 (testFile);
1172011710
@@ -11723,68 +11713,6 @@ int get b => 0;
1172311713 setId ('expectedUpdatedEvents' );
1172411714 await assertEventsText (collector, expectedUpdatedEvents);
1172511715 }
11726-
11727- static void _assertLibraryManifestSerialization ({
11728- required AnalysisDriver driver,
11729- required Uri libraryUri,
11730- }) {
11731- var idProvider = IdProvider ();
11732-
11733- String manifestAsStr (LibraryManifest manifest) {
11734- var buffer = StringBuffer ();
11735- LibraryManifestPrinter (
11736- configuration: DriverEventsPrinterConfiguration ()
11737- ..withElementManifests = true ,
11738- sink: TreeStringSink (sink: buffer, indent: '' ),
11739- idProvider: idProvider,
11740- ).write (manifest);
11741- return buffer.toString ().trim ();
11742- }
11743-
11744- Uint8List manifestAsBytes (LibraryManifest manifest) {
11745- var byteSink = BufferedSink ();
11746- manifest.write (byteSink);
11747- return byteSink.takeBytes ();
11748- }
11749-
11750- // Write the current manifest as string, and as bytes.
11751- String currentStr;
11752- Uint8List currentBytes;
11753- {
11754- var elementFactory = driver.libraryContext.elementFactory;
11755- var libraryElement = elementFactory.libraryOfUri2 (libraryUri);
11756- // SAFETY: this function is invoked when manifests are enabled.
11757- var manifest = libraryElement.manifest! ;
11758- currentStr = manifestAsStr (manifest);
11759- currentBytes = manifestAsBytes (manifest);
11760- }
11761-
11762- // Read from bytes; write as string and again as bytes.
11763- String readStr;
11764- Uint8List readBytes;
11765- {
11766- var manifest = LibraryManifest .read (
11767- SummaryDataReader (currentBytes),
11768- );
11769- readStr = manifestAsStr (manifest);
11770- readBytes = manifestAsBytes (manifest);
11771- }
11772-
11773- // The strings must be identical.
11774- if (readStr != currentStr) {
11775- print ('${'-' * 16 } current' );
11776- print (currentStr);
11777- print ('${'-' * 16 } read' );
11778- print (readStr);
11779- print ('-' * 32 );
11780- fail ('Library manifest strings are different' );
11781- }
11782-
11783- // The bytes must be identical.
11784- if (! const ListEquality <int >().equals (currentBytes, readBytes)) {
11785- fail ('Library manifest bytes are different' );
11786- }
11787- }
1178811716}
1178911717
1179011718/// A lint that is always reported for all linted files.
0 commit comments