@@ -248,6 +248,16 @@ class RenameTest extends AbstractLspAnalysisServerTest {
248
248
expect (error.message, contains ('already declares class with name' ));
249
249
}
250
250
251
+ Future <void > test_rename_rejectedForSameName () async {
252
+ const content = '''
253
+ class My^Class {}
254
+ ''' ;
255
+ final error = await _test_rename_failure (content, 'MyClass' );
256
+ expect (error.code, equals (ServerErrorCodes .RenameNotValid ));
257
+ expect (error.message,
258
+ contains ('new name must be different than the current name' ));
259
+ }
260
+
251
261
Future <void > test_rename_rejectedForStaleDocument () async {
252
262
const content = '''
253
263
class MyClass {}
@@ -259,6 +269,22 @@ class RenameTest extends AbstractLspAnalysisServerTest {
259
269
expect (error.message, contains ('Document was modified' ));
260
270
}
261
271
272
+ Future <void > test_rename_rejectionsDoNotCrashServer () async {
273
+ // Checks that a rename failure does not stop the server from responding
274
+ // as was previously the case in https://github.com/dart-lang/sdk/issues/42573
275
+ // because the error code was duplicated/reused for ClientServerInconsistentState.
276
+ const content = '''
277
+ /// Test Class
278
+ class My^Class {}
279
+ ''' ;
280
+ final error = await _test_rename_failure (content, 'MyClass' );
281
+ expect (error.code, isNotNull);
282
+
283
+ // Send any other request to ensure the server is still responsive.
284
+ final hover = await getHover (mainFileUri, positionFromMarker (content));
285
+ expect (hover? .contents, isNotNull);
286
+ }
287
+
262
288
Future <void > test_rename_sdkClass () async {
263
289
const content = '''
264
290
final a = new [[Ob^ject]]();
0 commit comments