initialize method
Mixins should register their methods in this method, as well as editing the InitializeResult.capabilities as needed.
Implementation
@mustCallSuper
/// Mixins should register their methods in this method, as well as editing
/// the [InitializeResult.capabilities] as needed.
FutureOr<InitializeResult> initialize(InitializeRequest request) {
// If we don't support or understand the version, set it to the latest one
// that we do support. If the client doesn't support that version they will
// terminate the connection.
final clientProtocolVersion = request.protocolVersion;
if (clientProtocolVersion == null || !clientProtocolVersion.isSupported) {
protocolVersion = ProtocolVersion.latestSupported;
} else {
protocolVersion = clientProtocolVersion;
}
clientCapabilities = request.capabilities;
if (clientCapabilities.roots?.listChanged == true) {
_rootsListChangedController =
StreamController<RootsListChangedNotification>.broadcast();
registerNotificationHandler(
RootsListChangedNotification.methodName,
_rootsListChangedController!.sink.add,
);
}
clientInfo = request.clientInfo;
assert(!_initialized.isCompleted);
return InitializeResult(
protocolVersion: protocolVersion,
serverCapabilities: ServerCapabilities(),
serverInfo: implementation,
instructions: instructions,
);
}