Eliminate GPUI View, ViewContext, and WindowContext types (#22632)

There's still a bit more work to do on this, but this PR is compiling
(with warnings) after eliminating the key types. When the tasks below
are complete, this will be the new narrative for GPUI:

- `Entity<T>` - This replaces `View<T>`/`Model<T>`. It represents a unit
of state, and if `T` implements `Render`, then `Entity<T>` implements
`Element`.
- `&mut App` This replaces `AppContext` and represents the app.
- `&mut Context<T>` This replaces `ModelContext` and derefs to `App`. It
is provided by the framework when updating an entity.
- `&mut Window` Broken out of `&mut WindowContext` which no longer
exists. Every method that once took `&mut WindowContext` now takes `&mut
Window, &mut App` and every method that took `&mut ViewContext<T>` now
takes `&mut Window, &mut Context<T>`

Not pictured here are the two other failed attempts. It's been quite a
month!

Tasks:

- [x] Remove `View`, `ViewContext`, `WindowContext` and thread through
`Window`
- [x] [@cole-miller @mikayla-maki] Redraw window when entities change
- [x] [@cole-miller @mikayla-maki] Get examples and Zed running
- [x] [@cole-miller @mikayla-maki] Fix Zed rendering
- [x] [@mikayla-maki] Fix todo! macros and comments
- [x] Fix a bug where the editor would not be redrawn because of view
caching
- [x] remove publicness window.notify() and replace with
`AppContext::notify`
- [x] remove `observe_new_window_models`, replace with
`observe_new_models` with an optional window
- [x] Fix a bug where the project panel would not be redrawn because of
the wrong refresh() call being used
- [x] Fix the tests
- [x] Fix warnings by eliminating `Window` params or using `_`
- [x] Fix conflicts
- [x] Simplify generic code where possible
- [x] Rename types
- [ ] Update docs

### issues post merge

- [x] Issues switching between normal and insert mode
- [x] Assistant re-rendering failure
- [x] Vim test failures
- [x] Mac build issue



Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Cole Miller <cole@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Joseph <joseph@zed.dev>
Co-authored-by: max <max@zed.dev>
Co-authored-by: Michael Sloan <michael@zed.dev>
Co-authored-by: Mikayla Maki <mikaylamaki@Mikaylas-MacBook-Pro.local>
Co-authored-by: Mikayla <mikayla.c.maki@gmail.com>
Co-authored-by: joão <joao@zed.dev>
This commit is contained in:
Nathan Sobo 2025-01-25 20:02:45 -07:00 committed by GitHub
parent 21b4a0d50e
commit 6fca1d2b0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
648 changed files with 36248 additions and 28208 deletions

View file

@ -6,13 +6,13 @@ use crate::{
InlayHintLabel, InlayHintLabelPart, InlayHintLabelPartTooltip, InlayHintTooltip, Location,
LocationLink, MarkupContent, PrepareRenameResponse, ProjectTransaction, ResolveState,
};
use anyhow::{anyhow, Context, Result};
use anyhow::{anyhow, Context as _, Result};
use async_trait::async_trait;
use client::proto::{self, PeerId};
use clock::Global;
use collections::HashSet;
use futures::future;
use gpui::{AppContext, AsyncAppContext, Entity, Model};
use gpui::{App, AsyncAppContext, Entity};
use language::{
language_settings::{language_settings, InlayHintKind, LanguageSettings},
point_from_lsp, point_to_lsp,
@ -87,7 +87,7 @@ pub trait LspCommand: 'static + Sized + Send + std::fmt::Debug {
path: &Path,
buffer: &Buffer,
language_server: &Arc<LanguageServer>,
cx: &AppContext,
cx: &App,
) -> Result<
LspParamsOrResponse<<Self::LspRequest as lsp::request::Request>::Params, Self::Response>,
> {
@ -113,14 +113,14 @@ pub trait LspCommand: 'static + Sized + Send + std::fmt::Debug {
path: &Path,
buffer: &Buffer,
language_server: &Arc<LanguageServer>,
cx: &AppContext,
cx: &App,
) -> Result<<Self::LspRequest as lsp::request::Request>::Params>;
async fn response_from_lsp(
self,
message: <Self::LspRequest as lsp::request::Request>::Result,
lsp_store: Model<LspStore>,
buffer: Model<Buffer>,
lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>,
server_id: LanguageServerId,
cx: AsyncAppContext,
) -> Result<Self::Response>;
@ -129,8 +129,8 @@ pub trait LspCommand: 'static + Sized + Send + std::fmt::Debug {
async fn from_proto(
message: Self::ProtoRequest,
lsp_store: Model<LspStore>,
buffer: Model<Buffer>,
lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>,
cx: AsyncAppContext,
) -> Result<Self>;
@ -139,14 +139,14 @@ pub trait LspCommand: 'static + Sized + Send + std::fmt::Debug {
lsp_store: &mut LspStore,
peer_id: PeerId,
buffer_version: &clock::Global,
cx: &mut AppContext,
cx: &mut App,
) -> <Self::ProtoRequest as proto::RequestMessage>::Response;
async fn response_from_proto(
self,
message: <Self::ProtoRequest as proto::RequestMessage>::Response,
lsp_store: Model<LspStore>,
buffer: Model<Buffer>,
lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>,
cx: AsyncAppContext,
) -> Result<Self::Response>;
@ -255,7 +255,7 @@ impl LspCommand for PrepareRename {
path: &Path,
buffer: &Buffer,
language_server: &Arc<LanguageServer>,
cx: &AppContext,
cx: &App,
) -> Result<LspParamsOrResponse<lsp::TextDocumentPositionParams, PrepareRenameResponse>> {
let rename_provider = language_server
.adapter_server_capabilities()
@ -286,7 +286,7 @@ impl LspCommand for PrepareRename {
path: &Path,
_: &Buffer,
_: &Arc<LanguageServer>,
_: &AppContext,
_: &App,
) -> Result<lsp::TextDocumentPositionParams> {
make_lsp_text_document_position(path, self.position)
}
@ -294,8 +294,8 @@ impl LspCommand for PrepareRename {
async fn response_from_lsp(
self,
message: Option<lsp::PrepareRenameResponse>,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
_: LanguageServerId,
mut cx: AsyncAppContext,
) -> Result<PrepareRenameResponse> {
@ -337,8 +337,8 @@ impl LspCommand for PrepareRename {
async fn from_proto(
message: proto::PrepareRename,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
let position = message
@ -361,7 +361,7 @@ impl LspCommand for PrepareRename {
_: &mut LspStore,
_: PeerId,
buffer_version: &clock::Global,
_: &mut AppContext,
_: &mut App,
) -> proto::PrepareRenameResponse {
match response {
PrepareRenameResponse::Success(range) => proto::PrepareRenameResponse {
@ -391,8 +391,8 @@ impl LspCommand for PrepareRename {
async fn response_from_proto(
self,
message: proto::PrepareRenameResponse,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<PrepareRenameResponse> {
if message.can_rename {
@ -438,7 +438,7 @@ impl LspCommand for PerformRename {
path: &Path,
_: &Buffer,
_: &Arc<LanguageServer>,
_: &AppContext,
_: &App,
) -> Result<lsp::RenameParams> {
Ok(lsp::RenameParams {
text_document_position: make_lsp_text_document_position(path, self.position)?,
@ -450,8 +450,8 @@ impl LspCommand for PerformRename {
async fn response_from_lsp(
self,
message: Option<lsp::WorkspaceEdit>,
lsp_store: Model<LspStore>,
buffer: Model<Buffer>,
lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>,
server_id: LanguageServerId,
mut cx: AsyncAppContext,
) -> Result<ProjectTransaction> {
@ -486,8 +486,8 @@ impl LspCommand for PerformRename {
async fn from_proto(
message: proto::PerformRename,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
let position = message
@ -511,7 +511,7 @@ impl LspCommand for PerformRename {
lsp_store: &mut LspStore,
peer_id: PeerId,
_: &clock::Global,
cx: &mut AppContext,
cx: &mut App,
) -> proto::PerformRenameResponse {
let transaction = lsp_store.buffer_store().update(cx, |buffer_store, cx| {
buffer_store.serialize_project_transaction_for_peer(response, peer_id, cx)
@ -524,8 +524,8 @@ impl LspCommand for PerformRename {
async fn response_from_proto(
self,
message: proto::PerformRenameResponse,
lsp_store: Model<LspStore>,
_: Model<Buffer>,
lsp_store: Entity<LspStore>,
_: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<ProjectTransaction> {
let message = message
@ -567,7 +567,7 @@ impl LspCommand for GetDefinition {
path: &Path,
_: &Buffer,
_: &Arc<LanguageServer>,
_: &AppContext,
_: &App,
) -> Result<lsp::GotoDefinitionParams> {
Ok(lsp::GotoDefinitionParams {
text_document_position_params: make_lsp_text_document_position(path, self.position)?,
@ -579,8 +579,8 @@ impl LspCommand for GetDefinition {
async fn response_from_lsp(
self,
message: Option<lsp::GotoDefinitionResponse>,
lsp_store: Model<LspStore>,
buffer: Model<Buffer>,
lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>,
server_id: LanguageServerId,
cx: AsyncAppContext,
) -> Result<Vec<LocationLink>> {
@ -600,8 +600,8 @@ impl LspCommand for GetDefinition {
async fn from_proto(
message: proto::GetDefinition,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
let position = message
@ -623,7 +623,7 @@ impl LspCommand for GetDefinition {
lsp_store: &mut LspStore,
peer_id: PeerId,
_: &clock::Global,
cx: &mut AppContext,
cx: &mut App,
) -> proto::GetDefinitionResponse {
let links = location_links_to_proto(response, lsp_store, peer_id, cx);
proto::GetDefinitionResponse { links }
@ -632,8 +632,8 @@ impl LspCommand for GetDefinition {
async fn response_from_proto(
self,
message: proto::GetDefinitionResponse,
lsp_store: Model<LspStore>,
_: Model<Buffer>,
lsp_store: Entity<LspStore>,
_: Entity<Buffer>,
cx: AsyncAppContext,
) -> Result<Vec<LocationLink>> {
location_links_from_proto(message.links, lsp_store, cx).await
@ -666,7 +666,7 @@ impl LspCommand for GetDeclaration {
path: &Path,
_: &Buffer,
_: &Arc<LanguageServer>,
_: &AppContext,
_: &App,
) -> Result<lsp::GotoDeclarationParams> {
Ok(lsp::GotoDeclarationParams {
text_document_position_params: make_lsp_text_document_position(path, self.position)?,
@ -678,8 +678,8 @@ impl LspCommand for GetDeclaration {
async fn response_from_lsp(
self,
message: Option<lsp::GotoDeclarationResponse>,
lsp_store: Model<LspStore>,
buffer: Model<Buffer>,
lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>,
server_id: LanguageServerId,
cx: AsyncAppContext,
) -> Result<Vec<LocationLink>> {
@ -699,8 +699,8 @@ impl LspCommand for GetDeclaration {
async fn from_proto(
message: proto::GetDeclaration,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
let position = message
@ -722,7 +722,7 @@ impl LspCommand for GetDeclaration {
lsp_store: &mut LspStore,
peer_id: PeerId,
_: &clock::Global,
cx: &mut AppContext,
cx: &mut App,
) -> proto::GetDeclarationResponse {
let links = location_links_to_proto(response, lsp_store, peer_id, cx);
proto::GetDeclarationResponse { links }
@ -731,8 +731,8 @@ impl LspCommand for GetDeclaration {
async fn response_from_proto(
self,
message: proto::GetDeclarationResponse,
lsp_store: Model<LspStore>,
_: Model<Buffer>,
lsp_store: Entity<LspStore>,
_: Entity<Buffer>,
cx: AsyncAppContext,
) -> Result<Vec<LocationLink>> {
location_links_from_proto(message.links, lsp_store, cx).await
@ -758,7 +758,7 @@ impl LspCommand for GetImplementation {
path: &Path,
_: &Buffer,
_: &Arc<LanguageServer>,
_: &AppContext,
_: &App,
) -> Result<lsp::GotoImplementationParams> {
Ok(lsp::GotoImplementationParams {
text_document_position_params: make_lsp_text_document_position(path, self.position)?,
@ -770,8 +770,8 @@ impl LspCommand for GetImplementation {
async fn response_from_lsp(
self,
message: Option<lsp::GotoImplementationResponse>,
lsp_store: Model<LspStore>,
buffer: Model<Buffer>,
lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>,
server_id: LanguageServerId,
cx: AsyncAppContext,
) -> Result<Vec<LocationLink>> {
@ -791,8 +791,8 @@ impl LspCommand for GetImplementation {
async fn from_proto(
message: proto::GetImplementation,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
let position = message
@ -814,7 +814,7 @@ impl LspCommand for GetImplementation {
lsp_store: &mut LspStore,
peer_id: PeerId,
_: &clock::Global,
cx: &mut AppContext,
cx: &mut App,
) -> proto::GetImplementationResponse {
let links = location_links_to_proto(response, lsp_store, peer_id, cx);
proto::GetImplementationResponse { links }
@ -823,8 +823,8 @@ impl LspCommand for GetImplementation {
async fn response_from_proto(
self,
message: proto::GetImplementationResponse,
project: Model<LspStore>,
_: Model<Buffer>,
project: Entity<LspStore>,
_: Entity<Buffer>,
cx: AsyncAppContext,
) -> Result<Vec<LocationLink>> {
location_links_from_proto(message.links, project, cx).await
@ -857,7 +857,7 @@ impl LspCommand for GetTypeDefinition {
path: &Path,
_: &Buffer,
_: &Arc<LanguageServer>,
_: &AppContext,
_: &App,
) -> Result<lsp::GotoTypeDefinitionParams> {
Ok(lsp::GotoTypeDefinitionParams {
text_document_position_params: make_lsp_text_document_position(path, self.position)?,
@ -869,8 +869,8 @@ impl LspCommand for GetTypeDefinition {
async fn response_from_lsp(
self,
message: Option<lsp::GotoTypeDefinitionResponse>,
project: Model<LspStore>,
buffer: Model<Buffer>,
project: Entity<LspStore>,
buffer: Entity<Buffer>,
server_id: LanguageServerId,
cx: AsyncAppContext,
) -> Result<Vec<LocationLink>> {
@ -890,8 +890,8 @@ impl LspCommand for GetTypeDefinition {
async fn from_proto(
message: proto::GetTypeDefinition,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
let position = message
@ -913,7 +913,7 @@ impl LspCommand for GetTypeDefinition {
lsp_store: &mut LspStore,
peer_id: PeerId,
_: &clock::Global,
cx: &mut AppContext,
cx: &mut App,
) -> proto::GetTypeDefinitionResponse {
let links = location_links_to_proto(response, lsp_store, peer_id, cx);
proto::GetTypeDefinitionResponse { links }
@ -922,8 +922,8 @@ impl LspCommand for GetTypeDefinition {
async fn response_from_proto(
self,
message: proto::GetTypeDefinitionResponse,
project: Model<LspStore>,
_: Model<Buffer>,
project: Entity<LspStore>,
_: Entity<Buffer>,
cx: AsyncAppContext,
) -> Result<Vec<LocationLink>> {
location_links_from_proto(message.links, project, cx).await
@ -935,8 +935,8 @@ impl LspCommand for GetTypeDefinition {
}
fn language_server_for_buffer(
lsp_store: &Model<LspStore>,
buffer: &Model<Buffer>,
lsp_store: &Entity<LspStore>,
buffer: &Entity<Buffer>,
server_id: LanguageServerId,
cx: &mut AsyncAppContext,
) -> Result<(Arc<CachedLspAdapter>, Arc<LanguageServer>)> {
@ -951,7 +951,7 @@ fn language_server_for_buffer(
async fn location_links_from_proto(
proto_links: Vec<proto::LocationLink>,
lsp_store: Model<LspStore>,
lsp_store: Entity<LspStore>,
mut cx: AsyncAppContext,
) -> Result<Vec<LocationLink>> {
let mut links = Vec::new();
@ -1015,8 +1015,8 @@ async fn location_links_from_proto(
async fn location_links_from_lsp(
message: Option<lsp::GotoDefinitionResponse>,
lsp_store: Model<LspStore>,
buffer: Model<Buffer>,
lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>,
server_id: LanguageServerId,
mut cx: AsyncAppContext,
) -> Result<Vec<LocationLink>> {
@ -1099,7 +1099,7 @@ fn location_links_to_proto(
links: Vec<LocationLink>,
lsp_store: &mut LspStore,
peer_id: PeerId,
cx: &mut AppContext,
cx: &mut App,
) -> Vec<proto::LocationLink> {
links
.into_iter()
@ -1169,7 +1169,7 @@ impl LspCommand for GetReferences {
path: &Path,
_: &Buffer,
_: &Arc<LanguageServer>,
_: &AppContext,
_: &App,
) -> Result<lsp::ReferenceParams> {
Ok(lsp::ReferenceParams {
text_document_position: make_lsp_text_document_position(path, self.position)?,
@ -1184,8 +1184,8 @@ impl LspCommand for GetReferences {
async fn response_from_lsp(
self,
locations: Option<Vec<lsp::Location>>,
lsp_store: Model<LspStore>,
buffer: Model<Buffer>,
lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>,
server_id: LanguageServerId,
mut cx: AsyncAppContext,
) -> Result<Vec<Location>> {
@ -1238,8 +1238,8 @@ impl LspCommand for GetReferences {
async fn from_proto(
message: proto::GetReferences,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
let position = message
@ -1261,7 +1261,7 @@ impl LspCommand for GetReferences {
lsp_store: &mut LspStore,
peer_id: PeerId,
_: &clock::Global,
cx: &mut AppContext,
cx: &mut App,
) -> proto::GetReferencesResponse {
let locations = response
.into_iter()
@ -1286,8 +1286,8 @@ impl LspCommand for GetReferences {
async fn response_from_proto(
self,
message: proto::GetReferencesResponse,
project: Model<LspStore>,
_: Model<Buffer>,
project: Entity<LspStore>,
_: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Vec<Location>> {
let mut locations = Vec::new();
@ -1344,7 +1344,7 @@ impl LspCommand for GetDocumentHighlights {
path: &Path,
_: &Buffer,
_: &Arc<LanguageServer>,
_: &AppContext,
_: &App,
) -> Result<lsp::DocumentHighlightParams> {
Ok(lsp::DocumentHighlightParams {
text_document_position_params: make_lsp_text_document_position(path, self.position)?,
@ -1356,8 +1356,8 @@ impl LspCommand for GetDocumentHighlights {
async fn response_from_lsp(
self,
lsp_highlights: Option<Vec<lsp::DocumentHighlight>>,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
_: LanguageServerId,
mut cx: AsyncAppContext,
) -> Result<Vec<DocumentHighlight>> {
@ -1395,8 +1395,8 @@ impl LspCommand for GetDocumentHighlights {
async fn from_proto(
message: proto::GetDocumentHighlights,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
let position = message
@ -1418,7 +1418,7 @@ impl LspCommand for GetDocumentHighlights {
_: &mut LspStore,
_: PeerId,
_: &clock::Global,
_: &mut AppContext,
_: &mut App,
) -> proto::GetDocumentHighlightsResponse {
let highlights = response
.into_iter()
@ -1439,8 +1439,8 @@ impl LspCommand for GetDocumentHighlights {
async fn response_from_proto(
self,
message: proto::GetDocumentHighlightsResponse,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Vec<DocumentHighlight>> {
let mut highlights = Vec::new();
@ -1497,7 +1497,7 @@ impl LspCommand for GetSignatureHelp {
path: &Path,
_: &Buffer,
_: &Arc<LanguageServer>,
_cx: &AppContext,
_cx: &App,
) -> Result<lsp::SignatureHelpParams> {
Ok(lsp::SignatureHelpParams {
text_document_position_params: make_lsp_text_document_position(path, self.position)?,
@ -1509,8 +1509,8 @@ impl LspCommand for GetSignatureHelp {
async fn response_from_lsp(
self,
message: Option<lsp::SignatureHelp>,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
_: LanguageServerId,
mut cx: AsyncAppContext,
) -> Result<Self::Response> {
@ -1530,8 +1530,8 @@ impl LspCommand for GetSignatureHelp {
async fn from_proto(
payload: Self::ProtoRequest,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
buffer
@ -1555,7 +1555,7 @@ impl LspCommand for GetSignatureHelp {
_: &mut LspStore,
_: PeerId,
_: &Global,
_: &mut AppContext,
_: &mut App,
) -> proto::GetSignatureHelpResponse {
proto::GetSignatureHelpResponse {
signature_help: response
@ -1566,8 +1566,8 @@ impl LspCommand for GetSignatureHelp {
async fn response_from_proto(
self,
response: proto::GetSignatureHelpResponse,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self::Response> {
let language = buffer.update(&mut cx, |buffer, _| buffer.language().cloned())?;
@ -1605,7 +1605,7 @@ impl LspCommand for GetHover {
path: &Path,
_: &Buffer,
_: &Arc<LanguageServer>,
_: &AppContext,
_: &App,
) -> Result<lsp::HoverParams> {
Ok(lsp::HoverParams {
text_document_position_params: make_lsp_text_document_position(path, self.position)?,
@ -1616,8 +1616,8 @@ impl LspCommand for GetHover {
async fn response_from_lsp(
self,
message: Option<lsp::Hover>,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
_: LanguageServerId,
mut cx: AsyncAppContext,
) -> Result<Self::Response> {
@ -1697,8 +1697,8 @@ impl LspCommand for GetHover {
async fn from_proto(
message: Self::ProtoRequest,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
let position = message
@ -1720,7 +1720,7 @@ impl LspCommand for GetHover {
_: &mut LspStore,
_: PeerId,
_: &clock::Global,
_: &mut AppContext,
_: &mut App,
) -> proto::GetHoverResponse {
if let Some(response) = response {
let (start, end) = if let Some(range) = response.range {
@ -1763,8 +1763,8 @@ impl LspCommand for GetHover {
async fn response_from_proto(
self,
message: proto::GetHoverResponse,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self::Response> {
let contents: Vec<_> = message
@ -1827,7 +1827,7 @@ impl LspCommand for GetCompletions {
path: &Path,
_: &Buffer,
_: &Arc<LanguageServer>,
_: &AppContext,
_: &App,
) -> Result<lsp::CompletionParams> {
Ok(lsp::CompletionParams {
text_document_position: make_lsp_text_document_position(path, self.position)?,
@ -1840,8 +1840,8 @@ impl LspCommand for GetCompletions {
async fn response_from_lsp(
self,
completions: Option<lsp::CompletionResponse>,
lsp_store: Model<LspStore>,
buffer: Model<Buffer>,
lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>,
server_id: LanguageServerId,
mut cx: AsyncAppContext,
) -> Result<Self::Response> {
@ -2033,8 +2033,8 @@ impl LspCommand for GetCompletions {
async fn from_proto(
message: proto::GetCompletions,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
let version = deserialize_version(&message.version);
@ -2064,7 +2064,7 @@ impl LspCommand for GetCompletions {
_: &mut LspStore,
_: PeerId,
buffer_version: &clock::Global,
_: &mut AppContext,
_: &mut App,
) -> proto::GetCompletionsResponse {
proto::GetCompletionsResponse {
completions: completions
@ -2078,8 +2078,8 @@ impl LspCommand for GetCompletions {
async fn response_from_proto(
self,
message: proto::GetCompletionsResponse,
_project: Model<LspStore>,
buffer: Model<Buffer>,
_project: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self::Response> {
buffer
@ -2175,7 +2175,7 @@ impl LspCommand for GetCodeActions {
path: &Path,
buffer: &Buffer,
language_server: &Arc<LanguageServer>,
_: &AppContext,
_: &App,
) -> Result<lsp::CodeActionParams> {
let mut relevant_diagnostics = Vec::new();
for entry in buffer
@ -2221,8 +2221,8 @@ impl LspCommand for GetCodeActions {
async fn response_from_lsp(
self,
actions: Option<lsp::CodeActionResponse>,
_: Model<LspStore>,
_: Model<Buffer>,
_: Entity<LspStore>,
_: Entity<Buffer>,
server_id: LanguageServerId,
_: AsyncAppContext,
) -> Result<Vec<CodeAction>> {
@ -2269,8 +2269,8 @@ impl LspCommand for GetCodeActions {
async fn from_proto(
message: proto::GetCodeActions,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
let start = message
@ -2298,7 +2298,7 @@ impl LspCommand for GetCodeActions {
_: &mut LspStore,
_: PeerId,
buffer_version: &clock::Global,
_: &mut AppContext,
_: &mut App,
) -> proto::GetCodeActionsResponse {
proto::GetCodeActionsResponse {
actions: code_actions
@ -2312,8 +2312,8 @@ impl LspCommand for GetCodeActions {
async fn response_from_proto(
self,
message: proto::GetCodeActionsResponse,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Vec<CodeAction>> {
buffer
@ -2390,7 +2390,7 @@ impl LspCommand for OnTypeFormatting {
path: &Path,
_: &Buffer,
_: &Arc<LanguageServer>,
_: &AppContext,
_: &App,
) -> Result<lsp::DocumentOnTypeFormattingParams> {
Ok(lsp::DocumentOnTypeFormattingParams {
text_document_position: make_lsp_text_document_position(path, self.position)?,
@ -2402,8 +2402,8 @@ impl LspCommand for OnTypeFormatting {
async fn response_from_lsp(
self,
message: Option<Vec<lsp::TextEdit>>,
lsp_store: Model<LspStore>,
buffer: Model<Buffer>,
lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>,
server_id: LanguageServerId,
mut cx: AsyncAppContext,
) -> Result<Option<Transaction>> {
@ -2439,8 +2439,8 @@ impl LspCommand for OnTypeFormatting {
async fn from_proto(
message: proto::OnTypeFormatting,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
let position = message
@ -2472,7 +2472,7 @@ impl LspCommand for OnTypeFormatting {
_: &mut LspStore,
_: PeerId,
_: &clock::Global,
_: &mut AppContext,
_: &mut App,
) -> proto::OnTypeFormattingResponse {
proto::OnTypeFormattingResponse {
transaction: response
@ -2483,8 +2483,8 @@ impl LspCommand for OnTypeFormatting {
async fn response_from_proto(
self,
message: proto::OnTypeFormattingResponse,
_: Model<LspStore>,
_: Model<Buffer>,
_: Entity<LspStore>,
_: Entity<Buffer>,
_: AsyncAppContext,
) -> Result<Option<Transaction>> {
let Some(transaction) = message.transaction else {
@ -2501,7 +2501,7 @@ impl LspCommand for OnTypeFormatting {
impl InlayHints {
pub async fn lsp_to_project_hint(
lsp_hint: lsp::InlayHint,
buffer_handle: &Model<Buffer>,
buffer_handle: &Entity<Buffer>,
server_id: LanguageServerId,
resolve_state: ResolveState,
force_no_type_left_padding: bool,
@ -2897,7 +2897,7 @@ impl LspCommand for InlayHints {
path: &Path,
buffer: &Buffer,
_: &Arc<LanguageServer>,
_: &AppContext,
_: &App,
) -> Result<lsp::InlayHintParams> {
Ok(lsp::InlayHintParams {
text_document: lsp::TextDocumentIdentifier {
@ -2911,8 +2911,8 @@ impl LspCommand for InlayHints {
async fn response_from_lsp(
self,
message: Option<Vec<lsp::InlayHint>>,
lsp_store: Model<LspStore>,
buffer: Model<Buffer>,
lsp_store: Entity<LspStore>,
buffer: Entity<Buffer>,
server_id: LanguageServerId,
mut cx: AsyncAppContext,
) -> anyhow::Result<Vec<InlayHint>> {
@ -2967,8 +2967,8 @@ impl LspCommand for InlayHints {
async fn from_proto(
message: proto::InlayHints,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
let start = message
@ -2993,7 +2993,7 @@ impl LspCommand for InlayHints {
_: &mut LspStore,
_: PeerId,
buffer_version: &clock::Global,
_: &mut AppContext,
_: &mut App,
) -> proto::InlayHintsResponse {
proto::InlayHintsResponse {
hints: response
@ -3007,8 +3007,8 @@ impl LspCommand for InlayHints {
async fn response_from_proto(
self,
message: proto::InlayHintsResponse,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> anyhow::Result<Vec<InlayHint>> {
buffer
@ -3058,7 +3058,7 @@ impl LspCommand for LinkedEditingRange {
path: &Path,
buffer: &Buffer,
_server: &Arc<LanguageServer>,
_: &AppContext,
_: &App,
) -> Result<lsp::LinkedEditingRangeParams> {
let position = self.position.to_point_utf16(&buffer.snapshot());
Ok(lsp::LinkedEditingRangeParams {
@ -3070,8 +3070,8 @@ impl LspCommand for LinkedEditingRange {
async fn response_from_lsp(
self,
message: Option<lsp::LinkedEditingRanges>,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
_server_id: LanguageServerId,
cx: AsyncAppContext,
) -> Result<Vec<Range<Anchor>>> {
@ -3105,8 +3105,8 @@ impl LspCommand for LinkedEditingRange {
async fn from_proto(
message: proto::LinkedEditingRange,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Self> {
let position = message
@ -3129,7 +3129,7 @@ impl LspCommand for LinkedEditingRange {
_: &mut LspStore,
_: PeerId,
buffer_version: &clock::Global,
_: &mut AppContext,
_: &mut App,
) -> proto::LinkedEditingRangeResponse {
proto::LinkedEditingRangeResponse {
items: response
@ -3146,8 +3146,8 @@ impl LspCommand for LinkedEditingRange {
async fn response_from_proto(
self,
message: proto::LinkedEditingRangeResponse,
_: Model<LspStore>,
buffer: Model<Buffer>,
_: Entity<LspStore>,
buffer: Entity<Buffer>,
mut cx: AsyncAppContext,
) -> Result<Vec<Range<Anchor>>> {
buffer