Rename build_view to new_view and build_model to new_model (#3823)

The word "new" is shorter and blends in with `new` constructors that are
common in Rust. Been meaning to do this for a while.

Release Notes:

- N/A
This commit is contained in:
Nathan Sobo 2024-01-02 08:11:53 -07:00 committed by GitHub
commit 6b14f2fd08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
97 changed files with 470 additions and 494 deletions

View file

@ -51,7 +51,7 @@ pub fn init(
node_runtime: Arc<dyn NodeRuntime>,
cx: &mut AppContext,
) {
let copilot = cx.build_model({
let copilot = cx.new_model({
let node_runtime = node_runtime.clone();
move |cx| Copilot::start(new_server_id, http, node_runtime, cx)
});
@ -382,7 +382,7 @@ impl Copilot {
LanguageServer::fake("copilot".into(), Default::default(), cx.to_async());
let http = util::http::FakeHttpClient::create(|_| async { unreachable!() });
let node_runtime = FakeNodeRuntime::new();
let this = cx.build_model(|cx| Self {
let this = cx.new_model(|cx| Self {
server_id: LanguageServerId(0),
http: http.clone(),
node_runtime,
@ -1033,7 +1033,7 @@ mod tests {
async fn test_buffer_management(cx: &mut TestAppContext) {
let (copilot, mut lsp) = Copilot::fake(cx);
let buffer_1 = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "Hello"));
let buffer_1 = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "Hello"));
let buffer_1_uri: lsp::Url = format!("buffer://{}", buffer_1.entity_id().as_u64())
.parse()
.unwrap();
@ -1051,7 +1051,7 @@ mod tests {
}
);
let buffer_2 = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "Goodbye"));
let buffer_2 = cx.new_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "Goodbye"));
let buffer_2_uri: lsp::Url = format!("buffer://{}", buffer_2.entity_id().as_u64())
.parse()
.unwrap();

View file

@ -71,7 +71,7 @@ fn create_copilot_auth_window(
display_id: None,
};
let window = cx.open_window(window_options, |cx| {
cx.build_view(|_| CopilotCodeVerification::new(status.clone()))
cx.new_view(|_| CopilotCodeVerification::new(status.clone()))
});
window
}