!1143 401提示整改

Merge pull request !1143 from hemenghao/master
This commit is contained in:
openharmony_ci 2024-04-30 03:52:46 +00:00 committed by Gitee
commit 7f16c0735a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 90 additions and 88 deletions

View File

@ -175,7 +175,7 @@ napi_value JsPanel::MoveTo(napi_env env, napi_callback_info info)
auto ctxt = std::make_shared<PanelContentContext>(env, info);
auto input = [ctxt](napi_env env, size_t argc, napi_value *argv, napi_value self) -> napi_status {
napi_status status = napi_generic_failure;
PARAM_CHECK_RETURN(env, argc > 1, " should 2 or 3 parameters! ", TYPE_NONE, status);
PARAM_CHECK_RETURN(env, argc > 1, "should 2 or 3 parameters! ", TYPE_NONE, status);
// 0 means the first param x<int32_t>
status = JsUtils::GetValue(env, argv[0], ctxt->x);
CHECK_RETURN(status == napi_ok, "get x failed!", status);
@ -212,7 +212,7 @@ napi_value JsPanel::Show(napi_env env, napi_callback_info info)
}
ctxt->SetErrorCode(code);
};
// 1 means JsAPI:show has 1 params at most.
// 1 means JsAPI:show has 1 param at most.
AsyncCall asyncCall(env, info, ctxt, 1);
return asyncCall.Call(env, exec, "show");
}
@ -229,7 +229,7 @@ napi_value JsPanel::Hide(napi_env env, napi_callback_info info)
}
ctxt->SetErrorCode(code);
};
// 1 means JsAPI:hide has 1 params at most.
// 1 means JsAPI:hide has 1 param at most.
AsyncCall asyncCall(env, info, ctxt, 1);
return asyncCall.Call(env, exec, "panel.hide");
}
@ -240,7 +240,7 @@ napi_value JsPanel::ChangeFlag(napi_env env, napi_callback_info info)
napi_value argv[ARGC_MAX] = { nullptr };
napi_value thisVar = nullptr;
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr));
PARAM_CHECK_RETURN(env, argc > 0, " should 1 parameter! ", TYPE_NONE, nullptr);
PARAM_CHECK_RETURN(env, argc > 0, "should 1 parameter! ", TYPE_NONE, nullptr);
int32_t panelFlag = 0;
// 0 means the first param flag<PanelFlag>
napi_status status = JsUtils::GetValue(env, argv[0], panelFlag);
@ -258,7 +258,7 @@ napi_value JsPanel::SetPrivacyMode(napi_env env, napi_callback_info info)
napi_value argv[ARGC_MAX] = {nullptr};
napi_value thisVar = nullptr;
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr));
PARAM_CHECK_RETURN(env, argc > 0, " should 1 parameter! ", TYPE_NONE, nullptr);
PARAM_CHECK_RETURN(env, argc > 0, "should 1 parameter! ", TYPE_NONE, nullptr);
bool isPrivacyMode = false;
// 0 means the first param isPrivacyMode<boolean>
napi_status status = JsUtils::GetValue(env, argv[0], isPrivacyMode);
@ -311,18 +311,15 @@ napi_value JsPanel::UnSubscribe(napi_env env, napi_callback_info info)
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr));
std::string type;
// 1 means least param num.
if (argc < 1 || !JsUtil::GetValue(env, argv[0], type)
|| !EventChecker::IsValidEventType(EventSubscribeModule::PANEL, type)) {
IMSA_HILOGE("UnSubscribe failed, type:%{public}s", type.c_str());
JsUtils::ThrowException(env, IMFErrorCode::EXCEPTION_PARAMCHECK, "please check the params", TYPE_NONE);
return nullptr;
}
PARAM_CHECK_RETURN(env, argc >= 1, "At least 1 param", TYPE_NONE, nullptr);
PARAM_CHECK_RETURN(
env, JsUtil::GetValue(env, argv[0], type), "Failed to get param text", TYPE_NONE, nullptr);
PARAM_CHECK_RETURN(env, EventChecker::IsValidEventType(EventSubscribeModule::PANEL, type),
"EventType is invalid", TYPE_NONE, nullptr);
// if the second param is not napi_function/napi_null/napi_undefined, return
auto paramType = JsUtil::GetType(env, argv[1]);
if (paramType != napi_function && paramType != napi_null && paramType != napi_undefined) {
JsUtils::ThrowException(env, IMFErrorCode::EXCEPTION_PARAMCHECK, "please check the params", TYPE_FUNCTION);
return nullptr;
}
PARAM_CHECK_RETURN(env, (paramType == napi_function || paramType == napi_null || paramType == napi_undefined),
"ParamType should be function or null or undefined", TYPE_NONE, nullptr);
// if the second param is napi_function, delete it, else delete all
argv[1] = paramType == napi_function ? argv[1] : nullptr;

View File

@ -79,7 +79,7 @@ napi_value JsTextInputClientEngine::MoveCursor(napi_env env, napi_callback_info
{
auto ctxt = std::make_shared<MoveCursorContext>();
auto input = [ctxt](napi_env env, size_t argc, napi_value *argv, napi_value self) -> napi_status {
PARAM_CHECK_RETURN(env, argc > 0, " should 1 or 2 parameters! ", TYPE_NONE, napi_generic_failure);
PARAM_CHECK_RETURN(env, argc > 0, "should 1 or 2 parameters! ", TYPE_NONE, napi_generic_failure);
auto status = JsUtils::GetValue(env, argv[0], ctxt->num);
if (status == napi_ok) {
ctxt->info = { std::chrono::system_clock::now(), EditorEvent::MOVE_CURSOR };
@ -114,12 +114,13 @@ napi_value JsTextInputClientEngine::MoveCursorSync(napi_env env, napi_callback_i
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
int32_t direction = 0;
// 1 means least param num.
if (argc < 1 || JsUtil::GetType(env, argv[0]) != napi_number || !JsUtil::GetValue(env, argv[0], direction)
|| direction < 0) {
editorQueue_.Pop();
JsUtils::ThrowException(env, IMFErrorCode::EXCEPTION_PARAMCHECK, "please check the params", TYPE_NONE);
return JsUtil::Const::Null(env);
}
PARAM_CHECK_RETURN(env, argc >= 1, "At least 1 param", TYPE_NONE, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, JsUtil::GetType(env, argv[0]) == napi_number, "direction",
TYPE_NUMBER, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, JsUtil::GetValue(env, argv[0], direction), "Failed to get param direction",
TYPE_NONE, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, direction >= 0, "direction should be no less than 0", TYPE_NONE,
HandleParamCheckFailure(env, editorQueue_));
IMSA_HILOGD("moveCursor , direction: %{public}d", direction);
int32_t ret = InputMethodAbility::GetInstance()->MoveCursor(direction);
editorQueue_.Pop();
@ -284,7 +285,7 @@ napi_value JsTextInputClientEngine::SendPrivateCommand(napi_env env, napi_callba
}
};
ctxt->SetAction(std::move(input), std::move(output));
// 1 means JsAPI:SendPrivateCommand has 1 params at most.
// 1 means JsAPI:SendPrivateCommand has 1 param at most.
AsyncCall asyncCall(env, info, ctxt, 1);
return asyncCall.Call(env, exec, "SendPrivateCommand");
}
@ -302,12 +303,13 @@ napi_value JsTextInputClientEngine::DeleteForwardSync(napi_env env, napi_callbac
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
int32_t length = 0;
// 1 means least param num.
if (argc < 1 || JsUtil::GetType(env, argv[0]) != napi_number || !JsUtil::GetValue(env, argv[0], length)
|| length < 0) {
JsUtils::ThrowException(env, IMFErrorCode::EXCEPTION_PARAMCHECK, "please check the params", TYPE_NONE);
editorQueue_.Pop();
return JsUtil::Const::Null(env);
}
PARAM_CHECK_RETURN(env, argc >= 1, "At least 1 param", TYPE_NONE, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, JsUtil::GetType(env, argv[0]) == napi_number, "length",
TYPE_NUMBER, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, JsUtil::GetValue(env, argv[0], length), "Failed to get param length",
TYPE_NONE, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, length >= 0, "length should no less than 0", TYPE_NONE,
HandleParamCheckFailure(env, editorQueue_));
IMSA_HILOGD("Delete forward, length: %{public}d", length);
int32_t ret = InputMethodAbility::GetInstance()->DeleteForward(length);
editorQueue_.Pop();
@ -365,12 +367,13 @@ napi_value JsTextInputClientEngine::DeleteBackwardSync(napi_env env, napi_callba
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
int32_t length = 0;
// 1 means least param num.
if (argc < 1 || JsUtil::GetType(env, argv[0]) != napi_number || !JsUtil::GetValue(env, argv[0], length)
|| length < 0) {
editorQueue_.Pop();
JsUtils::ThrowException(env, IMFErrorCode::EXCEPTION_PARAMCHECK, "please check the params", TYPE_NONE);
return JsUtil::Const::Null(env);
}
PARAM_CHECK_RETURN(env, argc >= 1, "At least 1 param", TYPE_NONE, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, JsUtil::GetType(env, argv[0]) == napi_number, "length",
TYPE_NUMBER, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, JsUtil::GetValue(env, argv[0], length), "Failed to get param length",
TYPE_NONE, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, length >= 0, "length should no less than 0", TYPE_NONE,
HandleParamCheckFailure(env, editorQueue_));
IMSA_HILOGD("Delete backward, length: %{public}d", length);
int32_t ret = InputMethodAbility::GetInstance()->DeleteBackward(length);
editorQueue_.Pop();
@ -465,11 +468,11 @@ napi_value JsTextInputClientEngine::InsertTextSync(napi_env env, napi_callback_i
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
std::string text;
// 1 means least param num.
if (argc < 1 || JsUtil::GetType(env, argv[0]) != napi_string || !JsUtil::GetValue(env, argv[0], text)) {
editorQueue_.Pop();
JsUtils::ThrowException(env, IMFErrorCode::EXCEPTION_PARAMCHECK, "please check the params", TYPE_NONE);
return JsUtil::Const::Null(env);
}
PARAM_CHECK_RETURN(env, argc >= 1, "At least 1 param", TYPE_NONE, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, JsUtil::GetType(env, argv[0]) == napi_string, "text",
TYPE_STRING, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, JsUtil::GetValue(env, argv[0], text), "Failed to get param text",
TYPE_NONE, HandleParamCheckFailure(env, editorQueue_));
IMSA_HILOGD("insert text , text: %{public}s", text.c_str());
int32_t ret = InputMethodAbility::GetInstance()->InsertText(text);
editorQueue_.Pop();
@ -492,12 +495,13 @@ napi_value JsTextInputClientEngine::GetForwardSync(napi_env env, napi_callback_i
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
int32_t length = 0;
// 1 means least param num.
if (argc < 1 || JsUtil::GetType(env, argv[0]) != napi_number || !JsUtil::GetValue(env, argv[0], length)
|| length < 0) {
editorQueue_.Pop();
JsUtils::ThrowException(env, IMFErrorCode::EXCEPTION_PARAMCHECK, "please check the params", TYPE_NONE);
return JsUtil::Const::Null(env);
}
PARAM_CHECK_RETURN(env, argc >= 1, "At least 1 param", TYPE_NONE, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, JsUtil::GetType(env, argv[0]) == napi_number, "length",
TYPE_NUMBER, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, JsUtil::GetValue(env, argv[0], length), "Failed to get param length",
TYPE_NONE, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, length >= 0, "length should no less than 0", TYPE_NONE,
HandleParamCheckFailure(env, editorQueue_));
IMSA_HILOGD("Get forward, length: %{public}d", length);
std::u16string text;
int32_t ret = InputMethodAbility::GetInstance()->GetTextBeforeCursor(length, text);
@ -562,12 +566,13 @@ napi_value JsTextInputClientEngine::GetBackwardSync(napi_env env, napi_callback_
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
int32_t length = 0;
// 1 means least param num.
if (argc < 1 || JsUtil::GetType(env, argv[0]) != napi_number || !JsUtil::GetValue(env, argv[0], length)
|| length < 0) {
editorQueue_.Pop();
JsUtils::ThrowException(env, IMFErrorCode::EXCEPTION_PARAMCHECK, "please check the params", TYPE_NONE);
return JsUtil::Const::Null(env);
}
PARAM_CHECK_RETURN(env, argc >= 1, "At least 1 param", TYPE_NONE, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, JsUtil::GetType(env, argv[0]) == napi_number, "length",
TYPE_NUMBER, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, JsUtil::GetValue(env, argv[0], length), "Failed to get param length",
TYPE_NONE, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, length >= 0, "length should no less than 0", TYPE_NONE,
HandleParamCheckFailure(env, editorQueue_));
IMSA_HILOGD("Get backward, length: %{public}d", length);
std::u16string text;
int32_t ret = InputMethodAbility::GetInstance()->GetTextAfterCursor(length, text);
@ -659,7 +664,7 @@ napi_value JsTextInputClientEngine::GetEditorAttribute(napi_env env, napi_callba
}
};
ctxt->SetAction(std::move(input), std::move(output));
// 1 means JsAPI:getEditorAttribute has 1 params at most.
// 1 means JsAPI:getEditorAttribute has 1 param at most.
AsyncCall asyncCall(env, info, ctxt, 1);
return asyncCall.Call(env, exec, "getEditorAttribute");
}
@ -707,11 +712,9 @@ napi_value JsTextInputClientEngine::SelectByRangeSync(napi_env env, napi_callbac
size_t argc = 1;
napi_value argv[1] = { nullptr };
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
if (argc < 1 || JsUtil::GetType(env, argv[0]) != napi_object) {
editorQueue_.Pop();
JsUtils::ThrowException(env, IMFErrorCode::EXCEPTION_PARAMCHECK, "please check the params", TYPE_NONE);
return JsUtil::Const::Null(env);
}
PARAM_CHECK_RETURN(env, argc >= 1, "At least 1 param", TYPE_NONE, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, JsUtil::GetType(env, argv[0]) == napi_object, "range",
TYPE_OBJECT, HandleParamCheckFailure(env, editorQueue_));
auto ctxt = std::make_shared<SelectContext>();
auto status = GetSelectRange(env, argv[0], ctxt);
if (status != napi_ok) {
@ -737,11 +740,9 @@ napi_value JsTextInputClientEngine::SelectByMovementSync(napi_env env, napi_call
size_t argc = 1;
napi_value argv[1] = { nullptr };
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
if (argc < 1 || JsUtil::GetType(env, argv[0]) != napi_object) {
editorQueue_.Pop();
JsUtils::ThrowException(env, IMFErrorCode::EXCEPTION_PARAMCHECK, "please check the params", TYPE_NONE);
return JsUtil::Const::Null(env);
}
PARAM_CHECK_RETURN(env, argc >= 1, "At least 1 param", TYPE_NONE, HandleParamCheckFailure(env, editorQueue_));
PARAM_CHECK_RETURN(env, JsUtil::GetType(env, argv[0]) == napi_object, "direction",
TYPE_OBJECT, HandleParamCheckFailure(env, editorQueue_));
auto ctxt = std::make_shared<SelectContext>();
auto status = GetSelectMovement(env, argv[0], ctxt);
if (status != napi_ok) {
@ -844,7 +845,7 @@ napi_value JsTextInputClientEngine::GetTextIndexAtCursor(napi_env env, napi_call
}
};
ctxt->SetAction(std::move(input), std::move(output));
// 1 means JsAPI:getTextIndexAtCursor has 1 params at most.
// 1 means JsAPI:getTextIndexAtCursor has 1 param at most.
AsyncCall asyncCall(env, info, ctxt, 1);
return asyncCall.Call(env, exec, "getTextIndexAtCursor");
}
@ -1056,6 +1057,12 @@ bool JsCallingWindowInfo::Read(napi_env env, napi_value object, CallingWindowInf
return ret;
}
napi_value JsTextInputClientEngine::HandleParamCheckFailure(napi_env env, BlockQueue<EditorEventInfo> &editorQueue_)
{
editorQueue_.Pop();
return JsUtil::Const::Null(env);
}
napi_value JsRange::Write(napi_env env, const Range &nativeObject)
{
napi_value jsObject = nullptr;

View File

@ -441,6 +441,7 @@ private:
static napi_value GetResult(napi_env env, std::string &text);
static napi_value GetResultEditorAttribute(
napi_env env, std::shared_ptr<GetEditorAttributeContext> getEditorAttribute);
static napi_value HandleParamCheckFailure(napi_env env, BlockQueue<EditorEventInfo> &queue);
static void PrintEditorQueueInfoIfTimeout(int64_t start, const EditorEventInfo &currentInfo);
static napi_status GetPreviewTextParam(
napi_env env, size_t argc, napi_value *argv, std::string &text, Range &range);

View File

@ -339,13 +339,11 @@ napi_value JsGetInputMethodController::Subscribe(napi_env env, napi_callback_inf
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data));
std::string type;
// 2 means least param num.
if (argc < 2 || !JsUtil::GetValue(env, argv[0], type)
|| !EventChecker::IsValidEventType(EventSubscribeModule::INPUT_METHOD_CONTROLLER, type)
|| JsUtil::GetType(env, argv[1]) != napi_function) {
IMSA_HILOGE("Subscribe failed, type:%{public}s", type.c_str());
JsUtils::ThrowException(env, IMFErrorCode::EXCEPTION_PARAMCHECK, "please check the params", TYPE_NONE);
return nullptr;
}
PARAM_CHECK_RETURN(env, argc >= 2, "At least 2 params", TYPE_NONE, nullptr);
PARAM_CHECK_RETURN(env, JsUtil::GetValue(env, argv[0], type), "Failed to get param type", TYPE_NONE, nullptr);
PARAM_CHECK_RETURN(env, EventChecker::IsValidEventType(EventSubscribeModule::INPUT_METHOD_CONTROLLER, type),
"EventType is invalid", TYPE_NONE, nullptr);
PARAM_CHECK_RETURN(env, JsUtil::GetType(env, argv[1]) == napi_function, "callback", TYPE_FUNCTION, nullptr);
IMSA_HILOGD("Subscribe type:%{public}s.", type.c_str());
if (TEXT_EVENT_TYPE.find(type) != TEXT_EVENT_TYPE.end()) {
if (!InputMethodController::GetInstance()->WasAttached()) {
@ -457,7 +455,7 @@ napi_value JsGetInputMethodController::HandleSoftKeyboard(
}
};
ctxt->SetAction(std::move(input), std::move(output));
// 1 means JsAPI has 1 params at most.
// 1 means JsAPI has 1 param at most.
AsyncCall asyncCall(env, info, ctxt, 1);
return asyncCall.Call(env, exec, "handleSoftKeyboard");
}

View File

@ -158,7 +158,7 @@ napi_status JsGetInputMethodSetting::GetInputMethodProperty(
{
napi_valuetype valueType = napi_undefined;
napi_typeof(env, argv, &valueType);
PARAM_CHECK_RETURN(env, valueType == napi_object, "Parameter error.", TYPE_OBJECT, napi_invalid_arg);
PARAM_CHECK_RETURN(env, valueType == napi_object, "inputMethodProperty", TYPE_OBJECT, napi_invalid_arg);
napi_value result = nullptr;
napi_get_named_property(env, argv, "name", &result);
JsUtils::GetValue(env, result, ctxt->property.name);
@ -176,8 +176,8 @@ napi_status JsGetInputMethodSetting::GetInputMethodProperty(
napi_get_named_property(env, argv, "methodId", &result);
JsUtils::GetValue(env, result, ctxt->property.id);
}
PARAM_CHECK_RETURN(env, (!ctxt->property.name.empty() && !ctxt->property.id.empty()), "Parameter error.",
TYPE_NONE, napi_invalid_arg);
PARAM_CHECK_RETURN(env, (!ctxt->property.name.empty() && !ctxt->property.id.empty()),
"name and id should not empty", TYPE_NONE, napi_invalid_arg);
IMSA_HILOGD("methodId:%{public}s, packageName:%{public}s", ctxt->property.id.c_str(), ctxt->property.name.c_str());
return napi_ok;
}
@ -205,7 +205,7 @@ napi_value JsGetInputMethodSetting::ListInputMethod(napi_env env, napi_callback_
ctxt->SetErrorCode(errCode);
};
ctxt->SetAction(std::move(input), std::move(output));
// 1 means JsAPI:listInputMethod has 1 params at most.
// 1 means JsAPI:listInputMethod has 1 param at most.
AsyncCall asyncCall(env, info, ctxt, 1);
return asyncCall.Call(env, exec, "listInputMethod");
}
@ -219,7 +219,7 @@ napi_value JsGetInputMethodSetting::GetInputMethods(napi_env env, napi_callback_
bool enable = false;
// 0 means first param index
napi_status status = JsUtils::GetValue(env, argv[0], enable);
PARAM_CHECK_RETURN(env, status == napi_ok, "enable.", TYPE_NUMBER, napi_invalid_arg);
PARAM_CHECK_RETURN(env, status == napi_ok, "enable", TYPE_NUMBER, napi_invalid_arg);
ctxt->inputMethodStatus = enable ? InputMethodStatus::ENABLE : InputMethodStatus::DISABLE;
return napi_ok;
};
@ -253,10 +253,9 @@ napi_value JsGetInputMethodSetting::GetInputMethodsSync(napi_env env, napi_callb
bool enable = false;
// 0 means first param index
if (argc < 1 || JsUtils::GetValue(env, argv[0], enable) != napi_ok) {
JsUtils::ThrowException(env, IMFErrorCode::EXCEPTION_PARAMCHECK, "please check the params", TYPE_NONE);
return JsUtil::Const::Null(env);
}
PARAM_CHECK_RETURN(env, argc >= 1, "At least 1 param", TYPE_NONE, JsUtil::Const::Null(env));
PARAM_CHECK_RETURN(env, JsUtils::GetValue(env, argv[0], enable) == napi_ok, "Failed to get param enable",
TYPE_NONE, JsUtil::Const::Null(env));
std::vector<Property> properties;
int32_t ret = InputMethodController::GetInstance()->ListInputMethod(enable, properties);
@ -288,7 +287,7 @@ napi_value JsGetInputMethodSetting::GetAllInputMethods(napi_env env, napi_callba
ctxt->SetErrorCode(errCode);
};
ctxt->SetAction(std::move(input), std::move(output));
// 1 means JsAPI:getAllInputMethods has 1 params at most.
// 1 means JsAPI:getAllInputMethods has 1 param at most.
AsyncCall asyncCall(env, info, ctxt, 1);
return asyncCall.Call(env, exec, "getInputMethods");
}
@ -321,7 +320,7 @@ napi_value JsGetInputMethodSetting::DisplayOptionalInputMethod(napi_env env, nap
}
};
ctxt->SetAction(std::move(input), std::move(output));
// 1 means JsAPI:displayOptionalInputMethod has 1 params at most.
// 1 means JsAPI:displayOptionalInputMethod has 1 param at most.
AsyncCall asyncCall(env, info, ctxt, 1);
return asyncCall.Call(env, exec, "displayOptionalInputMethod");
}
@ -350,7 +349,7 @@ napi_value JsGetInputMethodSetting::ShowOptionalInputMethods(napi_env env, napi_
}
};
ctxt->SetAction(std::move(input), std::move(output));
// 1 means JsAPI:showOptionalInputMethods has 1 params at most.
// 1 means JsAPI:showOptionalInputMethods has 1 param at most.
AsyncCall asyncCall(env, info, ctxt, 1);
return asyncCall.Call(env, exec, "showOptionalInputMethods");
}
@ -409,7 +408,7 @@ napi_value JsGetInputMethodSetting::ListCurrentInputMethodSubtype(napi_env env,
ctxt->SetErrorCode(errCode);
};
ctxt->SetAction(std::move(input), std::move(output));
// 1 means JsAPI:listCurrentInputMethodSubtype has 1 params at most.
// 1 means JsAPI:listCurrentInputMethodSubtype has 1 param at most.
AsyncCall asyncCall(env, info, ctxt, 1);
return asyncCall.Call(env, exec, "listCurrentInputMethodSubtype");
}
@ -422,11 +421,11 @@ napi_value JsGetInputMethodSetting::IsPanelShown(napi_env env, napi_callback_inf
napi_value argv[1] = { nullptr };
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr));
// 1 means least param num
PARAM_CHECK_RETURN(env, argc >= 1, "should has 1 parameters!", TYPE_NONE, JsUtil::Const::Null(env));
PARAM_CHECK_RETURN(env, argc >= 1, "should has 1 parameter!", TYPE_NONE, JsUtil::Const::Null(env));
// 0 means parameter of info<PanelInfo>
napi_valuetype valueType = napi_undefined;
napi_typeof(env, argv[0], &valueType);
PARAM_CHECK_RETURN(env, valueType == napi_object, " panelInfo: ", TYPE_OBJECT, JsUtil::Const::Null(env));
PARAM_CHECK_RETURN(env, valueType == napi_object, "panelInfo", TYPE_OBJECT, JsUtil::Const::Null(env));
PanelInfo panelInfo;
napi_status status = JsUtils::GetValue(env, argv[0], panelInfo);

View File

@ -104,7 +104,7 @@ void JsUtils::ThrowException(napi_env env, int32_t err, const std::string &msg,
napi_value code;
napi_value message;
if (type == TypeCode::TYPE_NONE) {
errMsg = errMsg + msg;
errMsg = errMsg + " " + msg;
IMSA_HILOGE("THROW_ERROR message: %{public}s", errMsg.c_str());
} else {
auto iter = PARAMETER_TYPE.find(type);