|
11 | 11 | import 'package:df_config/df_config.dart';
|
12 | 12 | import 'package:df_gen_core/df_gen_core.dart';
|
13 | 13 | import 'package:df_log/df_log.dart';
|
| 14 | +import 'package:df_screen_core/df_screen_core.dart'; |
14 | 15 | import 'package:df_string/df_string.dart';
|
15 | 16 |
|
16 | 17 | import '_extract_class_insights_from_dart_file.dart';
|
@@ -65,86 +66,87 @@ Future<void> generateScreenAccess({
|
65 | 66 | fallbackDartSdkPath,
|
66 | 67 | );
|
67 | 68 |
|
| 69 | + final classInsights = <ClassInsight<ModelGenerateScreenBindings>>[]; |
| 70 | + |
68 | 71 | // For each file...
|
69 | 72 | for (final filePathResult in sourceFileExplorerResults.filePathResults
|
70 | 73 | .where((e) => e.category == _Categories.DART)) {
|
71 | 74 | final filePath = filePathResult.path;
|
72 | 75 |
|
73 | 76 | // Extract insights from the file.
|
74 |
| - final classInsights = await extractClassInsightsFromDartFile( |
| 77 | + final temp = await extractClassInsightsFromDartFile( |
75 | 78 | analysisContextCollection,
|
76 | 79 | filePath,
|
77 | 80 | );
|
78 | 81 |
|
79 |
| - if (classInsights.isNotEmpty) { |
80 |
| - final output = template.replaceData( |
81 |
| - { |
82 |
| - Placeholders.SCREEN_MAKERS.placeholder: classInsights.map( |
83 |
| - (e) { |
84 |
| - final a = e.className.toPascalCase(); |
85 |
| - return 'maker$a,'; |
86 |
| - }, |
87 |
| - ), |
88 |
| - Placeholders.PATHS.placeholder: classInsights.map( |
89 |
| - (e) { |
90 |
| - final a = e.className.toUpperSnakeCase(); |
91 |
| - return '...PATH_$a'; |
92 |
| - }, |
93 |
| - ), |
94 |
| - Placeholders.PATHS_NOT_REDIRECTABLE.placeholder: classInsights.map( |
95 |
| - (e) { |
96 |
| - final a = e.className.toUpperSnakeCase(); |
97 |
| - return '...PATH_NOT_REDIRECTABLE_$a'; |
98 |
| - }, |
99 |
| - ), |
100 |
| - Placeholders.PATHS_ALWAYS_ACCESSIBLE.placeholder: classInsights.map( |
101 |
| - (e) { |
102 |
| - final a = e.className.toUpperSnakeCase(); |
103 |
| - return '...PATH_ALWAYS_ACCESSIBLE_$a'; |
104 |
| - }, |
105 |
| - ), |
106 |
| - Placeholders.PATHS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED |
107 |
| - .placeholder: classInsights.map( |
108 |
| - (e) { |
109 |
| - final a = e.className.toUpperSnakeCase(); |
110 |
| - return '...PATH_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED_$a'; |
111 |
| - }, |
112 |
| - ), |
113 |
| - Placeholders.PATHS_ACCESSIBLE_ONLY_IF_LOGGED_IN.placeholder: |
114 |
| - classInsights.map( |
115 |
| - (e) { |
116 |
| - final a = e.className.toUpperSnakeCase(); |
117 |
| - return '...PATH_ACCESSIBLE_ONLY_IF_LOGGED_IN_$a'; |
118 |
| - }, |
119 |
| - ), |
120 |
| - Placeholders.PATHS_ACCESSIBLE_ONLY_IF_LOGGED_OUT.placeholder: |
121 |
| - classInsights.map( |
122 |
| - (e) { |
123 |
| - final a = e.className.toUpperSnakeCase(); |
124 |
| - return '...PATH_ACCESSIBLE_ONLY_IF_LOGGED_OUT_$a'; |
125 |
| - }, |
126 |
| - ), |
127 |
| - Placeholders.GENERATED_SCREEN_ROUTES.placeholder: classInsights.map( |
128 |
| - (e) { |
129 |
| - final a = e.className.toPascalCase(); |
130 |
| - return 'generated${a}Route'; |
131 |
| - }, |
132 |
| - ), |
133 |
| - }, |
134 |
| - ); |
135 |
| - |
136 |
| - // Write the generated Dart file. |
137 |
| - await writeFile(outputFilePath, output); |
138 |
| - |
139 |
| - // Fix the generated Dart file. |
140 |
| - await fixDartFile(outputFilePath); |
141 |
| - |
142 |
| - // Format the generated Dart file. |
143 |
| - await fmtDartFile(outputFilePath); |
144 |
| - |
145 |
| - // Log a success. |
146 |
| - debugLogSuccess('Generated "${previewPath(outputFilePath)}"'); |
147 |
| - } |
| 82 | + classInsights.addAll(temp); |
| 83 | + } |
| 84 | + |
| 85 | + if (classInsights.isNotEmpty) { |
| 86 | + final output = template.replaceData( |
| 87 | + { |
| 88 | + Placeholders.SCREEN_MAKERS.placeholder: classInsights.map( |
| 89 | + (e) { |
| 90 | + final a = e.className.toPascalCase(); |
| 91 | + return 'maker$a,'; |
| 92 | + }, |
| 93 | + ).join(','), |
| 94 | + Placeholders.PATHS.placeholder: classInsights.map( |
| 95 | + (e) { |
| 96 | + final a = e.className.toUpperSnakeCase(); |
| 97 | + return '...PATH_$a'; |
| 98 | + }, |
| 99 | + ).join(','), |
| 100 | + Placeholders.PATHS_NOT_REDIRECTABLE.placeholder: classInsights.map( |
| 101 | + (e) { |
| 102 | + final a = e.className.toUpperSnakeCase(); |
| 103 | + return '...PATH_NOT_REDIRECTABLE_$a'; |
| 104 | + }, |
| 105 | + ), |
| 106 | + Placeholders.PATHS_ALWAYS_ACCESSIBLE.placeholder: classInsights.map( |
| 107 | + (e) { |
| 108 | + final a = e.className.toUpperSnakeCase(); |
| 109 | + return '...PATH_ALWAYS_ACCESSIBLE_$a'; |
| 110 | + }, |
| 111 | + ).join(','), |
| 112 | + Placeholders.PATHS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED.placeholder: classInsights.map( |
| 113 | + (e) { |
| 114 | + final a = e.className.toUpperSnakeCase(); |
| 115 | + return '...PATH_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED_$a'; |
| 116 | + }, |
| 117 | + ).join(','), |
| 118 | + Placeholders.PATHS_ACCESSIBLE_ONLY_IF_LOGGED_IN.placeholder: classInsights.map( |
| 119 | + (e) { |
| 120 | + final a = e.className.toUpperSnakeCase(); |
| 121 | + return '...PATH_ACCESSIBLE_ONLY_IF_LOGGED_IN_$a'; |
| 122 | + }, |
| 123 | + ).join(','), |
| 124 | + Placeholders.PATHS_ACCESSIBLE_ONLY_IF_LOGGED_OUT.placeholder: classInsights.map( |
| 125 | + (e) { |
| 126 | + final a = e.className.toUpperSnakeCase(); |
| 127 | + return '...PATH_ACCESSIBLE_ONLY_IF_LOGGED_OUT_$a'; |
| 128 | + }, |
| 129 | + ).join(','), |
| 130 | + Placeholders.GENERATED_SCREEN_ROUTES.placeholder: classInsights.map( |
| 131 | + (e) { |
| 132 | + final a = e.className.toPascalCase(); |
| 133 | + return 'generated${a}Route'; |
| 134 | + }, |
| 135 | + ).join(','), |
| 136 | + }, |
| 137 | + ); |
| 138 | + |
| 139 | + // Write the generated Dart file. |
| 140 | + await writeFile(outputFilePath, output); |
| 141 | + |
| 142 | + // Fix the generated Dart file. |
| 143 | + await fixDartFile(outputFilePath); |
| 144 | + |
| 145 | + // Format the generated Dart file. |
| 146 | + await fmtDartFile(outputFilePath); |
| 147 | + |
| 148 | + // Log a success. |
| 149 | + debugLogSuccess('Generated "${previewPath(outputFilePath)}"'); |
148 | 150 | }
|
149 | 151 |
|
150 | 152 | // await writeFile(outputFilePath, outputContent);
|
|
0 commit comments