-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 1c534e5 into dev
- Loading branch information
Showing
25 changed files
with
1,371 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
pkg/analysis_server/lib/src/services/correction/dart/insert_body.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:analysis_server/src/services/correction/fix.dart'; | ||
import 'package:analysis_server_plugin/edit/dart/correction_producer.dart'; | ||
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart'; | ||
import 'package:analyzer_plugin/utilities/fixes/fixes.dart'; | ||
|
||
class InsertBody extends ResolvedCorrectionProducer { | ||
InsertBody({required super.context}); | ||
|
||
@override | ||
CorrectionApplicability get applicability => | ||
// TODO(applicability): comment on why. | ||
CorrectionApplicability.singleLocation; | ||
|
||
@override | ||
FixKind get fixKind => DartFixKind.INSERT_BODY; | ||
|
||
@override | ||
Future<void> compute(ChangeBuilder builder) async { | ||
var diagnostic = this.diagnostic; | ||
if (diagnostic == null) return; | ||
|
||
var message = diagnostic.problemMessage; | ||
var insertOffset = message.offset + message.length; | ||
await builder.addDartFileEdit(file, (builder) { | ||
builder.addSimpleInsertion(insertOffset, ' {}'); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.