Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 311a184

Browse files
DanTupcommit-bot@chromium.org
authored andcommitted
Remove type merging and the only instance that used it
Change-Id: I7b1f18073e4d204d0d92b531369888ec8f1f3dfb Reviewed-on: https://dart-review.googlesource.com/c/79685 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Danny Tuppeny <dantup@google.com>
1 parent dd59921 commit 311a184

3 files changed

Lines changed: 10 additions & 55 deletions

File tree

pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,21 +1044,6 @@ class Hover {
10441044
final Range range;
10451045
}
10461046

1047-
class InitializeError {
1048-
InitializeError(this.retry);
1049-
1050-
/// If the protocol version provided by the client can't be handled by the
1051-
/// server. @deprecated This initialize error got replaced by client
1052-
/// capabilities. There is no version handshake in version 3.0x
1053-
static const unknownProtocolVersion = 1;
1054-
1055-
/// Indicates whether the client execute the following retry logic: (1) show
1056-
/// the message provided by the ResponseError to the user (2) user selects
1057-
/// retry or cancel (3) if user selected retry the initialize method is sent
1058-
/// again.
1059-
final bool retry;
1060-
}
1061-
10621047
class InitializeParams {
10631048
InitializeParams(this.capabilities, this.initializationOptions,
10641049
this.processId, this.rootPath, this.rootUri, this.workspaceFolders);

pkg/analysis_server/test/tool/lsp_spec/typescript_test.dart

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -184,24 +184,6 @@ export namespace ResourceOperationKind {
184184
equals('Supports deleting existing files and folders.'));
185185
});
186186

187-
test('folds a namespace of constants into an interface', () {
188-
final String input = '''
189-
export interface Thing {
190-
}
191-
export namespace Thing {
192-
export const b: String = 'string';
193-
}
194-
''';
195-
final List<ApiItem> output = extractTypes(input);
196-
expect(output, hasLength(1));
197-
expect(output[0], const TypeMatcher<Interface>());
198-
final Interface interface = output[0];
199-
expect(interface.members, hasLength(1));
200-
expect(interface.members[0], const TypeMatcher<Const>());
201-
final Const b = interface.members[0];
202-
expect(b.name, equals('b'));
203-
});
204-
205187
test('sorts types and members', () {
206188
final String input = '''
207189
export interface b {

pkg/analysis_server/tool/lsp_spec/typescript.dart

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,17 @@ List<ApiItem> extractAllTypes(List<String> code) {
1414

1515
List<ApiItem> extractTypes(String code) {
1616
final types = ApiItem.extractFrom(code);
17+
_removeUnwantedTypes(types);
1718
_sort(types);
18-
return _mergeTypes(types);
19+
return types;
20+
}
21+
22+
/// Removes types that are in the spec that we don't want.
23+
void _removeUnwantedTypes(List<ApiItem> types) {
24+
// These types are not used for v3.0 (Feb 2017) and by dropping them we don't
25+
// have to handle any cases where both a namespace and interfaces are declared
26+
// with the same name.
27+
types.removeWhere((item) => item.name == 'InitializeError');
1928
}
2029

2130
String _cleanComment(String comment) {
@@ -38,27 +47,6 @@ String _cleanComment(String comment) {
3847
return comment.trim();
3948
}
4049

41-
/// The LSP contains Interfaces and Namespaces (of constants) with the
42-
/// same name. This step merges them together into one so that the output
43-
/// code does not contain two definitions.
44-
List<ApiItem> _mergeTypes(List<ApiItem> items) {
45-
final interfaces = <String, Interface>{};
46-
for (var interface in items.whereType<Interface>()) {
47-
interfaces[interface.name] = interface;
48-
}
49-
for (var namespace in items.whereType<Namespace>()) {
50-
final matchedInterface = interfaces[namespace.name];
51-
if (matchedInterface != null) {
52-
matchedInterface.members.addAll(namespace.members);
53-
}
54-
}
55-
// Return the list minus any interfaces that would've been merged above.
56-
return items
57-
.where((item) =>
58-
item is Namespace ? !interfaces.containsKey(item.name) : true)
59-
.toList();
60-
}
61-
6250
List<String> _parseTypes(String baseTypes, String sep) {
6351
// Special case for a single complicated type we can't parse easily...
6452
if (baseTypes ==

0 commit comments

Comments
 (0)