Skip to content

Commit 7dbd6d3

Browse files
committed
Refactor: fix variable shadowing warnings
1 parent fe129a4 commit 7dbd6d3

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

plugin/vscode/quick-lint-js-vscode-node.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,7 @@ class thread_safe_js_function {
280280
/*maxQueueSize=*/0,
281281
/*initialThreadCount=*/1,
282282
/*context=*/this->create_weak_reference(env, object),
283-
/*finalizeCallback=*/
284-
[](Napi::Env env, [[maybe_unused]] void* data,
285-
void* context) -> void {
286-
// See NOTE[workspace-cleanup].
287-
::napi_status status = ::napi_delete_reference(
288-
env, reinterpret_cast<::napi_ref>(context));
289-
QLJS_ASSERT(status == ::napi_ok);
290-
},
283+
/*finalizeCallback=*/finalize_weak_reference,
291284
/*data=*/static_cast<void*>(nullptr))) {}
292285

293286
// Like ::Napi::TypedThreadSafeFunction::BlockingCall.
@@ -309,6 +302,15 @@ class thread_safe_js_function {
309302
return result;
310303
}
311304

305+
static void finalize_weak_reference(::Napi::Env env,
306+
[[maybe_unused]] void* data,
307+
void* context) {
308+
// See NOTE[workspace-cleanup].
309+
::napi_status status =
310+
::napi_delete_reference(env, reinterpret_cast<::napi_ref>(context));
311+
QLJS_ASSERT(status == ::napi_ok);
312+
}
313+
312314
static void call_func(::Napi::Env env, ::Napi::Function, void* context,
313315
[[maybe_unused]] void* data) {
314316
if (!env) {
@@ -627,7 +629,7 @@ class qljs_workspace : public ::Napi::ObjectWrap<qljs_workspace> {
627629
env, message, {"Open config"},
628630
[this, self = ::Napi::Persistent(this->Value()),
629631
config_file_path](
630-
::Napi::Env env,
632+
::Napi::Env callback_env,
631633
::Napi::Value clicked_button_label) -> void {
632634
bool popup_dismissed = clicked_button_label.IsUndefined();
633635
if (popup_dismissed) {
@@ -637,7 +639,7 @@ class qljs_workspace : public ::Napi::ObjectWrap<qljs_workspace> {
637639
clicked_button_label.As<::Napi::String>().Utf8Value();
638640
QLJS_ASSERT(clicked_button_label_string == "Open config");
639641
this->vscode_.open_and_show_text_document_by_path(
640-
env, config_file_path);
642+
callback_env, config_file_path);
641643
});
642644
}
643645
doc->config_ = &loaded_config->config;

plugin/vscode/quick-lint-js/vscode.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,17 @@ struct vscode_module {
9595
::Napi::Function open_text_document_func = ::Napi::Function::New(
9696
env,
9797
[state = std::move(state)](const ::Napi::CallbackInfo& info) -> void {
98-
::Napi::Env env = info.Env();
99-
10098
::Napi::Value uri = state->uri_file.Value().Call(
10199
/*this=*/state->uri_class.Value(),
102-
{::Napi::String::New(env, state->path)});
100+
{::Napi::String::New(info.Env(), state->path)});
103101
::Napi::Value promise =
104102
state->workspace_open_text_document.Value().Call(
105103
/*this=*/state->workspace_namespace.Value(), {uri});
106104

107-
promise_then(promise,
108-
[state](const ::Napi::CallbackInfo& info) -> void {
109-
std::move(state->callback)(info.Env(), info[0]);
110-
});
105+
promise_then(
106+
promise, [state](const ::Napi::CallbackInfo& then_info) -> void {
107+
std::move(state->callback)(then_info.Env(), then_info[0]);
108+
});
111109

112110
state->workspace_namespace.Reset();
113111
state->workspace_open_text_document.Reset();

0 commit comments

Comments
 (0)