Skip to content

Commit

Permalink
add a packageImports fields to the analysis reponse (#2687)
Browse files Browse the repository at this point in the history
  • Loading branch information
devoncarew authored Oct 20, 2023
1 parent 38f90b8 commit 4c5b0a7
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 10 deletions.
1 change: 1 addition & 0 deletions pkgs/dart_services/lib/src/common_server_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class CommonServerApi {
column: issue.column,
);
}).toList(),
packageImports: result.packageImports,
).toJson());
} else {
return unhandledVersion(apiVersion);
Expand Down
17 changes: 16 additions & 1 deletion 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.

11 changes: 7 additions & 4 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.

3 changes: 3 additions & 0 deletions pkgs/dart_services/test/server_v3_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void main() {
}
'''));
expect(result.issues, isEmpty);
expect(result.packageImports, isEmpty);
});

test('analyze flutter', () async {
Expand All @@ -79,6 +80,8 @@ class MyApp extends StatelessWidget {

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

test('analyze errors', () async {
Expand Down
17 changes: 16 additions & 1 deletion pkgs/dartpad_shared/lib/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ class SourceRequest {
@JsonSerializable()
class AnalysisResponse {
final List<AnalysisIssue> issues;
final List<String> packageImports;

AnalysisResponse({this.issues = const []});
AnalysisResponse({
required this.issues,
required this.packageImports,
});

factory AnalysisResponse.fromJson(Map<String, dynamic> json) =>
_$AnalysisResponseFromJson(json);
Expand Down Expand Up @@ -138,6 +142,11 @@ class FlutterBuildResponse {

@JsonSerializable()
class FixesResponse {
static final FixesResponse empty = FixesResponse(
fixes: [],
assists: [],
);

final List<SourceChange> fixes;
final List<SourceChange> assists;

Expand Down Expand Up @@ -222,6 +231,12 @@ class DocumentResponse {

@JsonSerializable()
class CompleteResponse {
static final CompleteResponse empty = CompleteResponse(
replacementLength: 0,
replacementOffset: 0,
suggestions: [],
);

final int replacementOffset;
final int replacementLength;
final List<CompletionSuggestion> suggestions;
Expand Down
11 changes: 7 additions & 4 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.

0 comments on commit 4c5b0a7

Please sign in to comment.