Skip to content

Commit bea092d

Browse files
stereotype441Commit Queue
authored andcommitted
[kernel/_fe_analyzer_shared] Share demangleMixinApplicationName.
It's not necessary for `package:kernel` and `package:_fe_analyzer_shared` to have duplicate implementations of this method. `package:kernel` depends on `package:_fe_analyzer_shared`, so they can share one definition. Change-Id: I6a6a696462a0e22a2ea818c42f58187c45821afc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447842 Commit-Queue: Paul Berry <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent 34bb197 commit bea092d

File tree

4 files changed

+7
-25
lines changed

4 files changed

+7
-25
lines changed

pkg/_fe_analyzer_shared/lib/src/messages/codes.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,6 @@ String itemizeNames(List<String> names) {
410410
/// For example, when compiling "class A extends S with M1, M2", the
411411
/// two synthetic classes will be named "_A&S&M1" and "_A&S&M1&M2".
412412
/// This function will return "S with M1" and "S with M1, M2", respectively.
413-
///
414-
/// This method is copied from package:kernel/ast.dart.
415-
// TODO(johnniwinther): Avoid the need for this method.
416413
String demangleMixinApplicationName(String name) {
417414
List<String> nameParts = name.split('&');
418415
if (nameParts.length < 2 || name == "&") return name;

pkg/front_end/lib/src/codes/cfe_codes.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'package:_fe_analyzer_shared/src/messages/codes.dart'
6-
hide demangleMixinApplicationName;
5+
import 'package:_fe_analyzer_shared/src/messages/codes.dart';
76
import 'package:_fe_analyzer_shared/src/messages/severity.dart';
8-
import 'package:kernel/ast.dart'
9-
show Constant, DartType, demangleMixinApplicationName;
7+
import 'package:kernel/ast.dart' show Constant, DartType;
108

119
import 'type_labeler.dart';
1210

13-
export 'package:_fe_analyzer_shared/src/messages/codes.dart'
14-
hide demangleMixinApplicationName;
11+
export 'package:_fe_analyzer_shared/src/messages/codes.dart';
1512
export 'package:_fe_analyzer_shared/src/messages/severity.dart';
1613

1714
part 'cfe_codes_generated.dart';

pkg/kernel/lib/ast.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ import 'package:_fe_analyzer_shared/src/types/shared_type.dart'
8181
SharedType,
8282
SharedVoidType,
8383
Variance;
84+
import 'package:_fe_analyzer_shared/src/messages/codes.dart'
85+
show demangleMixinApplicationName;
8486

8587
import 'src/extension_type_erasure.dart';
8688
import 'visitor.dart';
@@ -103,6 +105,8 @@ import 'src/printer.dart';
103105
import 'src/text_util.dart';
104106

105107
export 'package:_fe_analyzer_shared/src/types/shared_type.dart' show Variance;
108+
export 'package:_fe_analyzer_shared/src/messages/codes.dart'
109+
show demangleMixinApplicationName;
106110

107111
part 'src/ast/constants.dart';
108112
part 'src/ast/components.dart';

pkg/kernel/lib/src/ast/helpers.dart

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -275,22 +275,6 @@ Location? _getLocationInComponent(Component? component, Uri fileUri, int offset,
275275
}
276276
}
277277

278-
/// Convert the synthetic name of an implicit mixin application class
279-
/// into a name suitable for user-faced strings.
280-
///
281-
/// For example, when compiling "class A extends S with M1, M2", the
282-
/// two synthetic classes will be named "_A&S&M1" and "_A&S&M1&M2".
283-
/// This function will return "S with M1" and "S with M1, M2", respectively.
284-
String demangleMixinApplicationName(String name) {
285-
List<String> nameParts = name.split('&');
286-
if (nameParts.length < 2 || name == "&") return name;
287-
String demangledName = nameParts[1];
288-
for (int i = 2; i < nameParts.length; i++) {
289-
demangledName += (i == 2 ? " with " : ", ") + nameParts[i];
290-
}
291-
return demangledName;
292-
}
293-
294278
/// Extract from the synthetic name of an implicit mixin application class
295279
/// the name of the final subclass of the mixin application.
296280
///

0 commit comments

Comments
 (0)