[analysis_server] Update + test for LSP readme being up-to-date with implemented methods

Change-Id: I4c25da38da937d76c4a1b1c9ba1e6318f16c1046
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333400
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
Danny Tuppeny 2023-11-02 20:59:20 +00:00 committed by Commit Queue
parent 988c301109
commit a18a24c16c
2 changed files with 54 additions and 4 deletions

View file

@ -4,6 +4,8 @@
import 'dart:io';
import 'package:analysis_server/src/lsp/handlers/handler_states.dart';
import 'package:analysis_server/src/lsp/lsp_analysis_server.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
@ -37,6 +39,43 @@ void main() {
);
}
});
test('has implemented methods ticked', () {
final readmeContent = readmeFile.readAsStringSync();
final handlerGenerators = [
...InitializedLspStateMessageHandler.lspHandlerGenerators,
...InitializedStateMessageHandler.sharedHandlerGenerators,
];
final missingMethods = StringBuffer();
for (final generator in handlerGenerators) {
final handler = generator(_MockServer());
final method = handler.handlesMessage.toString();
if (method.startsWith('dart')) {
// Dart methods are included under their own heading.
final expectedHeading = '### $method Method';
if (!readmeContent.contains(expectedHeading)) {
missingMethods.writeln('$method does not have a section');
}
} else {
// Standard methods should be listed in the table and ticked.
final escapedMethod = RegExp.escape(method);
final expectedMarkdown = RegExp(' $escapedMethod .*\\| ✅ \\|');
if (!readmeContent.contains(expectedMarkdown)) {
missingMethods.writeln('$method is not listed/ticked in the table');
}
}
}
if (missingMethods.isNotEmpty) {
fail(
'The following are not listed correctly in the README.md file:\n\n'
'$missingMethods',
);
}
});
});
}
@ -46,3 +85,14 @@ String _getAnalysisServerPkgPath() {
final index = components.indexOf('analysis_server');
return path.joinAll(components.sublist(0, index + 1));
}
class _MockServer implements LspAnalysisServer {
@override
final initializationOptions = LspInitializationOptions(null);
@override
bool get onlyAnalyzeProjectsWithOpenFiles => false;
@override
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}

View file

@ -91,7 +91,7 @@ Below is a list of LSP methods and their implementation status.
| textDocument/documentColor | ✅ | | |
| textDocument/colorPresentation | ✅ | | |
| textDocument/documentHighlight | ✅ | | |
| textDocument/documentLink | | | |
| textDocument/documentLink | | | |
| documentLink/resolve | | | |
| textDocument/documentSymbol | ✅ | | |
| textDocument/foldingRange | ✅ | ✅ | |
@ -110,9 +110,9 @@ Below is a list of LSP methods and their implementation status.
| callHierarchy/outgoingCalls | ✅ | | |
| textDocument/prepareRename | ✅ | | |
| textDocument/rename | ✅ | | |
| textDocument/prepareTypeHierarchy | | | |
| typeHierarchy/subtypes | | | |
| typeHierarchy/supertypes | | | |
| textDocument/prepareTypeHierarchy | | | |
| typeHierarchy/subtypes | | | |
| typeHierarchy/supertypes | | | |
| textDocument/publishDiagnostics | ✅ | ✅ | |
| textDocument/references | ✅ | | |
| textDocument/selectionRange | ✅ | | |