# Copyright (c) 2025-2026 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE(@srokashevich, #29196): enable with asan after fix
if (PANDA_ENABLE_ADDRESS_SANITIZER)
    return()
endif()

option(ENABLE_LSP_BENCHMARK "Enable LSP benchmark build" OFF)

if(ENABLE_LSP_BENCHMARK)
    add_subdirectory(benchmark)
endif()

ets2panda_add_gtest(lsp_get_definition_at_position_test CPP_SOURCES
    get_definition_at_position_test.cpp
)

ets2panda_add_gtest(lsp_get_file_references_test CPP_SOURCES
    get_file_references_test.cpp
)

ets2panda_add_gtest(lsp_incremental_prepare_test CPP_SOURCES
    lsp_incremental_prepare_test.cpp
)

ets2panda_add_gtest(lsp_api_script_element_kind CPP_SOURCES
    script_element_kind_test.cpp
)

ets2panda_add_gtest(lsp_get_references_at_position_test CPP_SOURCES
    get_references_at_position_test.cpp
)

ets2panda_add_gtest(lsp_document_highlights_test CPP_SOURCES
    document_highlights.cpp
)

ets2panda_add_gtest(lsp_diagnostic_test CPP_SOURCES
    diagnostic_test.cpp
)

ets2panda_add_gtest(lsp_unused_warning_diagnostic_test CPP_SOURCES
    unused_warning_diagnostic_test.cpp
    unused_warning_ast_coverage_test.cpp
)

ets2panda_add_gtest(lsp_isolated_declaration_test CPP_SOURCES
    isolated_declaration.cpp
)

ets2panda_add_gtest(lsp_cancellation_token_test CPP_SOURCES
    cancellation_token_test.cpp
)

ets2panda_add_gtest(lsp_get_span_of_enclosing_comment_test CPP_SOURCES
    get_span_of_enclosing_comment_test.cpp
)

ets2panda_add_gtest(lsp_user_preferences_test CPP_SOURCES
    user_preferences.cpp
)

ets2panda_add_gtest(lsp_keyword_completion_data_test CPP_SOURCES
    keyword_completion_data_test.cpp
)

ets2panda_add_gtest(lsp_rename_test CPP_SOURCES
    lsp_rename_test.cpp
)

ets2panda_add_gtest(lsp_get_current_token_value_test CPP_SOURCES
    get_current_token_value_test.cpp
)

ets2panda_add_gtest(lsp_get_file_references_impl_test CPP_SOURCES
    get_file_references_impl_test.cpp
)

ets2panda_add_gtest(lsp_get_preceding_token_test CPP_SOURCES
    get_preceding_token_test.cpp
)

ets2panda_add_gtest(lsp_get_touching_token_test CPP_SOURCES
    get_touching_token_test.cpp
)

ets2panda_add_gtest(lsp_get_type_of_symbol_at_location_test CPP_SOURCES
    get_type_of_symbol_at_location_test.cpp
)

ets2panda_add_gtest(lsp_api_test_organize_imports CPP_SOURCES
    organize_imports_test.cpp
)

ets2panda_add_gtest(lsp_quick_info_api_test CPP_SOURCES
    quick_info_test.cpp
)

ets2panda_add_gtest(lsp_quick_info_api_test_1 CPP_SOURCES
    quick_info_test_1.cpp
)

ets2panda_add_gtest(lsp_quick_info_api_test_api CPP_SOURCES
    quick_info_api_test.cpp
)

ets2panda_add_gtest(lsp_api_completions_entry_details_test CPP_SOURCES
    get_completions_entry_details.cpp
)

ets2panda_add_gtest(lsp_api_classifier_test CPP_SOURCES
    classifier_test.cpp
)

ets2panda_add_gtest(lsp_api_test_class_hierarchies CPP_SOURCES
    class_hierarchys_test.cpp
)

ets2panda_add_gtest(lsp_api_test_refactor_extract_symbol CPP_SOURCES	 
    refactor_extract_symbol_test.cpp 
)

ets2panda_add_gtest(lsp_api_test_refactor_extract_symbol_2 CPP_SOURCES
    refactor_extract_symbol_test_2.cpp
)

ets2panda_add_gtest(lsp_api_test_refactor_extract_symbol_variable CPP_SOURCES 
    refactor_extract_symbol_test_variable.cpp 
)

ets2panda_add_gtest(lsp_api_test_refactor_extract_symbol_function CPP_SOURCES
    refactor_extract_symbol_test_function.cpp
)

ets2panda_add_gtest(lsp_api_test_refactor_extract_symbol_constant CPP_SOURCES
    refactor_extract_symbol_test_constant.cpp
)

ets2panda_add_gtest(lsp_api_test_refactors_convert_chain CPP_SOURCES
    refactors_convert_chain_test.cpp
)

ets2panda_add_gtest(lsp_api_test_refactors_generate_override_methods CPP_SOURCES
    refactors_generate_override_methods_test.cpp
)

ets2panda_add_gtest(lsp_api_test_refactors_convert_arrow_braces CPP_SOURCES
    refactors_convert_arrow_braces_test.cpp
)

ets2panda_add_gtest(lsp_api_test_refactors_convert_function CPP_SOURCES
    refactors_convert_function_test.cpp
)

ets2panda_add_gtest(lsp_api_test_refactors_convert_import CPP_SOURCES
    refactors_convert_import_test.cpp
)

ets2panda_add_gtest(lsp_api_test_refactors_convert_params_to_object CPP_SOURCES
    refactors_convert_params_to_object_test.cpp
)

ets2panda_add_gtest(lsp_api_test_refactors_extract_type CPP_SOURCES
    refactors_extract_type_test.cpp
)

ets2panda_add_gtest(lsp_api_test_refactors_extract_interface CPP_SOURCES
    refactors_extract_interface_test.cpp
)

ets2panda_add_gtest(lsp_api_test_refactors_convert_template CPP_SOURCES
    refactors_convert_template_test.cpp
)
ets2panda_add_gtest(lsp_api_test_generate_getters_and_setters CPP_SOURCES
    refactor_generate_getters_and_setters_test.cpp
)


ets2panda_add_gtest(lsp_api_test_refactors_move_to_new_file CPP_SOURCES
    refactors_move_to_new_file_test.cpp
)

ets2panda_add_gtest(lsp_api_test_refactors_convert_overload_list CPP_SOURCES
    refactors_convert_overload_list_test.cpp
)

ets2panda_add_gtest(lsp_api_diagnostics_test CPP_SOURCES
    get_compiler_options_diagnostics_test.cpp
    get_diagnostics.cpp
)

ets2panda_add_gtest(lsp_api_get_adjusted_location_test CPP_SOURCES
    get_adjusted_location_test.cpp
)

ets2panda_add_gtest(lsp_api_test_class_hierarchy CPP_SOURCES
    class_hierarchy_test.cpp
)

ets2panda_add_gtest(lsp_api_test_class_hierarchy2 CPP_SOURCES
    class_hierarchy2_test.cpp
)

ets2panda_add_gtest(lsp_api_test_class_hierarchy3 CPP_SOURCES
    class_hierarchy3_test.cpp
)

ets2panda_add_gtest(lsp_api_test_class_hierarchy4 CPP_SOURCES
    class_hierarchy4_test.cpp
)

ets2panda_add_gtest(lsp_api_test_find_safe_delete_location CPP_SOURCES
    find_safe_delete_location_test.cpp
)

ets2panda_add_gtest(lsp_api_test_find_references CPP_SOURCES
    find_references_test.cpp
)

ets2panda_add_gtest(lsp_api_slc_tests CPP_SOURCES
    string_completions_test.cpp
)

ets2panda_add_gtest(lsp_api_test_suggestion_diagnostics CPP_SOURCES
    suggestion_diagnostics_test.cpp
)

ets2panda_add_gtest(lsp_api_test_suggestion_diagnostics_1 CPP_SOURCES
    suggestion_diagnostics_test_1.cpp
)

ets2panda_add_gtest(lsp_api_test_get_class_property_info CPP_SOURCES
    get_class_property_info_test.cpp
)

ets2panda_add_gtest(lsp_api_test_brace_matching CPP_SOURCES
    brace_matching_test.cpp
)

ets2panda_add_gtest(lsp_api_completions_test CPP_SOURCES
    get_completions.cpp
)

ets2panda_add_gtest(lsp_api_completions_test_1 CPP_SOURCES
    get_completions_1.cpp
)

ets2panda_add_gtest(lsp_api_completions_module_test CPP_SOURCES
    get_completions_module_test.cpp
)

ets2panda_add_gtest(lsp_api_ui_suggest_test CPP_SOURCES
    code_fix/ui_plugin_suggest.cpp
)

ets2panda_add_gtest(lsp_api_import_fixes_test CPP_SOURCES
    code_fix/import_fixes.cpp
)

ets2panda_add_gtest(lsp_api_remove_catch_type_annotation_test CPP_SOURCES
    code_fix/remove_catch_type_annotation_test.cpp
)

ets2panda_add_gtest(lsp_api_fix_forbidden_any_type_test CPP_SOURCES
    code_fix/fix_forbidden_any_type_test.cpp
)

ets2panda_add_gtest(lsp_api_fix_import_source_test CPP_SOURCES
    code_fix/fix_import_source_test.cpp
)

ets2panda_add_gtest(lsp_api_test_get_class_hierarchy_info CPP_SOURCES
    class_hierarchy_info_test.cpp
)

ets2panda_add_gtest(lsp_api_gilap_test CPP_SOURCES
    get_implementation_location.cpp
)

ets2panda_add_gtest(lsp_api_lco_test CPP_SOURCES
    line_column_offset_test.cpp
)

ets2panda_add_gtest(lsp_api_get_constructor_test CPP_SOURCES
    get_constructor_test.cpp
)

ets2panda_add_gtest(lsp_api_test_auto_completion CPP_SOURCES
    get_auto_completion_test.cpp
)

ets2panda_add_gtest(lsp_api_test_inlay_hints CPP_SOURCES
    inlay_hints_test.cpp
)

ets2panda_add_gtest(lsp_api_test_refactor_provider_test CPP_SOURCES
    refactor_provider_test.cpp
)

ets2panda_add_gtest(lsp_api_test_find_rename_locations CPP_SOURCES
    find_rename_locations_test.cpp
)

ets2panda_add_gtest(lsp_api_test_find_rename_locations_2 CPP_SOURCES
    find_rename_locations_test_2.cpp
)

ets2panda_add_gtest(lsp_api_test_change_tracker CPP_SOURCES
    change_tracker_test.cpp
)

ets2panda_add_gtest(lsp_api_test_get_safe_delete_info CPP_SOURCES
    get_safe_delete_info_test.cpp
)

ets2panda_add_gtest(lsp_api_test_create_type_help_items CPP_SOURCES
    create_type_help_items_test.cpp
)

ets2panda_add_gtest(lsp_api_test_signature_help_items CPP_SOURCES
    signature_help_items_test.cpp
)

ets2panda_add_gtest(lsp_api_test_get_def_and_bound_span CPP_SOURCES
    get_definition_and_bound_span_test.cpp
)

ets2panda_add_gtest(lsp_api_test_formatting_context CPP_SOURCES
    formatting_context_test.cpp
)

ets2panda_add_gtest(lsp_api_test_formatting CPP_SOURCES
    formatting_test.cpp
)

ets2panda_add_gtest(lsp_api_test_formatting_1 CPP_SOURCES
    formatting_test_1.cpp
)

ets2panda_add_gtest(lsp_api_test_formatting_2 CPP_SOURCES
    formatting_test_2.cpp
)

ets2panda_add_gtest(lsp_api_test_formatting_3 CPP_SOURCES
    formatting_test_3.cpp
)

ets2panda_add_gtest(lsp_api_test_formatting_after_keystroke CPP_SOURCES
    formatting_after_keystroke_test.cpp
)

ets2panda_add_gtest(lsp_api_test_rulesmap CPP_SOURCES
    rules_map_cache_test.cpp
)

ets2panda_add_gtest(lsp_api_test_todo_comments CPP_SOURCES
    todo_comments_test.cpp
)

ets2panda_add_gtest(lsp_api_test_navigate_to CPP_SOURCES
    navigate_to_test.cpp
)

ets2panda_add_gtest(lsp_api_test_offset CPP_SOURCES
    get_offset_by_col_and_line.cpp
)

ets2panda_add_gtest(lsp_api_test_code_fix_registration CPP_SOURCES
    code_fix_registration_test.cpp
)
ets2panda_add_gtest(lsp_api_test_super_must_precede_this CPP_SOURCES
    fix_class_super_must_precede_this_access_test.cpp
)

ets2panda_add_gtest(lsp_api_test_fix_return_type_in_async_func CPP_SOURCES
    fix_return_type_in_async_function_test.cpp
)

ets2panda_add_gtest(lsp_api_test_fix_abstract_member CPP_SOURCES
    fix_class_doesnt_implement_inherited_abstract_member_test.cpp
)

ets2panda_add_gtest(lsp_api_test_fix_class_incorrectly_implements_interface CPP_SOURCES
    fix_class_incorrectly_implements_interface_test.cpp
)

ets2panda_add_gtest(lsp_api_test_fix_add_function_return_statement_test CPP_SOURCES
    fix_add_function_return_statement_test.cpp
)

ets2panda_add_gtest(lsp_api_test_get_name_or_dotted_name_span CPP_SOURCES
    get_name_or_dotted_name_span_test.cpp
)

ets2panda_add_gtest(lsp_api_test_fix_convert_const_to_let CPP_SOURCES
    fix_convert_const_to_let_test.cpp
)

ets2panda_add_gtest(lsp_api_test_fix_extends_interface_becomes_implements CPP_SOURCES
    fix_extends_interface_becomes_implements_test.cpp
)

ets2panda_add_gtest(lsp_api_test_forgotten_this_property_access CPP_SOURCES
    forgotten_this_property_access_test.cpp
)

ets2panda_add_gtest(lsp_api_test_remove_accidental_call_parentheses CPP_SOURCES
    remove_accidental_call_parentheses_test.cpp
)

ets2panda_add_gtest(lsp_api_test_fix_remove_override_modifier_test CPP_SOURCES
    fix_remove_override_modifier_test.cpp
)

ets2panda_add_gtest(lsp_api_add_missing_new_operator CPP_SOURCES
    add_missing_new_operator_test.cpp
)

ets2panda_add_gtest(lsp_api_test_add_local_variable CPP_SOURCES
    add_local_variable_test.cpp
)

ets2panda_add_gtest(lsp_get_import_file_path_test CPP_SOURCES
    get_import_file_path_test.cpp
)

ets2panda_add_gtest(lsp_get_signature_test CPP_SOURCES
    get_signature_test.cpp
)

ets2panda_add_gtest(lsp_api_test_fix_import_non_exported_member CPP_SOURCES
    fix_import_non_exported_member_test.cpp
)
ets2panda_add_gtest(lsp_api_get_node_test CPP_SOURCES
    get_node_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_infos_test CPP_SOURCES
    get_node_infos_test.cpp
)

ets2panda_add_gtest(lsp_api_get_definition_from_node_test CPP_SOURCES
    get_definition_from_node_test.cpp
)

# NOTE(@srokashevich, #29405): enable with tsan after fix
if (NOT PANDA_ENABLE_THREAD_SANITIZER)
    ets2panda_add_gtest(lsp_api_spelling_test CPP_SOURCES
        fix_spelling_test.cpp
    )
endif()

ets2panda_add_gtest(lsp_api_get_node_expression_test CPP_SOURCES
    get_node_expression_test.cpp
)

ets2panda_add_gtest(lsp_api_test_constructor_for_derived_need_super_call CPP_SOURCES
    constructor_for_derived_need_super_call_test.cpp
)

ets2panda_add_gtest(lsp_api_test_add_name_to_nameless_parameter CPP_SOURCES
    add_name_to_nameless_parameter_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_interface_test CPP_SOURCES
    get_node_interface_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_type_namespace_test CPP_SOURCES
    get_node_type_namespace_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_export_test CPP_SOURCES
    get_node_export_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_ts_class_Implements_test CPP_SOURCES
    get_node_ts_class_Implements_test.cpp
)

ets2panda_add_gtest(lsp_api_fix_unreachable_code_test CPP_SOURCES
    fix_unreachable_code_test.cpp
)

ets2panda_add_gtest(lsp_api_fix_spelling_for_type_test CPP_SOURCES
    fix_spelling_for_type_test.cpp
)

ets2panda_add_gtest(lsp_api_fix_remove_illegal_await_test CPP_SOURCES
    fix_remove_illegal_await_test.cpp
)

ets2panda_add_gtest(lsp_api_fix_remove_duplicate_export_import_test CPP_SOURCES
    fix_remove_duplicate_export_import_test.cpp
)

ets2panda_add_gtest(lsp_api_fix_spelling_for_property_test CPP_SOURCES
    fix_spelling_for_property_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_etsstring_literal_test CPP_SOURCES
    get_node_string_literal_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_type_reference_test CPP_SOURCES
    get_node_type_reference_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_keyof_type_test CPP_SOURCES
    get_node_etskeyof_type_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_newclass_instance_test CPP_SOURCES
    get_node_newclass_instance_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_etsstruct_declaration_test CPP_SOURCES
    get_node_etsstruct_declaration_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_spread_element_test CPP_SOURCES
    get_node_spread_element_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_ts_type_reference_test CPP_SOURCES
    get_node_ts_type_reference_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_script_function_test CPP_SOURCES
    get_node_script_function_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_declaration_test CPP_SOURCES
    get_node_declaration_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_declarator_test CPP_SOURCES
    get_node_declarator_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_class_declaration_test CPP_SOURCES
    get_node_class_declaration_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_annotation_declaration_test CPP_SOURCES
    get_node_annotation_declaration_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_annotation_usage_test CPP_SOURCES
    get_node_annotation_usage_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_await_expression_test CPP_SOURCES
    get_node_await_expression_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_bigInt_literal_test CPP_SOURCES
    get_node_bigInt_literal_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_import_test CPP_SOURCES
	get_node_import_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_ts_type_param_test CPP_SOURCES
    get_node_ts_type_param_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_ets_parameter_expression CPP_SOURCES
    get_node_ets_parameter_expression_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_switch_statement CPP_SOURCES
    get_node_switch_statement_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_ts_nonnull_expression CPP_SOURCES
    get_node_ts_nonnull_expression_test.cpp
)

ets2panda_add_gtest(lsp_api_convert_function_test CPP_SOURCES
    convert_function_test.cpp
)
ets2panda_add_gtest(lsp_api_infer_function_test CPP_SOURCES
    infer_function_return_type_test.cpp
)
ets2panda_add_gtest(lsp_api_get_node_function_declaration_test CPP_SOURCES
    get_node_function_declaration_test.cpp
)
ets2panda_add_gtest(lsp_api_get_node_info_interface_test CPP_SOURCES
    get_node_info_interface_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_info_typealias_declaration_test CPP_SOURCES
    get_node_info_typealias_declaration.cpp
)

ets2panda_add_gtest(lsp_api_get_node_info_spread_element_test CPP_SOURCES
    get_node_info_spread_element.cpp
)

ets2panda_add_gtest(lsp_api_get_node_info_sturct_decalaration_test CPP_SOURCES
    get_node_info_sturct_decalaration_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_infos_annotation_declaration_test CPP_SOURCES
    get_node_infos_annotation_declaration_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_infos_script_function_test CPP_SOURCES
    get_node_infos_script_function_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_infos_expression_test CPP_SOURCES
    get_node_infos_expression_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_info_await_expression_test CPP_SOURCES
    get_node_info_await_expression_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_infos_annotation_usage_test CPP_SOURCES
    get_node_infos_annotation_usage_test.cpp
)

ets2panda_add_gtest(lsp_api_get_node_info_class_property_import_test CPP_SOURCES
    get_node_info_class_property_import_test.cpp
)

ets2panda_add_gtest(lsp_api_get_rename_locations_from_node_test CPP_SOURCES
    get_rename_locations_from_node_test.cpp
)

ets2panda_add_gtest(lsp_api_test_fix_property_assignment CPP_SOURCES
    fix_property_assignment_test.cpp
)

ets2panda_add_gtest(lsp_api_test_convert_function_to_class CPP_SOURCES
    convert_function_to_class_test.cpp
)
ets2panda_add_gtest(lsp_api_test_add_missing_declare_property CPP_SOURCES
    add_missing_declare_property_test.cpp
)
ets2panda_add_gtest(lsp_api_test_refactors_generate_constructor CPP_SOURCES
    refactors_generate_constructor_test.cpp
)

ets2panda_add_gtest(lsp_api_test_smart_indenter_test CPP_SOURCES
    smart_indenter_test.cpp
)

ets2panda_add_gtest(lsp_api_get_token_native_test CPP_SOURCES
    get_token_native_test.cpp
)
