Skip to content

Commit

Permalink
Deprecate unused packageImports field in analysis response (#2756)
Browse files Browse the repository at this point in the history
* Remove unused packageImports field in analysis response

* Make packageImports nullable and continue to supply on the backend
  • Loading branch information
parlough committed Dec 19, 2023
1 parent 270f9d9 commit 7e7f533
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
5 changes: 1 addition & 4 deletions pkgs/dart_services/lib/src/analysis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,7 @@ class AnalysisServerWrapper {
...importIssues,
...issues,
],
packageImports: imports
.where((import) => import.packageImport)
.map((import) => import.packageName)
.toList(),
packageImports: [],
);
}

Expand Down
6 changes: 4 additions & 2 deletions pkgs/dart_services/lib/src/shared/model.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkgs/dart_services/lib/src/shared/model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkgs/dart_services/test/server_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MyApp extends StatelessWidget {

expect(result, isNotNull);
expect(result.issues, isEmpty);
expect(result.packageImports, contains('flutter'));
expect(result.packageImports, isEmpty);
});

test('analyze errors', () async {
Expand Down
6 changes: 4 additions & 2 deletions pkgs/dartpad_shared/lib/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ class SourceRequest {
@JsonSerializable()
class AnalysisResponse {
final List<AnalysisIssue> issues;
final List<String> packageImports;

@Deprecated('This field was unused and will be removed in a future update.')
final List<String>? packageImports;

AnalysisResponse({
required this.issues,
required this.packageImports,
this.packageImports,
});

factory AnalysisResponse.fromJson(Map<String, dynamic> json) =>
Expand Down
4 changes: 2 additions & 2 deletions pkgs/dartpad_shared/lib/model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions pkgs/sketch_pad/lib/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class AppModel {
final ValueNotifier<bool> appReady = ValueNotifier(false);

final ValueNotifier<List<AnalysisIssue>> analysisIssues = ValueNotifier([]);
final ValueNotifier<List<String>> packageImports = ValueNotifier([]);

final ValueNotifier<String> title = ValueNotifier('');

Expand Down Expand Up @@ -318,7 +317,6 @@ class AppServices {
SourceRequest(source: appModel.sourceCodeController.text),
);
appModel.analysisIssues.value = results.issues;
appModel.packageImports.value = results.packageImports;
} catch (error) {
appModel.analysisIssues.value = [
AnalysisIssue(
Expand All @@ -327,7 +325,6 @@ class AppServices {
location: Location(line: 0, column: 0),
),
];
appModel.packageImports.value = [];
}
}

Expand Down

0 comments on commit 7e7f533

Please sign in to comment.