@@ -43,39 +43,9 @@ void computeLibraryCycle(Uint32List linkedSalt, FileState file) {
4343 libraryWalker.walk (libraryWalker.getNode (file));
4444}
4545
46- class CiderUnitTopLevelDeclarations {
47- final List <String > extensionNames;
48- final List <String > functionNames;
49- final List <String > typeNames;
50- final List <String > variableNames;
51-
52- CiderUnitTopLevelDeclarations ({
53- required this .extensionNames,
54- required this .functionNames,
55- required this .typeNames,
56- required this .variableNames,
57- });
58-
59- factory CiderUnitTopLevelDeclarations .read (SummaryDataReader reader) {
60- return CiderUnitTopLevelDeclarations (
61- extensionNames: reader.readStringUtf8List (),
62- functionNames: reader.readStringUtf8List (),
63- typeNames: reader.readStringUtf8List (),
64- variableNames: reader.readStringUtf8List (),
65- );
66- }
67-
68- void write (BufferedSink sink) {
69- sink.writeStringUtf8Iterable (extensionNames);
70- sink.writeStringUtf8Iterable (functionNames);
71- sink.writeStringUtf8Iterable (typeNames);
72- sink.writeStringUtf8Iterable (variableNames);
73- }
74- }
75-
7646class CiderUnlinkedUnit {
7747 /// Top-level declarations of the unit.
78- final CiderUnitTopLevelDeclarations topLevelDeclarations;
48+ final Set < String > topLevelDeclarations;
7949
8050 /// Unlinked summary of the compilation unit.
8151 final UnlinkedUnit unit;
@@ -93,7 +63,7 @@ class CiderUnlinkedUnit {
9363
9464 factory CiderUnlinkedUnit .read (SummaryDataReader reader) {
9565 return CiderUnlinkedUnit (
96- topLevelDeclarations: CiderUnitTopLevelDeclarations . read (reader ),
66+ topLevelDeclarations: reader. readStringUtf8Set ( ),
9767 unit: UnlinkedUnit .read (reader),
9868 );
9969 }
@@ -106,7 +76,7 @@ class CiderUnlinkedUnit {
10676 }
10777
10878 void write (BufferedSink sink) {
109- topLevelDeclarations. write (sink );
79+ sink. writeStringUtf8Iterable (topLevelDeclarations );
11080 unit.write (sink);
11181 }
11282}
@@ -386,40 +356,12 @@ class FileSystemState {
386356 }
387357
388358 /// Return files that have a top-level declaration with the [name] .
389- List <FileWithTopLevelDeclaration > getFilesWithTopLevelDeclarations (
390- String name,
391- ) {
392- var result = < FileWithTopLevelDeclaration > [];
393-
359+ List <FileState > getFilesWithTopLevelDeclarations (String name) {
360+ var result = < FileState > [];
394361 for (var file in _pathToFile.values) {
395- void addDeclaration (
396- List <String > names,
397- FileTopLevelDeclarationKind kind,
398- ) {
399- if (names.contains (name)) {
400- result.add (
401- FileWithTopLevelDeclaration (file: file, kind: kind),
402- );
403- }
362+ if (file._unlinked.unlinked.topLevelDeclarations.contains (name)) {
363+ result.add (file);
404364 }
405-
406- var topLevelDeclarations = file._unlinked.unlinked.topLevelDeclarations;
407- addDeclaration (
408- topLevelDeclarations.extensionNames,
409- FileTopLevelDeclarationKind .extension ,
410- );
411- addDeclaration (
412- topLevelDeclarations.functionNames,
413- FileTopLevelDeclarationKind .function,
414- );
415- addDeclaration (
416- topLevelDeclarations.typeNames,
417- FileTopLevelDeclarationKind .type,
418- );
419- addDeclaration (
420- topLevelDeclarations.variableNames,
421- FileTopLevelDeclarationKind .variable,
422- );
423365 }
424366 return result;
425367 }
@@ -527,20 +469,6 @@ class FileSystemStateTimers {
527469 }
528470}
529471
530- /// The kind in [FileWithTopLevelDeclaration] .
531- enum FileTopLevelDeclarationKind { extension , function, type, variable }
532-
533- /// The data structure for top-level declarations response.
534- class FileWithTopLevelDeclaration {
535- final FileState file;
536- final FileTopLevelDeclarationKind kind;
537-
538- FileWithTopLevelDeclaration ({
539- required this .file,
540- required this .kind,
541- });
542- }
543-
544472/// Information about libraries that reference each other, so form a cycle.
545473class LibraryCycle {
546474 /// The libraries that belong to this cycle.
@@ -1004,27 +932,24 @@ class _FileStateUnlinked {
1004932 );
1005933 }
1006934
1007- var declaredExtensions = < String > [];
1008- var declaredFunctions = < String > [];
1009- var declaredTypes = < String > [];
1010- var declaredVariables = < String > [];
935+ var topLevelDeclarations = < String > {};
1011936 for (var declaration in unit.declarations) {
1012937 if (declaration is ClassDeclaration ) {
1013- declaredTypes .add (declaration.name.name);
938+ topLevelDeclarations .add (declaration.name.name);
1014939 } else if (declaration is EnumDeclaration ) {
1015- declaredTypes .add (declaration.name.name);
940+ topLevelDeclarations .add (declaration.name.name);
1016941 } else if (declaration is ExtensionDeclaration ) {
1017942 var name = declaration.name;
1018943 if (name != null ) {
1019- declaredExtensions .add (name.name);
944+ topLevelDeclarations .add (name.name);
1020945 }
1021946 } else if (declaration is FunctionDeclaration ) {
1022- declaredFunctions .add (declaration.name.name);
947+ topLevelDeclarations .add (declaration.name.name);
1023948 } else if (declaration is MixinDeclaration ) {
1024- declaredTypes .add (declaration.name.name);
949+ topLevelDeclarations .add (declaration.name.name);
1025950 } else if (declaration is TopLevelVariableDeclaration ) {
1026951 for (var variable in declaration.variables.variables) {
1027- declaredVariables .add (variable.name.name);
952+ topLevelDeclarations .add (variable.name.name);
1028953 }
1029954 }
1030955 }
@@ -1044,12 +969,7 @@ class _FileStateUnlinked {
1044969
1045970 return CiderUnlinkedUnit (
1046971 unit: unlinkedUnit,
1047- topLevelDeclarations: CiderUnitTopLevelDeclarations (
1048- extensionNames: declaredExtensions,
1049- functionNames: declaredFunctions,
1050- typeNames: declaredTypes,
1051- variableNames: declaredVariables,
1052- ),
972+ topLevelDeclarations: topLevelDeclarations,
1053973 );
1054974 }
1055975
0 commit comments